Multiple textures on Voxel mesh?
So I built a marching cubes voxel mesh and I would like to texture it. The problem, I can set a texture easily with TriPlanar shader but that only works with 1 texture. (or 1 / direction) However I need to set different texture based on the voxel data. The first problem that I can't pass the voxel data to the Surface shader, either I use UV coords or vertex color, it gets interpolated. It would work with 2 texture max but I need 10+
Any idea how to solve it, that the shader can decide ehich texture to use, and the level of the interpolation.
Answer by AurimasBlazulionis · Dec 30, 2016 at 09:20 PM
This can get you 4 textures. You need to set triangle color to how much of each texture to have in the position (edit the marching cubes algorithm so you can also pass color array or something similar) and in the shader, add 4 texture fields, and then blend between r, g, b and a values.
But this won't cut it for you. I have had another idea in my head for quite a while. Divide the mesh color values into more (with less precision) color values. You do this in shader and this way you can easily have 8 or more textures.
4 Texture is just not enough.... Now i'm experiencing with with HSV color codiing, where I store the texture index in the Hue value, and the shader can find it more precisely with the Saturation and Brightness, but i'm still working on the function for this. Also RGB storing would not be a good idea, since the GPU interpolates vertex colors in surface / fragment shaders... That would mean while I interpolate from ($$anonymous$$g.) Dirt to Gold textures, It would go throught many other. The same would apply to HSV, but saturation can compensate the mis-leading for some level... For example the Hue go throught 5 more values between the vertices, but the with the saturation I can "hide" it with some default color.
Your answer
Follow this Question
Related Questions
Can I add the same UV coordinates to multiple vertices? 0 Answers
Blocky (pixelated) textures on build only (not in editor) 0 Answers
How do I displace mesh texture to always face camera? 0 Answers
How do you draw a sprite from an atlas on to a mesh? 1 Answer
Change mesh texture when a line renderer has formed a loop on it 0 Answers