Jump to content
  • Advertisement
Sign in to follow this  
tealrabbit

Vertex color alpha not working

This topic is 4839 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 writing a particle system using point sprites and I am using vertex color blending for it. This works well and the particles change color. I am using .png textures for the particles and the texture transparency works. But when I lower the alpha value in the vertex color nothing happens. I've tried every render state I can think of but nothing works. I'm guessing it has something to do with the D3D_BLEND state. What am I doing wrong?

Share this post


Link to post
Share on other sites
Advertisement
You must use the diffuse colour alpha as secondary input to the alpha operation.
Try this:

// TEXTURE BLENDING
// modulate texture alpha
device->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE );
// use diffuse colour as second alpha argument
device->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE );

// COLOUR BLENDING
// use alpha from source pixel
device->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA );
// use 1-alpha for destination pixel
device->SetRenderState( D3DRS_DSTBLEND, D3DBLEND_INVSRCALPHA );

// optional - enable alpha testing
device->SetRenderState( D3DRS_ALPHATESTENABLE, TRUE );
device->SetRenderState( D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL );



HTH,
Pat

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!