I'm using DX9.0, and am rendering 2D images on quads. Right now the images are simply trees, with transparent sections where there is no tree.
Is z-sorting required when two or more of these images overlap? It is the way I'm doing it now, but it seems to me that if the z buffer's value is retained (ignored) for sections where the image is transparent, this wouldn't be an issue. I wouldn't have to z-sort. Iows, where the alpha channel value is zero, don't change the z buffer's value, but do change it where the current image is opaque and closer than previous images.
Is this doable?
Note, I'm not doing translucency, i.e. partial transparency, but, rather full transparency, which means that the technique should work, so long as there is a means to doing it.
Is there some other trivial way of doing this without z-sorting?
I'm using the following code now:
g_pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, true); g_pDevice->SetTextureStageState(0,D3DTSS_ALPHAARG1, D3DTA_TEXTURE); g_pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1); g_pDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); g_pDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); g_pDevice->SetStreamSource(0, m_pQuad, 0, sizeof(VertTx)); g_pDevice->SetFVF(VertTx::FVF); g_pDevice->SetTexture(0, m_pTexture); g_pDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 2); g_pDevice->SetTexture(0, NULL); g_pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, false);
Thanks for any feedback!












