Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Shader created with Shader Forge v1.26
- // 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.26;sub:START;pass:START;ps:flbk:Standard,iptp:0,cusa:False,bamd:0,lico:1,lgpr:1,limd:1,spmd:1,trmd:0,grmd:0,uamb:True,mssp:True,bkdf:False,hqlp:False,rprd:False,enco:False,rmgx:True,rpth:0,vtps:0,hqsc:True,nrmq:1,nrsp:0,vomd:0,spxs:False,tesm:1,olmd:1,culm:0,bsrc:0,bdst:1,dpts:2,wrdp:True,dith:0,rfrpo:True,rfrpn:Refraction,coma:15,ufog:True,aust:False,igpj:True,qofs:0,qpre:3,rntp:2,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,stcl:False,stva:128,stmr:255,stmw:255,stcp:6,stps:0,stfa:0,stfz:0,ofsf:0,ofsu:0,f2p0:False,fnsp:False,fnfb:True;n:type:ShaderForge.SFN_Final,id:4013,x:32719,y:32712,varname:node_4013,prsc:2|diff-2627-OUT,refract-673-OUT,voffset-9336-OUT;n:type:ShaderForge.SFN_Color,id:1304,x:32118,y:32628,ptovrint:False,ptlb: Color A,ptin:_ColorA,varname:_ColorA,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,c1:1,c2:1,c3:1,c4:1;n:type:ShaderForge.SFN_ValueProperty,id:366,x:32613,y:33441,ptovrint:False,ptlb:Tesselletion,ptin:_Tesselletion,varname:_Tesselletion,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,v1:0;n:type:ShaderForge.SFN_DepthBlend,id:7273,x:31483,y:33023,varname:nodeDepth,prsc:2|DIST-5643-OUT;n:type:ShaderForge.SFN_ValueProperty,id:5643,x:31249,y:33023,ptovrint:False,ptlb:Depth,ptin:_Depth,varname:_Depth,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,v1:30;n:type:ShaderForge.SFN_Divide,id:3843,x:31711,y:33128,varname:node_3843,prsc:2|A-7273-OUT,B-9196-OUT;n:type:ShaderForge.SFN_Dot,id:9196,x:31483,y:33215,varname:node_9196,prsc:2,dt:4|A-1173-OUT,B-6234-OUT;n:type:ShaderForge.SFN_NormalVector,id:6234,x:31249,y:33290,prsc:2,pt:False;n:type:ShaderForge.SFN_ViewVector,id:1173,x:31249,y:33152,varname:node_1173,prsc:2;n:type:ShaderForge.SFN_Lerp,id:2627,x:32459,y:32795,varname:node_2627,prsc:2|A-1304-RGB,B-940-RGB,T-3843-OUT;n:type:ShaderForge.SFN_Color,id:940,x:31982,y:32817,ptovrint:False,ptlb:Color B,ptin:_ColorB,varname:_ColorB,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,c1:0,c2:0,c3:0,c4:1;n:type:ShaderForge.SFN_Vector2,id:673,x:32384,y:33004,varname:node_673,prsc:2,v1:0,v2:0;n:type:ShaderForge.SFN_Vector3,id:168,x:32200,y:33338,varname:node_168,prsc:2,v1:0,v2:1,v3:0;n:type:ShaderForge.SFN_Multiply,id:9336,x:32384,y:33213,varname:node_9336,prsc:2|A-3843-OUT,B-168-OUT;n:type:ShaderForge.SFN_Desaturate,id:9957,x:32065,y:33157,varname:node_9957,prsc:2|COL-3843-OUT;n:type:ShaderForge.SFN_Vector1,id:5011,x:32218,y:33191,varname:node_5011,prsc:2,v1:1;proporder:1304-366-5643-940;pass:END;sub:END;*/
- Shader "Shader Forge/Tesselation Depth Mask" {
- Properties {
- _ColorA (" Color A", Color) = (1,1,1,1)
- _Tesselletion ("Tesselletion", Float ) = 0
- _Depth ("Depth", Float ) = 30
- _ColorB ("Color B", Color) = (0,0,0,1)
- }
- SubShader {
- Tags {
- "IgnoreProjector"="True"
- "Queue"="Transparent"
- "RenderType"="Transparent"
- }
- GrabPass{ }
- Pass {
- Name "FORWARD"
- Tags {
- "LightMode"="ForwardBase"
- }
- CGPROGRAM
- #pragma vertex vert
- #pragma fragment frag
- #define UNITY_PASS_FORWARDBASE
- #include "UnityCG.cginc"
- #pragma multi_compile_fwdbase
- #pragma multi_compile_fog
- #pragma exclude_renderers gles3 metal d3d11_9x xbox360 xboxone ps3 ps4 psp2
- #pragma target 3.0
- uniform float4 _LightColor0;
- uniform sampler2D _GrabTexture;
- uniform sampler2D _CameraDepthTexture;
- uniform float4 _ColorA;
- uniform float _Depth;
- uniform float4 _ColorB;
- struct VertexInput {
- float4 vertex : POSITION;
- float3 normal : NORMAL;
- };
- struct VertexOutput {
- float4 pos : SV_POSITION;
- float4 posWorld : TEXCOORD0;
- float3 normalDir : TEXCOORD1;
- float4 screenPos : TEXCOORD2;
- float4 projPos : TEXCOORD3;
- UNITY_FOG_COORDS(4)
- };
- VertexOutput vert (VertexInput v) {
- VertexOutput o = (VertexOutput)0;
- o.normalDir = UnityObjectToWorldNormal(v.normal);
- float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - mul(_Object2World, v.vertex).xyz);
- float nodeDepth = saturate((sceneZ-partZ)/_Depth);
- float node_3843 = (nodeDepth/0.5*dot(viewDirection,v.normal)+0.5);
- v.vertex.xyz += (node_3843*float3(0,1,0));
- o.posWorld = mul(_Object2World, v.vertex);
- float3 lightColor = _LightColor0.rgb;
- o.pos = mul(UNITY_MATRIX_MVP, v.vertex );
- UNITY_TRANSFER_FOG(o,o.pos);
- o.projPos = ComputeScreenPos (o.pos);
- COMPUTE_EYEDEPTH(o.projPos.z);
- o.screenPos = o.pos;
- return o;
- }
- float4 frag(VertexOutput i) : COLOR {
- #if UNITY_UV_STARTS_AT_TOP
- float grabSign = -_ProjectionParams.x;
- #else
- float grabSign = _ProjectionParams.x;
- #endif
- i.normalDir = normalize(i.normalDir);
- i.screenPos = float4( i.screenPos.xy / i.screenPos.w, 0, 0 );
- i.screenPos.y *= _ProjectionParams.x;
- float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz);
- float3 normalDirection = i.normalDir;
- float sceneZ = max(0,LinearEyeDepth (UNITY_SAMPLE_DEPTH(tex2Dproj(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos)))) - _ProjectionParams.g);
- float partZ = max(0,i.projPos.z - _ProjectionParams.g);
- float2 sceneUVs = float2(1,grabSign)*i.screenPos.xy*0.5+0.5 + float2(0,0);
- float4 sceneColor = tex2D(_GrabTexture, sceneUVs);
- float3 lightDirection = normalize(_WorldSpaceLightPos0.xyz);
- float3 lightColor = _LightColor0.rgb;
- ////// Lighting:
- float attenuation = 1;
- float3 attenColor = attenuation * _LightColor0.xyz;
- /////// Diffuse:
- float NdotL = max(0.0,dot( normalDirection, lightDirection ));
- float3 directDiffuse = max( 0.0, NdotL) * attenColor;
- float3 indirectDiffuse = float3(0,0,0);
- indirectDiffuse += UNITY_LIGHTMODEL_AMBIENT.rgb; // Ambient Light
- float nodeDepth = saturate((sceneZ-partZ)/_Depth);
- float node_3843 = (nodeDepth/0.5*dot(viewDirection,i.normalDir)+0.5);
- float3 diffuseColor = lerp(_ColorA.rgb,_ColorB.rgb,node_3843);
- float3 diffuse = (directDiffuse + indirectDiffuse) * diffuseColor;
- /// Final Color:
- float3 finalColor = diffuse;
- fixed4 finalRGBA = fixed4(lerp(sceneColor.rgb, finalColor,1),1);
- UNITY_APPLY_FOG(i.fogCoord, finalRGBA);
- return finalRGBA;
- }
- ENDCG
- }
- Pass {
- Name "FORWARD_DELTA"
- Tags {
- "LightMode"="ForwardAdd"
- }
- Blend One One
- CGPROGRAM
- #pragma vertex vert
- #pragma fragment frag
- #define UNITY_PASS_FORWARDADD
- #include "UnityCG.cginc"
- #include "AutoLight.cginc"
- #pragma multi_compile_fwdadd
- #pragma multi_compile_fog
- #pragma exclude_renderers gles3 metal d3d11_9x xbox360 xboxone ps3 ps4 psp2
- #pragma target 3.0
- uniform float4 _LightColor0;
- uniform sampler2D _GrabTexture;
- uniform sampler2D _CameraDepthTexture;
- uniform float4 _ColorA;
- uniform float _Depth;
- uniform float4 _ColorB;
- struct VertexInput {
- float4 vertex : POSITION;
- float3 normal : NORMAL;
- };
- struct VertexOutput {
- float4 pos : SV_POSITION;
- float4 posWorld : TEXCOORD0;
- float3 normalDir : TEXCOORD1;
- float4 screenPos : TEXCOORD2;
- float4 projPos : TEXCOORD3;
- LIGHTING_COORDS(4,5)
- UNITY_FOG_COORDS(6)
- };
- VertexOutput vert (VertexInput v) {
- VertexOutput o = (VertexOutput)0;
- o.normalDir = UnityObjectToWorldNormal(v.normal);
- float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - mul(_Object2World, v.vertex).xyz);
- float nodeDepth = saturate((sceneZ-partZ)/_Depth);
- float node_3843 = (nodeDepth/0.5*dot(viewDirection,v.normal)+0.5);
- v.vertex.xyz += (node_3843*float3(0,1,0));
- o.posWorld = mul(_Object2World, v.vertex);
- float3 lightColor = _LightColor0.rgb;
- o.pos = mul(UNITY_MATRIX_MVP, v.vertex );
- UNITY_TRANSFER_FOG(o,o.pos);
- o.projPos = ComputeScreenPos (o.pos);
- COMPUTE_EYEDEPTH(o.projPos.z);
- o.screenPos = o.pos;
- TRANSFER_VERTEX_TO_FRAGMENT(o)
- return o;
- }
- float4 frag(VertexOutput i) : COLOR {
- #if UNITY_UV_STARTS_AT_TOP
- float grabSign = -_ProjectionParams.x;
- #else
- float grabSign = _ProjectionParams.x;
- #endif
- i.normalDir = normalize(i.normalDir);
- i.screenPos = float4( i.screenPos.xy / i.screenPos.w, 0, 0 );
- i.screenPos.y *= _ProjectionParams.x;
- float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz);
- float3 normalDirection = i.normalDir;
- float sceneZ = max(0,LinearEyeDepth (UNITY_SAMPLE_DEPTH(tex2Dproj(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos)))) - _ProjectionParams.g);
- float partZ = max(0,i.projPos.z - _ProjectionParams.g);
- float2 sceneUVs = float2(1,grabSign)*i.screenPos.xy*0.5+0.5 + float2(0,0);
- float4 sceneColor = tex2D(_GrabTexture, sceneUVs);
- float3 lightDirection = normalize(lerp(_WorldSpaceLightPos0.xyz, _WorldSpaceLightPos0.xyz - i.posWorld.xyz,_WorldSpaceLightPos0.w));
- float3 lightColor = _LightColor0.rgb;
- ////// Lighting:
- float attenuation = LIGHT_ATTENUATION(i);
- float3 attenColor = attenuation * _LightColor0.xyz;
- /////// Diffuse:
- float NdotL = max(0.0,dot( normalDirection, lightDirection ));
- float3 directDiffuse = max( 0.0, NdotL) * attenColor;
- float nodeDepth = saturate((sceneZ-partZ)/_Depth);
- float node_3843 = (nodeDepth/0.5*dot(viewDirection,i.normalDir)+0.5);
- float3 diffuseColor = lerp(_ColorA.rgb,_ColorB.rgb,node_3843);
- float3 diffuse = directDiffuse * diffuseColor;
- /// Final Color:
- float3 finalColor = diffuse;
- fixed4 finalRGBA = fixed4(finalColor * 1,0);
- UNITY_APPLY_FOG(i.fogCoord, finalRGBA);
- return finalRGBA;
- }
- ENDCG
- }
- Pass {
- Name "ShadowCaster"
- Tags {
- "LightMode"="ShadowCaster"
- }
- Offset 1, 1
- CGPROGRAM
- #pragma vertex vert
- #pragma fragment frag
- #define UNITY_PASS_SHADOWCASTER
- #include "UnityCG.cginc"
- #include "Lighting.cginc"
- #pragma fragmentoption ARB_precision_hint_fastest
- #pragma multi_compile_shadowcaster
- #pragma multi_compile_fog
- #pragma exclude_renderers gles3 metal d3d11_9x xbox360 xboxone ps3 ps4 psp2
- #pragma target 3.0
- uniform sampler2D _CameraDepthTexture;
- uniform float _Depth;
- struct VertexInput {
- float4 vertex : POSITION;
- float3 normal : NORMAL;
- };
- struct VertexOutput {
- V2F_SHADOW_CASTER;
- float4 posWorld : TEXCOORD1;
- float3 normalDir : TEXCOORD2;
- float4 projPos : TEXCOORD3;
- };
- VertexOutput vert (VertexInput v) {
- VertexOutput o = (VertexOutput)0;
- o.normalDir = UnityObjectToWorldNormal(v.normal);
- float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - mul(_Object2World, v.vertex).xyz);
- float nodeDepth = saturate((sceneZ-partZ)/_Depth);
- float node_3843 = (nodeDepth/0.5*dot(viewDirection,v.normal)+0.5);
- v.vertex.xyz += (node_3843*float3(0,1,0));
- o.posWorld = mul(_Object2World, v.vertex);
- o.pos = mul(UNITY_MATRIX_MVP, v.vertex );
- o.projPos = ComputeScreenPos (o.pos);
- COMPUTE_EYEDEPTH(o.projPos.z);
- TRANSFER_SHADOW_CASTER(o)
- return o;
- }
- float4 frag(VertexOutput i) : COLOR {
- i.normalDir = normalize(i.normalDir);
- float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz);
- float3 normalDirection = i.normalDir;
- float sceneZ = max(0,LinearEyeDepth (UNITY_SAMPLE_DEPTH(tex2Dproj(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos)))) - _ProjectionParams.g);
- float partZ = max(0,i.projPos.z - _ProjectionParams.g);
- SHADOW_CASTER_FRAGMENT(i)
- }
- ENDCG
- }
- }
- CustomEditor "ShaderForgeMaterialInspector"
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement