Advertisement
BlueBear

LFade.shader

Mar 21st, 2014
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.02 KB | None | 0 0
  1. Shader "Custom/LFade" {
  2.     Properties {
  3.         _Color ("Main Color", Color) = (1, 1, 1, 1)      
  4.         _DawnTex ("Dawn (RGB)", 2D) = "white" {}
  5.         _DayTex ("Day (RGB)", 2D) = "white" {}
  6.         _DuskTex ("Dusk (RGB)", 2D) = "white" {}
  7.         _NightTex ("Night (RGB)", 2D) = "white" {}
  8.         _ViharTex ("Storm (RGB)", 2D) = "white" {}
  9.         _Csuszka ("Day cycle", Range (0,4)) = 2.0
  10.         _ViharCsuszka ("Storm scale", Range (0,0.9)) = 0.3
  11.     }
  12.     SubShader {
  13.         Tags { "RenderType"="Opaque" "IgnoreProjector"="True" }    
  14.        
  15.         Pass
  16.         {      
  17.             Tags { "LightMode"= "Always" }
  18.             Lighting Off
  19.             SetTexture[_DawnTex]
  20.             SetTexture[_DayTex]
  21.             SetTexture[_DuskTex]
  22.             SetTexture[_NightTex]
  23.  
  24.         }
  25.        
  26.         CGPROGRAM
  27.         #pragma surface surf Unlit noambient novertexlights noforwardadd
  28.         #pragma target 3.0
  29.  
  30.         sampler2D _DawnTex;
  31.         sampler2D _DayTex;
  32.         sampler2D _DuskTex;
  33.         sampler2D _NightTex;
  34.         sampler2D _ViharTex;
  35.         float _Csuszka;
  36.         float _ViharCsuszka;
  37.  
  38.         struct Input {
  39.             float2 uv_DawnTex;
  40.             float2 uv_DayTex;
  41.             float2 uv_DuskTex;
  42.             float2 uv_NightTex;
  43.             float2 uv_ViharTex;
  44.         };
  45.  
  46.         void surf (Input IN, inout SurfaceOutput o) {
  47.             half4 dawn = tex2D (_DawnTex, IN.uv_DawnTex);
  48.             half4 day = tex2D (_DayTex, IN.uv_DayTex);
  49.             half4 dusk = tex2D (_DuskTex, IN.uv_DuskTex);
  50.             half4 night = tex2D (_NightTex, IN.uv_NightTex);
  51.             half4 storm = tex2D (_ViharTex, IN.uv_ViharTex);
  52.             half4 output;
  53.             if(_Csuszka <= 1)
  54.             {
  55.                 output = lerp(dawn, day, _Csuszka);
  56.             }
  57.             else if(_Csuszka > 1 && _Csuszka <= 2)
  58.             {
  59.                 output = lerp(day, dusk, _Csuszka - 1);
  60.             }
  61.             else if(_Csuszka > 2 && _Csuszka <= 3)
  62.             {
  63.                 output = lerp(dusk, night, _Csuszka - 2);
  64.             }
  65.             else if(_Csuszka > 3 && _Csuszka <= 4)
  66.             {
  67.                 output = lerp(night, dawn, _Csuszka - 3);
  68.             }
  69.            
  70.            
  71.            
  72.             half4 viharedOutput = lerp(output, storm, _ViharCsuszka);
  73.            
  74.             o.Albedo = viharedOutput.rgb ;
  75.         }
  76.        
  77.         half4 LightingUnlit(SurfaceOutput s, half3 lightDir, half atten)
  78.         {
  79.             return half4(s.Albedo, s.Alpha);
  80.         }
  81.  
  82.         ENDCG
  83.     }
  84.     FallBack "Diffuse"
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement