Back to Main Page

This page is about the evolution of the helicopter effects mod and how it eventually became part of a trio of mods with a common goal... collect vehicles and apply a variety of effects to them.


Helicopter Effects / Random Dirty Cars / Bus Lights - collecting and sharing to ease performance

It will come as no surprise to know that this is another 2 out of 3 mods that were inspired by requests.

After taking on what turned out to be the Mt Everest of learning curves with the On-Foot camera mod, I continued my masochistic trend by taking on something else that was going to eat away my life. I had two options with this mod, the easy way, or the stupidly-complex way and I chose the latter... and paid the price with unreliability.

The premise seemed simple, spawn some particles in a circle around the helicopter, until you start asking yourself "How many particles?", "How often?", "How big?", "What colour?", "How opaque?", "How many different surface types" etc... you get the point. It's never as simple as just spawn some particles, unless you don't really care about the end result... and I did.

So taking inspiration from OFCC, I opted for a probe system that circled the helicopter at a distance based on the size of the rotor. Here was a problem straight away, there was no Vehicle.Rotorsize property, so I thought "I know, I can use the width of the model" and that was kinda working okay, until someone said "Hey, can it work with the Osprey?". The Osprey isn't a helicopter, it's a plane. Not only that but it was a plane with twin rotors that meant that I couldn't use the model width for the rotor size. On top of the fact that I was discovering that the model width wasn't an accurate way to get the rotor size, things were complicated from the start. I used the model width during testing as it was easy and almost correct, so on I went.

To make things even more complex than they already were, I also decided I wanted to track the probes height above the ground, so I could alter the particle parameters based on distance. That meant I had to track the pitch and roll (or the plane) of the rotor, which actually came together fairly quickly. Here's an early video of the rotor tracking tests and preliminary particle spawning.


So things seemed to be going okay but a bigger problem was already apparent by this time. Gaps were appearing between the particles and the number of particles I needed to fill the gaps, was impractical. Alpha-blended particles will eat performance like ravenous cannibals eating deep-fried people. This sadly became the achilles heel of the mod, because I never did manage to get this working in a way that was as I wanted it.

But anyway... I decided that the gaps problem was something that I would tackle as the mod progressed. I had the rotors being tracked, I had the particles being spawned, now I need the materials to be checked. I had no real idea where to even start like this. At one point I planned on taking samples from across the whole map to try and build a library of known material types but that was in truth a madness idea. So I aked for help on GTAForums and my request was answered by Camxxcore, who managed to provide a fantastic piece of code that made the whole process much simpler than I had ever thought.

So I could now detect what type of ground you are over and to pair with that I built a set of material structs that held various parameters that should be applied to particles, colour, opacity, how much they were affected by rotor size etc... so I now had this.


That material checking code basically unlocked the whole mod, without it, it probably would have stopped before it ever really got going. There wasn't any alternative solution around and it took over 12 months before an alternate solution ever appeared. Now I had one final part of the surface code to deal with and that was water.

The biggest problem with water, was finding a suitable particle effect that could be used as a non-looped particle. To explain that a bit more, there are two types of particle, looped and non-looped. Looped particles offer more control because you can alter them after they have been created, however, the Rockstar Editor can't handle them, because you can't run scripts in the editor. With looped particles, you have to spawn them, manage them and then delete them because there is a finite number that can be used. Because the editor can't manage them, they simply stopped working after a short while. So it had to be non-looped as they simply do their thing and then the game deletes them automatically. This was another aspect of the mod that always felt like a compromise, because the effect wasn't ideal.

But it meant that I had got to the stage where the transition between ground and water worked great, so that was a winner. To further solve the rotor size problem, for vanilla vehicles at least, I exported every model, measured their rotor size in ZModeler 3 and stored those values in the mod. For addon models, I had to rely on the model size check, not ideal but there was no other way of determining the size.

The final piece of the effects puzzle was the spindown timer. Helicopter rotors don't just stop spinning when you get out of the helicopter, which meant the dust couldn't just suddenly stop appearing. So I added a spindown timer that kept the effects active for a fixed period after the engine was shut off... which made for cool shots like this.

Up to now, the mod had been written to work exclusively with the player but I thought "How cool would it be if you got into a desert battle with the cops and the police helicopter could kick up the dust?". I was about to discover that there were consequences to this that weren't cool in the slightest.

To apply affects to NPC vehicles, you have to collect NPC vehicles, lots of NPC vehicles. Then when you've collected them, you have to go through them one-by-one, to see if you have found anything that you can use. This takes time... lots of time and the penalty was a huge hit on the FPS levels of the game. I had to solve this, it was hitting people's performance at unacceptable levels, so I had to get creative. Thus the PCS was born, that stands for Petal Collection System


Managing performance loads isn't about doing something less often. It's no good running collections every 500ms or more, because all that does is create performance spikes and they're never a good thing. So what this system does, is to collect as frequently as it needs to do but balances the processing over a number of frames. That way you avoid massive spikes. So when the performance does drop, it drops more gradually, even though you might have just hit a very congested area. It took my helicopter effects from up to a 15fps drop, to an almost zero fps drop... even when I combined three mods into this single mod.

The way it worked was by splitting the overall collection area into 6 zones. Each collection period would occur in that specific zone. Once a collection had occured, it moved to the next zone in the pattern and then processed the colection of vehicles over a fixed number of frames. It allowed you to collect a much wider area, with the impact of a smaller collection radius. The six zones were laid out in a pattern, very much like the petals round a flower, hence the name.

So that really opened the door for NPC effects to be possible. So now, any NPC helicopter within the detection range had the ability to spawn dust effects.

There was still one major problem though... the Rockstar Editor. Even though it worked better with non-looped particles, it didn't like them and it made a mess of displaying them as they should be displayed. The solution came from another 5Mods user, Akila Reigns. He discovered a process that would display the effects closer to how they should look but it required a bit of timeline manipulation to get them to work. This was what I eventually called the "Pause and Jump trick" and it works like this...


It wasn't ideal but it was the best way to get decent screenshots. Because of how this worked, videos were still impossible to create... in the Rockstar Editor anyway.

Continued on next page...