Sign in to follow this  
DvDmanDT

Textures, diffuselightning and alpha/transparency

Recommended Posts

How can I use diffuselightning to make a texture transparent? I have a texture, with parts that are either invisible or opaque. A Sprite, it's for 2d use. Now, I wish to use the diffuse component of my vertices for alpha. So, I got a texture, which pixels have either 255 or 0 in alpha, nothing in between. Then, I render that texture with a vertex, which has alpha 20. Now, either the texture is rendered normally (without any alpha, but with the right pixels transparent), or blended, but with black pixels where it should be transparent. I'm using MDX 1.1. device.RenderState.SourceBlend = Blend.SourceAlpha; device.RenderState.DestinationBlend = Blend.InvSourceAlpha; device.RenderState.AlphaBlendEnable = true; //What should that one be? What should the others be? //device.TextureState[0].AlphaOperation = TextureOperation.MultiplyAdd; device.RenderState.Lighting = false;

Share this post


Link to post
Share on other sites
Tell lighting to use vertex colors, not material colors
D3DRS_COLORVERTEX, true
D3DRS_DIFFUSEMATERIALSOURCE, D3DMCS_COLOR1

Tell the fixed pixel pipeline that alpha is texture.a*diffuse.a
0, D3DTSS_ALPHAOP, D3DTOP_MODULATE
0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE
0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE

Share this post


Link to post
Share on other sites

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