Skip to content

Instantly share code, notes, and snippets.

@adamnew123456
Created February 20, 2017 02:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save adamnew123456/1e835ea05237a991598eea3a641b8f32 to your computer and use it in GitHub Desktop.
Save adamnew123456/1e835ea05237a991598eea3a641b8f32 to your computer and use it in GitHub Desktop.
Ghost Shader
vec4 colorAt(in vec2 coord, in int channel) {
if (channel == 0) return texture2D(iChannel0, coord.xy / iChannelResolution[0].xy);
if (channel == 1) return texture2D(iChannel1, coord.xy / iChannelResolution[1].xy);
if (channel == 2) return texture2D(iChannel2, coord.xy / iChannelResolution[2].xy);
if (channel == 3) return texture2D(iChannel3, coord.xy / iChannelResolution[3].xy);
}
float monochrome(in vec4 color) {
return (color.r + color.g + color.b) / 3.0;
}
vec4 lighten(in vec4 color, in float degree) {
return vec4(
clamp(color.r * degree, 0.0, 1.0),
clamp(color.g * degree, 0.0, 1.0),
clamp(color.b * degree, 0.0, 1.0),
1.0
);
}
void mainImage( out vec4 fragColor, in vec2 fragCoord)
{
vec4 baseColor = colorAt(fragCoord, 0);
float lightFactor = monochrome(colorAt(fragCoord, 1)) + 0.5;
fragColor = lighten(baseColor, lightFactor);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment