Real-Time Volumetric Smoke using D3D10. Sarah Tariq and Ignacio Llamas NVIDIA Developer Technology

Similar documents
CS GPU and GPGPU Programming Lecture 2: Introduction; GPU Architecture 1. Markus Hadwiger, KAUST

Applications of Explicit Early-Z Culling

Applications of Explicit Early-Z Z Culling. Jason Mitchell ATI Research

Abstract. Introduction. Kevin Todisco

Adarsh Krishnamurthy (cs184-bb) Bela Stepanova (cs184-bs)

CUDA. Fluid simulation Lattice Boltzmann Models Cellular Automata

Real-Time Hair Simulation and Rendering on the GPU. Louis Bavoil

Chapter 10 Computation Culling with Explicit Early-Z and Dynamic Flow Control

Pipeline Operations. CS 4620 Lecture Steve Marschner. Cornell CS4620 Spring 2018 Lecture 11

Real-Time Universal Capture Facial Animation with GPU Skin Rendering

Navier-Stokes & Flow Simulation

Realtime Water Simulation on GPU. Nuttapong Chentanez NVIDIA Research

DirectX10 Effects. Sarah Tariq

Programming Graphics Hardware

Pipeline Operations. CS 4620 Lecture 14

Real-Time Rendering (Echtzeitgraphik) Michael Wimmer

Cloth Simulation on the GPU. Cyril Zeller NVIDIA Corporation

TSBK03 Screen-Space Ambient Occlusion

About Phoenix FD PLUGIN FOR 3DS MAX AND MAYA. SIMULATING AND RENDERING BOTH LIQUIDS AND FIRE/SMOKE. USED IN MOVIES, GAMES AND COMMERCIALS.

GUERRILLA DEVELOP CONFERENCE JULY 07 BRIGHTON

Fluids in Games. Jim Van Verth Insomniac Games

CS4620/5620: Lecture 14 Pipeline

First Steps in Hardware Two-Level Volume Rendering

CGT 581 G Fluids. Overview. Some terms. Some terms

Direct Rendering of Trimmed NURBS Surfaces

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

CSE 167: Introduction to Computer Graphics Lecture #5: Rasterization. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2015

What is a Rigid Body?

Evolution of GPUs Chris Seitz

Volume Illumination. Visualisation Lecture 11. Taku Komura. Institute for Perception, Action & Behaviour School of Informatics

Robust Stencil Shadow Volumes. CEDEC 2001 Tokyo, Japan

Clipping. CSC 7443: Scientific Information Visualization

Navier-Stokes & Flow Simulation

Real - Time Rendering. Graphics pipeline. Michal Červeňanský Juraj Starinský

2.11 Particle Systems

Deferred Rendering Due: Wednesday November 15 at 10pm

Dynamic Ambient Occlusion and Indirect Lighting. Michael Bunnell NVIDIA Corporation

The Traditional Graphics Pipeline

INFOMAGR Advanced Graphics. Jacco Bikker - February April Welcome!

DirectX10 Effects and Performance. Bryan Dudash

Last Time. Why are Shadows Important? Today. Graphics Pipeline. Clipping. Rasterization. Why are Shadows Important?

L10 Layered Depth Normal Images. Introduction Related Work Structured Point Representation Boolean Operations Conclusion

TDA362/DIT223 Computer Graphics EXAM (Same exam for both CTH- and GU students)

CSE 167: Introduction to Computer Graphics Lecture #18: More Effects. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2016

Navier-Stokes & Flow Simulation

Graphics Processing Unit Architecture (GPU Arch)

Computer Graphics Ray Casting. Matthias Teschner

Last Time. Reading for Today: Graphics Pipeline. Clipping. Rasterization

Overview of Traditional Surface Tracking Methods

Computer Graphics Shadow Algorithms

For Intuition about Scene Lighting. Today. Limitations of Planar Shadows. Cast Shadows on Planar Surfaces. Shadow/View Duality.

Visualization. Images are used to aid in understanding of data. Height Fields and Contours Scalar Fields Volume Rendering Vector Fields [chapter 26]

Real-Time Shadows. Last Time? Textures can Alias. Schedule. Questions? Quiz 1: Tuesday October 26 th, in class (1 week from today!

COMP 4801 Final Year Project. Ray Tracing for Computer Graphics. Final Project Report FYP Runjing Liu. Advised by. Dr. L.Y.

Rendering. Converting a 3D scene to a 2D image. Camera. Light. Rendering. View Plane

11/1/13. Visualization. Scientific Visualization. Types of Data. Height Field. Contour Curves. Meshes

Visualization. CSCI 420 Computer Graphics Lecture 26

Sign up for crits! Announcments

The Application Stage. The Game Loop, Resource Management and Renderer Design

Enhancing Traditional Rasterization Graphics with Ray Tracing. March 2015

CS451Real-time Rendering Pipeline

Scanline Rendering 2 1/42

Adaptive Point Cloud Rendering

The Traditional Graphics Pipeline

The Rasterization Pipeline

Shape of Things to Come: Next-Gen Physics Deep Dive

Real-Time Simulation and Rendering of 3D Fluids

C P S C 314 S H A D E R S, O P E N G L, & J S RENDERING PIPELINE. Mikhail Bessmeltsev

Graphics Pipeline 2D Geometric Transformations

Lecture notes: Object modeling

UberFlow: A GPU-Based Particle Engine

Cloth Simulation on GPU

Rasterization Overview

CPSC GLOBAL ILLUMINATION

GPU-based Distributed Behavior Models with CUDA

Real - Time Rendering. Pipeline optimization. Michal Červeňanský Juraj Starinský

Shadows. COMP 575/770 Spring 2013

Optimized Rendering Techniques Based on Local Cubemaps

Programmable Shaders for Deformation Rendering

Approximate Catmull-Clark Patches. Scott Schaefer Charles Loop

INF3320 Computer Graphics and Discrete Geometry

Enhancing Traditional Rasterization Graphics with Ray Tracing. October 2015

Real Time Rendering of Complex Height Maps Walking an infinite realistic landscape By: Jeffrey Riaboy Written 9/7/03

A Trip Down The (2011) Rasterization Pipeline

#Short presentation of the guys

Computer Graphics. Shadows

Real-Time Voxelization for Global Illumination

Tutorial on GPU Programming #2. Joong-Youn Lee Supercomputing Center, KISTI

6.837 Introduction to Computer Graphics Final Exam Tuesday, December 20, :05-12pm Two hand-written sheet of notes (4 pages) allowed 1 SSD [ /17]

RSX Best Practices. Mark Cerny, Cerny Games David Simpson, Naughty Dog Jon Olick, Naughty Dog

Many rendering scenarios, such as battle scenes or urban environments, require rendering of large numbers of autonomous characters.

CUDA/OpenGL Fluid Simulation. Nolan Goodnight

Hardware Displacement Mapping

Real-Time Shadows. Last Time? Today. Why are Shadows Important? Shadows as a Depth Cue. For Intuition about Scene Lighting

CS 354R: Computer Game Technology

CSE 167: Introduction to Computer Graphics Lecture #9: Visibility. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2018

CMSC427 Advanced shading getting global illumination by local methods. Credit: slides Prof. Zwicker

Discrete representations of geometric objects: Features, data structures and adequacy for dynamic simulation. Part I : Solid geometry

Hardware Accelerated Volume Visualization. Leonid I. Dimitrov & Milos Sramek GMI Austrian Academy of Sciences

Transcription:

Real-Time Volumetric Smoke using D3D10 Sarah Tariq and Ignacio Llamas NVIDIA Developer Technology

Smoke in NVIDIA s DirectX10 SDK Sample

Smoke in the game Hellgate London

Talk outline: Why 3D fluid simulation is important Overview of process Fluid simulation basics Dynamic arbitrary boundaries Rendering Tradeoffs and optimizations

Why is this cool Current approaches to rendering smoke in games have limitations Video textures Particle systems Generalizes to other fluids like water or fire

Why now? Jos Stam 03: Real time fluids for games Harris03, Sander04, FluidSim on the GPU Sheer number of operations needed can only be supported by modern high end GPUs New features in DirectX10 Render to 3D texture Geometry Shader Stream Out

Overview Scene Composite on top of scene Decide where to place the smoke Discretize space and simulate Render

Fluid Simulation A fluid (with constant density and temperature) is described by a velocity and pressure field Navier-Stokes equations mathematically defines the evolution of these fields over time; impose that the field conserves both mass and momentum To use these equations we discretize the space into a grid Define smoke density, velocity and pressure at the center of each grid cell At each time step, we use the equations to determine the new values of the fields Velocity Pressure Density

Fluid Simulation steps Initialize Each time step Advect Advect Add Density Add Velocity Project Density Density Velocity Density Velocity Velocity Velocity Pressure Iterate Pressure * We skip the diffusion step

Advect Density Velocity Time Step t Density Time Step t + 1

Fluid Simulation on the GPU Velocity, Density, Pressure Textures Simulate one substep for entire grid Render a grid sized, screen aligned, quad Calculations for a grid cell Pixel Shader Output values using Render to Texture

Advect on the GPU O O Velocity in x Velocity in y M M Density Texture at timestep t Velocity Texture at timestep t O Texture fetch Texture fetch O M rasterized PS_ADVECT calculate new density for this grid cell using the density and velocity textures from the previous time step rendered M Quad Pixel Shader Render Target Density for timestep t+1

Advect on the GPU in 3D O M O M N N M O N Quads Density Texture at timestep t rasterized GS is used to rasterize each quad to proper layer in output Render Target Texture fetch PS_ADVECT calculate new density for this grid cell using the density and velocity textures from the previous time step Pixel Shader Velocity Texture at timestep t Texture fetch rendered N O M Render Target Density for timestep t+1

Obstacles Smoke only compositing with the scene Smoke interacting with obstacles and compositing with the scene

Obstacles Implicit shapes Like spheres, cylinders Voxelize objects Static : Voxelize just once, offline Moving:Voxelize objects per frame Obstacle texture Fluid cell inside obstacle Fluid cell outside obstacle

Dealing with Obstacles How should the fluid react to obstacles? The fluid should not enter obstacles cells If the obstacles are moving they should impart the correct velocity on the fluid How the fluid reacts to the obstacles Boundary Conditions

Boundary Conditions for Density No density should be added to or advected into the interior of obstacles Density Obstacles

Boundary Conditions for Pressure Derivative of the pressure across the boundary should be zero (Neumann boundary conditions - specifying derivative ) v cell1 cell2 PressureCell1 PressureCell2 = 0 PressureCell1 = PressureCell2 u

Boundary Conditions for Velocity The velocity normal to the boundary of the obstacle should be equal for fluid and obstacle (Dirichlet boundary conditions specifying value) v u

Voxelizing an object Obstacle texture Obstacle Velocity texture

Use low res collision model for voxelization

Voxelizing a simple object?

Voxelizing a simple object Orthographic camera Near plane Stencil Buffer Decrement on back faces Increment on front faces Far plane

Voxelization Render model N times, each time with a different near plane 2DArray of N stencil buffers

Optimizations Skin the mesh once per frame, stream out the skinned mesh, and rendered n times using instancing Each instance uses a different projection matrix with the appropriate near plane Each instance is rasterized to a different slice in the output 3D obstacle texture using the geometry shader.

Voxelizing velocity Obstacle Velocity texture

Moving obstacles Velocity in x Velocity in y?

Moving obstacles Velocity in x Velocity in y Use GS to compute plane triangle intersection and output a quad. The quad is rendered with the interpolated velocities of the vertices (derived by subtracting current vertex positions from previous ones)

Rendering Render front faces of box Composite into scene Raycast into the 3D Density texture

Raycasting into 3D texture What we have What we don t have - Ray from eye to box Transform from world to texture space Transform from world - Ray in texture space - Ray box intersection to texture space Transform from world to grid space - Ray entry point in the texture - Distance the eye ray traverses through the box 3D Density Texture - Number of voxels the ray traverses = Number of samples to take

Raycasting setup Render back faces of the box To RayDataTexture Render front faces of the box To RayDataTexture Float4(0,0,0,depthInViewSpace) Float4( -posingrid, depthinviewspace) With subtractive (DST - SRC) blending RayDataTexture.a RayDataTexture.rgb

Raycasting: blending Render Fullscreen quad to frame buffer PositionInTexture = TransformToTexSpace (RayDataTexture.rgb) Density Texture = Trilinear sample from 3D texture MarchingVector = TransformToTexSpace (eye - RayDataTexture.rgb) NumberOfSamples = TransformToGridSpace (RayDataTexture.a) RayDataTexture FinalColor.rgba = 0 FinalColor.rgb += samplecolor.rgb * SampleColor.a *(1.0 FinalColor.a) FinalColor.a += SampleColor.a * (1.0 FinalColor.a)

Occluding the scene Smoke directly blended on top of the scene Smoke correctly compositing with the scene

Integrating scene depth

Integrating scene depth Before After using scene depth Back Faces float4(0,0,0,depthinviewspace) float4(0,0,0, min(scenedepth,depthinviewspace) ) Front Faces float4(-posingrid,depthinviewspace) if( scenedepth < depthinviewspace) float4(0,0,0,0) float4(-posingrid,depthinviewspace)

Artifacts Artifacts resulting from an integral number of samples Correctly using the depth by weighted sampling

Artifacts

Correctly integrating scene depth by weighting the last sample d samplewidth FinalColor.rgb += d/samplewidth * SampleColor.rgb * SampleColor.a * (1.0 FinalColor.a) FinalColor.a += d/samplewidth * SampleColor.a * (1.0 FinalColor.a)

Camera inside smoke volume Near plane of camera Smoke Volume inside scene

Camera inside smoke volume Near plane of camera Part of smoke volume clipped by near plane Smoke Volume inside scene

Camera inside smoke volume Render back faces of the box To RayDataTexture Render front faces of the box To RayDataTexture Float4(0,0,0,depthInViewSpace) Float4( -posingrid, depthinviewspace) With subtractive (DST - SRC) blending Front faces clipped by near plane; Depth at these pixels is incorrect No information about the pixel s position in grid RayDataTexture.a RayDataTexture.rgb

Camera inside smoke volume Mark pixels where back faces have been rendered but not front In the raycasting step, for these marked pixels we explicitly set the position in the grid, and also subtract ZNear from the depth

Space Requirements Total Space Exclusive Shared Simulation 32 bytes per cell 12 bytes per cell 1 x RGBA16 2 x R16 20 bytes per cell 2 x RGBA16 2 x R16 Voxelization Rendering 9 bytes per cell - 9 bytes per cell 1 x RGBA16 1 x R8 20 bytes per pixel - 20 bytes per pixel 1 x RGBA32 1 x R32

Space Requirements for demo Grid Size: 70 x 70 x 100 Screen Resolution : 1280 x 1024 Total Space Exclusive Shared Simulation 14.95 MB 5.6 MB 9.3 MB Voxelization 4.2 MB - 4.2 MB Rendering 25 MB - 25 MB

Optimizations Tradeoffs: Reduce grid size Reduce number of Jacobi iterations Early Z cull technique introduced by Sander et al, 2004 LOD approach for simulation Render final smoke to a fixed sized off-screen buffer

Conclusion Interactive 3D fluid simulation at reasonable grid resolutions is feasible for games We presented here a brief overview of the entire process More information NVIDIA DirectX10 SDK code sample Upcoming GPU Gems3 article

References and acknowledgements NVIDIA Developer Technology team, Keenan Crane, and the developers of Hellgate:London Real-Time Fluid Dynamics for Games. Jos Stam, Alias Wavefront. GDC 2003 Simulation of Cloud Dynamics on Graphics Hardware. Mark Harris, W. Baxter, T. Scheurmann, A. Lastra. Eurographics Workshop on Graphics Hardware. 2003 Fast Fluid Dynamics Simulation on the GPU. Mark Harris, NVIDIA. GPU Gems 2004 Explicit Early-Z Culling for Efficient Fluid Flow Simulation and Rendering, Pedro V. Sander, Natalya Tatarchuk, Jason L. Mitchell, ATI Research Technical Report, August 2004 Hardware Accelerated Voxelization. S. Fang and H. Cheng. Computers and Graphics, 2000