Skip to content

Instantly share code, notes, and snippets.

@raphaelameaume
Created May 29, 2020 15:00
Show Gist options
  • Save raphaelameaume/e36cd686266c741559309dcfb1087dcd to your computer and use it in GitHub Desktop.
Save raphaelameaume/e36cd686266c741559309dcfb1087dcd to your computer and use it in GitHub Desktop.
Scale uv in fragment shader
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