Created
April 17, 2019 01:54
-
-
Save Chaosed0/77111cd7185b19fc894bb35d42ffd9bc to your computer and use it in GitHub Desktop.
Simple rim light shader
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Shader "Custom/Rimlight" { | |
Properties { | |
_MainTex ("Base (RGB)", 2D) = "white" {} | |
_RimValue ("Rim value", Range(0, 1)) = 0.5 | |
} | |
SubShader { | |
Tags { "RenderType"="Transparent" "Queue"="Transparent" } | |
CGPROGRAM | |
#pragma surface surf Lambert alpha | |
sampler2D _MainTex; | |
fixed _RimValue; | |
struct Input { | |
float2 uv_MainTex; | |
float3 viewDir; | |
float3 worldNormal; | |
}; | |
void surf (Input IN, inout SurfaceOutput o) { | |
half4 c = tex2D (_MainTex, IN.uv_MainTex); | |
o.Albedo = c.rgb; | |
float3 normal = normalize(IN.worldNormal); | |
float3 dir = normalize(IN.viewDir); | |
float val = 1 - (abs(dot(dir, normal))); | |
float rim = val * val * _RimValue; | |
o.Alpha = c.a * rim; | |
} | |
ENDCG | |
} | |
FallBack "Diffuse" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment