2D blur artifact

Started by
1 comment, last by Akitsune 13 years, 5 months ago
I've been working on porting my ORPG to 2D and have this painful issue with my blur. There's a giant artifact that stretches across the screen quad - it looks like a diagonal line from UV(1, 1) to UV(0, 0).

Of course, it only shows up in my blur. Sampling just the world doesn't have this artifact. I tried not downsampling my blur and I still get the artifact. I've exaggerated the blur to show you the artifact.

http://img687.imageshack.us/i/18979256.jpg/

////////////////////////////////////////////////////// BlurX////////////////////////////////////////////////////float Pixel;texture Texture0:TEXTURE0;sampler2D Sampler0 = sampler_state{    texture = (Texture0);    MIPFILTER = LINEAR;    MAGFILTER = LINEAR;    MINFILTER = LINEAR;    ADDRESSU = CLAMP;    ADDRESSV = CLAMP;};struct IN0{     float4 Position : POSITION;     float2 UV : TEXCOORD0;};struct OUT0{    float4 Position : POSITION;    float2 UV : TEXCOORD0;};OUT0 VS(IN0 IN){    OUT0 OUT;    OUT.Position = IN.Position;    OUT.UV = IN.UV;    return OUT;}float4 PS(OUT0 IN) : COLOR{    float2 UV = IN.UV;    float4 RGBA = tex2D(Sampler0, UV);    UV.x += Pixel;    RGBA += tex2D(Sampler0, UV);    UV.x += Pixel;    RGBA += tex2D(Sampler0, UV);    UV.x += Pixel;    RGBA += tex2D(Sampler0, UV);    UV.x += Pixel;    RGBA += tex2D(Sampler0, UV);    UV.x -= Pixel * 8;    RGBA += tex2D(Sampler0, UV);    UV.x += Pixel;    RGBA += tex2D(Sampler0, UV);    UV.x += Pixel;    RGBA += tex2D(Sampler0, UV);    UV.x += Pixel;    RGBA += tex2D(Sampler0, UV);    RGBA /= 9;    return RGBA;}technique T0{    pass P0    {        VertexShader = compile vs_2_0 VS();        PixelShader = compile ps_2_0 PS();    }}


////////////////////////////////////////////////////// Render////////////////////////////////////////////////////float time : TIME;float2 BlurPixel;float2 BlurCenter;texture Texture0:TEXTURE0;sampler2D Sampler0 = sampler_state{    texture = (Texture0);    MIPFILTER = LINEAR;    MAGFILTER = LINEAR;    MINFILTER = LINEAR;    ADDRESSU = CLAMP;    ADDRESSV = CLAMP;};texture Texture1:TEXTURE1;sampler2D Sampler1 = sampler_state{    texture = (Texture1);    MIPFILTER = LINEAR;    MAGFILTER = LINEAR;    MINFILTER = LINEAR;    ADDRESSU = CLAMP;    ADDRESSV = CLAMP;};struct IN0{     float4 Position : POSITION;     float2 UV : TEXCOORD0;};struct OUT0{    float4 Position : POSITION;    float2 UV : TEXCOORD0;};OUT0 VS(IN0 IN){    OUT0 OUT;    OUT.Position = IN.Position;    OUT.UV = IN.UV;    return OUT;}float4 PS(OUT0 IN) : COLOR{    float2 UV = IN.UV;    float4 RGBA = tex2D(Sampler0, UV);    float4 Blur = tex2D(Sampler1, IN.UV + BlurPixel);    float2 BlurDistance = IN.UV - BlurCenter;    float BlurStrength = min(4 * dot(BlurDistance, BlurDistance), 1);    RGBA = lerp(RGBA, Blur, BlurStrength);    RGBA = max(Blur - 0.95f, 0) * 1.0f + RGBA;    float2 CenterDistance = IN.UV - float2(0.5f, 0.5f);    float VignetteStrength = 1.0f - dot(CenterDistance, CenterDistance);    RGBA *= VignetteStrength;    return RGBA;}technique T0{    pass P0    {        VertexShader = compile vs_2_0 VS();        PixelShader = compile ps_2_0 PS();    }}


Any ideas are appreciated :)
Advertisement
Maybe there's an issue with your fullscreen "quad". It looks like rendering two triangles. When your source and target renderbuffer are the same(is it possible in DX ?), you will get an error.
Quote:Original post by Ashaman73
Maybe there's an issue with your fullscreen "quad". It looks like rendering two triangles. When your source and target renderbuffer are the same(is it possible in DX ?), you will get an error.


Brilliant! Here's what I changed in the render code (not in anything shader related)

Original:
SurfaceBlur.StartRender(false);TV2D.Action_Begin2D();TV2D.Draw_FullscreenQuadWithShader(ShaderBlurX, 0, 0, 1, 1, SurfaceRender.GetTexture());TV2D.Draw_FullscreenQuadWithShader(ShaderBlurY, 0, 0, 1, 1, SurfaceBlur.GetTexture());TV2D.Action_End2D();SurfaceBlur.EndRender();


Fixed:
SurfaceBlur0.StartRender(false);TV2D.Action_Begin2D();TV2D.Draw_FullscreenQuadWithShader(ShaderBlurX, 0, 0, 1, 1, SurfaceRender.GetTexture());TV2D.Action_End2D();SurfaceBlur0.EndRender();SurfaceBlur1.StartRender(false);TV2D.Action_Begin2D();TV2D.Draw_FullscreenQuadWithShader(ShaderBlurY, 0, 0, 1, 1, SurfaceBlur0.GetTexture());TV2D.Action_End2D();SurfaceBlur1.EndRender();




Thanks a ton for your help - I was at my wit's end.

This topic is closed to new replies.

Advertisement