Search Unity

Unwrap light information to uv space?

Discussion in 'Shaders' started by Morc, Apr 9, 2011.

  1. Morc

    Morc

    Joined:
    Jul 21, 2009
    Posts:
    31
    Hello everybody

    How can I access the light information in the surface part of the shader?

    Code (csharp):
    1. #pragma surface surf SimpleLambert
    2.  
    3.       half4 LightingSimpleLambert (SurfaceOutput s, half3 lightDir, half atten) {
    4.           half NdotL = dot (s.Normal, lightDir);
    5.           half4 c;
    6.           c.rgb = s.Albedo * _LightColor0.rgb * (NdotL * atten * 2);
    7.           c.a = s.Alpha;
    8.           return c;
    9.       }
    I'd like to use c.rgb in the surface part of the shader, where I specify o.Albedo, etc.
    So that I could write there something like this:
    Code (csharp):
    1. float4 light = c.rgb;
    Any ideas on how to do so?

    Many thanks in advance!
     
    Last edited: Apr 9, 2011