Created
February 7, 2019 13:59
-
-
Save Samsy/89984a5f5e1a43c121b8ed20d1caa13a to your computer and use it in GitHub Desktop.
common.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 when_fgt(float x, float y) { | |
return max(sign(x - y), 0.0); | |
} | |
vec2 correctRatio(vec2 inUv, float baseratio, float asp){ | |
return mix( | |
vec2( | |
inUv.x, | |
inUv.y * baseratio / asp + .5 * ( 1. - baseratio / asp ) | |
), | |
vec2( | |
inUv.x * asp / baseratio + .5 * ( 1. - asp / baseratio), | |
inUv.y | |
) | |
,when_fgt(baseratio, asp) | |
); | |
} | |
vec2 screenspacefrompos(vec4 sspPos){ | |
vec4 tempssp = sspPos; | |
tempssp.xyz /= tempssp.w; | |
tempssp.xy = (0.5)+(tempssp.xy)*0.5; | |
return tempssp.xy; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment