Jump to content
  • Advertisement
Sign in to follow this  
  • entries
  • comments
  • views

Implementing the particle fountain effect

Sign in to follow this  


So, over the past week i have been busy implementing the first of many different particle effects for the game.

A video of the particle effect can be found here on my YouTube channel.

The whole of the game hinges around pretty (and rather deadly) particle effects, so this is an important part of the design. The first of these effects is a particle "fountain" much like a roman candle firework. The effect is implemented as a combination of a pixel and geometry shader, with instancing used to display many thousands of identical quads each containing a simple texture:


This texture is used to build up the effect, with each particle having a pseudo-random velocity. Over time each particle is pulled back to earth via a gravity effect, which causes the outwards momentum to drop by 75% and the upwards momentum to be replaced slowly by downwards momentum as shown in the code below.[code=nocode:0]void ParticleSystem::Update(){ for (int i = 0; i < activeParticles; i++) { particles.pos.y += particles.yvelocity; particles.pos.x += particles.xvelocity; particles.pos.z += particles.zvelocity; particles.yvelocity -= particles.falloff; if (particles.zvelocity > particles.initialzvelocity / 6.0f) particles.zvelocity -= particles.falloff; if (particles.xvelocity > particles.initialxvelocity / 6.0f) particles.xvelocity -= particles.falloff; }}
In the game proper, each of these particles will be destructive to any crates they come into contact with so it is unlikely that i will be outputting so many particles during gameplay or this may make the game far too hard.

At present the system does not free particles which have been allocated, as this is for testing only - once i have finished this portion of the game the textures which are allocated will be freed back into a pool (with a maximum of 10,000 at a time) to be displayed when needed.

The particle effect seems to run quite well at over 100 frames per second, so long as fraps doesnt get loaded as fraps does not seem to like my laptop one bit.

Now that we have a basic firework particle effect, i will add the crate movement next and conveyor belts, which are also just as fundamental to the basic gameplay as the particle effect!

Stay tuned for further updates coming soon!

Sign in to follow this  


Recommended Comments

If your particles behave deterministically, you don't need to process them on the CPU after they've been generated. You can push their processing out to the GPU and send the shader all of the values it needs to know about to calculate the particle position. So, all you'd need to do is send the initial particle vertex info to the GPU and then just call draw on the instanced particles :)

Share this comment

Link to comment

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
  • 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!