Created
January 29, 2022 16:24
-
-
Save bergwerf/e67badeef837f7c10b03cc0856a09dbe to your computer and use it in GitHub Desktop.
Hue cycling over grayscale
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Try on: https://www.shadertoy.com/new | |
// With: https://github.com/andrewhills/ShadertoyCustomTextures | |
// https://www.shadertoy.com/view/XljGzV | |
vec3 hsl2rgb( in vec3 c ) | |
{ | |
vec3 rgb = clamp( abs(mod(c.x*6.0+vec3(0.0,4.0,2.0),6.0)-3.0)-1.0, 0.0, 1.0 ); | |
return c.z + c.y * (rgb-0.5)*(1.0-abs(2.0*c.z-1.0)); | |
} | |
// CCIR 601 | |
float rgb2gray( in vec3 c ) | |
{ | |
return 0.2989*c.x + 0.5870*c.y + 0.1140*c.z; | |
} | |
void mainImage( out vec4 fragColor, in vec2 fragCoord ) | |
{ | |
vec2 uv = fragCoord/iResolution.xy; | |
vec4 col = texture(iChannel0, uv); | |
float v = rgb2gray(col.xyz); | |
vec3 hsl = vec3(v*3.0 + iTime/3.0, 0.5, 0.5); | |
fragColor = vec4(hsl2rgb(hsl), 1.0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment