Skip to content

Instantly share code, notes, and snippets.

@OnlyInAmerica
Created April 8, 2016 02:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save OnlyInAmerica/f0f62c44c6acfb4b7e6f245de5ddd01b to your computer and use it in GitHub Desktop.
Save OnlyInAmerica/f0f62c44c6acfb4b7e6f245de5ddd01b to your computer and use it in GitHub Desktop.
A Vertex shader that mirrors its source horizontally
private static final String FRAGMENT_SHADER_MIRROR =
"#extension GL_OES_EGL_image_external : require\n" +
"precision mediump float;\n" +
"varying vec2 vTextureCoord;\n" + // Coordinate within texture
"uniform samplerExternalOES sTexture;\n" + // Texture
"uniform vec2 uPosition;\n" + // Position within OpenGL scene
"void main() {\n" +
" vec2 texCoord = vTextureCoord.xy;\n" +
" vec2 normCoord = 2.0 * texCoord - 1.0;\n"+
" normCoord.x = normCoord.x * sign(normCoord.x + uPosition.x);\n"+
" texCoord = normCoord / 2.0 + 0.5;\n"+
" gl_FragColor = texture2D(sTexture, texCoord);\n"+
"}\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment