Search Unity

Question How can I make grass take its color from the underlying terrain?

Discussion in 'General Graphics' started by sdrawkacB, Nov 10, 2021.

  1. sdrawkacB

    sdrawkacB

    Joined:
    May 4, 2021
    Posts:
    1
    Hello, for quite some time I have been trying to replicate the effect in this video but have had no real success.


    I am a beginner and have no formal training with Unity

    The scene uses a toon shader on a terrain asset and the grass sprites take their color from the pixel directly underneath them on the terrain. From what I have read this is not that hard to do but I am still cannot figure out how to do it.

    I have tried:
    1. Using a grab pass (does work but very inefficient and flickers on camera movement)
    2. Using the UV cords of the terrain (terrain doesn't have a texture so I couldn't get it to work)
    3. Considering using this mesh blending technique but it seems very inefficient for hundred/thousands of grass sprites and it is complicated https://inresin.wordpress.com/2020/04/03/terrain-and-mesh-blending-in-unity/

    I think that there is some way to do this with Unity TerrainData but I cannot figure it out

    Any help is much appreciated
    Thanks
     
    lukasnocker likes this.
  2. ohlin

    ohlin

    Joined:
    Mar 3, 2013
    Posts:
    17
    I am wondering the exact same thing...
     
  3. TerraUnity

    TerraUnity

    Joined:
    Aug 3, 2012
    Posts:
    1,255
    That's how grass is rendered in TerraWorld where grass's blade color blends with its albedo by sampling the underlying pixel from the satellite image of the area via mesh UVS. You can see it in action here:

     
    c0d3_m0nk3y likes this.