Created
May 16, 2023 10:58
-
-
Save hikari-no-yume/311742a22eaa194c1a9174387167a471 to your computer and use it in GitHub Desktop.
one way to automatically flip texture co-ordinates in GLSL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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