Search Unity

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

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

  1. Lucospade

    Lucospade

    Joined:
    Aug 23, 2014
    Posts:
    4
    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.

    NoLights.PNG
    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.


    FrontMatched.PNG
    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.

    Backmatched.PNG

    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.

    Lightchange.PNG

    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.

    Thanks.