6
6
7
7
precision mediump float ;
8
8
9
- #ifdef ENABLE_color
9
+ #ifdef ENABLE_COLOR
10
10
uniform float u_color;
11
- #endif // ENABLE_color
11
+ #endif // ENABLE_COLOR
12
12
13
- #ifdef ENABLE_brightness
13
+ #ifdef ENABLE_BRIGHTNESS
14
14
uniform float u_brightness;
15
- #endif // ENABLE_brightness
15
+ #endif // ENABLE_BRIGHTNESS
16
16
17
- #ifdef ENABLE_ghost
17
+ #ifdef ENABLE_GHOST
18
18
uniform float u_ghost;
19
- #endif // ENABLE_ghost
19
+ #endif // ENABLE_GHOST
20
20
21
- #ifdef ENABLE_fisheye
21
+ #ifdef ENABLE_FISHEYE
22
22
uniform float u_fisheye;
23
- #endif // ENABLE_fisheye
23
+ #endif // ENABLE_FISHEYE
24
24
25
- #ifdef ENABLE_whirl
25
+ #ifdef ENABLE_WHIRL
26
26
uniform float u_whirl;
27
- #endif // ENABLE_whirl
27
+ #endif // ENABLE_WHIRL
28
28
29
- #ifdef ENABLE_pixelate
29
+ #ifdef ENABLE_PIXELATE
30
30
uniform float u_pixelate;
31
31
uniform vec2 u_skinSize;
32
- #endif // ENABLE_pixelate
32
+ #endif // ENABLE_PIXELATE
33
33
34
- #ifdef ENABLE_mosaic
34
+ #ifdef ENABLE_MOSAIC
35
35
uniform float u_mosaic;
36
- #endif // ENABLE_mosaic
36
+ #endif // ENABLE_MOSAIC
37
37
38
38
in vec2 v_texCoord;
39
39
out vec4 fragColor;
@@ -43,7 +43,7 @@ uniform sampler2D u_skin;
43
43
// Smaller values can cause problems on some mobile devices.
44
44
const float epsilon = 1e-3 ;
45
45
46
- #if defined(ENABLE_color )
46
+ #if defined(ENABLE_COLOR )
47
47
// Branchless color conversions based on code from:
48
48
// http://www.chilliant.com/rgb2hsv.html by Ian Taylor
49
49
// Based in part on work by Sam Hocevar and Emil Persson
@@ -99,27 +99,27 @@ vec3 convertHSV2RGB(vec3 hsv)
99
99
float c = hsv.z * hsv.y;
100
100
return rgb * c + hsv.z - c;
101
101
}
102
- #endif // ENABLE_color
102
+ #endif // ENABLE_COLOR
103
103
104
104
const vec2 kCenter = vec2 (0.5 , 0.5 );
105
105
106
106
void main()
107
107
{
108
108
vec2 texcoord0 = v_texCoord;
109
109
110
- #ifdef ENABLE_mosaic
110
+ #ifdef ENABLE_MOSAIC
111
111
texcoord0 = fract (u_mosaic * texcoord0);
112
- #endif // ENABLE_mosaic
112
+ #endif // ENABLE_MOSAIC
113
113
114
- #ifdef ENABLE_pixelate
114
+ #ifdef ENABLE_PIXELATE
115
115
{
116
116
// TODO: clean up "pixel" edges
117
117
vec2 pixelTexelSize = u_skinSize / u_pixelate;
118
118
texcoord0 = (floor (texcoord0 * pixelTexelSize) + kCenter) / pixelTexelSize;
119
119
}
120
- #endif // ENABLE_pixelate
120
+ #endif // ENABLE_PIXELATE
121
121
122
- #ifdef ENABLE_whirl
122
+ #ifdef ENABLE_WHIRL
123
123
{
124
124
const float kRadius = 0.5 ;
125
125
vec2 offset = texcoord0 - kCenter;
@@ -135,9 +135,9 @@ void main()
135
135
136
136
texcoord0 = rotationMatrix * offset + kCenter;
137
137
}
138
- #endif // ENABLE_whirl
138
+ #endif // ENABLE_WHIRL
139
139
140
- #ifdef ENABLE_fisheye
140
+ #ifdef ENABLE_FISHEYE
141
141
{
142
142
vec2 vec = (texcoord0 - kCenter) / kCenter;
143
143
float vecLength = length (vec);
@@ -146,16 +146,16 @@ void main()
146
146
147
147
texcoord0 = kCenter + r * unit * kCenter;
148
148
}
149
- #endif // ENABLE_fisheye
149
+ #endif // ENABLE_FISHEYE
150
150
151
151
fragColor = texture(u_skin, texcoord0);
152
152
153
- #if defined(ENABLE_color ) || defined(ENABLE_brightness )
153
+ #if defined(ENABLE_COLOR ) || defined(ENABLE_BRIGHTNESS )
154
154
// Divide premultiplied alpha values for proper color processing
155
155
// Add epsilon to avoid dividing by 0 for fully transparent pixels
156
156
fragColor.rgb = clamp (fragColor.rgb / (fragColor.a + epsilon), 0.0 , 1.0 );
157
157
158
- #ifdef ENABLE_color
158
+ #ifdef ENABLE_COLOR
159
159
{
160
160
vec3 hsv = convertRGB2HSV(fragColor.rgb);
161
161
@@ -170,18 +170,18 @@ void main()
170
170
171
171
fragColor.rgb = convertHSV2RGB(hsv);
172
172
}
173
- #endif // ENABLE_color
173
+ #endif // ENABLE_COLOR
174
174
175
- #ifdef ENABLE_brightness
175
+ #ifdef ENABLE_BRIGHTNESS
176
176
fragColor.rgb = clamp (fragColor.rgb + vec3 (u_brightness), vec3 (0 ), vec3 (1 ));
177
- #endif // ENABLE_brightness
177
+ #endif // ENABLE_BRIGHTNESS
178
178
179
179
// Re-multiply color values
180
180
fragColor.rgb *= fragColor.a + epsilon;
181
181
182
- #endif // defined(ENABLE_color ) || defined(ENABLE_brightness )
182
+ #endif // defined(ENABLE_COLOR ) || defined(ENABLE_BRIGHTNESS )
183
183
184
- #ifdef ENABLE_ghost
184
+ #ifdef ENABLE_GHOST
185
185
fragColor *= u_ghost;
186
- #endif // ENABLE_ghost
186
+ #endif // ENABLE_GHOST
187
187
}
0 commit comments