daily pastebin goal
24%
SHARE
TWEET

Demo 04 - Snow effect

tonynogo Jul 6th, 2017 1,606 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Shader "Custom/SnowEffect" {
  2.     Properties {
  3.         _SnowColor ("Snow color", Color) = (1, 1, 1, 1)
  4.         _MainTex ("MainTexture", 2D) = "white" {}
  5.         _Bump ("BumpTex", 2D) = "bump" {}
  6.         _SnowDirection ("Snow direction", Vector) = (0, 1, 0)
  7.         _SnowLevel ("Amount of Snow", Range(1, -1)) = 0
  8.     }
  9.  
  10.     SubShader {
  11.         Tags { "RenderType" = "Opaque" }
  12.         LOD 200
  13.  
  14.         CGPROGRAM
  15.         #pragma surface surf Lambert
  16.  
  17.         half4 _SnowColor;
  18.         sampler2D _MainTex;
  19.         sampler2D _Bump;
  20.         half3 _SnowDirection;
  21.         fixed _SnowLevel;
  22.  
  23.         struct Input {
  24.             float2 uv_MainTex;
  25.             float2 uv_Bump;
  26.             float3 worldNormal;
  27.             INTERNAL_DATA
  28.         };
  29.  
  30.         void surf(Input IN, inout SurfaceOutput o)
  31.         {
  32.             half4 tex = tex2D(_MainTex, IN.uv_MainTex);
  33.             o.Normal = UnpackNormal (tex2D(_Bump, IN.uv_Bump));
  34.             if(dot(WorldNormalVector(IN, o.Normal), _SnowDirection) >= _SnowLevel)
  35.             {
  36.                 o.Albedo = _SnowColor.rgb;
  37.             }
  38.             else
  39.             {
  40.                 o.Albedo = tex.rgb;
  41.             }
  42.         }
  43.         ENDCG
  44.     }
  45. }
RAW Paste Data
Top