Search Unity

Incorrect baked shadow for alpha clipped shader

Discussion in 'Shaders' started by Blastom, Nov 21, 2017.

  1. Blastom

    Blastom

    Joined:
    Aug 13, 2013
    Posts:
    24
    I'm using a surface shader modified from "legacy/mobile/diffuse" for the trees in a mobile game.
    I've added the "addshadow" code after the defination of surface shader, which made the shadows from realtime lights correct.
    But after I baked the scene, the shadow of the leaves didn't have their clipped part properly removed like when under realtime lighting.

    Also I've tried to replace the clip function with "alphatest:[variable name]", which provided the same result.

    I'm currently using old 5.4.1f1 version. Could anyone help me?
     
    Last edited: Nov 21, 2017
  2. Blastom

    Blastom

    Joined:
    Aug 13, 2013
    Posts:
    24
    Solved. It's some kind of pit. The shader must have a "Transparent" in its name path, like "xx/Transparent/xx" or Unity won't check the alpha of the fragments during baking.
     
    Dance_M likes this.
  3. Dance_M

    Dance_M

    Joined:
    Aug 17, 2014
    Posts:
    15
    OMG, 6y later it still works (custom URP based shader in ASE). THANK YOU MAN!!

    PS: here is another thing you may miss and can work without renaming - RenderType tag of type "TransparentCutout"
    https://forum.unity.com/threads/sha...-shader-and-lightmapping.712925/#post-8121815