Particle Reduction for slow machines
by Davis Ray Sickmon, Jr · 10/02/2002 (10:53 am) · 1 comments
The project I'm working on, Trajectory Zone, uses a TON of particles. In fact, enough that on my Dual P400 + Matrox 400 card it slows waaaaaaaaaay down because of the number of particles being calculated and rendered. On my serious machine, it works just fine.
After having integrated Melv's newest version of his FxFoliageReplicator which includes a nice new client side settable foliage reduction system, I realized it was dead simple to implement the same thing in the particle engine.
Pop open the source to Torque, and open up particleEngine.cc, and find ParticleEmitterData::onAdd(). Just after:
// Validate the parameters...
add the following:
F32 modParticleDensity= Con::getFloatVariable("$pref::particles::particleDensity", 1.0f);
ejectionPeriodMS = ejectionPeriodMS * modParticleDensity; // Adjust how often we produce particles
periodVarianceMS = periodVarianceMS * modParticleDensity; // Adjust the variance, so that we don't generate errors.
Compile, and run. You won't see anything different at first - $pref::particles::particleDensity isn't set, so it defaults to 1.0
$pref::particles::particleDensity needs to be set before something will change. So, exit the level, pop down the console, and type:
$pref::particles::particleDensity = 20;
Now go back into the level, and view whatever particle activity you should normally see (ie, shoot weapon, stare at the fire, what have you) You should see quite a bit of reduction in the number of particles being produced.
The higher the setting for $pref::particles::particleDensity, the less often it produces particles. Now he're a cool trick - you can also do just the opposite. If you want more than the normal particles produced, use: $pref::particles::particleDensity = .01;
That's it. Really. I only submitted it because it made a HUGE difference in performace on my slower machine, and also means that I can make things look even prettier than the default particle settings on my Dual Athlon machine :-)
Thank Melv for this really - I looked at his code, and suddenly realized how I could gracefully pull off this trick ;-)
The only downside - this doesn't change anything in-game, so you can't do dynamic changes to it based off of CPU usage. I'm implementing it as an item in the video setup area of Trajectory Zone, so clients who experience problems can exit the game, change thier settings, and go back in. Not a perfect solution, but a solution.
After having integrated Melv's newest version of his FxFoliageReplicator which includes a nice new client side settable foliage reduction system, I realized it was dead simple to implement the same thing in the particle engine.
Pop open the source to Torque, and open up particleEngine.cc, and find ParticleEmitterData::onAdd(). Just after:
// Validate the parameters...
add the following:
F32 modParticleDensity= Con::getFloatVariable("$pref::particles::particleDensity", 1.0f);
ejectionPeriodMS = ejectionPeriodMS * modParticleDensity; // Adjust how often we produce particles
periodVarianceMS = periodVarianceMS * modParticleDensity; // Adjust the variance, so that we don't generate errors.
Compile, and run. You won't see anything different at first - $pref::particles::particleDensity isn't set, so it defaults to 1.0
$pref::particles::particleDensity needs to be set before something will change. So, exit the level, pop down the console, and type:
$pref::particles::particleDensity = 20;
Now go back into the level, and view whatever particle activity you should normally see (ie, shoot weapon, stare at the fire, what have you) You should see quite a bit of reduction in the number of particles being produced.
The higher the setting for $pref::particles::particleDensity, the less often it produces particles. Now he're a cool trick - you can also do just the opposite. If you want more than the normal particles produced, use: $pref::particles::particleDensity = .01;
That's it. Really. I only submitted it because it made a HUGE difference in performace on my slower machine, and also means that I can make things look even prettier than the default particle settings on my Dual Athlon machine :-)
Thank Melv for this really - I looked at his code, and suddenly realized how I could gracefully pull off this trick ;-)
The only downside - this doesn't change anything in-game, so you can't do dynamic changes to it based off of CPU usage. I'm implementing it as an item in the video setup area of Trajectory Zone, so clients who experience problems can exit the game, change thier settings, and go back in. Not a perfect solution, but a solution.

Torque Owner Prairie Games
Prairie Games, Inc.
www.garagegames.com/index.php?sec=mg&mod=forums&page=result.thread&qt=7484