I try to develop an android application that swap the pixels (of the camera preview) bottom <=> top. swap diagram
So I wrote this vertex shader but it displays very strange things (a black screen with digital noise).
attribute vec4 vPosition;
attribute vec2 inputTextureCoordinate;
varying vec2 textureCoordinate;
void main()
{
if (vPosition.y > 0.0)
{
gl_Position = vPosition - vec4(0.0, 1.0, 0.0, 0.0);
}
else
{
gl_Position = vPosition + vec4(0.0, 1.0, 0.0, 0.0);
}
textureCoordinate = inputTextureCoordinate;
}
But this vertex shader below works, but it only moves top pixels to bottom.
attribute vec4 vPosition;
attribute vec2 inputTextureCoordinate;
varying vec2 textureCoordinate;
void main()
{
if (vPosition.y > 0.0)
{
gl_Position = vPosition - vec4(0.0, 1.0, 0.0, 0.0);
}
else
{
gl_Position = vPosition;
}
textureCoordinate = inputTextureCoordinate;
}
Do you know how to swap the pixels as in my diagram (make my first vertex shader work)? Thank you