Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Inspired by MinionsArt: https://pastebin.com/LxDYqWBh
- Shader "Winter/SnowTracking"
- {
- Properties
- {
- _Tess ("Tessellation", Range(1, 32)) = 4
- _HighTex ("High Snow (RGB)", 2D) = "white" {}
- _HighColor ("High Snow Color", Color) = (1,1,1,1)
- _LowTex ("Low Snow (RGB)", 2D) = "white" {}
- _LowColor ("Low Snow Color", Color) = (1,1,1,1)
- _SplatMap ("Splat Map", 2D) = "black" {}
- _NormalMap ("Normal Map", 2D) = "bump" {}
- _SnowHeight ("Snow Height", Range(0, 15)) = 1
- _WorldUp ("World Up Vector", Vector) = (0, 1, 0, 0)
- _Displacement ("Displacement", Range(0, 15.0)) = 0.3
- _SpecColor ("Specular Color", color) = (0.5, 0.5, 0.5, 0.5)
- }
- SubShader
- {
- Tags { "RenderType"="Opaque" }
- LOD 200
- CGPROGRAM
- // Physically based Standard lighting model, and enable shadows on all light types
- #pragma surface surf BlinnPhong addshadow fullforwardshadows vertex:disp tessellate:tessDistance nolightmap
- #pragma target 4.6
- #include "Tessellation.cginc"
- struct appdata
- {
- float4 vertex : POSITION;
- float4 tangent : TANGENT;
- float3 normal : NORMAL;
- float2 texcoord : TEXCOORD0;
- };
- float _Tess;
- float4 tessDistance (appdata v0, appdata v1, appdata v2)
- {
- float minDist = 10.0;
- float maxDist = 100.0;
- return UnityDistanceBasedTess(v0.vertex, v1.vertex, v2.vertex, minDist, maxDist, _Tess);
- }
- sampler2D _SplatMap;
- float _Displacement;
- float _SnowHeight;
- float4 _WorldUp;
- void disp (inout appdata v)
- {
- float d = tex2Dlod(_SplatMap, float4(v.texcoord.xy,0,0)).r * _Displacement;
- v.vertex.xyz -= _WorldUp * d;
- v.vertex.y = v.vertex.y + _SnowHeight;
- }
- struct Input
- {
- float2 uv_HighTex;
- float2 uv_LowTex;
- float2 uv_SplatMap;
- };
- sampler2D _HighTex;
- fixed4 _HighColor;
- sampler2D _LowTex;
- fixed4 _LowColor;
- sampler2D _NormalMap;
- void surf (Input IN, inout SurfaceOutput o)
- {
- half amount = tex2Dlod(_SplatMap, float4(IN.uv_SplatMap, 0, 0)).r;
- half4 c = lerp(tex2D(_HighTex, IN.uv_HighTex) * _HighColor, tex2D(_LowTex, IN.uv_LowTex) * _LowColor, amount);
- o.Albedo = c.rgb;
- o.Specular = 0.2;
- o.Gloss = 1.0;
- o.Normal = UnpackNormal(tex2D(_NormalMap, IN.uv_HighTex));
- }
- ENDCG
- }
- FallBack "Diffuse"
- }
Add Comment
Please, Sign In to add comment