Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Shader created with Shader Forge v1.04
- // Shader Forge (c) Neat Corporation / Joachim Holmer - http://www.acegikmo.com/shaderforge/
- // Note: Manually altering this data may prevent you from opening it in Shader Forge
- /*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;*/
- Shader "Shader Forge/Wet_Shader_01" {
- Properties {
- _Glossiness ("Glossiness", Float ) = 0.5
- _Diffuse ("Diffuse", 2D) = "white" {}
- _Normal ("Normal", 2D) = "bump" {}
- }
- SubShader {
- Tags {
- "RenderType"="Opaque"
- }
- Pass {
- Name "ForwardBase"
- Tags {
- "LightMode"="ForwardBase"
- }
- CGPROGRAM
- #pragma vertex vert
- #pragma fragment frag
- #define UNITY_PASS_FORWARDBASE
- #define SHOULD_SAMPLE_SH_PROBE ( defined (LIGHTMAP_OFF) )
- #include "UnityCG.cginc"
- #include "AutoLight.cginc"
- #pragma multi_compile_fwdbase_fullshadows
- #pragma exclude_renderers xbox360 ps3 flash d3d11_9x
- #pragma target 3.0
- uniform float4 _LightColor0;
- uniform sampler2D _Diffuse; uniform float4 _Diffuse_ST;
- uniform sampler2D _Normal; uniform float4 _Normal_ST;
- uniform float _Glossiness;
- struct VertexInput {
- float4 vertex : POSITION;
- float3 normal : NORMAL;
- float4 tangent : TANGENT;
- float2 texcoord0 : TEXCOORD0;
- };
- struct VertexOutput {
- float4 pos : SV_POSITION;
- float2 uv0 : TEXCOORD0;
- float4 posWorld : TEXCOORD1;
- float3 normalDir : TEXCOORD2;
- float3 tangentDir : TEXCOORD3;
- float3 binormalDir : TEXCOORD4;
- LIGHTING_COORDS(5,6)
- float3 shLight : TEXCOORD7;
- };
- VertexOutput vert (VertexInput v) {
- VertexOutput o = (VertexOutput)0;
- o.uv0 = v.texcoord0;
- #if SHOULD_SAMPLE_SH_PROBE
- o.shLight = ShadeSH9(float4(mul(_Object2World, float4(v.normal,0)).xyz * unity_Scale.w,1));
- #endif
- o.normalDir = mul(_Object2World, float4(v.normal,0)).xyz;
- o.tangentDir = normalize( mul( _Object2World, float4( v.tangent.xyz, 0.0 ) ).xyz );
- o.binormalDir = normalize(cross(o.normalDir, o.tangentDir) * v.tangent.w);
- o.posWorld = mul(_Object2World, v.vertex);
- float3 lightColor = _LightColor0.rgb;
- o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
- TRANSFER_VERTEX_TO_FRAGMENT(o)
- return o;
- }
- fixed4 frag(VertexOutput i) : COLOR {
- i.normalDir = normalize(i.normalDir);
- float3x3 tangentTransform = float3x3( i.tangentDir, i.binormalDir, i.normalDir);
- /////// Vectors:
- float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz);
- float3 _Normal_var = UnpackNormal(tex2D(_Normal,TRANSFORM_TEX(i.uv0, _Normal)));
- float3 normalLocal = _Normal_var.rgb;
- float3 normalDirection = normalize(mul( normalLocal, tangentTransform )); // Perturbed normals
- float3 lightDirection = normalize(_WorldSpaceLightPos0.xyz);
- float3 lightColor = _LightColor0.rgb;
- float3 halfDirection = normalize(viewDirection+lightDirection);
- ////// Lighting:
- float attenuation = LIGHT_ATTENUATION(i)*2;
- float3 attenColor = attenuation * _LightColor0.xyz;
- ///////// Gloss:
- float gloss = _Glossiness;
- float specPow = exp2( gloss * 10.0+1.0);
- ////// Specular:
- float NdotL = max(0, dot( normalDirection, lightDirection ));
- float node_7347 = pow(1.0-max(0,dot(normalDirection, viewDirection)),4.0);
- float4 _Diffuse_var = tex2D(_Diffuse,TRANSFORM_TEX(i.uv0, _Diffuse));
- float3 node_6757 = (_Diffuse_var.rgb*_Diffuse_var.a);
- float3 specularColor = (node_6757+node_6757);
- float3 directSpecular = (floor(attenuation) * _LightColor0.xyz) * pow(max(0,dot(halfDirection,normalDirection)),specPow);
- float3 indirectSpecular = (0 + float3(node_7347,node_7347,node_7347));
- float3 specular = (directSpecular + indirectSpecular) * specularColor;
- /////// Diffuse:
- NdotL = max(0.0,dot( normalDirection, lightDirection ));
- float3 indirectDiffuse = float3(0,0,0);
- float3 directDiffuse = max( 0.0, NdotL) * attenColor;
- #if SHOULD_SAMPLE_SH_PROBE
- indirectDiffuse += i.shLight; // Per-Vertex Light Probes / Spherical harmonics
- #endif
- float3 diffuse = (directDiffuse + indirectDiffuse) * _Diffuse_var.rgb;
- /// Final Color:
- float3 finalColor = diffuse + specular;
- return fixed4(finalColor,1);
- }
- ENDCG
- }
- Pass {
- Name "ForwardAdd"
- Tags {
- "LightMode"="ForwardAdd"
- }
- Blend One One
- Fog { Color (0,0,0,0) }
- CGPROGRAM
- #pragma vertex vert
- #pragma fragment frag
- #define UNITY_PASS_FORWARDADD
- #define SHOULD_SAMPLE_SH_PROBE ( defined (LIGHTMAP_OFF) )
- #include "UnityCG.cginc"
- #include "AutoLight.cginc"
- #pragma multi_compile_fwdadd_fullshadows
- #pragma exclude_renderers xbox360 ps3 flash d3d11_9x
- #pragma target 3.0
- uniform float4 _LightColor0;
- uniform sampler2D _Diffuse; uniform float4 _Diffuse_ST;
- uniform sampler2D _Normal; uniform float4 _Normal_ST;
- uniform float _Glossiness;
- struct VertexInput {
- float4 vertex : POSITION;
- float3 normal : NORMAL;
- float4 tangent : TANGENT;
- float2 texcoord0 : TEXCOORD0;
- };
- struct VertexOutput {
- float4 pos : SV_POSITION;
- float2 uv0 : TEXCOORD0;
- float4 posWorld : TEXCOORD1;
- float3 normalDir : TEXCOORD2;
- float3 tangentDir : TEXCOORD3;
- float3 binormalDir : TEXCOORD4;
- LIGHTING_COORDS(5,6)
- };
- VertexOutput vert (VertexInput v) {
- VertexOutput o = (VertexOutput)0;
- o.uv0 = v.texcoord0;
- o.normalDir = mul(_Object2World, float4(v.normal,0)).xyz;
- o.tangentDir = normalize( mul( _Object2World, float4( v.tangent.xyz, 0.0 ) ).xyz );
- o.binormalDir = normalize(cross(o.normalDir, o.tangentDir) * v.tangent.w);
- o.posWorld = mul(_Object2World, v.vertex);
- float3 lightColor = _LightColor0.rgb;
- o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
- TRANSFER_VERTEX_TO_FRAGMENT(o)
- return o;
- }
- fixed4 frag(VertexOutput i) : COLOR {
- i.normalDir = normalize(i.normalDir);
- float3x3 tangentTransform = float3x3( i.tangentDir, i.binormalDir, i.normalDir);
- /////// Vectors:
- float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz);
- float3 _Normal_var = UnpackNormal(tex2D(_Normal,TRANSFORM_TEX(i.uv0, _Normal)));
- float3 normalLocal = _Normal_var.rgb;
- float3 normalDirection = normalize(mul( normalLocal, tangentTransform )); // Perturbed normals
- float3 lightDirection = normalize(lerp(_WorldSpaceLightPos0.xyz, _WorldSpaceLightPos0.xyz - i.posWorld.xyz,_WorldSpaceLightPos0.w));
- float3 lightColor = _LightColor0.rgb;
- float3 halfDirection = normalize(viewDirection+lightDirection);
- ////// Lighting:
- float attenuation = LIGHT_ATTENUATION(i)*2;
- float3 attenColor = attenuation * _LightColor0.xyz;
- ///////// Gloss:
- float gloss = _Glossiness;
- float specPow = exp2( gloss * 10.0+1.0);
- ////// Specular:
- float NdotL = max(0, dot( normalDirection, lightDirection ));
- float4 _Diffuse_var = tex2D(_Diffuse,TRANSFORM_TEX(i.uv0, _Diffuse));
- float3 node_6757 = (_Diffuse_var.rgb*_Diffuse_var.a);
- float3 specularColor = (node_6757+node_6757);
- float3 directSpecular = attenColor * pow(max(0,dot(halfDirection,normalDirection)),specPow);
- float3 specular = directSpecular * specularColor;
- /////// Diffuse:
- NdotL = max(0.0,dot( normalDirection, lightDirection ));
- float3 directDiffuse = max( 0.0, NdotL) * attenColor;
- float3 diffuse = directDiffuse * _Diffuse_var.rgb;
- /// Final Color:
- float3 finalColor = diffuse + specular;
- return fixed4(finalColor * 1,0);
- }
- ENDCG
- }
- }
- FallBack "Diffuse"
- CustomEditor "ShaderForgeMaterialInspector"
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement