Sign in to follow this  

Problem in rendering transparent textures [SOLVED]

This topic is 2855 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 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]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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 ?

Share this post


Link to post
Share on other sites

This topic is 2855 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this