45 lines
1.7 KiB
GLSL
45 lines
1.7 KiB
GLSL
#version 300 es
|
|
|
|
/* _______________ ,--------------------------------------------------------.
|
|
//`````````````\\ \ \
|
|
//~~~~~~~~~~~~~~~\\ \ by @ohsqueezy & @sleepin \
|
|
//=================\\ \ [ohsqueezy.itch.io] [sleepin.itch.io] \
|
|
// \\ \ \
|
|
// \\ \ zlib licensed code at [git.nugget.fun/nugget/gunkiss] \
|
|
// ☆ GUNKISS ☆ \\ \ \
|
|
//_________________________\\ `--------------------------------------------------------*/
|
|
|
|
/* The precision declaration is required by OpenGL ES */
|
|
precision mediump float;
|
|
|
|
in vec2 uv;
|
|
uniform sampler2D base_texture;
|
|
uniform vec3 blend_min_hsv;
|
|
uniform float time;
|
|
uniform bool scroll;
|
|
out vec4 outputColor;
|
|
|
|
/* 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;
|
|
outputColor = texelFetch(base_texture, ivec2(mod(vec2(gl_FragCoord.x + speed, gl_FragCoord.y - speed), vec2(texture_size))), 0);
|
|
}
|
|
else
|
|
{
|
|
outputColor = texture(base_texture, uv);
|
|
}
|
|
/* apply blending, leaving alpha unchanged */
|
|
outputColor.xyz = min(outputColor.xyz, hsv2rgb(blend_min_hsv));
|
|
}
|