-
-
Save ayamflow/ce1f69b1a95ec31df91b8b792079bb87 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