For my android application, I want to apply brightness and contrast shader on same image.
At present I am using gpuimage plugin. In that I found two separate program for brightness and contrast as per the following.
Contrast shader:
varying highp vec2 textureCoordinate;
uniform sampler2D inputImageTexture;
uniform lowp float contrast;
void main()
{
lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
gl_FragColor = vec4(((textureColor.rgb - vec3(0.5)) * contrast + vec3(0.5)), textureColor.w);
}
Brightness shader:
varying highp vec2 textureCoordinate;
uniform sampler2D inputImageTexture;
uniform lowp float brightness;
void main()
{
lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
gl_FragColor = vec4((textureColor.rgb + vec3(brightness)), textureColor.w);
}
Now applying both of the effects I write following code
varying highp vec2 textureCoordinate;
uniform sampler2D inputImageTexture;
varying highp vec2 textureCoordinate2;
uniform sampler2D inputImageTexture2;
uniform lowp float contrast;
uniform lowp float brightness;
void main()
{
lowp vec4 textureColorForContrast = texture2D(inputImageTexture, textureCoordinate);
lowp vec4 contastVec4 = vec4(((textureColorForContrast.rgb - vec3(0.5)) * contrast + vec3(0.5)), textureColorForContrast.w);
lowp vec4 textureColorForBrightness = texture2D(inputImageTexture2, textureCoordinate2);
lowp vec4 brightnessVec4 = vec4((textureColorForBrightness.rgb + vec3(brightness)), textureColorForBrightness.w);
gl_FragColor = contastVec4 + brightnessVec4;
}
Doesn't able to get desire result. I can't able to figure out what I have to do next? So please friends help me in this. What program I have to write?