Hi
I'm trying to change a parameter in a shader :
float Brightness;
float Contrast;
varying vec2 uvVarying;
uniform sampler2D texture0;
void main(void) {
vec4 pixelColor = texture2D(texture0, uvVarying);
pixelColor.r /= pixelColor.a;
pixelColor.g /= pixelColor.a;
pixelColor.b /= pixelColor.a;
// Apply contrast.
pixelColor.r = ((pixelColor.r - 0.5f) * max(Contrast, 0)) + 0.5f;
pixelColor.g = ((pixelColor.g - 0.5f) * max(Contrast, 0)) + 0.5f;
pixelColor.b = ((pixelColor.b - 0.5f) * max(Contrast, 0)) + 0.5f;
// Apply brightness.
pixelColor.r += Brightness;
pixelColor.g += Brightness;
pixelColor.b += Brightness;
// Return final pixel color.
pixelColor.r *= pixelColor.a;
pixelColor.g *= pixelColor.a;
pixelColor.b *= pixelColor.a;
gl_FragColor.r = pixelColor.r;
gl_FragColor.g = pixelColor.g;
gl_FragColor.b = pixelColor.b;
gl_FragColor.a = pixelColor.a;
}
If I change the two first line by :
float Brightness=1.0;
float Contrast=5.0;
It works fine, I have the brighness of 1.0 and the contrast of 5.0.
But If I want to change dynamically in AGk by :
SetShaderConstantByName( EraserShaderID, "Brightness", 5.0, 0.0, 0.0, 0.0 )
SetShaderConstantByName( EraserShaderID, "Contrast", 1.0, 0.0, 0.0, 0.0 )
How can i change the brightness and contrast of the sahder in real time ?
Thank you for your answer.
http://www.dracaena-studio.com