From c365c450a75c843e0f3e7a1a25b836fe887194f4 Mon Sep 17 00:00:00 2001 From: LMLB Date: Sun, 11 Mar 2018 15:09:30 +0100 Subject: [PATCH] Fix shaders that break with specific pixel factors OmniScaleLegacy seems to has problems with every odd factor (3x, 5x, 7x, 9x, etc.). SmoothBilinear has problems with 5x and 11x and probably more. --- Shaders/OmniScaleLegacy.fsh | 8 ++++---- Shaders/SmoothBilinear.fsh | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Shaders/OmniScaleLegacy.fsh b/Shaders/OmniScaleLegacy.fsh index cd4257d..f4bdea9 100644 --- a/Shaders/OmniScaleLegacy.fsh +++ b/Shaders/OmniScaleLegacy.fsh @@ -10,10 +10,10 @@ vec4 scale(sampler2D image) vec2 pixel = texCoord * textureDimensions - vec2(0.5, 0.5); - vec4 q11 = texture(image, (pixel ) / textureDimensions); - vec4 q12 = texture(image, (pixel + vec2(0.0, 1.0)) / textureDimensions); - vec4 q21 = texture(image, (pixel + vec2(1.0, 0.0)) / textureDimensions); - vec4 q22 = texture(image, (pixel + vec2(1.0, 1.0)) / textureDimensions); + vec4 q11 = texture(image, (floor(pixel) + 0.5) / textureDimensions); + vec4 q12 = texture(image, (vec2(floor(pixel.x), ceil(pixel.y)) + 0.5) / textureDimensions); + vec4 q21 = texture(image, (vec2(ceil(pixel.x), floor(pixel.y)) + 0.5) / textureDimensions); + vec4 q22 = texture(image, (ceil(pixel) + 0.5) / textureDimensions); vec2 pos = fract(pixel); diff --git a/Shaders/SmoothBilinear.fsh b/Shaders/SmoothBilinear.fsh index e7060b7..b796d88 100644 --- a/Shaders/SmoothBilinear.fsh +++ b/Shaders/SmoothBilinear.fsh @@ -11,8 +11,8 @@ vec4 scale(sampler2D image) vec2 s = smoothstep(0., 1., fract(pixel)); - vec4 r1 = mix(q11, q21, fract(s.x)); - vec4 r2 = mix(q12, q22, fract(s.x)); + vec4 r1 = mix(q11, q21, s.x); + vec4 r2 = mix(q12, q22, s.x); - return mix (r1, r2, fract(s.y)); + return mix (r1, r2, s.y); } \ No newline at end of file