Advertisement Jump to content
Sign in to follow this  
JeremyCAFE

Point Sprite Transparency

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

I have some rain particles created with point sprites, however I am trying to use a texture that looks a bit more like rain instead of a square. In order to make it look a little better I need to apply a transparency to the texture to create more of a thin particle. Is this possible with point sprites? This is how I am rendering the particles now.
	m_pd3dDevice->SetRenderState(D3DRS_POINTSPRITEENABLE, TRUE);
	m_pd3dDevice->SetRenderState(D3DRS_POINTSCALEENABLE, TRUE);
	m_pd3dDevice->SetRenderState(D3DRS_POINTSIZE_MIN, *((DWORD*)&MinSize));
	m_pd3dDevice->SetRenderState(D3DRS_POINTSCALE_A,  *((DWORD*)&ScaleA));
	m_pd3dDevice->SetRenderState(D3DRS_POINTSCALE_B,  *((DWORD*)&ScaleB));
	m_pd3dDevice->SetRenderState(D3DRS_POINTSCALE_C,  *((DWORD*)&ScaleA));
	m_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,TRUE);
	m_pd3dDevice->SetRenderState(D3DRS_ZENABLE,D3DZB_FALSE);
	m_pd3dDevice->SetRenderState(D3DRS_LIGHTING,FALSE);

	m_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,true);
	m_pd3dDevice->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_ONE);
	m_pd3dDevice->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_ONE);

	m_pd3dDevice->SetStreamSource( 0, m_pVB, 0, sizeof(CUSTOMVERTEX) );
	m_pd3dDevice->SetFVF( D3DFVF_CUSTOMVERTEX );
	m_pd3dDevice->SetTexture(0, CFileManager::GetInstance()->GetImage(m_Texture)->pTexture);
	m_pd3dDevice->DrawPrimitive( D3DPT_POINTLIST, 0, m_NumParticles );



Share this post


Link to post
Share on other sites
Advertisement

m_pd3dDevice->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_ONE);
m_pd3dDevice->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_ONE);



These two lines of code effectively make DX ignore any alpha information in the particle's texture. Any pixel is blended additively with the backbuffer, regardless of alpha value.

Try settings such as:
SRCBLEND: SRCALPHA
DESTBLEND: INVSRCALPHA
or
SRCBLEND: SRCALPHA
DESTBLEND: ONE
with textures that contain an alpha channel. That might produce better results.

Hope this helps.

Share this post


Link to post
Share on other sites
Thank you sir, I don't know why I skipped over those 2 lines when trying to figure out the problem. Looks much more like rain now that they are not squares falling :)

Thanks again

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!