Nick Gravelyn

So one thing I wanted in my game was a way to fill the space up with dust and particles. Just little things here and there to give a sense of motion when there aren't any larger objects around. Any ideas how to go about this My one idea was simply to use billboarded textures for various sized particles but I'm not sure I could create the number I wanted. So before I went ahead with this slightly more tedious approach (which also requires I create all the objects), I figured I'd see if anyone had any ideas.


Re: XNA Game Studio Express Space Dust And Particles

Joel Martinez

Whatever you do, just make sure that you pull our dust sprites/billboards/whatever from a pool of existing ones. that way, as you move along ... particles that move offscreen can simply be repositioned ahead of your craft. This will avoid adding additional GC pressure.

edit: and oh yeah ... I think creating each particle individually will give you the best effect visually.  but depending on your aesthetic target, perhaps you could get away with larger textures (with transparent backgrounds) of space junk, then layering them on top of each other to create a sense of parallax. 





Re: XNA Game Studio Express Space Dust And Particles

a.d.m

Yeah, I have a giant array of space dust I use in my project. 10,000 point sprites slowly drifting around. I would recommend trying to find a texture that will look good with additive blending because otherwise, you'll need to depth sort them all every frame, which can be kind of expensive when you have upwards of 1000 particles.




Re: XNA Game Studio Express Space Dust And Particles

Nick Gravelyn

I tried implementing a small system, but it's not very scalable. For instance, I start seeing performance drop around 1000-1500 point sprites. I'm using additive blending and not depth sorting, but I'm wondering where to start looking for the problem. I've uploaded the code to http://code.grave-media.com/SpaceDustRenderer.cs if you want to take a look and offer any suggestions. I tried to make it able to support multiple textures in a (hopefully) efficient way. I'm thinking that my usage of the foreach a lot might be hurting a little. Also I'm figuring perhaps my matrix math is killing me too, but I really don't know for sure.





Re: XNA Game Studio Express Space Dust And Particles

GroZZleR

Your Update() has to be to blame for the slowdown. You're counting all the objects in the list that need to be removed, then removing them (after iterating through them all again) and then generating new objects.

Inside your foreach (Vector3 v in list.Positions), you can just set new values to the particle that you've found to be out of the camera's view instead of removing it from a list and recreating it. No




Re: XNA Game Studio Express Space Dust And Particles

a.d.m

your code is running slowly because you are making 1000 draw calls every frame. those aren't point sprites you are rendering; they are billboarded quads. with point sprites, you can render 1000 of them with one draw call, passing an array of 1000 verts to your shader. and you don't even need to calculate a billboard matrix because its done on the graphics hardware. i'd reccomend taking a look at the particle system in Derek Nedelman's "Balls" project: http://www.gameprojects.com/project/ id=2a9221cf3d

That is what I based my code on (and how I learned about how to use point sprites).




Re: XNA Game Studio Express Space Dust And Particles

Nick Gravelyn

Ah. I thought point sprites was a different name for billboarded quads. I'll take a look at that.