forked from microsoft/MixedRealityToolkit-Unity
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBlinnPhongConfigurable.cginc
More file actions
70 lines (54 loc) · 1.2 KB
/
BlinnPhongConfigurable.cginc
File metadata and controls
70 lines (54 loc) · 1.2 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#if _USEMAINTEX_ON
UNITY_DECLARE_TEX2D(_MainTex);
#endif
#if _USECOLOR_ON
float4 _Color;
#endif
#if _USEBUMPMAP_ON
UNITY_DECLARE_TEX2D(_BumpMap);
#endif
#if _USEEMISSIONTEX_ON
UNITY_DECLARE_TEX2D(_EmissionTex);
#endif
float _Specular;
float _Gloss;
struct Input
{
// Will get compiled out if not touched
float2 uv_MainTex;
#if _NEAR_PLANE_FADE_ON
float fade;
#endif
};
void vert(inout appdata_full v, out Input o)
{
UNITY_INITIALIZE_OUTPUT(Input, o);
#if _NEAR_PLANE_FADE_ON
o.fade = ComputeNearPlaneFadeLinear(v.vertex);
#endif
}
void surf(Input IN, inout SurfaceOutput o)
{
float4 c;
#if _USEMAINTEX_ON
c = UNITY_SAMPLE_TEX2D(_MainTex, IN.uv_MainTex);
#else
c = 1;
#endif
#if _USECOLOR_ON
c *= _Color;
#endif
o.Albedo = c.rgb;
#if _NEAR_PLANE_FADE_ON
o.Albedo.rgb *= IN.fade;
#endif
o.Alpha = c.a;
o.Specular = _Specular;
o.Gloss = _Gloss;
#if _USEBUMPMAP_ON
o.Normal = UnpackNormal(UNITY_SAMPLE_TEX2D(_BumpMap, IN.uv_MainTex));
#endif
#if _USEEMISSIONTEX_ON
o.Emission = UNITY_SAMPLE_TEX2D(_EmissionTex, IN.uv_MainTex);
#endif
}