I need to remove all the odd lines from the texture - this is part of a simple deinterlacer.
In the following code example, instead of getting RGB from the texture, I select the output for white for an odd line and red for an even line - so I can visually check if the result is what I expected.
_texcoord is passed from the vertex shader and has a range of [0, 1] for x and y
uniform sampler2D sampler0;
varying highp vec2 _texcoord;
void main() {
highp float height = 480.0;
highp float y = height * _texcoord.y;
if (mod(y, 2.0) >= 1.0) {
gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);
} else {
gl_FragColor = vec4(0.0, 0.0, 1.0, 1.0);
}
}
When displayed on the screen, output is not expected. Vertically this is RRWWWRRWWW But I really expect RWRWRWRW (i.e. alternates between red and white)
My code runs on iOS and targets GLES 2.0, so it shouldn't be different on Android with GLES 2.0
Question: Where did I go wrong?
EDIT
- Yes, the texture height is correct.
- , : _texcoord.y, , .