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! Welcome to Shader Programming 101 🙂
I won’t go into details, but what I made is a node group that can generate any N-Gon. 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.
Update: Fixed some bugs, played around with other ideas. Made different node groups useful for other shader tasks – pixelating UV spaces etc.
Here is the Blender scene! Have fun and let me know if you think about any useful features this setup needs!
If you want to learn more about shader programming, I highly recommend reading this awesome and free online book – The Book of Shaders!