@@ -45,13 +45,13 @@ uniform sampler2D u_skin;
45
45
46
46
varying vec2 v_texCoord;
47
47
48
- #if ! defined(DRAW_MODE_silhouette) && (defined(ENABLE_color) || defined(ENABLE_brightness) )
48
+ #if ! defined(DRAW_MODE_silhouette) && (defined(ENABLE_color))
49
49
// Branchless color conversions based on code from:
50
50
// http://www.chilliant.com/rgb2hsv.html by Ian Taylor
51
51
// Based in part on work by Sam Hocevar and Emil Persson
52
52
// See also: https://en.wikipedia.org/wiki/HSL_and_HSV#Formal_derivation
53
53
54
- // Smaller values can cause problems with "color" and "brightness" effects on some mobile devices
54
+ // Smaller values can cause problems on some mobile devices
55
55
const float epsilon = 1e-3 ;
56
56
57
57
// Convert an RGB color to Hue, Saturation, and Value.
@@ -103,7 +103,7 @@ vec3 convertHSV2RGB(vec3 hsv)
103
103
float c = hsv.z * hsv.y;
104
104
return rgb * c + hsv.z - c;
105
105
}
106
- #endif // !defined(DRAW_MODE_silhouette) && (defined(ENABLE_color) || defined(ENABLE_brightness) )
106
+ #endif // !defined(DRAW_MODE_silhouette) && (defined(ENABLE_color))
107
107
108
108
const vec2 kCenter = vec2 (0.5 , 0.5 );
109
109
@@ -164,31 +164,27 @@ void main()
164
164
gl_FragColor = u_silhouetteColor;
165
165
#else // DRAW_MODE_silhouette
166
166
167
- #if defined(ENABLE_color) || defined(ENABLE_brightness)
167
+ #if defined(ENABLE_color)
168
168
{
169
169
vec3 hsv = convertRGB2HSV(gl_FragColor .xyz);
170
170
171
- #ifdef ENABLE_color
172
- {
173
- // this code forces grayscale values to be slightly saturated
174
- // so that some slight change of hue will be visible
175
- const float minLightness = 0.11 / 2.0 ;
176
- const float minSaturation = 0.09 ;
177
- if (hsv.z < minLightness) hsv = vec3 (0.0 , 1.0 , minLightness);
178
- else if (hsv.y < minSaturation) hsv = vec3 (0.0 , minSaturation, hsv.z);
171
+ // this code forces grayscale values to be slightly saturated
172
+ // so that some slight change of hue will be visible
173
+ const float minLightness = 0.11 / 2.0 ;
174
+ const float minSaturation = 0.09 ;
175
+ if (hsv.z < minLightness) hsv = vec3 (0.0 , 1.0 , minLightness);
176
+ else if (hsv.y < minSaturation) hsv = vec3 (0.0 , minSaturation, hsv.z);
179
177
180
- hsv.x = mod (hsv.x + u_color, 1.0 );
181
- if (hsv.x < 0.0 ) hsv.x += 1.0 ;
182
- }
183
- #endif // ENABLE_color
184
-
185
- #ifdef ENABLE_brightness
186
- hsv.z = clamp (hsv.z + u_brightness, 0.0 , 1.0 );
187
- #endif // ENABLE_brightness
178
+ hsv.x = mod (hsv.x + u_color, 1.0 );
179
+ if (hsv.x < 0.0 ) hsv.x += 1.0 ;
188
180
189
181
gl_FragColor .rgb = convertHSV2RGB(hsv);
190
182
}
191
- #endif // defined(ENABLE_color) || defined(ENABLE_brightness)
183
+ #endif // defined(ENABLE_color)
184
+
185
+ #if defined(ENABLE_brightness)
186
+ gl_FragColor .rgb = clamp (gl_FragColor .rgb + vec3 (u_brightness), vec3 (0 ), vec3 (1 ));
187
+ #endif // defined(ENABLE_brightness)
192
188
193
189
#ifdef DRAW_MODE_colorMask
194
190
vec3 maskDistance = abs (gl_FragColor .rgb - u_colorMask);
0 commit comments