Search Unity

Shadows smooth disappear in CG shader

Discussion in 'Shaders' started by Bravo_cr, Sep 1, 2017.

  1. Bravo_cr

    Bravo_cr

    Joined:
    Jul 19, 2012
    Posts:
    148
    Hi,

    I had made a simple unlit shadow shader written in CG. The shadows work but the problem is that they don't fade out/in when approaching the shadow distance in the same way as a surface shader does. They just popin/popout. I have included the following line to make the shadow work:

    #pragma multi_compile_fwdbase
    #include "UnityCG.cginc"
    #include "AutoLight.cginc"
    LIGHTING_COORDS(x,x)
    TRANSFER_VERTEX_TO_FRAGMENT(x)
    LIGHT_ATTENUATION(x)

    LIGHT_ATTENUATION(x) is multiplied by the final color to get the shadows.

    Anyone knows how to make them behave the same way as the surface shader ones?