What I want is to create a shader graph that will texture a generated mesh based on some variable like vertex height.
I plan on using this in a terrain generator, and I found this video that shows how to do it with color:
This is the result I want, but instead of changing the mesh’s color based on height I want to actually use different textures. Is that dowable with shader graph? I can’t find a guide or anything on how to do it, but I’m not even sure I’m searching with the right keywords.
If it’s not doable with shader graph, does anyone know how to implement such a system?
Isn’t what he did in 4:45 what you want? Proper UV of mesh and standard texture sampling.
It sounds too easy, so I guess I misunderstood the question - if so, tell me what you mean by “use different textures” (gradients?).
He adds a texture to his terrain, and then adds a way to vary colors by terrain level.
I want to vary texture by terrain level, rather than just color. So I have a grass texture I want to tile/repeat at the low level and when the terrain if higher I want to switch to a, different, stone texture.
Is that more clear? Let me know if I’m still not making sense haha again, not sure if this is doable with a shader.
In short obviously it’s possible, but the thing is it might be a lot of data. If you need only like 3-4 “layers” then you can pass texture array to shader (or 4 textures, but array would be better) and lerp between them using height. You can remap height, so they are not evenly spaced. Or you could use texture 3D instead (what is probably even better), but remember you are entering a shaky ground - for example 1024x1024 x 16 “layers” is already ~11MB and if it’s real terrain then I guess 1024 might be not enough.
Depending on how your terrain looks like you could maybe create some crazy triplanar, but I have no other good idea to make flat top fitting the rest of ground.
The best solution would be to create texture once, before it’s used, but I don’t think it’s possible as you need tiling and stuff.