Effects Tutorial: Creating Firelight (using startdelay)

Moderators: GSH, Commando, Red Devil, VSMIT

Post Reply
User avatar
Zero Angel
Attila
Posts: 1536
Joined: Mon Feb 21, 2011 12:54 am
Contact:

Effects Tutorial: Creating Firelight (using startdelay)

Post by Zero Angel »

Startdelay is a effects parameter introduced in 1.3 PB4. Do to its fairly 'new' status (in the entire lifetime of bz2) none of the classic mods or stock bz2 take advantage of it; but it gives modders and mapmakers the capability to do the following things that werent easy to do before:
  • Create a pulsating texture, light, or other effect.
  • Delay the removal of objects or effects from the world while still allowing them to fade out gracefully
  • Some simple multi-stage effects on a single ODF
In this tutorial we are going to use this parameter to create semi-realistic firelight that pulses and flickers. A counterpart to the animation a fire effect itself which does not light up its nearby environment.

To start we are going to be basing our ODF off of mbruine3 which is the mire ruin featured on the singleplayer mission 'Get Help' (isdf08.bzn), where you and Shabayev are stranded in a ruin and you have to hike through Scion territory. Unlike the normal mire ruin buildings this one contains a firepit which is nothing but an effect hardpoint with a fire animation attached to it. However this fire animation does not emit light. We're gonna make one that does. The current ODF looks similar to this.

Code: Select all

[GameObjectClass]
geometryName = "mbruine3.xsi"
classLabel = "i76building"
scrapCost = 8
scrapValue = 3
maxHealth = 5000
maxAmmo = 0
unitName = "Ruins"
heatSignature = 0.8
imageSignature = 8.0
radarSignature = 1.0
collisionRadius = 5.0
canDetect = 0
canInteract = 0
canSnipe = 0

effectHard1 = "hp_emit_1"
effectName1 = "mbruine3.render"

[render]
renderBase = "draw_multi"
renderCount = 3
renderName1 = "mbruine3.smokeemitter"
renderName2 = "mbruine3.flameemitter"
renderName3 = "mbruine3.sparkemitter"

[SmokeEmitter]
renderBase = "draw_twirl_trail"
emitDelay = 0.05
emitDelayVar = 0.03
emitVelocity = "0.0 3.0 0.0"
emitVariance = "2.0 2.0 2.0"
emitInherit = "0.2 0.2 0.2"
emitLife = 2.0
textureName = "smoke.tga"
textureBlend = "srcalpha invsrcalpha modulatealpha"
startColor = "0 0 0 128"
finishColor = "0 0 0 0"
startRadius = 0.5
finishRadius = 2.0
animateTime = 2.0
rotationRate = 2.0

[FlameEmitter]
renderBase = "draw_twirl_trail"
emitDelay = 0.03
emitDelayVar = 0.02
emitVelocity = "0.0 3.0 0.0"
emitVariance = "2.0 2.0 2.0"
emitInherit = "0.5 0.5 0.5"
emitLife = 1.0
textureName = "fire.tga"
textureBlend = "one one modulate"
startColor = "255 255 200 128"
finishColor = "255 0 0 0"
startRadius = 1
finishRadius = .5
animateTime = 1.0
rotationRate = 10.0

[SparkEmitter]
renderBase = "draw_twirl_trail"
emitDelay = 0.02
emitDelayVar = 0.01
emitVelocity = "0.0 2.0 0.0"
emitVariance = "5.0 5.0 5.0"
emitInherit = "1.0 1.0 1.0"
emitLife = 1.0
textureName = "spark.tga"
textureBlend = "one one modulate"
startColor = "255 255 0 255"
finishColor = "255 0 0 0"
startRadius = 0.1
finishRadius = 0.05
animateTime = 1.0
rotationRate = 20.0
==== Setting Up ====

To start, let's create a new text file in somewhere where bz2 looks for our assets, such as in /addon/ (you can also put it in /tveditor/custom/ if you're using the TVEditor for 1.3), we'll create simple text file called mbruintest.odf and open it in notepad (or your favorite text editor), paste the contents of the ^above ODF inside of the file.

Now let's do some prep work. Add or change the following settings in the ODF.

Code: Select all

maxHealth = 0 
lightingType = 1 

// Make the effectName point to our current ODF
effectHard1 = "hp_emit_1"
effectName1 = "mbruintest.render"

// Have the renders point to our current ODF as well
[render]
renderBase = "draw_multi"
renderCount = 7
renderName1 = "mbruintest.smokeemitter"
renderName2 = "mbruintest.flameemitter"
renderName3 = "mbruintest.sparkemitter"
renderName4 = "mbruintest.firepitfade"
renderName5 = "mbruintest.firepitgrow"
renderName6 = "mbruintest.fireflickerfade"
renderName7 = "mbruintest.fireflickergrow"
maxHealth = 0 makes it indestructable. lightingType=1 fixes to 'overbrighting' that the more recent 1.3s tends to apply to all objects, and will make lighting effects be more visible on the building. RenderName4...7 do not exist yet. It's fine, we will eventually create them in the tutorial

==== Adding our first effect ====

Now, we are going to add an effect to the ODF to demonstrate the StartDelay parameter. Now let's add the firepitfade effect. This is going to be ugly because it's going to cause a sudden transition from dark to light, but just to demonstrate, do it. Add to the bottom of the file.

Code: Select all

[firepitfade]
simulateBase = "sim_null"
lifeTime = 0
renderBase = "draw_emit"
emitName = "mbruintest.firelightfade"
emitDelay = 4.4
emitVelocity = "0 0 0"
emitVariance = "0 0 0"

[firelightfade]
simulateBase = "sim_null"
lifeTime = 4.4
renderBase = "draw_light"
startColor = "500 255 0 455"
finishColor = "500 255 0 155"
startRadius = 40.0
finishRadius = 40.0
animateTime = 1.7
attenuateLinear = 1.0
This will create an effect where light appears and fades out for 1.5 seconds, then starts again 4.4 seconds. save and test.

It's ugly. Sure you could set the animateTime to 4.4 but it's still going to cause an abrupt transition from dark to light at the end of the effect's lifespan.

==== Making it pulse ====

Now we are going to fix that by adding an effect which stays in the background at low intensity and ramps up the brightness to create a 'pulse' effect.

at the bottom of the file add the following

Code: Select all

[firepitgrow]
simulateBase = "sim_null"
lifeTime = 0
renderBase = "draw_emit"
emitName = "mbruintest.firelightgrow"
emitDelay = 4.4
emitVelocity = "0 0 0"
emitVariance = "0 0 0"

[firelightgrow]
simulateBase = "sim_null"
lifeTime = 4.4
renderBase = "draw_light"
startColor = "500 255 0 155"
finishColor = "500 255 0 455"
startRadius = 40.0
finishRadius = 40.0
startDelay = 1.7
animateTime = 2.7
attenuateLinear = 1.0
Note the new parameter "StartDelay" on [firelightgrow]. This param will keep the effect in its 'start' phase for 1.5 seconds, delaying color and radius transitions from happening until that time has elapsed. The effect will then animate for 2.9 seconds for a total of 4.4 seconds. Save and test.

==== Adding some Finesse ====

Now we can see that things look MUCH better. The effect lacks some detail but we'll get to that by doing a set of similar pulsing effects, except this time we're going to play 'out of phase' with the first pulsing effects so that its more random.

Add this to the bottom of your file:

Code: Select all

[fireflickerfade]
simulateBase = "sim_null"
lifeTime = 0
renderBase = "draw_emit"
emitName = "mbruintest.firelight2fade"
emitDelay = 0.6
emitVelocity = "0 0 0"
emitVariance = "0 0 0"

[fireflickergrow]
simulateBase = "sim_null"
lifeTime = 0
renderBase = "draw_emit"
emitName = "mbruintest.firelight2grow"
emitDelay = 0.6
emitVelocity = "0 0 0"
emitVariance = "0 0 0"

[firelight2fade]
simulateBase = "sim_null"
lifeTime = 0.6
renderBase = "draw_light"
startColor = "500 255 0 255"
finishColor = "500 225 0 165"
startRadius = 40.0
finishRadius = 25.0
animateTime = 0.4
attenuateLinear = 1.0

[firelight2grow]
simulateBase = "sim_null"
lifeTime = 0.6
renderBase = "draw_light"
startColor = "500 255 0 165"
finishColor = "500 225 0 255"
startRadius = 25.0
finishRadius = 40.0
startDelay = 0.4
animateTime = 0.2
attenuateLinear = 1.0
Save and Test.

You should see the secondary effect adding a subtle flickering effect. Congratulations you now know how to use StartDelay to create interesting effects.
Last edited by Zero Angel on Fri Mar 01, 2013 4:57 pm, edited 2 times in total.
Regulators
Regulate any stealin' of this biometal pool, we're damn good, too
But you can't be any geek off the street
Gotta be handy with the chains if you know what I mean
Earn your keep
User avatar
Zero Angel
Attila
Posts: 1536
Joined: Mon Feb 21, 2011 12:54 am
Contact:

Re: Effects Tutorial: Creating Firelight (using startdelay)

Post by Zero Angel »

The finished ODF should look like this:

Code: Select all

[GameObjectClass]
geometryName = "mbruine3.xsi"
classLabel = "i76building"
scrapCost = 8
scrapValue = 3
maxHealth = 0
maxAmmo = 0
unitName = "Ruins"
heatSignature = 0.8
imageSignature = 8.0
radarSignature = 1.0
collisionRadius = 5.0
canDetect = 0
canInteract = 0
canSnipe = 0

lightingType = 1

effectHard1 = "hp_emit_1"
effectName1 = "mbruintest.render"

[render]
renderBase = "draw_multi"
renderCount = 7
renderName1 = "mbruintest.smokeemitter"
renderName2 = "mbruintest.flameemitter"
renderName3 = "mbruintest.sparkemitter"
renderName4 = "mbruintest.firepitfade"
renderName5 = "mbruintest.firepitgrow"
renderName6 = "mbruintest.fireflickerfade"
renderName7 = "mbruintest.fireflickergrow"

[SmokeEmitter]
renderBase = "draw_twirl_trail"
emitDelay = 0.05
emitDelayVar = 0.03
emitVelocity = "0.0 3.0 0.0"
emitVariance = "2.0 2.0 2.0"
emitInherit = "0.2 0.2 0.2"
emitLife = 2.0
textureName = "smoke.tga"
textureBlend = "srcalpha invsrcalpha modulatealpha"
startColor = "0 0 0 128"
finishColor = "0 0 0 0"
startRadius = 0.5
finishRadius = 2.0
animateTime = 2.0
rotationRate = 2.0

[FlameEmitter]
renderBase = "draw_twirl_trail"
emitDelay = 0.03
emitDelayVar = 0.02
emitVelocity = "0.0 3.0 0.0"
emitVariance = "2.0 2.0 2.0"
emitInherit = "0.5 0.5 0.5"
emitLife = 1.0
textureName = "fire.tga"
textureBlend = "one one modulate"
startColor = "255 255 200 128"
finishColor = "255 0 0 0"
startRadius = 1
finishRadius = .5
animateTime = 1.0
rotationRate = 10.0

[SparkEmitter]
renderBase = "draw_twirl_trail"
emitDelay = 0.02
emitDelayVar = 0.01
emitVelocity = "0.0 2.0 0.0"
emitVariance = "5.0 5.0 5.0"
emitInherit = "1.0 1.0 1.0"
emitLife = 1.0
textureName = "spark.tga"
textureBlend = "one one modulate"
startColor = "255 255 0 255"
finishColor = "255 0 0 0"
startRadius = 0.1
finishRadius = 0.05
animateTime = 1.0
rotationRate = 20.0

[firepitfade]
simulateBase = "sim_null"
lifeTime = 0
renderBase = "draw_emit"
emitName = "mbruintest.firelightfade"
emitDelay = 4.4
emitVelocity = "0 0 0"
emitVariance = "0 0 0"

[firelightfade]
simulateBase = "sim_null"
lifeTime = 4.4
renderBase = "draw_light"
startColor = "500 255 0 455"
finishColor = "500 255 0 155"
startRadius = 40.0
finishRadius = 40.0
animateTime = 1.7
attenuateLinear = 1.0

[firepitgrow]
simulateBase = "sim_null"
lifeTime = 0
renderBase = "draw_emit"
emitName = "mbruintest.firelightgrow"
emitDelay = 4.4
emitVelocity = "0 0 0"
emitVariance = "0 0 0"

[firelightgrow]
simulateBase = "sim_null"
lifeTime = 4.4
renderBase = "draw_light"
startColor = "500 255 0 155"
finishColor = "500 255 0 455"
startRadius = 40.0
finishRadius = 40.0
startDelay = 1.7
animateTime = 2.7
attenuateLinear = 1.0

[fireflickerfade]
simulateBase = "sim_null"
lifeTime = 0
renderBase = "draw_emit"
emitName = "mbruintest.firelight2fade"
emitDelay = 0.6
emitVelocity = "0 0 0"
emitVariance = "0 0 0"

[fireflickergrow]
simulateBase = "sim_null"
lifeTime = 0
renderBase = "draw_emit"
emitName = "mbruintest.firelight2grow"
emitDelay = 0.6
emitVelocity = "0 0 0"
emitVariance = "0 0 0"

[firelight2fade]
simulateBase = "sim_null"
lifeTime = 0.6
renderBase = "draw_light"
startColor = "500 255 0 255"
finishColor = "500 225 0 165"
startRadius = 40.0
finishRadius = 25.0
animateTime = 0.4

[firelight2grow]
simulateBase = "sim_null"
lifeTime = 0.6
renderBase = "draw_light"
startColor = "500 255 0 165"
finishColor = "500 225 0 255"
startRadius = 25.0
finishRadius = 40.0
startDelay = 0.4
animateTime = 0.2
If you want to compare it to the older one that it replaces, then launch isdf08.bzn in the editor and swap out mbruine3 for the one you created.
Regulators
Regulate any stealin' of this biometal pool, we're damn good, too
But you can't be any geek off the street
Gotta be handy with the chains if you know what I mean
Earn your keep
User avatar
Zero Angel
Attila
Posts: 1536
Joined: Mon Feb 21, 2011 12:54 am
Contact:

Re: Effects Tutorial: Creating Firelight (using startdelay)

Post by Zero Angel »

Updated the tutorial and ODF to fix some badly named effects which did not appear if copy/pasted.
Regulators
Regulate any stealin' of this biometal pool, we're damn good, too
But you can't be any geek off the street
Gotta be handy with the chains if you know what I mean
Earn your keep
Post Reply