Flip Vertex Shader (GLES)

Given the next vertex shader, what is the easiest, most efficient and fastest way to flip coordinates upside down so that the fragment shader will also create an inverted image?

attribute vec4 a_position; attribute vec2 a_texcoord; varying vec2 v_texcoord; void main() { v_texcoord = a_texcoord.st; gl_Position = a_position; } 
+8
shader glsl flip vertex
source share
1 answer

Just flip v_texcoord . For example,

 v_texcoord = a_texcoord.st * vec2(1.0, -1.0); 

Or, I think:

 v_texcoord = vec2(a_texcoord.s, 1.0 - a_texcoord.t); 

Depending on what exactly you want to do with the .t range.

+13
source share

All Articles