Skip to content

Instantly share code, notes, and snippets.

@CharStiles
Created December 12, 2020 02:52
Show Gist options
  • Save CharStiles/9802ef698f85206fc55be463eb3ba02f to your computer and use it in GitHub Desktop.
Save CharStiles/9802ef698f85206fc55be463eb3ba02f to your computer and use it in GitHub Desktop.
// to see this function graphed out go to: https://www.desmos.com/calculator/rz7abjujdj
vec3 cosPalette( float t )
{
// please play around with these numbers to get a better palette
vec3 brightness = vec3(0.3);
vec3 contrast = vec3(0.5);
vec3 osc = vec3(0.5,1.0,0.0);
vec3 phase = vec3(0.4,0.9,0.2);
return brightness + contrast*cos( 6.28318*(osc*t+phase) );
}
void main () {
vec2 pos = uvN();
vec4 webcam = texture2D(channel0, pos );
vec4 bb = texture2D(backbuffer, pos* vec2(1.01));
vec3 cosPal = cosPalette(webcam.r);
vec4 color = mix(bb,vec4(cosPal,1.), 1.-webcam);
gl_FragColor = color;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment