Skip to content

Instantly share code, notes, and snippets.

@hikari-no-yume
Created May 16, 2023 10:58
Show Gist options
  • Save hikari-no-yume/311742a22eaa194c1a9174387167a471 to your computer and use it in GitHub Desktop.
Save hikari-no-yume/311742a22eaa194c1a9174387167a471 to your computer and use it in GitHub Desktop.
one way to automatically flip texture co-ordinates in GLSL
#version 300 es
precision mediump float;
precision mediump sampler2D;
precision mediump sampler3D;
vec4 textureFlipped(sampler2D s, vec2 coords) {
return texture(s, vec2(coords.x, 1.0 - coords.y));
}
vec4 textureFlipped(sampler3D s, vec3 coords) {
return texture(s, vec3(coords.x, 1.0 - coords.y, coords.z));
}
#define texture textureFlipped
uniform sampler2D someTex;
in vec2 texCoords;
out vec4 fragColor;
void main(void) {
fragColor = texture(someTex, texCoords);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment