Created
July 12, 2020 17:40
-
-
Save CharStiles/49c96ca3304ee39c9aef79dfca9416f5 to your computer and use it in GitHub Desktop.
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
// http://www.iquilezles.org/www/articles/palettes/palettes.htm | |
// As t runs from 0 to 1 (our normalized palette index or domain), | |
//the cosine oscilates c times with a phase of d. | |
//The result is scaled and biased by a and b to meet the desired constrast and brightness. | |
vec3 cosPalette( float t, vec3 a, vec3 b, vec3 c, vec3 d ) | |
{ | |
return a + b*cos( 6.28318*(c*t+d) ); | |
} | |
void main () { | |
// we put the pixel coordinates in a variable for easy access | |
vec2 pos = uvN(); | |
// each chanel of the vec 3 corresponds to a color chanel | |
// red, green, blue! | |
vec3 brightness = vec3(0.5,0.5,0.5); | |
vec3 contrast = vec3(0.2,sin(time)*0.2,cos(time)*0.2); | |
vec3 osc = vec3(0.2); // how frequently we cycles through the colors | |
vec3 phase = vec3(0.5); // where does it start? | |
// getting the cosine palette | |
vec3 cp = cosPalette((time/1.0) +pos.x, brightness, contrast, osc, phase ); | |
// casting the cosinePalette into a vector 4 by adding a 1 at the end | |
// the last number doesnt matter | |
vec4 col = vec4(cp,1); | |
// access the webcam texture at the input pixels position | |
// multiplied times 1 + a small number, which returns a number | |
// close to its original but modified slightly. | |
vec4 web =texture2D(channel0,pos); | |
col = mix(web,col,1.0-web); | |
gl_FragColor = col ; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment