gunkiss/src/flat.frag

20 lines
506 B
GLSL
Raw Normal View History

2021-07-02 22:51:59 -04:00
#version 130
2021-09-01 00:08:45 -04:00
in vec2 uv;
uniform sampler2D base_texture;
uniform vec3 blend_min_hsv;
/* from http://lolengine.net/blog/2013/07/27/rgb-to-hsv-in-glsl, licensed under WTFPL */
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);
}
2021-07-02 22:51:59 -04:00
void main(void)
{
2021-09-01 00:08:45 -04:00
gl_FragColor = texture(base_texture, uv);
gl_FragColor = min(gl_FragColor, vec4(hsv2rgb(blend_min_hsv), 1));
2021-07-02 22:51:59 -04:00
}