Jump to content
  • Advertisement


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



This topic is 5402 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

Hello, I''m trying to implement billboards into my psuedo-game for trees, clouds, explosions, all the typicals. I''m simply using textured, alpha-blended quads rotating around the Y-Axis. My problem is that I''m getting weird-looking artifacts. That is, until I turn on alpha blending, after which the thing displays properly, but the transparent areas aren''t transparent. The other problem is that the rotation appears to be off but I couldn''t tell you how or why. The code I''m using to render is
	D3DXMATRIXA16 WorldMat;
	float angle = AngleBetween(D3DXVECTOR3(0.0f, 0.0f, 1.0f), D3DXVECTOR3(CameraPos.x, 0.0f, CameraPos.z));
	D3DXMatrixRotationY( &WorldMat, angle ); 
	g_pd3dDevice->SetTransform( D3DTS_WORLD, &WorldMat );
	g_pd3dDevice->SetStreamSource( 0, m_VB, 0, sizeof(BILLBOARDVERTEX) );
	g_pd3dDevice->SetTexture(0, m_Texture);
	g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 );
	g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
	g_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 );
	g_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
	g_pd3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
	g_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);

	g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2 );

	//Restore render states...

and just to be fair:
float AngleBetween(D3DXVECTOR3 p1, D3DXVECTOR3 p2)
	float dotp = p2.x * p1.x + p2.y * p1.y + p2.z * p1.z;
	float mag1sq =  p1.x * p1.x + p1.y * p1.y + p1.z * p1.z;
	float mag2sq =  p2.x * p2.x + p2.y * p2.y + p2.z * p2.z;
	float den = sqrtf(mag1sq*mag2sq);
	if(den == 0.0f) return 0.0f;
	return acosf(dotp/den);
Thanks for any help in advance. ms

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!