Search Unity

Shader Affected by unity lights?

Discussion in 'Shaders' started by xsernakatomi, Jun 4, 2012.

  1. xsernakatomi

    xsernakatomi

    Joined:
    Apr 19, 2012
    Posts:
    25
    PHP:
    Shader "Custom/Hatching" {
        
    Properties {
            
    _Hatch0 ("Hatch 0"2D) = "white" {}
            
    _Hatch1 ("Hatch 1"2D) = "white" {}        
            
    _Hatch2 ("Hatch 2"2D) = "white" {}
            
    _Hatch3 ("Hatch 3"2D) = "white" {}        
            
    _Hatch4 ("Hatch 4"2D) = "white" {}        
            
    _Hatch5 ("Hatch 5"2D) = "white" {}                    
        }
        
    SubShader {
            
    Tags "RenderType" "Opaque" }
            
    CGPROGRAM
            
    #pragma target 3.0
            #pragma surface surf SimpleLambert

            
    sampler2D _Hatch0;
            
    sampler2D _Hatch1;
            
    sampler2D _Hatch2;
            
    sampler2D _Hatch3;
            
    sampler2D _Hatch4;
            
    sampler2D _Hatch5;

            
    half4 LightingSimpleLambert (inout SurfaceOutput shalf3 lightDirhalf atten)
            {
                
    float2 uv s.Albedo.xy;        
                
    s.Albedo 0.0;            
            
                
    half NdotL dot (s.NormallightDir);
                
    half diff NdotL;// * 0.75 + 0.25;
                
    half4 c;
                
                
    half lightColor _LightColor0.0.3 _LightColor0.0.59 _LightColor0.0.11;
                
    half intensity lightColor * (diff atten 2);
                
    intensity saturate(intensity);
                
                
    float part 6.0;
                
    // KLUDGE: with "if" instead of "else if" lines between regions are invisible        
                
    if (intensity <= part)
                {    
                    
    float temp intensity;
                    
    temp *= 6;
                    
    c.rgb lerp(tex2D(_Hatch0uv), tex2D(_Hatch1uv), temp);            
                }
                if (
    intensity part  intensity <= part 2)
                {
                    
    float temp intensity part;
                    
    temp *= 6;                
                    
    c.rgb lerp(tex2D(_Hatch1uv), tex2D(_Hatch2uv), temp);            
                }
                if (
    intensity part 2  intensity <= part 3)
                {
                    
    float temp intensity part 2;
                    
    temp *= 6;                
                    
    c.rgb lerp(tex2D(_Hatch2uv), tex2D(_Hatch3uv), temp);            
                }
                if (
    intensity part 3  intensity <= part 4)
                {
                    
    float temp intensity part 3;
                    
    temp *= 6;                
                    
    c.rgb lerp(tex2D(_Hatch3uv), tex2D(_Hatch4uv), temp);            
                }
                if (
    intensity part 4  intensity <= part 5)
                {
                    
    float temp intensity part 4;
                    
    temp *= 6;                
                    
    c.rgb lerp(tex2D(_Hatch4uv), tex2D(_Hatch5uv), temp);            
                }
                if (
    intensity part 5)
                {
                    
    float temp intensity part 5;
                    
    temp *= 6;                
                    
    c.rgb lerp(tex2D(_Hatch5uv), 1temp);            
                }    

                return 
    c;
            }

            
    struct Input 
            
    {
                
    float2 uv_Hatch0;
            };

            
    void surf (Input INinout SurfaceOutput o
            {
                
    o.Albedo.xy IN.uv_Hatch0;
            }
            
    ENDCG
        
    }
        
    Fallback "Diffuse"
    }
    Hi Guys, can anyone tell me, how i can modify the shader (thanks ufo_driver for the modifications) so that is affected by unity lights?

    thanks!