real-time visual simulation of smoke
DESCRIPTION
Project presentation for my MS Exam on April 09, 2010.TRANSCRIPT
![Page 1: Real-Time Visual Simulation of Smoke](https://reader033.vdocument.in/reader033/viewer/2022061215/549ec4c7b3795989198b45b1/html5/thumbnails/1.jpg)
Real Time Visual Simulation of Smoke on the GPU
By Muhammad S. KarimMSCS Student
Department of Computer ScienceThe University of New Mexico
![Page 2: Real-Time Visual Simulation of Smoke](https://reader033.vdocument.in/reader033/viewer/2022061215/549ec4c7b3795989198b45b1/html5/thumbnails/2.jpg)
Introduction & MotivationHORVATH, C., AND GEIGER, W. 2009. Directable, high-resolution
simulation of fire on the GPU. ACM Trans. Graph. 28, 3, 1-8.Used in creating visual effects in “Harry Potter and the Half Blood
Prince”.Uses a incompressible, inviscid Navier-stokes equations for fluid flow.Pursuing as part of an Individual Study project with Dr. Joe Kniss.
![Page 3: Real-Time Visual Simulation of Smoke](https://reader033.vdocument.in/reader033/viewer/2022061215/549ec4c7b3795989198b45b1/html5/thumbnails/3.jpg)
The Project and GoalStarting with an implantation of the following:FEDKIW, R., STAM, J., AND JANSEN H. W. 2001. Visual
Simulation of Smoke. In proc. of ACM SIGGRAPH 2001.Based on: Stam, J. 1999. Stable Fluids. In SIGGRAPH 99.Goal is to pursue the real-time implementation using GPU
specific vertex & fragment processing features.
Images from [FEDKIEW 2001]
![Page 4: Real-Time Visual Simulation of Smoke](https://reader033.vdocument.in/reader033/viewer/2022061215/549ec4c7b3795989198b45b1/html5/thumbnails/4.jpg)
Equations of Fluid FlowUsing incompressible and inviscid (leaving out the viscausity
term) form of Navier-Stokes equations for fluid flow:
u=velocity, p=pressure, f=force
Smoke properties (scalar fields): a. Density (ρ), b. Temperature (T)
Simulation Algorithm, inside a 3D grid:Step 1: Add Forces (Buoyancy, Vorticity)Step 2: Advect Velocity FieldStep 3: Solve for intermediate pressure term. Step 4: Project velocity field to make the field divergence free.Step 5: Apply boundary conditions to Velocity & Pressure fields.Step 6: Advect, Dissipate scalar fields (Density & Temperature)
u = Velocityp = Pressuref = Forcet = Time
Mass Conservation
Momentum Conservation
![Page 5: Real-Time Visual Simulation of Smoke](https://reader033.vdocument.in/reader033/viewer/2022061215/549ec4c7b3795989198b45b1/html5/thumbnails/5.jpg)
Simulation Algorithm Steps1.a Add Buoyant force to the velocity field:
+ =
Shader
u(t) F(buoy)
u’(t)
ρ(t) T(t)
*Tamb
![Page 6: Real-Time Visual Simulation of Smoke](https://reader033.vdocument.in/reader033/viewer/2022061215/549ec4c7b3795989198b45b1/html5/thumbnails/6.jpg)
Simulation Algorithm Steps1.b Add back Vorticity Confined Force to the velocity field:
+ =
u(t) Fvort u’(t)
Curl(u)
Shader
![Page 7: Real-Time Visual Simulation of Smoke](https://reader033.vdocument.in/reader033/viewer/2022061215/549ec4c7b3795989198b45b1/html5/thumbnails/7.jpg)
Simulation Algorithm Steps2. Advect Velocity field: (Semi-Lagrangian Advection)Move back along the vector back a timestep.Pick a vector by Tri-linear interpolating the 6 neighboring cells
from the 3D texture. Set this computed value to the current cell.]Benefits: ‘Stable’ field, avoid “blow-ups”, GPU friendly.
u(t) u’(t)
Shader
![Page 8: Real-Time Visual Simulation of Smoke](https://reader033.vdocument.in/reader033/viewer/2022061215/549ec4c7b3795989198b45b1/html5/thumbnails/8.jpg)
Simulation Algorithm Steps3. Compute field Pressure (for the next projection
step): u(t)
Shader
Div(u)
ShaderIterative
Jacobi Solver
p(t) after N Jacobi Iterations(I use 30-40)
Solve for p
![Page 9: Real-Time Visual Simulation of Smoke](https://reader033.vdocument.in/reader033/viewer/2022061215/549ec4c7b3795989198b45b1/html5/thumbnails/9.jpg)
Simulation Algorithm Steps4. Project Velocity field:Using Helmholtz-Hodge decomposition. (To ensure 0
divergence). Any vector field u* can be uniquely decomposed as the
following equation where u has 0 divergence:
u(t)u (t+1)
= -
Grad ( p(t) )
![Page 10: Real-Time Visual Simulation of Smoke](https://reader033.vdocument.in/reader033/viewer/2022061215/549ec4c7b3795989198b45b1/html5/thumbnails/10.jpg)
Simulation Algorithm Steps5. Apply boundary conditions:Based on ‘fixed-grid’, fluid confined to the grid.a. Velocity goes to zero on the boundary (no-slip condition).b. Pressure derivative goes to zero on the boundary.
(Neumann pressure condition).
Draw 4 lines along the boundary on each slice of the 3D texture
Draw a quad on the front (z=0) and another on the back (z=slices-1) of the 3D texture
GPU Implementation
![Page 11: Real-Time Visual Simulation of Smoke](https://reader033.vdocument.in/reader033/viewer/2022061215/549ec4c7b3795989198b45b1/html5/thumbnails/11.jpg)
Simulation Algorithm Steps6. Advect the scalar fields (Density & Temperature)Similar to velocity field advection.Dissipate the scalar fields based on time.
Shader
Shader
u(t)
ρ(t)
T(t)
![Page 12: Real-Time Visual Simulation of Smoke](https://reader033.vdocument.in/reader033/viewer/2022061215/549ec4c7b3795989198b45b1/html5/thumbnails/12.jpg)
Volume Renderinga. Slice the grid region from the viewer’s point-of-view.b. Render each slice from front-to-back order.c. Use the “under” operator to composite (blend) the slices to make
the final images of the smoke region. I used the polygon slicing algorithm implemented in a vertex
shader exactly described in: Ref “Real-time Volume Graphics” – Engel et. al. Ch-3.5.
Demonstration from my programshowing 2 slices
![Page 13: Real-Time Visual Simulation of Smoke](https://reader033.vdocument.in/reader033/viewer/2022061215/549ec4c7b3795989198b45b1/html5/thumbnails/13.jpg)
Volume Rendering (more…) Implemented volumetric shadows using the Half-Angle
Slicing technique by Kniss et al. 2003. Ref: Kniss, J., S. Premo e, C. Hansen, P. Shirley, and A. McPherson. 2003.
"A Model for Volume Lighting and Modeling." IEEE Transactions on Visualization and Computer Graphics 9(2), pp. 150–162.
Using a 2D light buffer to accumulate opacity at each slice, the use as a shadow map
![Page 14: Real-Time Visual Simulation of Smoke](https://reader033.vdocument.in/reader033/viewer/2022061215/549ec4c7b3795989198b45b1/html5/thumbnails/14.jpg)
Some ResultsSelf-shadowing the smoke volume produces more realism.Smoke volume transparency is computed based on the
smoke density values computed in the grid.
No self-showing inside the volume
With self-showing inside the volume
![Page 15: Real-Time Visual Simulation of Smoke](https://reader033.vdocument.in/reader033/viewer/2022061215/549ec4c7b3795989198b45b1/html5/thumbnails/15.jpg)
Closing Remarks and Demo I used 64 x 64 x 64 grids in the Demo, higher resolution
provides finer details. I also used a fixed grid, will possibly explore techniques to
move the fluid out of the box.Practical and possible to use in real-time applications with
mid-high end GPUs.