Anyone knows about a brightness and contrast 2d filter?
thanks!
Code to brighten/darken, controlled by the value of float brightness
uniform sampler2D bgl_RenderedTexture;
void main(void)
{
float brightness = .2;
vec4 texcolor = texture2D(bgl_RenderedTexture, gl_TexCoord[0].st);
vec3 bright = texcolor.rbg + vec3(brightness,brightness,brightness);
gl_FragColor = vec4(bright[0],bright[1],bright[2], texcolor.a);
}
Code to change contrast (have to be a non-negative value), controlled by the value of float contrast
uniform sampler2D bgl_RenderedTexture;
void main(void)
{
float contrast = 1.5;
vec4 texcolor = texture2D(bgl_RenderedTexture, gl_TexCoord[0].st);
vec3 contrasted = (texcolor.rbg - 0.5) * contrast + 0.5;
gl_FragColor = vec4(contrasted[0], contrasted[1], contrasted[2],texcolor.a);
}
put them in the text editor and apply them as custom filter.
Hey, really thanks for that, haha, this ll be very usefull for me.
Very cool!
You can of course use objects properties to control it if you like that instead of a hardcoded value.