Search Unity

UnityStandardParticleShadow

Discussion in 'General Graphics' started by ifurkend, Aug 10, 2018.

  1. ifurkend

    ifurkend

    Joined:
    Sep 4, 2012
    Posts:
    350
    I copied the ShadowCaster pass from Particles Standard Unlit shader to my custom particle shader:

    Code (CSharp):
    1.             Pass
    2.             {
    3.                 Name "ShadowCaster"
    4.                 Tags { "LightMode" = "ShadowCaster" }
    5.  
    6.                 BlendOp Add
    7.                 Blend One Zero
    8.                 ZWrite On
    9.                 Cull Off
    10.  
    11.                 CGPROGRAM
    12.                 #pragma target 2.5
    13.  
    14.                 //#pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON _ALPHAMODULATE_ON
    15.                 //#pragma shader_feature _ _COLOROVERLAY_ON _COLORCOLOR_ON _COLORADDSUBDIFF_ON
    16.                 //#pragma shader_feature _REQUIRE_UV2
    17.                 #pragma multi_compile_shadowcaster
    18.                 #pragma multi_compile_instancing
    19.                 //#pragma instancing_options procedural:vertInstancingSetup
    20.  
    21.                 #pragma vertex vertParticleShadowCaster
    22.                 #pragma fragment fragParticleShadowCaster
    23.  
    24.                 #include "UnityStandardParticleShadow.cginc"
    25.              
    26.                 ENDCG
    27.             }
    (Commented supposedly unnecessary pragmas.)

    Problem is I don't know how to change the Rendering Mode to Fade so the shadow applies the alpha from the _MainTex, instead of looking like quads. It's not like in Standard Shader I can add "alpha:fade" to define the alpha rendering mode instantly.
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    11,190
    This line exists in the original shader to allow it to swap between modes. Since you presumably only want fade, you just need to do:

    #define _ALPHABLEND_ON 1
     
  3. ifurkend

    ifurkend

    Joined:
    Sep 4, 2012
    Posts:
    350
    Thanks Ben. This makes sense, but the main texture alpha still doesn't apply on the shadow...
     
  4. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    11,190
    Assuming you're adding that #define before the #include, and your shader uses _MainTex for the main texture variable, that should work.
     
    Last edited: Aug 10, 2018
    richardkettlewell likes this.
  5. ifurkend

    ifurkend

    Joined:
    Sep 4, 2012
    Posts:
    350
    Thank you, you are totally right.
     
unityunity