low-frequency particles

Started by
3 comments, last by phantomus 17 years, 3 months ago
I have a problem, not too bad but I would like some opinions anyway: For a realtime ray tracer, I want a simple particle effect. As it is rendered using a ray tracer, the frame rate is really low: Typically 10 on my dual core laptop, but perhaps lower on other systems. The particle effect is a simple fountain, so the particles move along a curve. Question is: How do I simulate the particles under these circumstances? I suppose it's virtually impossible to guarantee the exact same path at each framerate, but how do I get something that is at least more or less the same? I would for example like to guarantee the fountain height to be in a certain range, regardless of framerate. One of the ways I thought of is: Do multiple 'simulation steps' until the simulation frequency exceeds a minimal framerate. This is probably the simplest way. Any other thoughts?
Advertisement
Fix your timestep (Gaffer on Games)

It comes highly recommended (planning to use it in my game - not using it yet)


He recommends fixing your timestep (locking it to a certain times per second) then interpolating the values (giving a very slight delay: ~1 timestep)

-M

p.s. He addresses several approaches, including the one you suggest :)
Definately use the intermediate time steps. Its straight forward and should yield good results. Since these physics simulation calculations should be much quicker in comparison to rendering each frame, this should cause minimal decrease in framerate.

If you want to go with the fixed-timestep route, which is a good one, I'd set the simulation rate at 30-50 hz. when you've got your frame-time, just chose the last simulation and the next, then interpolate between the two. Linear is easiest and would give accurate enough results, but you could probably do even better by taking the previous 2 or 3 simulations into account, as some cost to performance.

throw table_exception("(? ???)? ? ???");

Use an analytical position for you particle i.e:

Constants:
G = Gravity vector, typically (0, -9.82, 0)

For each spawned particle, keep the following:
t0 = Birth time of particle
P0 = Position vector at birth
V0 = Initital velocity

Analytically getting the position of the particle at the given time t:
P(t) = P0 + V0 * dt + (G * dt * dt / 2) where dt = t - t0

Or more optimized:

P(t) = P0 + dt * (V0 + G * dt) where GH = G / 2 (Calculated when gravity changes, typically just once).

I typically use this in vertex shader code etc, that way you can let the gpu worry about the particles, all the CPU need to do is to spawn them etc.



Thanks a lot for the replies! These are some very good options.

This topic is closed to new replies.

Advertisement