TexeL

Untitled

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