Skip to content

Instantly share code, notes, and snippets.

View ameliemaia's full-sized avatar
🦋

Amelie Maia ameliemaia

🦋
View GitHub Profile
@mattdesl
mattdesl / glsl-background.glsl
Created April 26, 2017 18:02
Like CSS background-size: contain but in GLSL
vec2 backgroundUV (vec2 uv, vec2 resolution, vec2 texResolution) {
float tAspect = texResolution.x / texResolution.y;
float pAspect = resolution.x / resolution.y;
float pwidth = resolution.x;
float pheight = resolution.y;
float width = 0.0;
float height = 0.0;
if (tAspect > pAspect) {
height = pheight;