66
77precision mediump float ;
88
9- #ifdef ENABLE_color
9+ #ifdef ENABLE_COLOR
1010uniform float u_color;
11- #endif // ENABLE_color
11+ #endif // ENABLE_COLOR
1212
13- #ifdef ENABLE_brightness
13+ #ifdef ENABLE_BRIGHTNESS
1414uniform float u_brightness;
15- #endif // ENABLE_brightness
15+ #endif // ENABLE_BRIGHTNESS
1616
17- #ifdef ENABLE_ghost
17+ #ifdef ENABLE_GHOST
1818uniform float u_ghost;
19- #endif // ENABLE_ghost
19+ #endif // ENABLE_GHOST
2020
21- #ifdef ENABLE_fisheye
21+ #ifdef ENABLE_FISHEYE
2222uniform float u_fisheye;
23- #endif // ENABLE_fisheye
23+ #endif // ENABLE_FISHEYE
2424
25- #ifdef ENABLE_whirl
25+ #ifdef ENABLE_WHIRL
2626uniform float u_whirl;
27- #endif // ENABLE_whirl
27+ #endif // ENABLE_WHIRL
2828
29- #ifdef ENABLE_pixelate
29+ #ifdef ENABLE_PIXELATE
3030uniform float u_pixelate;
3131uniform vec2 u_skinSize;
32- #endif // ENABLE_pixelate
32+ #endif // ENABLE_PIXELATE
3333
34- #ifdef ENABLE_mosaic
34+ #ifdef ENABLE_MOSAIC
3535uniform float u_mosaic;
36- #endif // ENABLE_mosaic
36+ #endif // ENABLE_MOSAIC
3737
3838in vec2 v_texCoord;
3939out vec4 fragColor;
@@ -43,7 +43,7 @@ uniform sampler2D u_skin;
4343// Smaller values can cause problems on some mobile devices.
4444const float epsilon = 1e-3 ;
4545
46- #if defined(ENABLE_color )
46+ #if defined(ENABLE_COLOR )
4747// Branchless color conversions based on code from:
4848// http://www.chilliant.com/rgb2hsv.html by Ian Taylor
4949// Based in part on work by Sam Hocevar and Emil Persson
@@ -99,27 +99,27 @@ vec3 convertHSV2RGB(vec3 hsv)
9999 float c = hsv.z * hsv.y;
100100 return rgb * c + hsv.z - c;
101101}
102- #endif // ENABLE_color
102+ #endif // ENABLE_COLOR
103103
104104const vec2 kCenter = vec2 (0.5 , 0.5 );
105105
106106void main()
107107{
108108 vec2 texcoord0 = v_texCoord;
109109
110- #ifdef ENABLE_mosaic
110+ #ifdef ENABLE_MOSAIC
111111 texcoord0 = fract (u_mosaic * texcoord0);
112- #endif // ENABLE_mosaic
112+ #endif // ENABLE_MOSAIC
113113
114- #ifdef ENABLE_pixelate
114+ #ifdef ENABLE_PIXELATE
115115 {
116116 // TODO: clean up "pixel" edges
117117 vec2 pixelTexelSize = u_skinSize / u_pixelate;
118118 texcoord0 = (floor (texcoord0 * pixelTexelSize) + kCenter) / pixelTexelSize;
119119 }
120- #endif // ENABLE_pixelate
120+ #endif // ENABLE_PIXELATE
121121
122- #ifdef ENABLE_whirl
122+ #ifdef ENABLE_WHIRL
123123 {
124124 const float kRadius = 0.5 ;
125125 vec2 offset = texcoord0 - kCenter;
@@ -135,9 +135,9 @@ void main()
135135
136136 texcoord0 = rotationMatrix * offset + kCenter;
137137 }
138- #endif // ENABLE_whirl
138+ #endif // ENABLE_WHIRL
139139
140- #ifdef ENABLE_fisheye
140+ #ifdef ENABLE_FISHEYE
141141 {
142142 vec2 vec = (texcoord0 - kCenter) / kCenter;
143143 float vecLength = length (vec);
@@ -146,16 +146,16 @@ void main()
146146
147147 texcoord0 = kCenter + r * unit * kCenter;
148148 }
149- #endif // ENABLE_fisheye
149+ #endif // ENABLE_FISHEYE
150150
151151 fragColor = texture(u_skin, texcoord0);
152152
153- #if defined(ENABLE_color ) || defined(ENABLE_brightness )
153+ #if defined(ENABLE_COLOR ) || defined(ENABLE_BRIGHTNESS )
154154 // Divide premultiplied alpha values for proper color processing
155155 // Add epsilon to avoid dividing by 0 for fully transparent pixels
156156 fragColor.rgb = clamp (fragColor.rgb / (fragColor.a + epsilon), 0.0 , 1.0 );
157157
158- #ifdef ENABLE_color
158+ #ifdef ENABLE_COLOR
159159 {
160160 vec3 hsv = convertRGB2HSV(fragColor.rgb);
161161
@@ -170,18 +170,18 @@ void main()
170170
171171 fragColor.rgb = convertHSV2RGB(hsv);
172172 }
173- #endif // ENABLE_color
173+ #endif // ENABLE_COLOR
174174
175- #ifdef ENABLE_brightness
175+ #ifdef ENABLE_BRIGHTNESS
176176 fragColor.rgb = clamp (fragColor.rgb + vec3 (u_brightness), vec3 (0 ), vec3 (1 ));
177- #endif // ENABLE_brightness
177+ #endif // ENABLE_BRIGHTNESS
178178
179179 // Re-multiply color values
180180 fragColor.rgb *= fragColor.a + epsilon;
181181
182- #endif // defined(ENABLE_color ) || defined(ENABLE_brightness )
182+ #endif // defined(ENABLE_COLOR ) || defined(ENABLE_BRIGHTNESS )
183183
184- #ifdef ENABLE_ghost
184+ #ifdef ENABLE_GHOST
185185 fragColor *= u_ghost;
186- #endif // ENABLE_ghost
186+ #endif // ENABLE_GHOST
187187}
0 commit comments