vec4 pixelize(vec4 image, vec2 scaleVec, vec2 texCoord) { float scale = max(scaleVec.x, scaleVec.y); float x = fract(texCoord.x * 160.0) * scale; float y = fract(texCoord.y * 144.0) * scale; float border = 1.0; if (scale > 5.0) { border = 2.0; } if (x < border || x > scale - border || y < border || y > scale - border) { return vec4(.95, .95, .95, 1); } return image; } vec4 scale(sampler2D image) { vec2 displayScale = uResolution / vec2(160.0, 144.0); vec2 texCoord = vec2(gl_FragCoord.x, uResolution.y - gl_FragCoord.y) / uResolution; vec4 sampled = texture(image, texCoord); if (displayScale.x < 3.0 || displayScale.y < 3.0) { return sampled; } float mixValue = 1.0; if (displayScale.x >= 5.0 && displayScale.y >= 5.0) { mixValue = 0.5; } else if (displayScale.x >= 3.0 && displayScale.y >= 3.0) { mixValue = 0.8; } return mix(pixelize(sampled, displayScale, texCoord), sampled, mixValue); }