Sign in to follow this  

dx9 fullscreen quad artifact (post process - glow)

Recommended Posts

hi, just been going back to my old dx9 renderer and adding some post process effects.

I've started on glow/bloom and for some reason I'm getting the seams of the full screen quad showing up. I've tried everything I could think of to erradicate it.

I assumed it had something to do with the halfpixel off set but every method i have tried produces the same results.
I'm downsampleing to 0.25 of the original image then bluring H, bluring V the blur H and V again. the seams start showing on the first blur V stage.

my half pixel for the vertex shader...

float2 halfPixel = float2(1.0f/(ViewportSize.x/4.0f),1.0f/(ViewportSize.y/4.0f));

applying it in the pixel shader...

UV.x = IN.Tex0.x + (1.0f * IN.Tex0.z);
    UV.y = IN.Tex0.y + (1.0f * IN.Tex0.w);

have also tried applying it to the vert pos directly in the vertex shader but same results.

I'm stumped would appreciate if anyone knows what this is and how to deal with it.

below is a pic of the full scrren quad artifact.





Share this post

Link to post
Share on other sites

Instead of drawing two triangles to the screen, draw one single oversized triangle twice the width and height of the screen with text coordinates ranging from [0.0-2.0] to repeat the texture (the extra area will be clipped away). This guarantees a continuous set of pixels get drawn, eradicating the seam.

Share this post

Link to post
Share on other sites

Have you checked you texture lookup coordinates in pixel shader. Check if they are really set for fullscreen. Check for texture coord output in vertex shader. It appears that interpolator outputs wrong numbers to pixel shader.


When using halfpixel offset it is easier for me to use something like:


float2 UV = IN.Tex0 + float2(0.49 * 1.0/ScreenWidth, 0.49*1.0/ScreenHeight);


Also check for texture sampler states like D3DSAMP_ADDRESSU, D3DSAMP_ADDRESSV

Share this post

Link to post
Share on other sites

Thanks, will have a look tomorrow to see the samplers are currently just Linear and uv are set to clamp. I may also try using a smaller viewport for the downscaled texture or reducing the quad size, not sure if that is the issue but it might be now that I think about it, the smaller texture is filling the whole screen when blurring so will try that and see.

Share this post

Link to post
Share on other sites
Hi just got another idea to your problem. Is your rectangle correctly rendered over full screen. Because from the looks of your picture it appears as if only one triangle is rendered. Check your 2d rectangles vertex and index buffers.

Share this post

Link to post
Share on other sites

reverted to doing the half pixel outside of the shader and applying to the buffer directy and only doing blur in the pixel shader...


FLOAT fWidth5 = ( FLOAT )dtdsdRT.Width - 0.5f;
FLOAT fHeight5 = ( FLOAT )dtdsdRT.Height - 0.5f;

FLOAT fTexWidth1 = (( FLOAT )fWidth5) / (FLOAT)dtdsdRT.Width;
FLOAT fTexHeight1 = (( FLOAT )fHeight5) / (FLOAT)dtdsdRT.Height;

pCamera[CameraIndex].pScreenQuadVB->Lock( 0, 0,( void** )&pVBData, D3DLOCK_DISCARD );

pVBData[0].p = D3DXVECTOR4((fWidth5+PosX), (-0.5f+PosY), 0.5f ,1.0f);
pVBData[0].uv = D3DXVECTOR2( fTexWidth1, 0.0f );
pVBData[0].c = D3DXVECTOR4(1.0f,0.0f,0.0f,1.0f);

pVBData[1].p = D3DXVECTOR4( ((fWidth5)+PosX), (fHeight5+PosY), 0.5f ,1.0f);
pVBData[1].uv = D3DXVECTOR2( fTexWidth1, fTexHeight1 );
pVBData[1].c = D3DXVECTOR4(0.0f,1.0f,0.0f,1.0f);

pVBData[2].p = D3DXVECTOR4( (-0.5f+PosX), (-0.5f+PosY), 0.5f ,1.0f);
pVBData[2].uv = D3DXVECTOR2( 0.0f, 0.0f );
pVBData[2].c = D3DXVECTOR4(0.0f,0.0f,1.0f,1.0f);

pVBData[3].p = D3DXVECTOR4( (-0.5f+PosX), (fHeight5+PosY), 0.5f ,1.0f);
pVBData[3].uv = D3DXVECTOR2( 0.0f, fTexHeight1 );
pVBData[3].c = D3DXVECTOR4(1.0f,0.0f,1.0f,1.0f);




and this gives this result with ugly line (only did one H and one V blur pass very minimal bluring to make sure i can see artifacts).




and just out of frustration i changed the code above slightly to this...

FLOAT fTexWidth1 = (( FLOAT )fWidth5) / (FLOAT)dtdsdRT.Width;
FLOAT fTexHeight1 = (( FLOAT )fWidth5) / (FLOAT)dtdsdRT.Height;

dividing both by width gave this result with no artifacts (as I manually stretched in the pixel shader, not in this picture though,to see)

but not the correct texture scale...





basically if anyone has any ideas what I'm doing wrong please let me know I've tried everything i can think of...


also some additional code being sent to the pixel shader...


float texelKernel[2*13];
float pixToTexX;
float pixToTexY;
pixToTexX = 1.0f/Width;
pixToTexY = 1.0f/Height;
float Scale = 1.0f;
Edited by David Ga11agher

Share this post

Link to post
Share on other sites

oh well I redid the post process pipeline and fully adhered to the direct3d9 example and got it working. tomorrow I will see if can do the blur on a smaller texture...

Thanks for those that tried to help.



Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this