TexeL

Untitled

Feb 7th, 2012
410
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Shader "Duffuse_Transp_Normal_Dual"
  2. {
  3.     Properties
  4.     {
  5. _Distans("_Distans", Float) = -0.7
  6. _Soft("_Soft", Float) = 0.1
  7. _MainColor("_MainColor", Color) = (1,1,1,1)
  8. _MainTex("_MainTex", 2D) = "white" {}
  9. _Alphatest("Alphatest", Range (0, 1))= 0
  10. _LightMap("_LightMap", 2D) = "white" {}
  11. _GIMap("_GIMap", 2D) = "white" {}
  12. _Contrast("_Contrast", Float) = 1
  13. _Brightness("_Brightness", Float) = 0.5
  14. _Normal("_Normal", 2D) = "bump" {}
  15. _Gloss("_Gloss", Float) = 0
  16. _Specular("_Specular", Color) = (1,1,1,1)
  17. _Range("_Range", Float) = 1
  18. _Frequent("_Frequent", Float) = 0.1
  19. _Speed("_Speed", Float) = 1
  20.  
  21.     }
  22.    
  23.     SubShader
  24.     {
  25.         Tags
  26.         {
  27. "Queue"="Transparent"
  28. "IgnoreProjector"="False"
  29. "RenderType"="TreeTransparentCutout"
  30.  
  31.         }
  32.  
  33.        
  34. Cull Off
  35. ZWrite On
  36. ZTest LEqual
  37. ColorMask RGBA
  38. Blend SrcAlpha OneMinusSrcAlpha
  39. Alphatest Greater [_Alphatest]
  40. Fog{
  41. }
  42.  
  43.  
  44.         CGPROGRAM
  45. #pragma surface surf BlinnPhongEditor  vertex:vert
  46. #pragma target 2.0
  47.  
  48.  
  49. float _Distans;
  50. float _Soft;
  51. float4 _MainColor;
  52. sampler2D _MainTex;
  53. sampler2D _LightMap;
  54. sampler2D _GIMap;
  55. float _Contrast;
  56. float _Brightness;
  57. sampler2D _Normal;
  58. float _Gloss;
  59. float4 _Specular;
  60. float _Range;
  61. float _Frequent;
  62. float _Speed;
  63.  
  64.             struct EditorSurfaceOutput {
  65.                 half3 Albedo;
  66.                 half3 Normal;
  67.                 half3 Emission;
  68.                 half3 Gloss;
  69.                 half Specular;
  70.                 half Alpha;
  71.                 half4 Custom;
  72.             };
  73.            
  74.             inline half4 LightingBlinnPhongEditor_PrePass (EditorSurfaceOutput s, half4 light)
  75.             {
  76. half3 spec = light.a * s.Gloss;
  77. half4 c;
  78. c.rgb = (s.Albedo * light.rgb + light.rgb * spec);
  79. c.a = s.Alpha;
  80. return c;
  81.  
  82.             }
  83.  
  84.             inline half4 LightingBlinnPhongEditor (EditorSurfaceOutput s, half3 lightDir, half3 viewDir, half atten)
  85.             {
  86.                 half3 h = normalize (lightDir + viewDir);
  87.                
  88.                 half diff = max (0, dot ( lightDir, s.Normal ));
  89.                
  90.                 float nh = max (0, dot (s.Normal, h));
  91.                 float spec = pow (nh, s.Specular*128.0);
  92.                
  93.                 half4 res;
  94.                 res.rgb = _LightColor0.rgb * diff;
  95.                 res.w = spec * Luminance (_LightColor0.rgb);
  96.                 res *= atten * 2.0;
  97.  
  98.                 return LightingBlinnPhongEditor_PrePass( s, res );
  99.             }
  100.            
  101.             struct Input {
  102.                 float2 uv_MainTex;
  103. float4 fullMeshUV2;
  104. float4 screenPos;
  105. float2 uv_Normal;
  106.  
  107.             };
  108.  
  109.             void vert (inout appdata_full v, out Input o) {
  110. float4 Multiply0=_Time * _Speed.xxxx;
  111. float4 Add0=v.vertex + Multiply0;
  112. float4 Splat0=Add0.y;
  113. float4 Multiply1=Splat0 * _Frequent.xxxx;
  114. float4 Sin0=sin(Multiply1);
  115. float4 Mask0=float4(Sin0.x,0.0,0.0,0.0);
  116. float4 Multiply2=_Range.xxxx * Mask0;
  117. float4 Add1=Multiply2 + v.vertex;
  118. float4 VertexOutputMaster0_1_NoInput = float4(0,0,0,0);
  119. float4 VertexOutputMaster0_2_NoInput = float4(0,0,0,0);
  120. float4 VertexOutputMaster0_3_NoInput = float4(0,0,0,0);
  121. v.vertex = Add1;
  122.  
  123. o.fullMeshUV2 = v.texcoord1;
  124.  
  125.             }
  126.            
  127.  
  128.             void surf (Input IN, inout EditorSurfaceOutput o) {
  129.                 o.Normal = float3(0.0,0.0,1.0);
  130.                 o.Alpha = 1.0;
  131.                 o.Albedo = 0.0;
  132.                 o.Emission = 0.0;
  133.                 o.Gloss = 0.0;
  134.                 o.Specular = 0.0;
  135.                 o.Custom = 0.0;
  136.                
  137. float4 Tex2D2=tex2D(_MainTex,(IN.uv_MainTex.xyxy).xy);
  138. float4 Multiply5=_MainColor * Tex2D2;
  139. float4 Tex2D1=tex2D(_GIMap,(IN.fullMeshUV2).xy);
  140. float4 Splat0=IN.screenPos.z;
  141. float4 Multiply0=Splat0 * _Soft.xxxx;
  142. float4 Add0=Multiply0 + _Distans.xxxx;
  143. float4 Saturate0=saturate(Add0);
  144. float4 Invert0= float4(1.0, 1.0, 1.0, 1.0) - Saturate0;
  145. float4 Multiply2=Tex2D1 * Invert0;
  146. float4 Multiply3=Multiply5 * Multiply2;
  147. float4 Subtract0=Multiply3 - float4( 0.5,0.5,0.5,0.5 );
  148. float4 Multiply6=Subtract0 * _Contrast.xxxx;
  149. float4 Add1=Multiply6 + _Brightness.xxxx;
  150. float4 Tex2DNormal0=float4(UnpackNormal( tex2D(_Normal,(IN.uv_Normal.xyxy).xy)).xyz, 1.0 );
  151. float4 Tex2D0=tex2D(_LightMap,(IN.fullMeshUV2).xy);
  152. float4 Add3=Tex2D1 + Tex2D0;
  153. float4 Multiply1=Add3 * Saturate0;
  154. float4 Multiply4=Multiply5 * Multiply1;
  155. float4 Subtract1=Multiply4 - float4( 0.5,0.5,0.5,0.5 );
  156. float4 Multiply7=Subtract1 * _Contrast.xxxx;
  157. float4 Add2=Multiply7 + _Brightness.xxxx;
  158. float4 Master0_7_NoInput = float4(0,0,0,0);
  159. float4 Master0_6_NoInput = float4(1,1,1,1);
  160. o.Albedo = Add1;
  161. o.Normal = Tex2DNormal0;
  162. o.Emission = Add2;
  163. o.Specular = _Gloss.xxxx;
  164. o.Gloss = _Specular;
  165. o.Alpha = Tex2D2.aaaa;
  166.  
  167.                 o.Normal = normalize(o.Normal);
  168.             }
  169.         ENDCG
  170.     }
  171.     Fallback "Diffuse"
  172. }
Advertisement
Add Comment
Please, Sign In to add comment