I’ve been trying to rebuild an old project of mine, and have started working on a material for use with hexagonal grid systems. The material is intended to take a texture, and convert each pixel in that texture into a hexagon of arbitrary size. I’m largely there, but something I’m doing is slightly off and the results speak for themselves. The top-left is what my hexagonal coordinates look like, the top-right is what a normal texture coordinate looks like, the bottom-left is how my test texture is being shown with those hex coordinates, and the bottom-right is what it looks like with normal coordinates.
As you can see, the hexagonal shapes are certainly there, but actual coordinates look to be wrong. I’m not quite sure where I’ve made the mistake. I’ve used Amit Patel’s excellent site as a reference: http://www.redblobgames.com/grids/hexagons/#pixel-to-hex
The material looks like this:
The custom node contains the following:
if(dX > dY && dX > dZ) return float3(-rY-rZ,rY,rZ); else if(dY > dZ) return float3(rX,-rX-rZ,rZ); else return float3(rX,rY,-rX-rY);
Here’s a version of the material that can be pasted into the material editor (I’m on 4.7):
If anyone can see where I’ve gone wrong, it’d be much appreciated!