Real-time volumetric effects - PowerPoint PPT Presentation

1 / 50
About This Presentation
Title:

Real-time volumetric effects

Description:

Title: Slide 1 Author: NVIDIA Last modified by: sd Created Date: 8/30/2006 7:59:43 PM Document presentation format: Company: NVIDIA Other titles – PowerPoint PPT presentation

Number of Views:66
Avg rating:3.0/5.0
Slides: 51
Provided by: NVI579
Category:

less

Transcript and Presenter's Notes

Title: Real-time volumetric effects


1
Real-time volumetric effects
  • Andrei Tatarinov

2
Talk outline
  • Introduction
  • Part I Generating fire with Perlin noise
  • Part II Generate smoke using 3D fluid
    simulation
  • Part III Rendering volumetrics

3
Why is this cool?
  • Volumetrics represent such common effects as fog,
    smoke, fire, explosions
  • Current approaches to rendering volumetrics in
    games have limitations
  • Video textures
  • Particle systems

4
What do we have now?
  • Most volumetric effects are represented as sets
    of video textures
  • Everything looks cool until effect intersects an
    obstacle

5
Why now?
  • Sheer number of operations needed can only be
    supported by modern high end GPUs
  • New features in DirectX10
  • Render to 3D texture
  • Integer maths
  • Geometry Shader
  • Stream Out

6
Part I - FireOutline
  • Perlin noise overview
  • Simplex noise overview
  • Ways to generate procedural textures
  • How to generate a flame using Perlin noise

7
Perlin Fire
Fire in NVIDIAs DirectX10 SDK Sample
8
Perlin noise
  • Given an input point P
  • Find its neighboring grid points Q
  • For each grid point
  • Pick pseudo-random gradient vector G
  • Compute linear function G (P - Q)
  • Interpolate between values in grid points

9
Random Number generation on GPU
  • Use a set of power and modulation operations,
    using some big prime number as a modulation base
  • Use a permutation texture

R PermTex.Sample ( P.yw PermTex.Sample ( P.xz
) )
10
Simplex Noise
  • The same as Perlin noise, but using a simplex
    grid instead of hypercube grid
  • For a space with N dimensions, simplex is the
    most compact shape that can be repeated to fill
    the entire space
  • Using simplex grid can significantly reduce a
    number of interpolations

11
Procedural Textures
  • Use a weighted sum of several noise frequencies
    to create a texture







12
Procedural Textures
  • Try noise in different expressions

noise
sin (x sum 1/f( noise ))
sum 1/f(noise)
sum 1/f( noise )
13
Volumetric Effects
  • Use noise to animate turbulent flow
  • Flame
  • Clouds

14
Flame
  • Take a basic fire shape and revolve it around
    y-axis to create a fire unit
  • Fire shape can be customized to achieve different
    look and feel

y
Basic shape
Fire unit
15
Flame
  • Perturb fire unit with 4D noise (4th component
    stands for time)



Fire unit
Perlin noise turbulence field
Flame
16
Flame
  • Use a weighted sum of several noise frequencies.
    Change weights to achieve different look







17
Part II - SmokeOutline
  • Why 3D fluid simulation is important
  • Overview of process
  • Fluid simulation basics
  • Dynamic arbitrary boundaries

18
Smoke
Smoke in NVIDIAs DirectX10 SDK Sample
19
Overview
Composite on top of scene
Scene
Decide where to place the smoke
Render
Discretize space and simulate
20
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

Pressure
Density
Velocity
21
Fluid Simulation steps
Each time step
Initialize
Add Density
Add Velocity
Advect
Project
Advect
Density
Density
Density
Velocity
Velocity
Velocity
Velocity
Pressure
Iterate
Pressure
We skip the diffusion step
22
Advect
Density
Velocity
Time Step t
Density
Time Step t 1
23
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

24
Advect on the GPU
O
O
Velocity in x
Velocity in y
M
M
Velocity Texture at timestep t
Density Texture at timestep t
Texture fetch
Texture fetch
O
O
PS_ADVECT calculate new density for this grid
cell using the density and velocity textures from
the previous time step
M
M
rasterized
rendered
Render Target Density for timestep t1
Quad
Pixel Shader
25
Advect on the GPU in 3D
O
O
M
M
N
N
Velocity Texture at timestep t
Density Texture at timestep t
O
Texture fetch
Texture fetch
O
M
PS_ADVECT calculate new density for this grid
cell using the density and velocity textures from
the previous time step
M
N
rasterized
rendered
N Quads
Render Target Density for timestep t1
Pixel Shader
GS is used to rasterize each quad to proper layer
in output Render Target
26
Obstacles
  • Smoke interacting with
  • obstacles and compositing with the scene

Smoke only compositing with the scene
27
Obstacles
  • Implicit shapes
  • Like spheres, cylinders
  • Voxelize objects
  • Static Voxelize just once, offline
  • MovingVoxelize objects per frame

Obstacle texture
Fluid cell inside obstacle
Fluid cell outside obstacle
28
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

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

Obstacles
Density
30
Boundary Conditions for Pressure
  • Derivative of the pressure across the boundary
    should be zero
  • (Neumann boundary conditions - specifying
    derivative )

cell1
cell2
v
PressureCell1 PressureCell2 0
PressureCell1 PressureCell2
u
31
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
32
Voxelizing an object
Obstacle texture
Obstacle Velocity texture
33
Use low res collision model for voxelization
34
Voxelizing a simple object
?
35
Voxelizing a simple object
Orthographic camera
Near plane
Stencil Buffer
Decrement on back faces Increment on front faces
Far plane
36
Voxelization
Render model N times, each time with a different
near plane



2DArray of N stencil buffers
37
Part III - RenderingOutline
  • Ray marching
  • Occluding the scene
  • Artifacts and ways to avoid them

38
Rendering
Render front faces of box
Composite into scene
Raycast into the 3D Density texture
39
Raycasting into 3D texture
What we have
What we dont have
3D Density Texture
Transform from world to texture space
- Ray from eye to box
- Ray in texture space
Transform from world to texture space
- Ray entry point in the texture
- Ray box intersection
Transform from world to grid space
- Distance the eye ray traverses through the
box
- Number of voxels the ray traverses Number
of samples to take
40
Raycasting blending
Trilinear samplefrom 3D texture
Render Fullscreen quad to frame buffer
  • Density Texture

PositionInTexture TransformToTexSpace (RayDataT
exture.rgb)
MarchingVector TransformToTexSpace (eye -
RayDataTexture.rgb)
NumberOfSamples TransformToGridSpace (RayDataTe
xture.a)
RayDataTexture
FinalColor.rgb sampleColor.rgb SampleColor.a
(1.0
FinalColor.a) FinalColor.a SampleColor.a
(1.0 FinalColor.a)
FinalColor.rgba 0
41
Occluding the scene
  • Smoke correctly compositing with the scene

Smoke directly blended on top of the scene
42
Integrating scene depth
43
Artifacts
  • During the ray-marching use jittering to avoid
    banding

Without jittering
With jittering
44
Jittered sampling
  • During the ray-marching use jittering to avoid
    banding

45
Artifacts
  • Increase sampling rate to reduce a noise caused
    by jittering
  • Increasing sampling rate leads to performance
    loss


Low sampling rate
High sampling rate
46
Artifacts
  • Correctly using the depth by weighted sampling

Artifacts resulting from an integral number of
samples
47
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)
48
Combining techniques
49
Conclusion
  • Interactive volumetric effect 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

50
Questions?
Write a Comment
User Comments (0)
About PowerShow.com