Jump to content
  • Advertisement
Sign in to follow this  
michael879

particle transparency

This topic is 5099 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

Hey Im making this particle system and Im pretty much done except for one problem. I dont know how to set it so that the background color of the particle picture isnt rendered. My particles are circles and I dont rly want black squares surrounding each one. I looked through my directX book and couldnt find anything, and Id look in the msdn reference except I rly have no clue what to search for.

Share this post


Link to post
Share on other sites
Advertisement
Given you are using a file format that supports transparency/alpha channels you can just set the appropriate render states so that the alpha blending can be enabled and then destination can be alpha blended with the source. Also note that you will need to render the solid objects first and then the transparent objects.

c++ example

pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
pDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
pDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);



C# example

Device.RenderState.SourceBlend = Blend.SourceAlpha;
Device.RenderState.DestinationBlend = Blend.InvSourceAlpha;
Device.RenderState.AlphaBlendEnable = true;



I hope this helps.
Take care.

Share this post


Link to post
Share on other sites
yea thanks I found an old post that suggested that but it still isnt working. I loaded the texture with the Ex function and specified the background color as the colorkey...

Share this post


Link to post
Share on other sites
Sounds like everything's working in your program, but you need to inspect the texture itself... When you say 'flashes of black', do you mean there's little pieces of black around your particles? If so, examine your particle texture's alpha channel carefully in your paint program... I'm suspecting you'll find parts of the black area of your texture are going to appear masked along with your main round particle image. Edit your texture and clean up its alpha channel, and see if that gets rid of the black anomalies.

Hope that helps!

Share this post


Link to post
Share on other sites
yes I have that problem but its subtle and not whats happening. Whats happening is most of the particles look like circles, with nothing around them, and then sometimes when Im looking at one I see the black corners appear for a second.

Share this post


Link to post
Share on other sites
I had it turned off but then I get all these weird effects where particles that are farther away appear in front so I turned it back on. If I turn it back off, how do I fix that? is sorting them the only way?

Share this post


Link to post
Share on other sites
But you've got alpha blending ON...surely the order that the particles are drawn won't make a difference?

Maybe a screenshot to clarify what the remaining problem(s) are...

Share this post


Link to post
Share on other sites
The order in which they are drawn will make a difference. To be totally correct yes you would need to sort the particles by depth, often however you can get away with approximations like just sorting the emitters by depth. For sorting you might want to look into radix sort, have a look here for example.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!