Created
February 20, 2017 02:05
-
-
Save adamnew123456/1e835ea05237a991598eea3a641b8f32 to your computer and use it in GitHub Desktop.
Ghost Shader
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
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