Created
May 29, 2020 15:00
-
-
Save raphaelameaume/e36cd686266c741559309dcfb1087dcd to your computer and use it in GitHub Desktop.
Scale uv in fragment shader
This file contains 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
vec2 uvScale (vec2 baseUv, float scale) { | |
vec2 uv = baseUv; | |
float s = 1. / scale; | |
uv = uv * s - ( s - 1.) * 0.5; | |
return uv; | |
} | |
vec2 uvScale (vec2 baseUv, vec2 scale) { | |
vec2 uv = baseUv; | |
float sx = 1. / scale.x; | |
float sy = 1. / scale.y; | |
uv.x = uv.x * sx - ( sx - 1.) * 0.5; | |
uv.y = uv.y * sy - ( sy - 1.) * 0.5; | |
return uv; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment