[source lang="cpp"]GetDevice ( )->SetRenderState ( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA );GetDevice ( )->SetRenderState ( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA );[/source]
Then I try any combination of using or not using the z-buffer and sorting or not sorting my std::vector of billboards:
[source lang="cpp"]GetDevice ( )->SetRenderState ( D3DRS_ZENABLE, true );std::sort ( billboards.begin ( ), billboards.end ( ) );[/source]
For reference, this is how I overload the < operator for my billboards that makes the std::sort call work:
[source lang="cpp"]bool operator < ( Object rhs ){ D3DXVECTOR3 pos_a = this->GetPosition ( ); D3DXVECTOR3 pos_b = rhs.GetPosition ( ); D3DXVECTOR3 distance_a ( camera->position.x - pos_a.x, camera->position.y - pos_a.y, camera->position.z - pos_a.z ); D3DXVECTOR3 distance_b ( camera->position.x - pos_b.x, camera->position.y - pos_b.y, camera->position.z - pos_b.z ); return D3DXVec3Length ( &distance_a ) > D3DXVec3Length ( &distance_b );}[/source]
However I always get this render output, no matter whether or not I use the z-buffer and/or sort the std::vector by distance:

As you can see, the parts of the billboard texture that are transparent cut out parts of the billboards behind. Additionally, the actual draw order only works correctly when I use the z-buffer and still sort by distance to the camera.
I'd love some clarification: what's the easiest way to render a number of DXT1 compressed textures with 1-bit alpha channel correctly on top of each other? Is manual sorting necessary? What am I doing wrong here?
Thanks ahead of time!






