Last active
January 17, 2023 14:27
-
-
Save romainavalle/0b155e34f260b24f2b7dfa43310878ca to your computer and use it in GitHub Desktop.
texture resize glsl
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
float scale(float _val, float _scale) { | |
_val -= 0.5; | |
_val *= _scale; | |
_val += 0.5; | |
return _val; | |
} | |
vec2 coverImage(vec2 _pos) { | |
float rS = uRes.x / uRes.y; | |
float rI = uImageRes.x / uImageRes.y; | |
float scaleX = 1.; | |
float scaleY = 1.; | |
// scale UVS | |
if (rS > rI) { | |
scaleY = rI / rS; | |
} else { | |
scaleX = rS / rI; | |
} | |
_pos.x = scale(_pos.x, scaleX); | |
_pos.y = scale(_pos.y, scaleY); | |
return _pos; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment