From BlenderWiki

Jump to: navigation, search

GSoC 2012 - Smoke Simulator Improvements

Original Proposal


My plan is to work on as many as possible of following improvements. Hopefully if all goes well I'll get them all done.

Fire Simulation

Implement real fire simulation for Blender smoke simulator. Basically this means adding new fuel and oxygen data types to the simulation and parameters to tweak the domain oxygen level, fuel ignition temperature etc.

Emitter will be able to emit smoke, fuel and/or heat. Smoke can be also emitted from flames depending on simulation oxygen levels. This also allows complex simulations where e.g. domain can be first filled with combustible gas and later ignited by a strong heat source.

Work is also required on investigating best ways to render the fire.

Possible papers to use for reference and ideas: http://graphics.ucsd.edu/~henrik/papers/fire/fire.pdf http://pages.cs.wisc.edu/~dekruijf/docs/capstone.pdf

Integrate simulation data with "Force Fields"

Simulation data itself already has easily accessible "force" for each simulation point. That data can be exposed to other Blender simulations through Blender's "force field" system.

This would allow particles (and other simulation types) to react to smoke simulator forces. For example fire sparkles could realistically flow along the air turbulence near fire.

Moving domain support

Currently smoke simulator is only good for simulations where the smoke emitter doesn't move much. Implementing a moving domain support would allow users to move the domain along with the smoke flow, so that only a small resolution domain has to be calculated. This would save both simulation time and required memory/disk space.

Basically all simulation data would be "shifted" depending on domain movements. If smoke shifts outside the domain it will disappear. This also requires a way to automatically fine tune simulation coordinates to match sub-simulation-cell movement.

This option would be ideal for "large" simulations of moving smoke emitters like airplanes, trains or vehicles. Domain only has to be large enough to cover smoke visible in renders and move along the emitter.

Smoke color support

Add color data to emitter settings and for smoke simulation. This allows true multicolor smoke simulations within a single domain.

New smoke emission types

Allow emission also from mesh volume and surface. Allow use of vertex groups (even animated) to define surface emission strength. For these new types add possibility to get fluid initial velocity from object itself.

Other Improvements

  • Only store required data types in point cache depending on simulation type and settings.
  • Add new simulation data types to voxel data texture for rendering.
  • Investigate best ways to provide simulation domain coordinates to the render engine. (Current "generated mesh coordinates" system is very problematic for users)
  • Also apply "high resolution" turbulence to other data types besides density to use for rendering.
  • Implement items from smoke ToDo list:
    • In case of subframes, interpolate simulation data from cached frames to allow basic motion blur. (#25631)
    • Also emit smoke from child particles if any. (#28307)
  • Other possible fixes or workflow enhancements that I come up with.

Current / Completed Progress


Week 1


  • Decided to first implement basic fire workflow and work on higher quality fire algorithm later this summer after doing other proposed items.
  • Coded initial implementation for fire simulation. For now fuel that is always burning and emits heat and smoke.
  • Added high res turbulence for flames.
  • Added 3D-view rendering of fire together with smoke:

  • Investigated possibility of changing simulation temperature units to match celsius or kelvin. (Possible but not sure if there is any actual benefit from this)

Week 2


  • Refactor and cleanup of smoke emission code.
  • Added ability to emit smoke directly from mesh surface and volume - without particles.
  • Surface emission rate can be controlled using vertex groups:

  • Additional initial velocity options to allow velocity customization also for mesh emission.

I also used lots of time trying to track down some bugs in smoke solver code (when using open borders whole domain velocity often starts to accelerate and it seems to be impossible to have a sphere with normal-directional initial velocity). So far no luck figuring a good solution to either of those.

Weeks 3 - 5


  • Added a new "Adaptive Domain" setting for smoke domains:
  • 1) Domain resolution and size adapts to only cover areas where smoke is, so that as small domain as possible has to be calculated at a time. You can also add additional simulation cells around the original domain area if needed.

Initial adaptive domain testing:

  • 2) When you move the domain object during simulation you only move the smoke "boundaries". Smoke itself remains still. This way you can limit simulated area to stay around moving emitters etc.

Moving adaptive domain to model steam of a moving locomotive:

  • Domain is now rotatable. This means you are no longer need to align your simulation on x, y or z axis but you can freely rotate the domain to match the target area.
  • Rotation and scaling also work during simulation with one limitation: Domain contents (smoke,fire) move with the domain.
  • Smoke now uses the scene gravity setting, so you can change gravity direction if required.
  • Added a new option for volume textures when "Generated" coordinates are used: "Map to Bounds". This maps texture coordinates to mesh bounding box allowing you to render adaptive domain content. It also solves issues with domains scaled in edit mode, so I'm considering to make this enabled by default.

Other notes:

  • Added "map to bounds" option also for "Object" coordinates.
  • Fix: smoke viewport shading and force fields now work properly for rotated/moved domains again.
  • Fix: first frame was initialized with maximum resolution even when using adaptive domain.
  • Some code cleanup.
  • Changing (most) smoke domain settings no longer clears whole domain but just the cache. This way it's easier to try out different settings while playback.
  • Copying domain object now also preserves adaptive settings. :p
  • Heat/velocity debug visualization (dev only) works again.
  • Some code cleanup.

Weeks 6 - 7


Added a new force field type: "Smoke Flow". It applies smoke simulation air flow velocity as a force to other Blender simulations that use force fields. To use it you need to add a "Smoke Flow" force field and select domain object for it.

To get an idea of what this is about, here is a video of it being used on particles:

Other notes:

  • Fix: Smoke obstacles were sometimes processed in wrong location when adaptive domain was enabled.
  • Fix: Emitting smoke from particles didn't work after last commit.
  • "Map to Bounds" is now enabled by default for new textures. One less thing to worry about when rendering adaptive domain. :p

Weeks 8 - 9


  • Added colors to smoke simulations. You can select smoke color for flows and for smoke emitted from fire.
  • Added color support to smoke 3D-view preview.
  • Added color support to Blender Internal "Voxel Data" textures. To render smoke with colors also enable "Reflection Color" from texture settings.

Here is a nice video of colored smoke by "Linny" from blenderartists.org:

Other commit notes:

  • Added options to disable heat, fire and colors from simulations. I'm going to make this automatic during next week, but until then you can use these settings for additional speedup if you don't need certain parts of simulation.
  • Fix: It wasn't possible to select "Domain Object" for smoke force field from same object.
  • Fix: Force fields affected smoke incorrectly when using adaptive domain.
  • Fix: Smoke initial velocity sometimes got messed up for first frame.
  • Fix: Smoke initial velocity was applied incorrectly in some cases.
  • Some code cleanup and refactoring.

Week 10


  • I added a new system that sets active simulation fields dynamically based on domain content.
    • For example fire related data/simulation is only processed when there is a fire type brush affecting the domain. Color data is enabled only when multiple colors are needed.
    • This way most simulations require less disk space and are faster to calculate compared to previous branch versions.
  • Tweaked smoke 3D-view shader to match previous non-colored version.
  • Fixed memory leak with smoke colors.
  • Spent one more day trying to fix that high resolution artifact bug I discovered last week. It seems to be limited to certain non-cubic domain resolutions, but strangely only to y-axis. I still couldn't figure what causes it.
  • I started investigating ways to improve fire simulation quality. For now I'm investigating ways to add more turbulence to smoke/fire emitted from meshes. My current solution is to add a way to use animated noise (or texture) to control emission strength. This way different areas of the mesh emit smoke/fire at different rates causing additional turbulence typical for fire.

Weeks 11 - 12


  • Fixed a high resolution smoke artifact bug. Fix was committed to trunk in r49485.
  • Fixed a bug that caused domain vertical velocity accelerate over time.
  • Fixed inconsistencies in domain boundary conditions. Even when domain type was set to "Open" other sides partly blocked smoke.
  • Finished last week's texture controlled emission code. Now it's possible to use textures to control emission strength of mesh type smoke flows.
  • General tweaking and improvements to fire simulation code.
  • Updated "Quick Smoke" operator with new fire material.
  • Couple of other smaller fixes.
  • Code cleanup.

I also prepared three fire simulation .blend files for testing. You can download them and watch rendered video here:

http://www.miikahweb.com/en/blog/2012/08/10/blender-fire-testing---blend-files