利用者:Luisbg/Fire And Smoke SOC Proposal

提供: wiki
移動先: 案内検索

Proposal For a Fire/Smoke Simulation Implementation in Blender

1.0 Introduction:

A fire and smoke simulation example

Realistic smoke and flame effects are among the most sought after special effects within the CG industry. Their “live-action” implementation requires expensive and difficult to control pyrotechnics which makes CG an attractive alternative.

Due to their fluid based nature, they are also one of the most challenging problems in the field. Fortunately, 50 years of development in the fields of fluid dynamics and computational physics have continued to raise the level of understanding of fluid based phenomena to the point where they are can be realistically and effectively simulated on today’s personal computers.

The implementation of such a simulation is well documented, and provides extensive room for further development and great expressive capability. To my knowledge this will be the first open source implementation of a flame/smoke simulation tool to be specifically targeted at realistic image synthesis. The aim is to bring the functionality of a fluid driven smoke and flame system to Blender, allowing the creation of realistic 3D static images or animations of fire and smoke, with their implicit characteristics, dealt with automatically by the solver.


2.0 Benefits to the Blender Community:

A smoke simulation

With the introduction of softbodies, fluid, and now cloth it is apparent that Blender is aiming to provide users with tools necessary to achieve the progression from artistic vision to final image in a coherent and realistic manner. Since Blender is not only a 3D modeler but also a compositor and animation application, integrated realistic simulations are a large part of the package, with fire/smoke simulation being one of the few remaining simulation tools that is missing from Blender’s suite.

Users creating both animations and static renders in Blender need tools to allow them to express what they see in their mind. Currently, attempting fire or smoke in Blender is tedious at best, relying on hard-to-control particle systems, especially when aiming for a realistic result. As this can be explained and simulated, with relative ease, by physical laws, it makes sense to integrate a fire/smoke solver with Blender, to allow a faster, smoother and, potentially, more harmonious workflow. This simulation tool will bring new creative possibilities, and a greater realism in a creative field traditionally plagued with difficulties.

This simulation will not only benefit Blender, but the entire open source software community since this will be the first fire/smoke simulation to be part of the public domain, providing a possible door to further development and new open source interest in and/or from physics, math and engineering fields.


3.0 Deliverables:

The inclusion of the fire/smoke simulation tool in the Blender Physics Panel (with Soft Body and Fluid Simulation). The tool's user interface will include an option button for the user to choose between Fire or Smoke. It will also include a "simple" and a "advanced" button, when "simple" is activated only the following parameters will be shown for the user to adjust: density, diffusion rate, viscosity, general force field vector value, and domain to control the animation. If "advanced" is chosen, the following options previously hidden will appear below the previous: ambient density, ambient temperature, and grid resolution. In the case of Fire being chosen 3 more fields will be visible: fuel source, fuel temperature and flash point of the fuel.

The user will enable the simulation for an object domain and the simulation will proceed to solve, step by step in a fixed time frame, being shown in a low resolution, high speed, version as particles in the 3d View.

The rendering of the system dealt with using grid aligned quads, described and reasoned in detail in the next section.

The tool's user interface.


4.0 Project Details:

Fluid in motion, and it's changes in density, temperature and velocity, from point to point, over discrete time intervals, due to the action of external and internal forces, have been deeply studied and are now well understood by the discipline of fluid dynamics, which mathematically, is described by a set of differential equations known as the Navier-Strokes equations.

There are a vast number of methods of implementing the Navier-Stokes equations, stemming from the fact that the equations cannot be analytically solved for anything other than very simple cases. It was not until computers with relatively modest capabilities became widely available that researchers began using numerical methods to solve the fluid flow equations, which involve three main steps; diffusion, advection, and mass. The methods of implementation for each step are described below.

4.1 Diffusion

Diffusion is the process of density stabilization, whereby, density from a cell will flow to that of a less dense cell.
The implementation of the diffusion solver requires calculating a solution for a sparse linear system of magnitude, X*Y*Z where X,Y,Z > 0 and equal to the number of grid units along each local axis.
Many iterative methods exist to solve such a system, some being more suitable than others. The integration of the diffusion solver will be done in such a way as to allow ‘plugging’ of new more advanced iterative methods, whilst providing a solver utilizing the gradient conjugate algorithm. This method is fast and stable, whilst being suitably accurate for most simulation requirements.

4.2 Advection

Advection is an auto-feedback mechanism apparent in fluids, which accounts for the non-linearities and chaotic nature of the fluid.
I propose the use of the elegant ‘semi-Lagrangian’ scheme to solve the advection step. This solution utilizes particles which are traced backwards, over a time step, through the velocity field. The velocity at the point, as determined by the backtrace, using linear interpolation, is transported to the starting position. The elegance in this solution is in the backward time integration, which stabilizes the system and eliminates ‘blooming’.

4.3 Mass conservation

Nearly all fluids encountered in reality are mass conserving, that is, we expect that the mass flowing in is equal to the mass flowing out. The fluid is rarely mass conserving after the previous steps, and requires correction.
As it happens, this step is most easily solved in the Fourier domain, and will be the basis of this part of the solver, whilst maintaining a pluggable, modular interface to allow the use of other methods of solving, such as the heightfield-gradient method.
Clearly, this will involve the implementation of functions to transform the vector field from the spatial domain to the Fourier domain.

The final part of the solver is to calculate the effects of the system variables on the nature of the flame/smoke and to update the forces on the system due to convection, expansion and cooling. This step makes further use of physical attributes and equations, utilizing the Universal Gas Law to calculate the effects of parameter changes in the system.

Initially the rendering of the system will be resolved using a system of semi-transparent, grid aligned, dynamically texture mapped quads. This method has a couple of intrinsic qualities. Firstly, it allows arbitrary materials/textures to be used for the flame/smoke, secondly it allows easy rendering of the shadow produced by the system.

Ideally, flame and smoke should be rendered volumetrically, using ray-marching and a global illumination scheme, however these features are beyond the scope of this project, and provide future possibilities for development and/or integration with other projects.

The most important part of the rendering algorithm will involve the implementation of a Blackbody radiation solver and exposure compensation to allow the physically correct colouring of flame.


A fire simulation example


5.0 Project Schedule:

  • Week 1: Study blender code;
  • Week 2: Familiarisation of numerical methods, design of project;
  • Weeks 3-8: Develop fluids;
  • Weeks 8-10: Develop render;
  • Weeks 10-14: Integration the subsystems together


The first week will, primarily, be spent familiarizing myself with the related Blender code, specifically focusing on the physics effects and their interfaces, and how they integrate with the rest of Blender. In the following week I will begin to develop a design and examine the required data constructs and interface requirements of the project. From the third week to the eighth I will, primarily, be developing, testing, and optimizing the fluid solver and related subsections. From the eighth week to the tenth I will work in the render code, implementing the ‘fake’ volume shading and integrating it with the other rendercode . The final the 4 weeks will be spent integrating the subsytems, debugging, and dealing with stabilization problems, to have a deliverable stable version in time for the end of the timeline.


6.0 Future Developments:

A smoke simulation with extended boundary conditions example.

The benefits of implementing a modular, pluggable system, will be instantly recognizable with the further development of this project beyond SoC.

There are a vast number of directions that the solver can take from the basics developed in this project, and the continuation of the project and implementation of a number of these features interests me greatly.

Interesting future developments include but are definitely not limited to :-

  1. Extending domain boundary conditions to allow realistic interaction with scene elements, including internal boundaries, moving obstacles, inflow, outflow and a vast number of other option.
  2. Adaptive grids (Kd-trees) for memory and speed considerations.
  3. The implementation of other subsystem solvers that are faster, more accurate, simulate different media, etc including the use of a minimal Guass-Siedel solver allowing realtime interaction with smoke and fire, for applications in the Game Engine.
  4. Implementing an effective method of counteracting numerical dissipation in the system, such as the Vortex Confinement method.
  5. Surface parameterization for conversion of point data sets to mesh, as well as baking the simulation to shape keys.
  6. Smoke morph targets allowing the power of keyframing the simulation at given steps to allow arbitrary shapes to be defined by smoke.

These are just a few among many other projects that extend into different fields including rendering, physics, and interaction.


7.0 Biography:

I am a 22 year old student in computer science at the Universidad Carlos III Madrid. I have experience using and also developing open source software. My main interests related to coding are in computer graphics, 3d virtual reality simulations, and human interfaces. On the user side I've been experimenting with computer graphics software as a vj/videoartist for 5 years, and have made videoinstallations for museums.

I started coding 6 years ago. Besides small personal projects, like a simple vj program, I have contributed to the Gimp and Gnome projects to various degrees.

I have been using Blender for 2 years and been for 2 months learning the Blender code and submitted a small patch. My experience is mostly in C/C++ (6 years), Python (4 years) and Java (2 years). Besides that I have lesser experience in Ada, Lisp, Pascal, and PHP.

The mathematical and physical nature of this project, make this an interesting and exciting undertaking. The idea that the result will be used by artists, to develop their personal projects, greatly appeals to me and motivates me further.


8.0 Referral Papers:

8.1 Principle:

  • Jos Stam, "Interacting with smoke and fire in real time", Communications of the ACM, Volume 43, Issue 7, 2000, 76-83.
  • Jos Stam, "A Simple Fluid Solver based on the FFT", Journal of Graphics Tools, Volume 6, Number 2, 2001, 43-52
  • Andrew Selle, Nick Rasmussen, Ronald Fedkiw, "A Vortex Particle Method for Smoke, Water and Explosions", SIGGRAPH 2005, ACM TOG 24, 910-914(2005).


8.2 Complementary:

  • Losasso, F., Gibou, F. and Fedkiw, R., "Simulating Water and Smoke with an Octree Data Structure", SIGGRAPH 2004, ACM TOG 23, 457-462 (2004).
  • Nguyen, D., Enright, D., and Fedkiw, R., "Simulation and Animation of Fire and Other Natural Phenomena in the Visual Effects Industry", Western States Section, Combustion Institute, Fall Meeting, UCLA, 2003.
  • Rasmussen, N., Nguyen, D., Geiger, W. and Fedkiw, R., "Smoke Simulation for Large Scale Phenomena", SIGGRAPH 2003, ACM TOG 22, 703-707 (2003).
  • Nguyen, D., Fedkiw, R. and Jensen, H., "Physically Based Modeling and Animation of Fire", SIGGRAPH 2002, ACM TOG 21, 721-728 (2002).
  • Fedkiw, R., Stam, J. and Jensen, H.W., "Visual Simulation of Smoke", SIGGRAPH 2001, 23-30 (2001).