Advertisement
tonynogo

Demo 43 - Misc rim effect

Jul 6th, 2017
5,298
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Shader "Custom/RimMiscellaneous"
  2. {
  3.     Properties {
  4.         _MainTex ("Base (RGB)", 2D) = "white" {}
  5.         _RimValue ("Rim value", Range(0, 1)) = 0.5
  6.         _Color ("Color", Color)=(1, 1, 1, 1)
  7.     }
  8.     SubShader {
  9.         Tags { "RenderType"="Transparent" "Queue"="Transparent" }
  10.  
  11.         CGPROGRAM
  12.         #pragma surface surf Lambert alpha
  13.  
  14.         sampler2D _MainTex;
  15.         fixed _RimValue;
  16.  
  17.         struct Input {
  18.             float2 uv_MainTex;
  19.             float3 viewDir;
  20.             float3 worldNormal;
  21.         };
  22.  
  23.         fixed4 _Color;
  24.  
  25.         void surf (Input IN, inout SurfaceOutput o) {
  26.             half4 c = tex2D (_MainTex, IN.uv_MainTex + _Time.y * 0.1);
  27.             o.Albedo = c.rgb * _Color;
  28.  
  29.             float3 normal = normalize(IN.worldNormal);
  30.             float3 dir = normalize(IN.viewDir);
  31.             float val = 1 - (abs(dot(dir, normal)));
  32.             float rim = val * val *  _RimValue;
  33.             o.Alpha = c.a * rim;
  34.         }
  35.         ENDCG
  36.     }
  37.     FallBack "Diffuse"
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement