1. Real Time Visual Simulation of Smoke on the GPU By Muhammad S. Karim MSCS Student Department of Computer Science The University of New Mexico
2. Introduction & Motivation HORVATH, 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, inviscidNavier-stokes equations for fluid flow. Pursuing as part of an Individual Study project with Dr. Joe Kniss.
3. The Project and Goal Starting 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]
12. Simulation Algorithm Steps 1.b Add back Vorticity Confined Force to the velocity field: Curl(u) Shader + = Fvort u’(t) u(t)
13. Simulation Algorithm Steps 2. 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. Shader u’(t) u(t)
14. Simulation Algorithm Steps 3. Compute field Pressure (for the next projection step): u(t) Solve for p Shader Shader Iterative Jacobi Solver Div(u) p(t) after N Jacobi Iterations (I use 30-40)
15. Simulation Algorithm Steps 4. 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: - = Grad ( p(t) ) u(t) u (t+1)
16. Simulation Algorithm Steps 5. 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 GPU Implementation Draw a quad on the front (z=0) and another on the back (z=slices-1) of the 3D texture
17. Simulation Algorithm Steps 6. Advectthe scalar fields (Density & Temperature) Similar to velocity field advection. Dissipate the scalar fields based on time. Shader ρ(t) Shader u(t) T(t)
18. Volume Rendering a. 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 program showing 2 slices
19. 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
20. Some Results Self-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
21. 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.