Skip to content

Instantly share code, notes, and snippets.

@Doom2fan
Last active Jun 26, 2021
Embed
What would you like to do?
vec2 texCoord = /* (e.g. vTexCoord.st) */;
vec2 texSize = /* (e.g. textureSize (tex, 0)) */;
float scalingFactor = /* The virtual res the user wants */
vec2 pixelCoords = texCoord * texSize;
vec2 subPixel = (fract (pixelCoords) - .5) * 2;
subPixel = pow (abs (subPixel), vec2 (scalingFactor)) * sign (subPixel) / 2 + .5;
texCoord = (floor (pixelCoords) + subPixel) / texSize;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment