Cut, Copy & Paste

Published December 24, 2005
Advertisement
Yesterday I made several improvements to the flame particle system. It was an interesting problem. I wanted randomness, but not too much. Also I didn't want to do collision on them to avoid the runtime cost, so I wanted to flame particles to stay within their trigger box ( or nearly so ).

What I did was to start the flames at a random location within the box, but effectively converted to a cylinder. I chose a random location in [-1,-1,-1]..[1,1,1], then added 1.0 to y, then normalized the resulting vector. This makes the distribution round instead of square, and concentrates more particles near the origin than at the edges. Then I scaled the x & z by the trigger box width & depth, then just took the abs of the original y value * the box height, to get the final position.

Next I changed the per-particle code to add a random displacement to its velocity every frame, apply the velocity to the position, then look to see of the particle has left the box. If so, I mark it for death, and then stop updating its velocity and fade it out over 300 msecs. I also do a fade as the particles reach the top of the box, multiplying the two fade factors together and using this as the particle alpha.

In the pixel shader, I additionally fade based on the fog factor, so the flames look correct in the distance.



Once I had it working well, I put some more flames in the various levels, and it really helps the look & immersion factor, when I added a sound source and light flicker to the effect. Of course, this was a pain to track 3 separate objects - the trigger, sound, and light in the editor, so I decided to partly automate it.

I made the engine look for facets on the trigger box for sound info as well as for light parameters, and put some useful defaults in for the flame case ( like the light will flicker by default, etc. ). So, now all the designer must do is create the trigger and give it 4-5 facets to get the effect. I also added a volume facet to a sound source, which was inexplicably not handled before.

This made it easier, but was still overly complicated, so at the level designer's request, I put in Cut, Copy & Paste into the level editor. It doesn't work for static world triangles, but only for editor objects, like meshes, triggers, entities, sound, lights, etc.

Took a while to get it all sorted out, compiling and working, but now I'm glad I did it - it will be a huge time saver, and much more generally useful than making separate macro butters for 'torch', etc., which was my previous idea.

Here is a shot of the crypt level with several torches visible. Note how the torch at the middle top of the shot is almost faded out in the fog.

0 likes 4 comments

Comments

HopeDagger
Looks wonderful. Glad to see things going groovily again. Keep it up! :D
December 24, 2005 03:24 PM
SimmerD
Yep, you are right - fixed.

Good to know someone is paying attention! :)
December 26, 2005 09:07 AM
roel
I love the screenshots!
January 15, 2006 10:45 AM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement

Latest Entries

1.2 Almost ready...

1169 views

Sound Paths

1384 views

Stately Progress

1209 views

State Lines

1339 views

Pulsing

915 views

Return to The Ship!

1056 views

Cameras & Boxes

1176 views
Advertisement