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