Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


3D rendering artifacts in 2D Ortho

This topic is 5866 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Does anyone know how to get rid of the 3D rendering artifacts when doing 2D via Orthographic projection? When I use the ID3DXSprite interface my tiles line up perfectly. But, if I use a texture mapped quad translated into position via an Ortho view I get small rendering artifacts between my tiles. I have filtering turned off btw. I've even tried offsetting the X & Y by 0.5f to allow for texel "degeneration". Here is my ortho and tile render code:
D3DXMATRIX	matWorld;
D3DXMATRIX	matRotation;
D3DXMATRIX	matTranslation;
D3DXMATRIX	matScale;

// Ortho projection

D3DXMatrixOrthoLH( &matproj, (float)m_shWindowWidth, (float)m_shWindowHeight, 0.0f, 1.0f );

m_pd3dDevice->SetTransform( D3DTS_PROJECTION, &matproj );
// Set default position, scale, rotation

D3DXMatrixIdentity( &matWorld );
// Scale the tile

D3DXMatrixScaling( &matScale, fXSize, fYSize, 1.0f );
D3DXMatrixMultiply( &matWorld, &matWorld, &matScale );
// Rotate the tile

D3DXMatrixRotationZ( &matRotation, 0.0f );
D3DXMatrixMultiply( &matWorld, &matWorld, &matRotation );
// Move the tile

D3DXMatrixTranslation( &matTranslation, fXPos, fYPos, 0.0f );
D3DXMatrixMultiply( &matWorld, &matWorld, &matTranslation );

// Set matrix

m_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );
// Set the texture to use

m_pd3dDevice->SetTexture( 0, m_pTexture[ iTexture ] );
// Use the tile vertex buffer

m_pd3dDevice->SetStreamSource( 0, m_pVBTile, 0, sizeof(TILEVERTEX) );
// Use the tile vertex format

m_pd3dDevice->SetFVF( D3DFVF_TILEVERTEX );
// Display the quad

m_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2 );
// Dereference texture

m_pd3dDevice->SetTexture( 0, NULL);
The following link shows the image when scaled, Scaled. If you look closely you can see black dots riddled throughout the rendering. The edges of the tiles wave in and out as well. The following link shows the image not scaled, Not Scaled. You can still see the anomalies, mainly along the tile edges. Any help is greatly appreciated! LostLogic www.lostlogic.com Author, Multiplayer Game Programming Author, Strategy Game Programming with Direct X 9 (Not yet released) [edited by - LostLogic on September 2, 2002 6:06:03 PM] [edited by - LostLogic on September 2, 2002 6:06:45 PM] [edited by - LostLogic on September 2, 2002 6:08:37 PM]

Share this post

Link to post
Share on other sites
Are you drawing "diamond shaped" quads, or rectangular quads with a masked isometric shape?

In either case, here''s my two cents, although there might be better/more elegant solutions.

Would it make sense to "feather" the edges of your textures (with alpha blending) and then overlap each quad by a couple of pixels? This might solve your problem and create better transitions between different tiles as well...

Share this post

Link to post
Share on other sites
The tiles are 64 x 32. I would rather do the blending on purpose than as a fix to a rendering problem.

The IDXSprite interface works fine, so it has to just be something I am setting wrong.

Share this post

Link to post
Share on other sites
I noticed this post a few down from this one. Maybe it might help point you in the right direction?

Love your books, looking forward to the next one.


Let's see how funny that is with one freakin' eye!

[edited by - BlueNexus on September 2, 2002 9:22:58 PM]

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!