Flip upside down vertex shader (GLES)

14,451

Just flip v_texcoord. So e.g.

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

Or, I guess:

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

Depending on what exactly you want to happen to the range of .t.

Share:
14,451
PerracoLabs
Author by

PerracoLabs

1729, what a peculiar number. In honor of the legendary Srinivasa Ramanujan.

Updated on June 04, 2022

Comments

  • PerracoLabs
    PerracoLabs about 2 years

    Given the next vertex shader, what is the simplest, most efficient and fastest way to flip the coordinates upside down, so the fragment shader will produce and upside down image?

    attribute vec4 a_position;
    attribute vec2 a_texcoord;                                                  
    varying vec2 v_texcoord;
    
    void main()
    {
        v_texcoord = a_texcoord.st;
        gl_Position = a_position;
    }