Problem in rendering transparent textures [SOLVED]

Started by
5 comments, last by Chetanhl 14 years, 1 month ago
I am trying to render fog using PointList But texture transparency is not working corectly. Screenshot from app - Screenshot from app Link to the texture i am using - snowflake.dds Here is the code for render states called before rendering pointlist - C++

this->chDevice->pd3dDevice->SetRenderState(D3DRS_LIGHTING,false);
	this->chDevice->pd3dDevice->SetRenderState(D3DRS_POINTSPRITEENABLE,true);
	this->chDevice->pd3dDevice->SetRenderState(D3DRS_POINTSCALEENABLE,true);
	this->chDevice->pd3dDevice->SetRenderState(D3DRS_POINTSIZE,chUtility::FtoDw(this->size));
	this->chDevice->pd3dDevice->SetRenderState(D3DRS_POINTSIZE_MIN,chUtility::FtoDw(0.0f));

	this->chDevice->pd3dDevice->SetRenderState(D3DRS_POINTSCALE_A,chUtility::FtoDw(0.0f));
	this->chDevice->pd3dDevice->SetRenderState(D3DRS_POINTSCALE_B,chUtility::FtoDw(0.0f));
	this->chDevice->pd3dDevice->SetRenderState(D3DRS_POINTSCALE_C,chUtility::FtoDw(1.0f));

	//use alpha from texture
	this->chDevice->pd3dDevice->SetTextureStageState(0,D3DTSS_ALPHAARG1,D3DTA_TEXTURE);
	this->chDevice->pd3dDevice->SetTextureStageState(0,D3DTSS_ALPHAOP,D3DTOP_SELECTARG1);

	this->chDevice->pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,true);
	this->chDevice->pd3dDevice->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_SRCALPHA);
	this->chDevice->pd3dDevice->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_INVSRCALPHA);




[Edited by - Chetanhl on February 19, 2010 5:42:28 AM]

My Game Development Blog : chetanjags.wordpress.com

Advertisement
If you're using D3DBLEND_SRCALPHA / D3DBLEND_INVSRCALPHA, you need to draw your transparent objects in back-to-front order, so the nearer objects blend correctly against those behind them.

Do you sort the points to render them from back to front?
For this i have to sort them with according to z values, this may take some extra cycles.

Is there any other way to achieve this ?

My Game Development Blog : chetanjags.wordpress.com

Quote:Original post by Chetanhl
For this i have to sort them with according to z values, this may take some extra cycles.
Actually, it's worse - you need to sort based on distance to camera (Which will only the be Z value if your camera points directly along the Z axis).

Quote:Original post by Chetanhl
Is there any other way to achieve this ?
Use a different blending type - but that'll give a different look to it; D3DBLEND_SRCALPHA / D3DBLEND_ONE may work ok - that'll "add" the quad to the backbuffer, but will saturate quickly.
Quote:Use a different blending type - but that'll give a different look to it; D3DBLEND_SRCALPHA / D3DBLEND_ONE may work ok - that'll "add" the quad to the backbuffer, but will saturate quickly.



D3DBLEND_ONE giving me quads as you said but wont work here.

Actually am looking for some different blending type only ?
Can you suggest something ?

My Game Development Blog : chetanjags.wordpress.com

After trying almost all possible blending types, finally i have sorted the particles from Front to Back and it worked.

My Game Development Blog : chetanjags.wordpress.com

This topic is closed to new replies.

Advertisement