• Advertisement
Sign in to follow this  

little particle system issue found?

This topic is 4259 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 found a small problem with my particle engine. Actually I’m not 100% sure it’s a problem, but tell me what you all think. I’m using a texture with an alpha channel, which results in a round texture visible (not square). As a test I’m coloring each sphere and emitting maybe 200 from the source in random directions. What I noticed at first was that where the particles overlapped each other I was seeing a square outline, not the round texture I should see. I’m pretty sure this was because at first I wasn’t depth sorting the particles and since I have alpha, they must be depth sorted and rendered back to front for the alpha to work correctly, right? However, at most angles I still see this artifact, but at one particular angle it seems ok. When I disable zwrite it seems a lot better, and I know I should probably have zwrite disabled for a particle emitter, but I still thought the sorting would have fixed it. Do you think I have a sorting problem, or is there something going on that I’m not accounting for? With zwrite disabled it looks fine, but I want to be certain.

Share this post


Link to post
Share on other sites
Advertisement
I'm not too sure about your problem, you didn't specify a whole lot.

2 things to watch out for:

1) When using a texture with an alpha channel, the color channels of the texture don't need to be corrected for alpha. I'll try to explain this with an example: For my particle systems, I use a texture that is completely white, and has a particle shape in it's alpha channel.

If you use a texture that has both an alpha channel AND color channels going from say white to black, you risk getting a darker aura around the particles. This all depends on the set-up, but it's a posibility.

2) You need to sort back-to-front(farthest first) in view space. This means the Z-buffer should clip nothing, so you might as well disable Z-testing (and writing unless you need it for something). If you've sorted in some other way, results may vary.

I'd recommend you try hooking up ID3DXSprite into your system and see how it performs (both speed-wise and in regards to sorting).

Hope this helps.

Share this post


Link to post
Share on other sites
Sorting all of the particles back-to-front is likely to be pretty expensive and mostly unnecessary.

The particle systems I've written have been fine with ZWriteEnable = False... is that not working for you?

Jack

Share this post


Link to post
Share on other sites
I've got a particle system that does the same thing you are describing and the only thing I had to do was set up some device settings:


device.RenderState.AlphaBlendEnable = true;
device.RenderState.SourceBlend = Blend.SourceAlpha;
device.RenderState.DestinationBlend = Blend.DestinationAlpha;



Try experimenting with the different .Blend values. The ones above yeild an awesome additive effect!

Share this post


Link to post
Share on other sites
It's working mostly fine with ZWriteEnable = False, except when I'm standing VERY close to the center of the particle emitter. But ignoring that for a second, I still thought it was best to sort it, although I was concerned about the performance hit. I thought you had to sort to guarantee you don't get wierd artifacts due to the alpha value. If everyone suggests using ZWriteEnable = False and not worrying about it, then that's good enough for me.

Share this post


Link to post
Share on other sites
Quote:
Original post by QuadMV
I thought you had to sort to guarantee you don't get wierd artifacts due to the alpha value.
Yup, thats correct - and is probably required in most cases for "normal" geometry.

Disabling Z-Writes is a hack that works for most particle systems where individual particle correctness isn't so important, rather the overall particle system effect is what you're after.

The cost of sorting any moderately complex particle system each time the camera/view moves could be pretty heavy - which is why the aforementioned hack is so popular [smile]

Cheers,
Jack

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement