Created
January 5, 2016 00:06
-
-
Save activetheory/b68c2d639e2bd272b2a7 to your computer and use it in GitHub Desktop.
A GLSL module for color levels manipulation
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
float levelChannel(float inPixel, float inBlack, float inGamma, float inWhite, float outBlack, float outWhite) { | |
return (pow(((inPixel * 255.0) - inBlack) / (inWhite - inBlack), inGamma) * (outWhite - outBlack) + outBlack) / 255.0; | |
} | |
vec3 levels(vec3 inPixel, float inBlack, float inGamma, float inWhite, float outBlack, float outWhite) { | |
vec3 o = vec3(1.0); | |
o.r = levelChannel(inPixel.r, inBlack, inGamma, inWhite, outBlack, outWhite); | |
o.g = levelChannel(inPixel.g, inBlack, inGamma, inWhite, outBlack, outWhite); | |
o.b = levelChannel(inPixel.b, inBlack, inGamma, inWhite, outBlack, outWhite); | |
return o; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment