Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Shading a terrain tree prefab, to match the way detail meshes are rendered.

Discussion in 'Shaders' started by Lucospade, Aug 20, 2019.

  1. Lucospade


    Aug 23, 2014
    Hi everyone.

    I am an artist and level designer working on a game with a friend of mine. I am currently stressing over how to get the grass to behave exactly how I want it.

    Essentially, I have two layers of grass. One is a larger terrain "tree" prefab which has a custom, swaying and interactable toon shader on it.

    The next layer is shorter grass used using the "detail mesh" layer of the terrain system. Combined they make really thick looking grass that has the appearance of interactability.

    The problem however is that each layer reacts differently to the lighting so in spots they are very obviously different.

    Have a look below.

    This is the grass combo. Obviously it looks very flat without lighting, but the colouration is very similar and looks like one homogenous patch. How I want it.

    With lighting on, I get the very nice colour variation that the terrain grass provides but as it moves into shadow at the back, the shading on the larger grass sticks out and looks lighter.


    Matching the colour to the back has the inverse effect.

    One additional point. When the grass meets hard lights it reacts very nicely. See below.


    The grass changes colour as you would expect, when it encounters the light. Ordinary shading methods I've tried don't do this so in these situations the different grasses are rendered very differently. This is just an extension of the problem really but I really need this behaviour.

    I was wondering if anyone out there who is shader savvy knows how Unitys terrain renders the grass? I really like the softness of the variation and how it fades away from the light. I can't replicate it by any other conventional shader means. I would very much appreciate any help, I'm unsure which direction to look in.