directx 10/11twvideo01.ubm-us.net/o1/vault/gdc09/slides/100_handout 4.pdf · » next generation...

54

Upload: others

Post on 23-May-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: DirectX 10/11twvideo01.ubm-us.net/o1/vault/gdc09/slides/100_Handout 4.pdf · » Next generation consoles will likely follow this path. Overview ... AO with 6 directions x 6 steps/dir
Page 2: DirectX 10/11twvideo01.ubm-us.net/o1/vault/gdc09/slides/100_Handout 4.pdf · » Next generation consoles will likely follow this path. Overview ... AO with 6 directions x 6 steps/dir

DirectX 10/11Visual EffectsSimon Green, NVIDIA

Page 3: DirectX 10/11twvideo01.ubm-us.net/o1/vault/gdc09/slides/100_Handout 4.pdf · » Next generation consoles will likely follow this path. Overview ... AO with 6 directions x 6 steps/dir

Introduction

» Graphics hardware feature set is starting to stabilize and mature

» New general-purpose compute functionality (DX11 CS)

- enables new graphical effects- and allows more of game computation to move to the GPU- Physics, AI, image processing

» Fast hardware graphics combined with compute is a powerful combination!

» Next generation consoles will likely follow this path

Page 4: DirectX 10/11twvideo01.ubm-us.net/o1/vault/gdc09/slides/100_Handout 4.pdf · » Next generation consoles will likely follow this path. Overview ... AO with 6 directions x 6 steps/dir

Overview

» Volumetric Particle Shadowing» Horizon Based Ambient Occlusion

(HBAO)» DirectX 11 Compute Shader

Effects

Page 5: DirectX 10/11twvideo01.ubm-us.net/o1/vault/gdc09/slides/100_Handout 4.pdf · » Next generation consoles will likely follow this path. Overview ... AO with 6 directions x 6 steps/dir

Volumetric Particle Shadowing

Page 6: DirectX 10/11twvideo01.ubm-us.net/o1/vault/gdc09/slides/100_Handout 4.pdf · » Next generation consoles will likely follow this path. Overview ... AO with 6 directions x 6 steps/dir

Particle Systems in Today’s Games» Commonly used for smoke, explosions,

spark effects» Typically use relatively small number of

large particles (10,000s)» Rendered using point sprites with artist

painted texturesUse animation / movies to hide large particles

» Sometimes include some lighting effectsnormal mapping

» Don’t interact much with scene

Page 7: DirectX 10/11twvideo01.ubm-us.net/o1/vault/gdc09/slides/100_Handout 4.pdf · » Next generation consoles will likely follow this path. Overview ... AO with 6 directions x 6 steps/dir

Particle Systems in Today’s Games

» Can get some great effects with current technology

» Game screen shot here (pending approval)

» World in Conflict?

Page 8: DirectX 10/11twvideo01.ubm-us.net/o1/vault/gdc09/slides/100_Handout 4.pdf · » Next generation consoles will likely follow this path. Overview ... AO with 6 directions x 6 steps/dir

Tomorrow’s Particle Systems» Will likely be more similar to particle

effects used in film» Millions of particles» Physically simulated

With artist control

» Interaction (collisions) with scene and characters

» Simulation using custom compute shaders or physics middleware

» High quality shading and shadowing

Page 9: DirectX 10/11twvideo01.ubm-us.net/o1/vault/gdc09/slides/100_Handout 4.pdf · » Next generation consoles will likely follow this path. Overview ... AO with 6 directions x 6 steps/dir

Tomorrow’s Particle Systems - Example

Low Viscosity Flow Simulations for Animation, Molemaker et al., 2008

Page 10: DirectX 10/11twvideo01.ubm-us.net/o1/vault/gdc09/slides/100_Handout 4.pdf · » Next generation consoles will likely follow this path. Overview ... AO with 6 directions x 6 steps/dir

Volume Shadowing

» Shadows are very important for diffuse volumes like smoke

- show density and shape

» Not much diffuse reflection from a cloud of smoke

- traditional lighting doesn’t help much

» Usually achieved in off-line rendering using deep shadow maps

- still too expensive for real time

Page 11: DirectX 10/11twvideo01.ubm-us.net/o1/vault/gdc09/slides/100_Handout 4.pdf · » Next generation consoles will likely follow this path. Overview ... AO with 6 directions x 6 steps/dir

Volume Shadowing

Before After

Page 12: DirectX 10/11twvideo01.ubm-us.net/o1/vault/gdc09/slides/100_Handout 4.pdf · » Next generation consoles will likely follow this path. Overview ... AO with 6 directions x 6 steps/dir

Half-Angle Slice Rendering» Very simple idea» Based on old volume rendering

technique by Joe Kniss et. Al [1]» Only requires sorting particles

along a given axis- you’re probably already doing this

» Plus a single 2D shadow texture- no 3D textures required

» Works well with simulation and sorting done on GPU (compute)

Page 13: DirectX 10/11twvideo01.ubm-us.net/o1/vault/gdc09/slides/100_Handout 4.pdf · » Next generation consoles will likely follow this path. Overview ... AO with 6 directions x 6 steps/dir

Half-Angle Slice Rendering

» Calculate vector half way between light and view direction

» Render particles in slices perpendicular to this half-angle vector

Page 14: DirectX 10/11twvideo01.ubm-us.net/o1/vault/gdc09/slides/100_Handout 4.pdf · » Next generation consoles will likely follow this path. Overview ... AO with 6 directions x 6 steps/dir

Half-Angle Slice Rendering

» Same slices are visible to both camera and light

» Lets us accumulate shadowing to shadow buffer at the same time as we are rendering to the screen

Page 15: DirectX 10/11twvideo01.ubm-us.net/o1/vault/gdc09/slides/100_Handout 4.pdf · » Next generation consoles will likely follow this path. Overview ... AO with 6 directions x 6 steps/dir

Half-Angle Slice Rendering» Need to change rendering direction (and

blend mode) based on dot(l, v)» if (dot(l, v) > 0) - render front-to-back» if (dot(l,v ) < 0) – render back-to-front» Always render from front-to-back w.r.t.

light

Presenter
Presentation Notes
Alternative would be to store render volume from point of view of light and store shadowing to a 3D texture – expensive.
Page 16: DirectX 10/11twvideo01.ubm-us.net/o1/vault/gdc09/slides/100_Handout 4.pdf · » Next generation consoles will likely follow this path. Overview ... AO with 6 directions x 6 steps/dir

Half-Angle Slice Rendering» Sort particles along half-angle axis

- based on dot(p, h)- can be done very quickly using compute shader

» Choose a number of slices- more slices improves quality- but causes more draw calls and render target switches

» batchSize = numParticles / numSlices» Render slices as batches of particles

starting at i*batchSize» Render particles as billboards using GS

Page 17: DirectX 10/11twvideo01.ubm-us.net/o1/vault/gdc09/slides/100_Handout 4.pdf · » Next generation consoles will likely follow this path. Overview ... AO with 6 directions x 6 steps/dir

Pseudo-CodeIf (dot(v, l) > 0) {

h = normalize(v + l)draw front-to-back

} else {h = normalize(-v + l)draw back-to-front

}sort particles along hbatchSize = numParticles / numSlicesfor(i=0; i<numSlices; i++) {

draw particles to screenlooking up in shadow buffer

draw particles to shadow buffer}

Page 18: DirectX 10/11twvideo01.ubm-us.net/o1/vault/gdc09/slides/100_Handout 4.pdf · » Next generation consoles will likely follow this path. Overview ... AO with 6 directions x 6 steps/dir

Tricks

» Shadow buffer can be quite low resolution (e.g. 256 x 256)

» Can also use final shadow buffer to shadow scene

» Screen image can also be rendered at reduced resolution (2 or 4x) to reduce fill rate requirements

» Can blur shadow buffer at each iteration to simulate scattering:

Page 19: DirectX 10/11twvideo01.ubm-us.net/o1/vault/gdc09/slides/100_Handout 4.pdf · » Next generation consoles will likely follow this path. Overview ... AO with 6 directions x 6 steps/dir

Without Scattering

Page 20: DirectX 10/11twvideo01.ubm-us.net/o1/vault/gdc09/slides/100_Handout 4.pdf · » Next generation consoles will likely follow this path. Overview ... AO with 6 directions x 6 steps/dir

With Scattering

Page 21: DirectX 10/11twvideo01.ubm-us.net/o1/vault/gdc09/slides/100_Handout 4.pdf · » Next generation consoles will likely follow this path. Overview ... AO with 6 directions x 6 steps/dir

Demo

Page 22: DirectX 10/11twvideo01.ubm-us.net/o1/vault/gdc09/slides/100_Handout 4.pdf · » Next generation consoles will likely follow this path. Overview ... AO with 6 directions x 6 steps/dir

Volume Shadowing -Conclusion

» Very simple to add to existing particle system renderer

» Only requires depth-sorting along a different axis

- Can be done using CPU radix sort or Compute

» Plus a single shadow map» Simulating particle systems on the

GPU can enable millions of particles in real-time

Page 23: DirectX 10/11twvideo01.ubm-us.net/o1/vault/gdc09/slides/100_Handout 4.pdf · » Next generation consoles will likely follow this path. Overview ... AO with 6 directions x 6 steps/dir

Horizon Based Ambient Occlusion

Page 24: DirectX 10/11twvideo01.ubm-us.net/o1/vault/gdc09/slides/100_Handout 4.pdf · » Next generation consoles will likely follow this path. Overview ... AO with 6 directions x 6 steps/dir

Ambient Occlusion

» Simulates lightingfrom hemi-sphericalsky light

» Occlusion amount is % of rays that hitsomething within a given radius R

» Usually solved offline using ray-tracing

scene

P

N

R

Page 25: DirectX 10/11twvideo01.ubm-us.net/o1/vault/gdc09/slides/100_Handout 4.pdf · » Next generation consoles will likely follow this path. Overview ... AO with 6 directions x 6 steps/dir

Ambient Occlusion

» Gives perceptual clues to depth, curvature and spatial proximity

Without AO With AO

Presenter
Presentation Notes
Change picture here!
Page 26: DirectX 10/11twvideo01.ubm-us.net/o1/vault/gdc09/slides/100_Handout 4.pdf · » Next generation consoles will likely follow this path. Overview ... AO with 6 directions x 6 steps/dir

Screen Space Ambient Occlusion» Approach introduced by

[Shanmugam and Orikan 07] [Mittring 07][Fox and Compton 08]

» Input - Z-Buffer + normalsRender approximate AO for dynamic scenes with no precomputations

» Z-Buffer = Height fieldz = f(x,y)

eye

image plane

Z-Buffer

Page 27: DirectX 10/11twvideo01.ubm-us.net/o1/vault/gdc09/slides/100_Handout 4.pdf · » Next generation consoles will likely follow this path. Overview ... AO with 6 directions x 6 steps/dir

Horizon Based Ambient Occlusion

» Screen Space Ambient Occlusion (SSAO) technique presented at SIGGRAPH'08 and in ShaderX7 [2]

» HBAO ApproachGoal = approximate the result of ray tracing the depth buffer in 2.5DBased on ideas from horizon mapping [Max 1986]

Page 28: DirectX 10/11twvideo01.ubm-us.net/o1/vault/gdc09/slides/100_Handout 4.pdf · » Next generation consoles will likely follow this path. Overview ... AO with 6 directions x 6 steps/dir

Integration in Games

» Implemented in DirectX 9 and DirectX 10

» Has been used successfully in several shipping games

Page 29: DirectX 10/11twvideo01.ubm-us.net/o1/vault/gdc09/slides/100_Handout 4.pdf · » Next generation consoles will likely follow this path. Overview ... AO with 6 directions x 6 steps/dir

Ray Traced AO

Several minutes with Gelato and 64 rays per pixel

Page 30: DirectX 10/11twvideo01.ubm-us.net/o1/vault/gdc09/slides/100_Handout 4.pdf · » Next generation consoles will likely follow this path. Overview ... AO with 6 directions x 6 steps/dir

HBAO with large radius

HBAO with 16x64 depth samples per pixel

Page 31: DirectX 10/11twvideo01.ubm-us.net/o1/vault/gdc09/slides/100_Handout 4.pdf · » Next generation consoles will likely follow this path. Overview ... AO with 6 directions x 6 steps/dir

HBAO with large radius

HBAO with 16x16 depth samples per pixel

Page 32: DirectX 10/11twvideo01.ubm-us.net/o1/vault/gdc09/slides/100_Handout 4.pdf · » Next generation consoles will likely follow this path. Overview ... AO with 6 directions x 6 steps/dir

“Crease shading” lookwith 6x6 depth samples per pixel

HBAO with small radius

Page 33: DirectX 10/11twvideo01.ubm-us.net/o1/vault/gdc09/slides/100_Handout 4.pdf · » Next generation consoles will likely follow this path. Overview ... AO with 6 directions x 6 steps/dir

“Crease shading” lookwith 4x8 depth samples per pixel

HBAO with small radius

Page 34: DirectX 10/11twvideo01.ubm-us.net/o1/vault/gdc09/slides/100_Handout 4.pdf · » Next generation consoles will likely follow this path. Overview ... AO with 6 directions x 6 steps/dir

HBAO Game Screenshots

» Screenshots pending approval

Page 35: DirectX 10/11twvideo01.ubm-us.net/o1/vault/gdc09/slides/100_Handout 4.pdf · » Next generation consoles will likely follow this path. Overview ... AO with 6 directions x 6 steps/dir

Horizon Mapping

• Given a 1D height field

P

-Z

sampling direction

horizon angle

+X

Page 36: DirectX 10/11twvideo01.ubm-us.net/o1/vault/gdc09/slides/100_Handout 4.pdf · » Next generation consoles will likely follow this path. Overview ... AO with 6 directions x 6 steps/dir

Finding the Horizon

» March along the height field

P

-Z

sampling direction

horizon angle+X

S0

Page 37: DirectX 10/11twvideo01.ubm-us.net/o1/vault/gdc09/slides/100_Handout 4.pdf · » Next generation consoles will likely follow this path. Overview ... AO with 6 directions x 6 steps/dir

Finding the Horizon

» Keeping track of maximum angle

P

-Z

sampling direction

horizon angle+X

S0

S1

Page 38: DirectX 10/11twvideo01.ubm-us.net/o1/vault/gdc09/slides/100_Handout 4.pdf · » Next generation consoles will likely follow this path. Overview ... AO with 6 directions x 6 steps/dir

Finding the Horizon

P

-Z

sampling direction

horizon angle

+X

S0

S1

S2

Page 39: DirectX 10/11twvideo01.ubm-us.net/o1/vault/gdc09/slides/100_Handout 4.pdf · » Next generation consoles will likely follow this path. Overview ... AO with 6 directions x 6 steps/dir

Finding the Horizon

P

-Z

sampling direction

horizon angle

+X

S0

S1

S2

S3

Page 40: DirectX 10/11twvideo01.ubm-us.net/o1/vault/gdc09/slides/100_Handout 4.pdf · » Next generation consoles will likely follow this path. Overview ... AO with 6 directions x 6 steps/dir

Sampling the Depth Image» Estimate occlusion by

sampling depth image» Use uniform

distribution of directions per pixel

Fixed number ofsamples / dir

» Per-pixel randomizationRotate directions by random per-pixel angleJitter samples along ray by a random offset

P

u

v

Page 41: DirectX 10/11twvideo01.ubm-us.net/o1/vault/gdc09/slides/100_Handout 4.pdf · » Next generation consoles will likely follow this path. Overview ... AO with 6 directions x 6 steps/dir

Noise

» Per-pixel randomization generates visible noise

AO with 6 directions x 6 steps/dir

Page 42: DirectX 10/11twvideo01.ubm-us.net/o1/vault/gdc09/slides/100_Handout 4.pdf · » Next generation consoles will likely follow this path. Overview ... AO with 6 directions x 6 steps/dir

Cross Bilateral Filter

» Blur the ambient occlusion to remove noise

» Depth-dependent Gaussian blur[Petschnigg et al. 04][Eisemann and Durand 04] - Reduces blurring across edges

» Although it is a non-separable filter, we apply it separately in the X and Y directions

No significant artifacts visible

Page 43: DirectX 10/11twvideo01.ubm-us.net/o1/vault/gdc09/slides/100_Handout 4.pdf · » Next generation consoles will likely follow this path. Overview ... AO with 6 directions x 6 steps/dir

Cross Bilateral Filter

Without Blur With 15x15 Blur

Page 44: DirectX 10/11twvideo01.ubm-us.net/o1/vault/gdc09/slides/100_Handout 4.pdf · » Next generation consoles will likely follow this path. Overview ... AO with 6 directions x 6 steps/dir

Half-Resolution AO

» AO is mostly low frequency- Can render the AO in half resolution- Source half-resolution depth image

» Still do the blur passes in full resolution

- To avoid bleeding across edges- Source full resolution eye-space depths [Kopf et al. 07]

Page 45: DirectX 10/11twvideo01.ubm-us.net/o1/vault/gdc09/slides/100_Handout 4.pdf · » Next generation consoles will likely follow this path. Overview ... AO with 6 directions x 6 steps/dir

Rendering PipelineRender opaque

geometry

Render AO(Half or Full Res)

Blur AO in X

Blur AO in Y

Modulate Color

(eye-spacenormals)

eye-spacedepths

colors

Unprojection parameters(fovy and aspect ratio)

Eye-space radius RNumber of directionsNumber of steps / direction

Kernel radiusSpatial sigmaRange sigma

Page 46: DirectX 10/11twvideo01.ubm-us.net/o1/vault/gdc09/slides/100_Handout 4.pdf · » Next generation consoles will likely follow this path. Overview ... AO with 6 directions x 6 steps/dir

Half-Resolution AO6x6 (36) samples / AO pixelNo Blur

Page 47: DirectX 10/11twvideo01.ubm-us.net/o1/vault/gdc09/slides/100_Handout 4.pdf · » Next generation consoles will likely follow this path. Overview ... AO with 6 directions x 6 steps/dir

Half-Resolution AO6x6 (36) samples / AO pixel15x15 Blur

Page 48: DirectX 10/11twvideo01.ubm-us.net/o1/vault/gdc09/slides/100_Handout 4.pdf · » Next generation consoles will likely follow this path. Overview ... AO with 6 directions x 6 steps/dir

Full-Resolution AO6x6 (36) samples / AO pixel15x15 Blur

Page 49: DirectX 10/11twvideo01.ubm-us.net/o1/vault/gdc09/slides/100_Handout 4.pdf · » Next generation consoles will likely follow this path. Overview ... AO with 6 directions x 6 steps/dir

Full-Resolution AO16x16 (256) samples / pixelNo Blur

Page 50: DirectX 10/11twvideo01.ubm-us.net/o1/vault/gdc09/slides/100_Handout 4.pdf · » Next generation consoles will likely follow this path. Overview ... AO with 6 directions x 6 steps/dir

Full-Resolution AO16x32 (512) samples / pixelNo Blur

Page 51: DirectX 10/11twvideo01.ubm-us.net/o1/vault/gdc09/slides/100_Handout 4.pdf · » Next generation consoles will likely follow this path. Overview ... AO with 6 directions x 6 steps/dir

Demo

Presenter
Presentation Notes
Fallback: Show Medusa Video?
Page 52: DirectX 10/11twvideo01.ubm-us.net/o1/vault/gdc09/slides/100_Handout 4.pdf · » Next generation consoles will likely follow this path. Overview ... AO with 6 directions x 6 steps/dir

HBAO - Conclusion

» DirectX10 SDK sampleNow available on developer.nvidia.com

Including video and whitepaper

» DirectX9 and OpenGL samples to be released soon

» Easy to integrate into a game engineRendered as a post-processing passOnly requires eye-space depths (normals can be derived from depth)

» More details in ShaderX7 (to appear)

Page 53: DirectX 10/11twvideo01.ubm-us.net/o1/vault/gdc09/slides/100_Handout 4.pdf · » Next generation consoles will likely follow this path. Overview ... AO with 6 directions x 6 steps/dir

Acknowledgments

NVIDIAMiguel Sainz, Louis Bavoil, Rouslan Dimitrov, Samuel Gateau, Jon Jansen

ModelsDragon - Stanford 3D Scanning RepositoryScience-Fiction scene - Juan Carlos Silva http://www.3drender.com/challenges/index.htm

Sibenik Cathedral - Marko Dabrovic

Presenter
Presentation Notes
Michael Thompson,�Ignacio Castano, NVIDIA demo team
Page 54: DirectX 10/11twvideo01.ubm-us.net/o1/vault/gdc09/slides/100_Handout 4.pdf · » Next generation consoles will likely follow this path. Overview ... AO with 6 directions x 6 steps/dir

References

1. Volume Rendering Techniques, Milan Ikits, Joe Kniss, Aaron Lefohn, Charles Hansen. Chapter 39, section 39.5.1, GPU Gems: Programming Techniques, Tips, and Tricks for Real-Time Graphics (2004).

2. BAVOIL, L., AND SAINZ, M. 2009. Image-space horizon-based ambient occlusion. In ShaderX7 - Advanced Rendering Techniques.