summarylogtreecommitdiffstats
path: root/ccShader_3D_ColorNormal.frag.patch
blob: ee1e2a47fecd36c7604cd8c0769eb3eaaf8e03f0 (plain)
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
--- /opt/cocos2d-x/cocos/renderer/ccShader_3D_ColorNormal.frag	2016-12-29 13:42:38.000000000 -0400
+++ /tmp/ccShader_3D_ColorNormal.frag	2017-01-04 15:03:03.186784936 -0400
@@ -1,49 +1,49 @@
 
-const char* cc3D_ColorNormal_frag = R"(
+const char* cc3D_ColorNormal_frag = STRINGIFY(
 
-#if (MAX_DIRECTIONAL_LIGHT_NUM > 0)
+\n#if (MAX_DIRECTIONAL_LIGHT_NUM > 0)\n
 uniform vec3 u_DirLightSourceColor[MAX_DIRECTIONAL_LIGHT_NUM];
 uniform vec3 u_DirLightSourceDirection[MAX_DIRECTIONAL_LIGHT_NUM];
-#endif
-#if (MAX_POINT_LIGHT_NUM > 0)
+\n#endif\n
+\n#if (MAX_POINT_LIGHT_NUM > 0)\n
 uniform vec3 u_PointLightSourceColor[MAX_POINT_LIGHT_NUM];
 uniform float u_PointLightSourceRangeInverse[MAX_POINT_LIGHT_NUM];
-#endif
-#if (MAX_SPOT_LIGHT_NUM > 0)
+\n#endif\n
+\n#if (MAX_SPOT_LIGHT_NUM > 0)\n
 uniform vec3 u_SpotLightSourceColor[MAX_SPOT_LIGHT_NUM];
 uniform vec3 u_SpotLightSourceDirection[MAX_SPOT_LIGHT_NUM];
 uniform float u_SpotLightSourceInnerAngleCos[MAX_SPOT_LIGHT_NUM];
 uniform float u_SpotLightSourceOuterAngleCos[MAX_SPOT_LIGHT_NUM];
 uniform float u_SpotLightSourceRangeInverse[MAX_SPOT_LIGHT_NUM];
-#endif
+\n#endif\n
 uniform vec3 u_AmbientLightSourceColor;
 
-#ifdef GL_ES
+\n#ifdef GL_ES\n
 varying mediump vec2 TextureCoordOut;
-#if MAX_POINT_LIGHT_NUM
+\n#if MAX_POINT_LIGHT_NUM\n
 varying mediump vec3 v_vertexToPointLightDirection[MAX_POINT_LIGHT_NUM];
-#endif
-#if MAX_SPOT_LIGHT_NUM
+\n#endif\n
+\n#if MAX_SPOT_LIGHT_NUM\n
 varying mediump vec3 v_vertexToSpotLightDirection[MAX_SPOT_LIGHT_NUM];
-#endif
-#if ((MAX_DIRECTIONAL_LIGHT_NUM > 0) || (MAX_POINT_LIGHT_NUM > 0) || (MAX_SPOT_LIGHT_NUM > 0))
+\n#endif\n
+\n#if ((MAX_DIRECTIONAL_LIGHT_NUM > 0) || (MAX_POINT_LIGHT_NUM > 0) || (MAX_SPOT_LIGHT_NUM > 0))\n
 varying mediump vec3 v_normal;
-#endif
+\n#endif\n
 
-#else
+\n#else\n
 
 varying vec2 TextureCoordOut;
-#if MAX_POINT_LIGHT_NUM
+\n#if MAX_POINT_LIGHT_NUM\n
 varying vec3 v_vertexToPointLightDirection[MAX_POINT_LIGHT_NUM];
-#endif
-#if MAX_SPOT_LIGHT_NUM
+\n#endif\n
+\n#if MAX_SPOT_LIGHT_NUM\n
 varying vec3 v_vertexToSpotLightDirection[MAX_SPOT_LIGHT_NUM];
-#endif
-#if ((MAX_DIRECTIONAL_LIGHT_NUM > 0) || (MAX_POINT_LIGHT_NUM > 0) || (MAX_SPOT_LIGHT_NUM > 0))
+\n#endif\n
+\n#if ((MAX_DIRECTIONAL_LIGHT_NUM > 0) || (MAX_POINT_LIGHT_NUM > 0) || (MAX_SPOT_LIGHT_NUM > 0))\n
 varying vec3 v_normal;
-#endif
+\n#endif\n
 
-#endif
+\n#endif\n
 
 uniform vec4 u_color;
 
@@ -57,33 +57,33 @@
 
 void main(void)
 {
-#if ((MAX_DIRECTIONAL_LIGHT_NUM > 0) || (MAX_POINT_LIGHT_NUM > 0) || (MAX_SPOT_LIGHT_NUM > 0))
+\n#if ((MAX_DIRECTIONAL_LIGHT_NUM > 0) || (MAX_POINT_LIGHT_NUM > 0) || (MAX_SPOT_LIGHT_NUM > 0))\n
     vec3 normal  = normalize(v_normal);
-#endif
+\n#endif\n
 
     vec4 combinedColor = vec4(u_AmbientLightSourceColor, 1.0);
 
     // Directional light contribution
-#if (MAX_DIRECTIONAL_LIGHT_NUM > 0)
+\n#if (MAX_DIRECTIONAL_LIGHT_NUM > 0)\n
     for (int i = 0; i < MAX_DIRECTIONAL_LIGHT_NUM; ++i)
     {
         vec3 lightDirection = normalize(u_DirLightSourceDirection[i] * 2.0);
         combinedColor.xyz += computeLighting(normal, -lightDirection, u_DirLightSourceColor[i], 1.0);
     }
-#endif
+\n#endif\n
 
     // Point light contribution
-#if (MAX_POINT_LIGHT_NUM > 0)
+\n#if (MAX_POINT_LIGHT_NUM > 0)\n
     for (int i = 0; i < MAX_POINT_LIGHT_NUM; ++i)
     {
         vec3 ldir = v_vertexToPointLightDirection[i] * u_PointLightSourceRangeInverse[i];
         float attenuation = clamp(1.0 - dot(ldir, ldir), 0.0, 1.0);
         combinedColor.xyz += computeLighting(normal, normalize(v_vertexToPointLightDirection[i]), u_PointLightSourceColor[i], attenuation);
     }
-#endif
+\n#endif\n
 
     // Spot light contribution
-#if (MAX_SPOT_LIGHT_NUM > 0)
+\n#if (MAX_SPOT_LIGHT_NUM > 0)\n
     for (int i = 0; i < MAX_SPOT_LIGHT_NUM; ++i)
     {
         // Compute range attenuation
@@ -101,13 +101,13 @@
         attenuation = clamp(attenuation, 0.0, 1.0);
         combinedColor.xyz += computeLighting(normal, vertexToSpotLightDirection, u_SpotLightSourceColor[i], attenuation);
     }
-#endif
+\n#endif\n
 
-#if ((MAX_DIRECTIONAL_LIGHT_NUM > 0) || (MAX_POINT_LIGHT_NUM > 0) || (MAX_SPOT_LIGHT_NUM > 0))
+\n#if ((MAX_DIRECTIONAL_LIGHT_NUM > 0) || (MAX_POINT_LIGHT_NUM > 0) || (MAX_SPOT_LIGHT_NUM > 0))\n
     gl_FragColor = u_color * combinedColor;
-#else
+\n#else\n
     gl_FragColor = u_color;
-#endif
+\n#endif\n
 
 }
-)";
+);