Hi,
I want to calculate
(C.r+C.g255.0+C.b255.0^2+C.a255.0^3)-(C’.r+C’.g255.0+C’.b255.0^2+C’.a255.0^3)
in fragment shader, where C, C’ are pixel values.
If input C is (38, 144, 0, 0) and C’ is (242, 143, 0, 0), result is expected (51, 0, 0, 0).
but, actually result is (82, 0, 0, 0).
What is the problem?
This is part of my source code
uniform sampler2D sTexture;
varying mediump vec2 TexCoord;
void main()
{
mediump float s = TexCoord.s;
mediump float t = TexCoord.t;
mediump float offsetX = 1.0/width; // width = texture width
highp vec4 C = texture2D(sTexture, vec2(s,t));
highp vec4 L = texture2D(sTexture, vec2(s-offsetX,t));
highp float CC = (((((C.a*255.0)+C.b)*255.0)+C.g)255.0)+C.r;
highp float LL = (((((L.a255.0)+L.b)*255.0)+L.g)*255.0)+L.r;
highp float value = float(CC-LL)/255.0;
gl_FragColor = vec4(value, 0.0, 0.0, 0.0);
}
Thanks