2015-03-15 15:35:14 +00:00
|
|
|
#ifdef GL_ES
|
|
|
|
precision mediump float;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
uniform vec2 u_resolution;
|
|
|
|
uniform float u_time;
|
|
|
|
|
|
|
|
vec3 rgb2hsb( in vec3 c ){
|
|
|
|
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
|
2017-08-19 10:11:58 +00:00
|
|
|
vec4 p = mix(vec4(c.bg, K.wz),
|
|
|
|
vec4(c.gb, K.xy),
|
2015-03-15 15:35:14 +00:00
|
|
|
step(c.b, c.g));
|
2017-08-19 10:11:58 +00:00
|
|
|
vec4 q = mix(vec4(p.xyw, c.r),
|
|
|
|
vec4(c.r, p.yzx),
|
2015-03-15 15:35:14 +00:00
|
|
|
step(p.x, c.r));
|
|
|
|
float d = q.x - min(q.w, q.y);
|
|
|
|
float e = 1.0e-10;
|
2017-08-19 10:11:58 +00:00
|
|
|
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)),
|
|
|
|
d / (q.x + e),
|
2015-03-15 15:35:14 +00:00
|
|
|
q.x);
|
|
|
|
}
|
|
|
|
|
2017-08-19 10:11:58 +00:00
|
|
|
// Function from Iñigo Quiles
|
2015-03-15 15:35:14 +00:00
|
|
|
// https://www.shadertoy.com/view/MsS3Wc
|
|
|
|
vec3 hsb2rgb( in vec3 c ){
|
|
|
|
vec3 rgb = clamp(abs(mod(c.x*6.0+vec3(0.0,4.0,2.0),
|
2017-08-19 10:11:58 +00:00
|
|
|
6.0)-3.0)-1.0,
|
|
|
|
0.0,
|
2015-03-15 15:35:14 +00:00
|
|
|
1.0 );
|
|
|
|
rgb = rgb*rgb*(3.0-2.0*rgb);
|
|
|
|
return c.z * mix(vec3(1.0), rgb, c.y);
|
|
|
|
}
|
|
|
|
|
|
|
|
void main(){
|
|
|
|
vec2 st = gl_FragCoord.xy/u_resolution;
|
|
|
|
vec3 color = vec3(0.0);
|
|
|
|
|
|
|
|
// We map x (0.0 - 1.0) to the hue (0.0 - 1.0)
|
|
|
|
// And the y (0.0 - 1.0) to the brightness
|
|
|
|
color = hsb2rgb(vec3(st.x,1.0,st.y));
|
|
|
|
|
|
|
|
gl_FragColor = vec4(color,1.0);
|
2017-08-19 10:11:58 +00:00
|
|
|
}
|