From b600cb36ba6bea7bd4d33e34e1e3b9e90772549c Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Fri, 7 Jul 2023 02:29:51 +0200 Subject: [PATCH] tweak shaders --- inc/d3d9shader.h | 10 ++++++---- inc/openglshader.h | 12 ++++++------ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/inc/d3d9shader.h b/inc/d3d9shader.h index 71575b8..f453597 100644 --- a/inc/d3d9shader.h +++ b/inc/d3d9shader.h @@ -434,6 +434,8 @@ uniform sampler2D SurfaceTex; float4 TextureSize : register(c0); +#define SourceSize float4(TextureSize.xy, 1.0 / TextureSize.xy) + float4 catmull_rom(float2 coord) { // The following code is licensed under the MIT license: https://gist.github.com/TheRealMJP/bc503b0b87b643d3505d41eab8b332ae @@ -443,7 +445,7 @@ float4 catmull_rom(float2 coord) // Modified to use 5 texture fetches - float2 samplePos = coord * TextureSize.xy; + float2 samplePos = coord * SourceSize.xy; float2 texPos1 = floor(samplePos - 0.5f) + 0.5f; float2 f = samplePos - texPos1; @@ -460,9 +462,9 @@ float4 catmull_rom(float2 coord) float2 texPos3 = texPos1 + 2; float2 texPos12 = texPos1 + offset12; - texPos0 /= TextureSize.xy; - texPos3 /= TextureSize.xy; - texPos12 /= TextureSize.xy; + texPos0 *= SourceSize.zw; + texPos3 *= SourceSize.zw; + texPos12 *= SourceSize.zw; float wtm = w12.x * w0.y; float wml = w0.x * w12.y; diff --git a/inc/openglshader.h b/inc/openglshader.h index 1b23724..9502f8a 100644 --- a/inc/openglshader.h +++ b/inc/openglshader.h @@ -171,9 +171,9 @@ const char CATMULL_ROM_FRAG_SHADER[] = " vec2 texPos3 = texPos1 + 2.;\n" " vec2 texPos12 = texPos1 + offset12;\n" "\n" - " texPos0 /= SourceSize.xy;\n" - " texPos3 /= SourceSize.xy;\n" - " texPos12 /= SourceSize.xy;\n" + " texPos0 *= SourceSize.zw;\n" + " texPos3 *= SourceSize.zw;\n" + " texPos12 *= SourceSize.zw;\n" "\n" " float wtm = w12.x * w0.y;\n" " float wml = w0.x * w12.y;\n" @@ -229,9 +229,9 @@ const char CATMULL_ROM_FRAG_SHADER_CORE[] = " vec2 texPos3 = texPos1 + 2.;\n" " vec2 texPos12 = texPos1 + offset12;\n" "\n" - " texPos0 /= SourceSize.xy;\n" - " texPos3 /= SourceSize.xy;\n" - " texPos12 /= SourceSize.xy;\n" + " texPos0 *= SourceSize.zw;\n" + " texPos3 *= SourceSize.zw;\n" + " texPos12 *= SourceSize.zw;\n" "\n" " float wtm = w12.x * w0.y;\n" " float wml = w0.x * w12.y;\n"