Last active
February 8, 2018 20:40
-
-
Save adielfernandez/244421a8bb8554761490e5f28e45124f to your computer and use it in GitHub Desktop.
Simple Contrast Adjustment Shader
This file contains 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
#version 330 core | |
in vec2 vTexCoord0; | |
out vec4 oColor; | |
uniform sampler2D uTex0; | |
uniform vec2 uResolution; | |
uniform float uExponent; //good values will be between 5 and 15 | |
uniform float uShift; //good values will be between 0 and 1 | |
void main(void) { | |
//get original pixel | |
vec4 pix = texture( uTex0, vTexCoord0 ); | |
//adjust the contrast by shifting the median | |
//value and applying an exponential | |
oColor = clamp( pow( pix + uShift, uExponent ), 0.0f, 1.0f); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment