Hi, i’ve made material in node editor that allows to use one texture to read texture atlas and mix them on one mesh.
Here it is material:
It uses a :
-
- Texture atlas, a 5x5 image mosaic that have textures for different types of ground
-
- Terrain map, red-green map which for each pixel has an offset marking the left upper corner of the texture atlas
-
- irrelevant color map
Yet I encounter quite weird behaviour as in the image below, the tiles are not filling the space, there are rectangular areas between them.
Do you guys have and idea where is comming from?
how this node material works, roughly:
- terrainMap assigns to each pixel an offset from 0 to 0.8, both for u and v coordinates, let’s call it
uv_offset = sample(terrain_tex, uv)
- this is added the the with, fract(uv * SCALE) to get a uv to read a atlas of textures
so
final_uv = sample(terrain_map, uv) + fract(uv * SCALE)
I checked how terrain texture looks like (the thing that hold coordinates offset to read into atlas):
And it looks good, sharp, so no interpolation issues.