Jump to content
  • Advertisement
Sign in to follow this  
hserver

Transparency

This topic is 3757 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 want to transparent a texture that use Alpha channel I know how to alpha blend a texture by set these two render state Direct3DDevice.SetRenderState D3DRS_SRCBLEND, D3DBLEND_SRCALPHA Direct3DDevice.SetRenderState D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA But How can I make it transparent?

Share this post


Link to post
Share on other sites
Advertisement
good for a laugh!
I already knew that but i want to change it in run time
I think it mey be done with "D3DRSD3DTA_TFACTOR"...

Share this post


Link to post
Share on other sites
Quote:
Original post by hserver
good for a laugh!
I already knew that but i want to change it in run time
I think it mey be done with "D3DRSD3DTA_TFACTOR"...
So you want to change the alpha of the entire triangle/quad, and not the alpha of individual texels?
In that case, either use alpha in the diffuse colour, or yes, use the TFACTOR register.
The texture stages are initially set up to modulate the texture and diffuse colour for stage 0.

Share this post


Link to post
Share on other sites
this is my code but I didn't get the right things

Direct3DDevice.SetRenderState D3DRS_ALPHABLENDENABLE, 1
Direct3DDevice.SetRenderState D3DRS_SRCBLEND, D3DBLEND_SRCALPHA
Direct3DDevice.SetRenderState D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA
Direct3DDevice.SetTextureStageState 0, D3DTSS_ALPHAARG1, D3DTA_TFACTOR
Direct3DDevice.SetRenderState D3DRS_TEXTUREFACTOR, D3DColorARGB(20, 255, 255, 255)
any idea?

[Edited by - hserver on April 2, 2008 2:54:42 PM]

Share this post


Link to post
Share on other sites
I think what you want is is the flexible vertex format.

You need to add a D3DFVF_DIFFUSE flag into your FVF. (Use binary or)

somthing like:

#define CUSTOMFVF (D3DFVF_XYZ)
struct Vertex {float X, Y, Z;};

into

#define CUSTOMFVF (D3DFVF_XYZ | D3DFVF_DIFFUSE)
struct CUSTOMVERTEX {float X, Y, Z; unsigned long COLOUR;};

Then you change the alpha channel int the COLOUR property.

Share this post


Link to post
Share on other sites
Hi,
I don't think you need to diffuse in your vertex format. I used the diffuse from the material..

I used this:

p_D3D_Device->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
p_D3D_Device->SetRenderState( D3DRS_ZWRITEENABLE, FALSE );
p_D3D_Device->SetRenderState( D3DRS_DIFFUSEMATERIALSOURCE, D3DMCS_MATERIAL );
p_D3D_Device->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE );
p_D3D_Device->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 );
//ALPHA BLENDING CODE HERE..


Share this post


Link to post
Share on other sites
Thanks
and I Use This :

D3DDevice.SetRenderState D3DRS_SRCBLEND, D3DBLEND_SRCALPHA
D3DDevice.SetRenderState D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA
D3DDevice.SetRenderState D3DRS_ALPHABLENDENABLE, 1
D3DDevice.SetTextureStageState 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE
D3DDevice.SetTextureStageState 0, D3DTSS_ALPHAARG2, D3DTA_TFACTOR
D3DDevice.SetTextureStageState 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE
D3DDevice.SetRenderState D3DRS_TEXTUREFACTOR, D3DColorARGB(ThaAlpha, 255, 255, 255)


PZLCreateQuadTexture MyPZLDrawChain(DChainID).TheTexturee, MyPZLDrawChain(DChainID).StartX, MyPZLDrawChain(DChainID).StartY, False, TriStripp() ', D3DColorARGB(ThaAlpha, 0, 0, 0)
D3DDevice.SetTexture 0, MyPZLDrawChain(DChainID).TheTexturee.Texture
D3DDevice.DrawPrimitiveUP D3DPT_TRIANGLESTRIP, 2, TriStripp(0), Len(TriStripp(0))

D3DDevice.SetTextureStageState 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1
D3DDevice.SetTextureStageState 0, D3DTSS_ALPHAARG2, D3DTA_CURRENT
D3DDevice.SetTextureStageState 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE

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.

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!