From 3eb91e38b51b4f7b699213514f60f99b1bafc80f Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 20 Jun 2017 19:37:57 +0200 Subject: [PATCH] CommonFilters: fix edge bleeding when using POT textures (LP 424640) --- direct/src/filter/filter-bloomx.sha | 5 +++-- direct/src/filter/filter-bloomy.sha | 5 +++-- direct/src/filter/filter-blurx.sha | 10 ++++++---- direct/src/filter/filter-blury.sha | 10 ++++++---- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/direct/src/filter/filter-bloomx.sha b/direct/src/filter/filter-bloomx.sha index 6819936fc4..300ffeff2e 100644 --- a/direct/src/filter/filter-bloomx.sha +++ b/direct/src/filter/filter-bloomx.sha @@ -12,8 +12,9 @@ void vshader(float4 vtx_position : POSITION, l_position=mul(mat_modelproj, vtx_position); float2 c=(vtx_position.xz * texpad_src.xy) + texpad_src.xy; float offset = texpix_src.x; - l_texcoord0 = float4(c.x-offset* -4, c.x-offset* -3, c.x-offset* -2, c.y); - l_texcoord1 = float4(c.x-offset* -1, c.x-offset* 0, c.x-offset* 1, c.y); + float pad = texpad_src.x * 2; + l_texcoord0 = float4(min(c.x-offset* -4, pad), min(c.x-offset* -3, pad), min(c.x-offset* -2, pad), c.y); + l_texcoord1 = float4(min(c.x-offset* -1, pad), c.x-offset* 0, c.x-offset* 1, c.y); l_texcoord2 = float4(c.x-offset* 2, c.x-offset* 3, c.x-offset* 4, c.y); } diff --git a/direct/src/filter/filter-bloomy.sha b/direct/src/filter/filter-bloomy.sha index 2351c70dd3..51912b8b60 100644 --- a/direct/src/filter/filter-bloomy.sha +++ b/direct/src/filter/filter-bloomy.sha @@ -12,8 +12,9 @@ void vshader(float4 vtx_position : POSITION, l_position=mul(mat_modelproj, vtx_position); float2 c=(vtx_position.xz * texpad_src.xy) + texpad_src.xy; float offset = texpix_src.y; - l_texcoord0 = float4(c.y-offset* -4, c.y-offset* -3, c.y-offset* -2, c.x); - l_texcoord1 = float4(c.y-offset* -1, c.y-offset* 0, c.y-offset* 1, c.x); + float pad = texpad_src.y * 2; + l_texcoord0 = float4(min(c.y-offset* -4, pad), min(c.y-offset* -3, pad), min(c.y-offset* -2, pad), c.x); + l_texcoord1 = float4(min(c.y-offset* -1, pad), c.y-offset* 0, c.y-offset* 1, c.x); l_texcoord2 = float4(c.y-offset* 2, c.y-offset* 3, c.y-offset* 4, c.x); } diff --git a/direct/src/filter/filter-blurx.sha b/direct/src/filter/filter-blurx.sha index 2cb6c1512d..47a2217af3 100644 --- a/direct/src/filter/filter-blurx.sha +++ b/direct/src/filter/filter-blurx.sha @@ -2,7 +2,7 @@ // //Cg profile arbvp1 arbfp1 -void vshader(float4 vtx_position : POSITION, +void vshader(float4 vtx_position : POSITION, float2 vtx_texcoord0 : TEXCOORD0, out float4 l_position : POSITION, out float2 l_texcoord0 : TEXCOORD0, @@ -17,16 +17,18 @@ void vshader(float4 vtx_position : POSITION, void fshader(float2 l_texcoord0 : TEXCOORD0, out float4 o_color : COLOR, uniform float2 texpix_src, + uniform float4 texpad_src, uniform sampler2D k_src : TEXUNIT0) { + float pad = texpad_src.x * 2; float3 offset = float3(1.0*texpix_src.x, 2.0*texpix_src.x, 3.0*texpix_src.x); o_color = tex2D(k_src, l_texcoord0); o_color += tex2D(k_src, float2(l_texcoord0.x - offset.z, l_texcoord0.y)); o_color += tex2D(k_src, float2(l_texcoord0.x - offset.y, l_texcoord0.y)); o_color += tex2D(k_src, float2(l_texcoord0.x - offset.x, l_texcoord0.y)); - o_color += tex2D(k_src, float2(l_texcoord0.x + offset.x, l_texcoord0.y)); - o_color += tex2D(k_src, float2(l_texcoord0.x + offset.y, l_texcoord0.y)); - o_color += tex2D(k_src, float2(l_texcoord0.x + offset.z, l_texcoord0.y)); + o_color += tex2D(k_src, float2(min(l_texcoord0.x + offset.x, pad), l_texcoord0.y)); + o_color += tex2D(k_src, float2(min(l_texcoord0.x + offset.y, pad), l_texcoord0.y)); + o_color += tex2D(k_src, float2(min(l_texcoord0.x + offset.z, pad), l_texcoord0.y)); o_color /= 7; o_color.w = 1; } diff --git a/direct/src/filter/filter-blury.sha b/direct/src/filter/filter-blury.sha index b927cf0329..ab135c363a 100644 --- a/direct/src/filter/filter-blury.sha +++ b/direct/src/filter/filter-blury.sha @@ -2,7 +2,7 @@ // //Cg profile arbvp1 arbfp1 -void vshader(float4 vtx_position : POSITION, +void vshader(float4 vtx_position : POSITION, float2 vtx_texcoord0 : TEXCOORD0, out float4 l_position : POSITION, out float2 l_texcoord0 : TEXCOORD0, @@ -17,16 +17,18 @@ void vshader(float4 vtx_position : POSITION, void fshader(float2 l_texcoord0 : TEXCOORD0, out float4 o_color : COLOR, uniform float2 texpix_src, + uniform float4 texpad_src, uniform sampler2D k_src : TEXUNIT0) { + float pad = texpad_src.y * 2; float3 offset = float3(1.0*texpix_src.y, 2.0*texpix_src.y, 3.0*texpix_src.y); o_color = tex2D(k_src, l_texcoord0); o_color += tex2D(k_src, float2(l_texcoord0.x, l_texcoord0.y - offset.z)); o_color += tex2D(k_src, float2(l_texcoord0.x, l_texcoord0.y - offset.y)); o_color += tex2D(k_src, float2(l_texcoord0.x, l_texcoord0.y - offset.x)); - o_color += tex2D(k_src, float2(l_texcoord0.x, l_texcoord0.y + offset.x)); - o_color += tex2D(k_src, float2(l_texcoord0.x, l_texcoord0.y + offset.y)); - o_color += tex2D(k_src, float2(l_texcoord0.x, l_texcoord0.y + offset.z)); + o_color += tex2D(k_src, float2(l_texcoord0.x, min(l_texcoord0.y + offset.x, pad))); + o_color += tex2D(k_src, float2(l_texcoord0.x, min(l_texcoord0.y + offset.y, pad))); + o_color += tex2D(k_src, float2(l_texcoord0.x, min(l_texcoord0.y + offset.z, pad))); o_color /= 7; o_color.w = 1; }