mirror of
https://github.com/cyberboy666/r_e_c_u_r.git
synced 2025-12-05 16:00:06 +01:00
60 lines
1.1 KiB
GLSL
60 lines
1.1 KiB
GLSL
//1-input
|
|
#ifdef GL_ES
|
|
precision mediump float;
|
|
#endif
|
|
|
|
varying vec2 v_texcoord;
|
|
uniform sampler2D u_tex0;
|
|
uniform sampler2D u_tex1;
|
|
uniform vec2 u_resolution;
|
|
uniform float u_time;
|
|
uniform float u_x0;
|
|
uniform float u_x1;
|
|
uniform float u_x2;
|
|
uniform float u_x3;
|
|
|
|
vec3 rgb2grayscale(vec3 c)
|
|
{
|
|
return(vec3(dot(c, vec3(0.299, 0.587, 0.114))));
|
|
}
|
|
|
|
vec3 rgb2hsv(vec3 c)
|
|
{
|
|
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
|
|
vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
|
|
vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
|
|
|
|
float d = q.x - min(q.w, q.y);
|
|
float e = 1.0e-10;
|
|
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
|
|
}
|
|
|
|
vec3 hsv2rgb(vec3 c)
|
|
{
|
|
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
|
|
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
|
|
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
|
|
}
|
|
|
|
void main(){
|
|
|
|
vec2 pos = v_texcoord;
|
|
vec4 color = texture2D(u_tex0, pos);
|
|
|
|
vec3 hsv = rgb2hsv(color.rgb);
|
|
hsv.x += 0.1*u_x0 - 0.05;
|
|
hsv.y += 0.1*u_x1 - 0.05;
|
|
hsv.z += 0.1*u_x2 - 0.05;
|
|
//hsv.x += -0.2;
|
|
vec3 rgb = hsv2rgb(hsv.xyz);
|
|
|
|
|
|
gl_FragColor = vec4(rgb, color.a);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|