forked from DMinsky/udemy_shaderdev
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHolisticRim.shader
More file actions
37 lines (27 loc) · 792 Bytes
/
Copy pathHolisticRim.shader
File metadata and controls
37 lines (27 loc) · 792 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
Shader "Holistic/Rim" {
Properties {
_RimColor ( "Rim Color", Color ) = ( 0, 0.5, 0.5, 0 )
_RimPower ( "Rim Power", Range( 0.2, 8.0 ) ) = 3.0
}
SubShader {
CGPROGRAM
#pragma surface surf Lambert
struct Input
{
float3 viewDir;
};
float4 _RimColor;
float _RimPower;
void surf( Input IN, inout SurfaceOutput o ) {
// Not sure if there is a need to normalize viewDir
// since it looks already normalized.
// Also, saturate here also has no visual effect
// so I leaved a simplified version of code instead of original
// half rim = 1 - saturate ( dot( normalize( IN.viewDir ), o.Normal ) );
half rim = 1 - dot( ( IN.viewDir ), o.Normal );
o.Emission = _RimColor.rgb * pow( rim, _RimPower );
}
ENDCG
}
FallBack "Diffuse"
}