daily pastebin goal
65%
SHARE
TWEET

Demo 43 - Misc rim effect

tonynogo Jul 6th, 2017 1,816 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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top