gunkiss/src/flat.frag

39 lines
1.8 KiB
GLSL

/* _______________ +---------------------------------------------------------------------------------------+
//~~~~~~~~~~~~~\\ | a game by @ohsqueezy & @sleepin |
//```````````````\\ | [ohsqueezy.itch.io] [instagram.com/sleepin] |
//_0_0_0_0_0_0_0_0_\\ | |
//_/_/_/_/___\_\_\_\_\\ | with code licensed for copy, modification and redistribution [git.nugget.fun/pudding] |
//GGGUUUNNNKKKIIISSSSSS\\ | |
//_/__/__/__/_\__\__\__\_\\ | 😀 Thank you for choosing Puddendo for your business 😀 |
+---------------------------------------------------------------------------------------+ */
#version 130
in vec2 uv;
uniform sampler2D base_texture;
uniform vec3 blend_min_hsv;
uniform float time;
uniform bool scroll = false;
/* 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);
}
void main(void)
{
if (scroll)
{
ivec2 texture_size = textureSize(base_texture, 0);
float speed = time * 35.0;
gl_FragColor = texelFetch(base_texture, ivec2(mod(vec2(gl_FragCoord.x + speed, gl_FragCoord.y - speed), texture_size)), 0);
}
else
{
gl_FragColor = texture(base_texture, uv);
}
gl_FragColor = min(gl_FragColor, vec4(hsv2rgb(blend_min_hsv), 1));
}