Recently I saw that someone was selling procedural hexagon tiles Blender shader. I became very curious about how this was achieved and spent couple days trying to figure this out on my own. Turns out you don’t need much more than just a bunch of math nodes and UV coordinates as an input. The rest is just basic geometry and basic math. No OSL. Works on GPU and in the viewport!

**Updated!**: Recently I updated this to Blender 2.8 and was pleasantly surprised that It also compiles and works in Eeevee exactly as in Cycles. That’s crazy awesome, if you ask me! Based on similar ideas, I also created procedural tiles shader that works in World space (independant from UV and topology) that allows to do some cool teleportation effects!

I won’t go into details, but what I made is a node group that can generate any N-Gon. You can control rotation, scaling, distribution/tiling as well as shape edge blending. On top of that there are couple helper groups that do tiling and other things. By combining these building blocks, you can create a lot of interesting textures.

If you want to learn more about shader programming, I highly recommend reading this awesome and free online book – **The Book of Shaders**!

Excellent work – very nice. I’d be very interested in how you’ve achieved this as I developed a hex shader of my own a short while back and love the way complex patterns can be created out of really quite simple maths.

Thanks! Well it’s basically just transforming your UV coords (tiling, rotating, scaling) + simple triganometry to create shapes from UV coordinates. You can download the file and look at the node graph.

I recommend reading free online book I mentioned at the end of the post. I had some trouble figuring out how do do the shape itself and this chapter from the book helped me to understand the math: https://thebookofshaders.com/07/

It’s quite easy to implement everything using blender nodes, because all the math operations used in shader coding are available also in Blender. Although I would still prefer code if it would be possible to do that in Blender – it’s much more readable than nodes.

That’s a really neat solution – completely different approach to my own. I see now how you can animate rotation and change of ngon, far more versatile than my own solution which is similar to how the Voronoi texture is produced – by positioning the centres of each cell and calculating the distance from each to determine the nearest. If you’re interested, take a look at https://blender.stackexchange.com/a/67654/29586.

That’s cool! I have not plyed with self-made voronoi shaders yet. It’s still something on my todo list 🙂

Thank you so much for sharing this also 🙂