Skip to content

Instantly share code, notes, and snippets.

@adielfernandez
Last active February 8, 2018 20:40
Show Gist options
  • Save adielfernandez/244421a8bb8554761490e5f28e45124f to your computer and use it in GitHub Desktop.
Save adielfernandez/244421a8bb8554761490e5f28e45124f to your computer and use it in GitHub Desktop.
Simple Contrast Adjustment Shader
#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