Posted by Duncan Brinsmead, 6 November 2012 9:08 pm
This example scene shows how one can do a realistic simulation of a roman candle including smoke. The roman candle has balls that are shot out of a tube, and as the balls burn up they shoot out glowing embers and smoke.
First create a particle system for the main balls. One can start with "nParticle:create emitter" using the cloud preset. Make the emitter type a volume, the rate around 6, and along axis to around 15. (this speed assumes that units are roughly defining meters) AwayFromAxis and random direction can be used to keep all the particles from emitting straight up, but actually we probably want them mostly emitted up. The emitter can be scaled down to limit the region the particles are emitted from. On the particle system turn off "ignore solver gravity" (it defaults to on for the cloud preset). Set the lifespan mode ot constant and the lifespan to about 1.5. The particles should just start falling before they die. The drag can be zero or near zero as the balls are relatively dense.
To simulate the random propulsive force acting on the balls resulting from non-uniform burning we can apply a volume axis field and use the turbulence settings. Make awayFromCenter zero and turbulence 1.0 and make turbulence speed 1.0, scaling up the field to cover the region the particles emit into. Turbulence frequency can be set to about 5,5,5 to make it more noisy. The particles should now diverge a bit from straight up but not too much. This effect is different from simply launching the particles in different directions.
Set the particle radius to a good value, perhaps 0.05. The balls get smaller as they burn so we can set radius scale input to "normalized age" and edit the ramp to go smaller on the right. Opacity and Incandescence Input can also be set to "Normalized Age" and the ramps set to make the particle bright when burning then fading out before it dies. In this example I set the incandescence value high around 26 with a moderately saturated orangish hue (hsv = 22,0.8, 25.0). This roughly fakes the coloration that result from black body radiation of the hot particles. Because the color is not 100 saturated very high value levels become white, even though the hue is reddish orange. The color interpolates naturally to black going from white to yellow, orange then red.
We can then add glow. The glow is important because the particles are much brighter than the camera or display device can show. If it could then the glow would happen in our eyes and we would not need to add it. On the particle's shader "npCloudVolume" we can set the glowIntensity to something like 0.1. Then on the glow shader (shaderGlow1) set the quality to a high value (say, 100), as this is good for small point glow sources. Also turn off auto exposure as it will cause flickering. I found a glow spread of about 0.01 and a halo spread of 0.05 worked well with glow intensity around 1.3 and halo intensity of 2.0, but you will likely need to tweak these values. Note also that the glowThreshold can be raised such that one can have fully white particles that do not glow, while particles that are brighter than white will glow.
Now we can create the embers. Select the first particle system and do "nParticle:emit from object" and setup the particle system as for the balls, but with smaller particles and less intensity on the incandescence. A rate on the emitter of about 300 works OK with the emission speed at 0.4 and the particle lifespan set to about 1.3. These embers are smaller and have more drag to the end of their life, so make the drag something like 0.1 and and the mass about 0.5. One can adjust the mass scale on the particle system so that the particles become lighter with age and thus fall more slowly due to the drag. Under emission attributes on the particle shape make the inherit factor about 0.3. This allows the embers to get some upward motion from the main balls before falling down under gravity.
To simulate a wind, select the embers particle system and create a wind field. On the wind field select the wind predefined setting, then make the magnitude about 100, speed 0.2 and attenuation 0.0.
To create the smoke select the particle system for the balls and do "fluid: emit from object". Set the emitterType to Omni and the maxDistance to about 0.1 (or about the size of your particles). The rate will need to be high, about 1500, and motionStreak should be enabled. Also lower fluidDropoff to about 0.5. The fluid resolution should be high enough to capture the required detail, in my example I made size = 2,2,2 and baseResolution = 50. Set all boundaries to none so the fluid can more freely expand and set the autoResizeMargin to about 2. Make the transparency low but not zero. For more detailed smoke set highDetailSolve to allGrids and make velocity noise about 0.03.
To create an illusion of illumination of the smoke by the particles I used a dynamic temperature grid on the fluid, combined with a very high diffusion of 2.0 along with a dissipation of about 1.0. With such a fast diffusion one needs very high temperature emission. I used a heat/Voxel/sec of 50.0. Then the brightness of the cloud can be set using the incandescence ramp. The temperature diffuses out from the emitting particles a bit like light emitting, although there is some lag. Better might be to use several point lights with fast decay and no shadowing. A mel script could be used to position this pool of lights(10 might be enough) to match living particles and match the light color to the particle incandescence.
As well the temperature buoyancy and turbulence can add detail to the flow.
One could use the dynamic relationship editor one to apply the previously created airfield to the fluid to push it with the wind. However it is hard to independently control the magnitude of this for the fluid. As well it will tend to accelerate the fluid velocity over time.
Instead I applied a separate drag field to the fluid. The drag field works well with the fluid and we can use the inherit motion on the drag to create the wind. First we can animate the position of the drag field. In the attribute editor for the drag click in the translate X edit box and type "= time * 1.3". This trick creates and expression for that attribute. You can edit the expression( rightmouse over the edit box) and change the 1.3 to any desired speed for the wind. Make the attenuation zero so the drag affects everywhere equally and make InheritVelocity = 1.0, so the drag uses the animated position. The magnitude needs to be carefully set. Full drag occurs when the magnitude = framerate, for example 24.0. A value around 2 will nudge the fluid to move with the wind while allowing the fluid to flow with sub eddies. One can also add a very small amount of turbulence( on the fluid shape ) to make the flow more interesting.
Here is a render with the camera a bit closer
Refinements of this scene with smoke ground and self illumination can be found here.
Please only report comments that are spam or abusive.