Search Unity

Shadows not being collected?

Discussion in 'Shaders' started by deram_scholzara, Mar 5, 2015.

  1. deram_scholzara

    deram_scholzara

    Joined:
    Aug 26, 2005
    Posts:
    1,043
    I'm trying to write a shader that only collects/displays shadow data - but for some reason it is displaying as flat white. What on earth am I missing here?

    Code (csharp):
    1. Shader "Shadow Composition"
    2. {
    3.     Properties
    4.     {
    5.         _Color("Background Color (RGB)", Color) = (1,1,1,1)
    6.     }
    7.  
    8.     SubShader
    9.     {
    10.         Tags { "RenderType"="Opaque" "Queue" = "Geometry" }
    11.        
    12.         Pass
    13.         {
    14.             Tags { "LightMode" = "ForwardBase" }
    15.            
    16.             ZWrite On
    17.             Cull Off
    18.            
    19.             CGPROGRAM
    20.  
    21.             #pragma vertex VertexFunction
    22.             #pragma fragment FragmentFunction
    23.  
    24.             #include "AutoLight.cginc"
    25.            
    26.             float4 _Color;
    27.            
    28.             //----------------
    29.            
    30.             struct VertexInput {
    31.                 float4 vertex : POSITION;
    32.             };
    33.            
    34.             struct VertexToFragment {
    35.                 float4 position : SV_POSITION;
    36.                 LIGHTING_COORDS(0,1)
    37.             };
    38.            
    39.             struct FragmentOutput {
    40.                 float4 color : COLOR;
    41.             };
    42.            
    43.             //----------------
    44.            
    45.             VertexToFragment VertexFunction (VertexInput input) {
    46.                 VertexToFragment output;
    47.                 output.position = mul(UNITY_MATRIX_MVP, input.vertex);
    48.                 TRANSFER_VERTEX_TO_FRAGMENT(output);
    49.                 return output;
    50.             }
    51.            
    52.             FragmentOutput FragmentFunction (VertexToFragment input) {
    53.                 FragmentOutput output;
    54.                 output.color = LIGHT_ATTENUATION(input);
    55.                 return output;
    56.             }
    57.  
    58.             ENDCG
    59.         }
    60.     }
    61. }
     
  2. kebrus

    kebrus

    Joined:
    Oct 10, 2011
    Posts:
    415
    I think it's the fallback, you need a fallback that has the shadow caster and shadow collector passes, the default diffuse should do