Search Unity

Question Material blending based on mesh height?

Discussion in 'Shader Graph' started by Schneider21, Apr 19, 2021.

  1. Schneider21

    Schneider21

    Joined:
    Feb 6, 2014
    Posts:
    3,512
    I'm trying to get back into an old project, where I'm creating terrain by instantiating mesh tiles that have their vertices' Y-axis offset to create the elevation. I've got that part working great, and I'm trying to make it look like real terrain, now.

    What I'd love to have is a shader that can blend between different textures/normal maps/etc automatically based on "elevation" (the Y value of the vertex), but I'm having trouble finding what this practice is even called to be able to look into how to do it.

    Could anyone clue me in on what this technique is called, and for bonus points, steer me in the right direction for a tutorial or asset I could purchase that can do this?
     
  2. florianBrn

    florianBrn

    Joined:
    Jul 31, 2019
    Posts:
    53
    One easy way to do it would be to have a camera above your player looking down, and use the depth of this camera to do the height blend. You could also bake the whole terrain to a texture, which would be more efficient. Here's an article explaining this.