-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathHolisticCustomBlinnLighting.shader
More file actions
49 lines (37 loc) · 1.03 KB
/
Copy pathHolisticCustomBlinnLighting.shader
File metadata and controls
49 lines (37 loc) · 1.03 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
Shader "Holistic/CustomBlinnLighting" {
Properties {
_Color ( "Color", Color ) = ( 1, 1, 1, 1 )
_SpecColor ( "Specular Color", Color ) = ( 1, 1, 1, 1 )
_SpecPow ( "Specular Power", Range( 0, 48 ) ) = 48.0
}
SubShader {
CGPROGRAM
#pragma surface surf CustomBlinn
struct Input
{
float2 uv_MainTex;
};
float4 _Color;
float _SpecPow;
void surf( Input IN, inout SurfaceOutput o ) {
o.Albedo = _Color.rgb;
}
half4 LightingCustomBlinn( SurfaceOutput s, half3 lightDir, half3 viewDir, half atten ) {
// diffuse component
// half diff = max( 0, dot( s.Normal, lightDir ) );
half diff = dot( s.Normal, lightDir );
// specular component
half3 hV = normalize( lightDir + viewDir );
// half NdotH = max ( 0, dot( s.Normal, hV ) );
half NdotH = dot( s.Normal, hV );
half spec = pow( NdotH, _SpecPow );
// result color
half4 c;
c.rgb = ( s.Albedo * _LightColor0.rgb * diff + spec * _LightColor0 ) * atten;
c.a = s.Alpha;
return c;
}
ENDCG
}
FallBack "Diffuse"
}