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);
3D rendering artifacts in 2D Ortho
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:
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]
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...
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...
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement