Advertisement
Guest User

Untitled

a guest
Jan 24th, 2015
484
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.76 KB | None | 0 0
  1. // Shader created with Shader Forge v1.04
  2. // Shader Forge (c) Neat Corporation / Joachim Holmer - http://www.acegikmo.com/shaderforge/
  3. // Note: Manually altering this data may prevent you from opening it in Shader Forge
  4. /*SF_DATA;ver:1.04;sub:START;pass:START;ps:flbk:,lico:1,lgpr:1,nrmq:1,limd:1,uamb:True,mssp:True,lmpd:False,lprd:True,rprd:False,enco:False,frtr:True,vitr:True,dbil:True,rmgx:True,rpth:0,hqsc:True,hqlp:False,tesm:0,blpr:0,bsrc:0,bdst:1,culm:0,dpts:2,wrdp:True,dith:2,ufog:True,aust:True,igpj:False,qofs:0,qpre:1,rntp:1,fgom:False,fgoc:False,fgod:False,fgor:False,fgmd:0,fgcr:0.5,fgcg:0.5,fgcb:0.5,fgca:1,fgde:0.01,fgrn:0,fgrf:300,ofsf:0,ofsu:0,f2p0:False;n:type:ShaderForge.SFN_Final,id:5453,x:32829,y:32702,varname:node_5453,prsc:2|diff-6419-RGB,spec-9615-OUT,gloss-6792-OUT,normal-3107-RGB,amspl-7347-OUT;n:type:ShaderForge.SFN_Tex2d,id:6419,x:31849,y:32445,ptovrint:False,ptlb:Diffuse,ptin:_Diffuse,varname:node_6419,prsc:2,tex:e6704f29740c84647b8dd17cd40bb4bb,ntxv:0,isnm:False;n:type:ShaderForge.SFN_Tex2d,id:3107,x:32424,y:32933,ptovrint:False,ptlb:Normal,ptin:_Normal,varname:node_3107,prsc:2,tex:6af146ab2f1d1eb47b028c88a7e47214,ntxv:3,isnm:True;n:type:ShaderForge.SFN_Fresnel,id:7347,x:32412,y:33135,varname:node_7347,prsc:2|NRM-8774-OUT,EXP-4566-OUT;n:type:ShaderForge.SFN_ValueProperty,id:6792,x:32436,y:32841,ptovrint:False,ptlb:Glossiness,ptin:_Glossiness,varname:node_6792,prsc:2,glob:False,v1:0.5;n:type:ShaderForge.SFN_Multiply,id:6757,x:32140,y:32563,varname:node_6757,prsc:2|A-6419-RGB,B-6419-A;n:type:ShaderForge.SFN_Add,id:9615,x:32436,y:32692,varname:node_9615,prsc:2|A-6757-OUT,B-6757-OUT;n:type:ShaderForge.SFN_Vector1,id:4566,x:32079,y:33191,varname:node_4566,prsc:2,v1:4;proporder:6792-6419-3107;pass:END;sub:END;*/
  5.  
  6. Shader "Shader Forge/Wet_Shader_01" {
  7. Properties {
  8. _Glossiness ("Glossiness", Float ) = 0.5
  9. _Diffuse ("Diffuse", 2D) = "white" {}
  10. _Normal ("Normal", 2D) = "bump" {}
  11. }
  12. SubShader {
  13. Tags {
  14. "RenderType"="Opaque"
  15. }
  16. Pass {
  17. Name "ForwardBase"
  18. Tags {
  19. "LightMode"="ForwardBase"
  20. }
  21.  
  22.  
  23. CGPROGRAM
  24. #pragma vertex vert
  25. #pragma fragment frag
  26. #define UNITY_PASS_FORWARDBASE
  27. #define SHOULD_SAMPLE_SH_PROBE ( defined (LIGHTMAP_OFF) )
  28. #include "UnityCG.cginc"
  29. #include "AutoLight.cginc"
  30. #pragma multi_compile_fwdbase_fullshadows
  31. #pragma exclude_renderers xbox360 ps3 flash d3d11_9x
  32. #pragma target 3.0
  33. uniform float4 _LightColor0;
  34. uniform sampler2D _Diffuse; uniform float4 _Diffuse_ST;
  35. uniform sampler2D _Normal; uniform float4 _Normal_ST;
  36. uniform float _Glossiness;
  37. struct VertexInput {
  38. float4 vertex : POSITION;
  39. float3 normal : NORMAL;
  40. float4 tangent : TANGENT;
  41. float2 texcoord0 : TEXCOORD0;
  42. };
  43. struct VertexOutput {
  44. float4 pos : SV_POSITION;
  45. float2 uv0 : TEXCOORD0;
  46. float4 posWorld : TEXCOORD1;
  47. float3 normalDir : TEXCOORD2;
  48. float3 tangentDir : TEXCOORD3;
  49. float3 binormalDir : TEXCOORD4;
  50. LIGHTING_COORDS(5,6)
  51. float3 shLight : TEXCOORD7;
  52. };
  53. VertexOutput vert (VertexInput v) {
  54. VertexOutput o = (VertexOutput)0;
  55. o.uv0 = v.texcoord0;
  56. #if SHOULD_SAMPLE_SH_PROBE
  57. o.shLight = ShadeSH9(float4(mul(_Object2World, float4(v.normal,0)).xyz * unity_Scale.w,1));
  58. #endif
  59. o.normalDir = mul(_Object2World, float4(v.normal,0)).xyz;
  60. o.tangentDir = normalize( mul( _Object2World, float4( v.tangent.xyz, 0.0 ) ).xyz );
  61. o.binormalDir = normalize(cross(o.normalDir, o.tangentDir) * v.tangent.w);
  62. o.posWorld = mul(_Object2World, v.vertex);
  63. float3 lightColor = _LightColor0.rgb;
  64. o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
  65. TRANSFER_VERTEX_TO_FRAGMENT(o)
  66. return o;
  67. }
  68. fixed4 frag(VertexOutput i) : COLOR {
  69. i.normalDir = normalize(i.normalDir);
  70. float3x3 tangentTransform = float3x3( i.tangentDir, i.binormalDir, i.normalDir);
  71. /////// Vectors:
  72. float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz);
  73. float3 _Normal_var = UnpackNormal(tex2D(_Normal,TRANSFORM_TEX(i.uv0, _Normal)));
  74. float3 normalLocal = _Normal_var.rgb;
  75. float3 normalDirection = normalize(mul( normalLocal, tangentTransform )); // Perturbed normals
  76. float3 lightDirection = normalize(_WorldSpaceLightPos0.xyz);
  77. float3 lightColor = _LightColor0.rgb;
  78. float3 halfDirection = normalize(viewDirection+lightDirection);
  79. ////// Lighting:
  80. float attenuation = LIGHT_ATTENUATION(i)*2;
  81. float3 attenColor = attenuation * _LightColor0.xyz;
  82. ///////// Gloss:
  83. float gloss = _Glossiness;
  84. float specPow = exp2( gloss * 10.0+1.0);
  85. ////// Specular:
  86. float NdotL = max(0, dot( normalDirection, lightDirection ));
  87. float node_7347 = pow(1.0-max(0,dot(normalDirection, viewDirection)),4.0);
  88. float4 _Diffuse_var = tex2D(_Diffuse,TRANSFORM_TEX(i.uv0, _Diffuse));
  89. float3 node_6757 = (_Diffuse_var.rgb*_Diffuse_var.a);
  90. float3 specularColor = (node_6757+node_6757);
  91. float3 directSpecular = (floor(attenuation) * _LightColor0.xyz) * pow(max(0,dot(halfDirection,normalDirection)),specPow);
  92. float3 indirectSpecular = (0 + float3(node_7347,node_7347,node_7347));
  93. float3 specular = (directSpecular + indirectSpecular) * specularColor;
  94. /////// Diffuse:
  95. NdotL = max(0.0,dot( normalDirection, lightDirection ));
  96. float3 indirectDiffuse = float3(0,0,0);
  97. float3 directDiffuse = max( 0.0, NdotL) * attenColor;
  98. #if SHOULD_SAMPLE_SH_PROBE
  99. indirectDiffuse += i.shLight; // Per-Vertex Light Probes / Spherical harmonics
  100. #endif
  101. float3 diffuse = (directDiffuse + indirectDiffuse) * _Diffuse_var.rgb;
  102. /// Final Color:
  103. float3 finalColor = diffuse + specular;
  104. return fixed4(finalColor,1);
  105. }
  106. ENDCG
  107. }
  108. Pass {
  109. Name "ForwardAdd"
  110. Tags {
  111. "LightMode"="ForwardAdd"
  112. }
  113. Blend One One
  114.  
  115.  
  116. Fog { Color (0,0,0,0) }
  117. CGPROGRAM
  118. #pragma vertex vert
  119. #pragma fragment frag
  120. #define UNITY_PASS_FORWARDADD
  121. #define SHOULD_SAMPLE_SH_PROBE ( defined (LIGHTMAP_OFF) )
  122. #include "UnityCG.cginc"
  123. #include "AutoLight.cginc"
  124. #pragma multi_compile_fwdadd_fullshadows
  125. #pragma exclude_renderers xbox360 ps3 flash d3d11_9x
  126. #pragma target 3.0
  127. uniform float4 _LightColor0;
  128. uniform sampler2D _Diffuse; uniform float4 _Diffuse_ST;
  129. uniform sampler2D _Normal; uniform float4 _Normal_ST;
  130. uniform float _Glossiness;
  131. struct VertexInput {
  132. float4 vertex : POSITION;
  133. float3 normal : NORMAL;
  134. float4 tangent : TANGENT;
  135. float2 texcoord0 : TEXCOORD0;
  136. };
  137. struct VertexOutput {
  138. float4 pos : SV_POSITION;
  139. float2 uv0 : TEXCOORD0;
  140. float4 posWorld : TEXCOORD1;
  141. float3 normalDir : TEXCOORD2;
  142. float3 tangentDir : TEXCOORD3;
  143. float3 binormalDir : TEXCOORD4;
  144. LIGHTING_COORDS(5,6)
  145. };
  146. VertexOutput vert (VertexInput v) {
  147. VertexOutput o = (VertexOutput)0;
  148. o.uv0 = v.texcoord0;
  149. o.normalDir = mul(_Object2World, float4(v.normal,0)).xyz;
  150. o.tangentDir = normalize( mul( _Object2World, float4( v.tangent.xyz, 0.0 ) ).xyz );
  151. o.binormalDir = normalize(cross(o.normalDir, o.tangentDir) * v.tangent.w);
  152. o.posWorld = mul(_Object2World, v.vertex);
  153. float3 lightColor = _LightColor0.rgb;
  154. o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
  155. TRANSFER_VERTEX_TO_FRAGMENT(o)
  156. return o;
  157. }
  158. fixed4 frag(VertexOutput i) : COLOR {
  159. i.normalDir = normalize(i.normalDir);
  160. float3x3 tangentTransform = float3x3( i.tangentDir, i.binormalDir, i.normalDir);
  161. /////// Vectors:
  162. float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz);
  163. float3 _Normal_var = UnpackNormal(tex2D(_Normal,TRANSFORM_TEX(i.uv0, _Normal)));
  164. float3 normalLocal = _Normal_var.rgb;
  165. float3 normalDirection = normalize(mul( normalLocal, tangentTransform )); // Perturbed normals
  166. float3 lightDirection = normalize(lerp(_WorldSpaceLightPos0.xyz, _WorldSpaceLightPos0.xyz - i.posWorld.xyz,_WorldSpaceLightPos0.w));
  167. float3 lightColor = _LightColor0.rgb;
  168. float3 halfDirection = normalize(viewDirection+lightDirection);
  169. ////// Lighting:
  170. float attenuation = LIGHT_ATTENUATION(i)*2;
  171. float3 attenColor = attenuation * _LightColor0.xyz;
  172. ///////// Gloss:
  173. float gloss = _Glossiness;
  174. float specPow = exp2( gloss * 10.0+1.0);
  175. ////// Specular:
  176. float NdotL = max(0, dot( normalDirection, lightDirection ));
  177. float4 _Diffuse_var = tex2D(_Diffuse,TRANSFORM_TEX(i.uv0, _Diffuse));
  178. float3 node_6757 = (_Diffuse_var.rgb*_Diffuse_var.a);
  179. float3 specularColor = (node_6757+node_6757);
  180. float3 directSpecular = attenColor * pow(max(0,dot(halfDirection,normalDirection)),specPow);
  181. float3 specular = directSpecular * specularColor;
  182. /////// Diffuse:
  183. NdotL = max(0.0,dot( normalDirection, lightDirection ));
  184. float3 directDiffuse = max( 0.0, NdotL) * attenColor;
  185. float3 diffuse = directDiffuse * _Diffuse_var.rgb;
  186. /// Final Color:
  187. float3 finalColor = diffuse + specular;
  188. return fixed4(finalColor * 1,0);
  189. }
  190. ENDCG
  191. }
  192. }
  193. FallBack "Diffuse"
  194. CustomEditor "ShaderForgeMaterialInspector"
  195. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement