real-time visual simulation of smoke

15
Real Time Visual Simulation of Smoke on the GPU By Muhammad S. Karim MSCS Student Department of Computer Science The University of New Mexico

Upload: muhammad-karim

Post on 27-Dec-2014

1.739 views

Category:

Documents


7 download

DESCRIPTION

Project presentation for my MS Exam on April 09, 2010.

TRANSCRIPT

Page 1: Real-Time Visual Simulation of Smoke

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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.