Real-time Atmospheric Effects in Games Revisited. Carsten Wenzel

Similar documents
GUERRILLA DEVELOP CONFERENCE JULY 07 BRIGHTON

TSBK03 Screen-Space Ambient Occlusion

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

Shadows. COMP 575/770 Spring 2013

Shadow Techniques. Sim Dietrich NVIDIA Corporation

LIGHTING - 1. Note. Lights. Ambient occlusion

Render methods, Compositing, Post-process and NPR in NX Render

Ultimate Graphics Performance for DirectX 10 Hardware

Advanced Shading I: Shadow Rasterization Techniques

CS 354R: Computer Game Technology

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

Shadows in the graphics pipeline

Optimizing DirectX Graphics. Richard Huddy European Developer Relations Manager

A Survey of Modelling and Rendering of the Earth s Atmosphere

Rendering Smoke & Clouds

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

SAMPLING AND NOISE. Increasing the number of samples per pixel gives an anti-aliased image which better represents the actual scene.

INFOGR Computer Graphics

Simpler Soft Shadow Mapping Lee Salzman September 20, 2007

Screen Space Ambient Occlusion TSBK03: Advanced Game Programming

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

The Animation Process. Lighting: Illusions of Illumination

#Short presentation of the guys

Scalable multi-gpu cloud raytracing with OpenGL

Real Time Atmosphere Rendering for the Space Simulators

Soft Particles. Tristan Lorach

Supplement for Real-Time Soft Shadows in Dynamic Scenes using Spherical Harmonic Exponentiation

Hidden Line and Surface

Applications of Explicit Early-Z Culling

#Short presentation of the guys

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

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

Soft shadows. Steve Marschner Cornell University CS 569 Spring 2008, 21 February

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

Hidden Surface Elimination Raytracing. Pre-lecture business. Outline for today. Review Quiz. Image-Space vs. Object-Space

Advanced Computer Graphics CS 563: Screen Space GI Techniques: Real Time

Enhancing Traditional Rasterization Graphics with Ray Tracing. March 2015

Bringing AAA graphics to mobile platforms. Niklas Smedberg Senior Engine Programmer, Epic Games

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

Rendering Algorithms: Real-time indirect illumination. Spring 2010 Matthias Zwicker

Deferred Rendering Due: Wednesday November 15 at 10pm

Real-Time Shadows. Computer Graphics. MIT EECS Durand 1

The Terrain Rendering Pipeline. Stefan Roettger, Ingo Frick. VIS Group, University of Stuttgart. Massive Development, Mannheim

Chapter 17: The Truth about Normals

Practical Implementation of Light Scattering Effects Using Epipolar Sampling and 1D Min/Max Binary Trees

MAXIS-mizing Darkspore*: A Case Study of Graphic Analysis and Optimizations in Maxis Deferred Renderer

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

Computer Graphics (CS 563) Lecture 4: Advanced Computer Graphics Image Based Effects: Part 2. Prof Emmanuel Agu

Canonical Shaders for Optimal Performance. Sébastien Dominé Manager of Developer Technology Tools

Ray tracing. Computer Graphics COMP 770 (236) Spring Instructor: Brandon Lloyd 3/19/07 1

Lighting and Shading

Today. Anti-aliasing Surface Parametrization Soft Shadows Global Illumination. Exercise 2. Path Tracing Radiosity

Direct3D 11 Performance Tips & Tricks

Movie: For The Birds. Announcements. Ray Tracing 1. Programming 2 Recap. Programming 3 Info Test data for part 1 (Lines) is available

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

Volume Rendering with libmini Stefan Roettger, April 2007

LOD and Occlusion Christian Miller CS Fall 2011

Cloth Simulation on the GPU. Cyril Zeller NVIDIA Corporation

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

A bit more Deferred - CryEngine 3. Triangle Game Conference 2009 Martin Mittring Lead Graphics Programmer

This work is about a new method for generating diffusion curve style images. Although this topic is dealing with non-photorealistic rendering, as you

Ray tracing. EECS 487 March 19,

Enhancing Traditional Rasterization Graphics with Ray Tracing. October 2015

Computer Graphics. Shadows

Fog and Cloud Effects. Karl Smeltzer Alice Cao John Comstock

A Trip Down The (2011) Rasterization Pipeline

Visualizer An implicit surface rendering application

Introduction to 3D Graphics

Optimizing for DirectX Graphics. Richard Huddy European Developer Relations Manager

Game Programming Lab 25th April 2016 Team 7: Luca Ardüser, Benjamin Bürgisser, Rastislav Starkov

Introduction to Visualization and Computer Graphics

Realistic and Fast Cloud Rendering in Computer Games. Niniane Wang Software Engineer Microsoft Flight Simulator (now at Google Inc) Intro Video

Previously... contour or image rendering in 2D

Building scalable 3D applications. Ville Miettinen Hybrid Graphics

Multi-View Soft Shadows. Louis Bavoil

Acknowledgement: Images and many slides from presentations by Mark J. Kilgard and other Nvidia folks, from slides on developer.nvidia.

The Rasterization Pipeline

Light scattering is an important natural phenomenon, which arises when the light interacts with the particles distributed in the media.

Overview. A real-time shadow approach for an Augmented Reality application using shadow volumes. Augmented Reality.

Planets Earth, Mars and Moon Shaders Asset V Documentation (Unity 5 version)

COSC 448: REAL-TIME INDIRECT ILLUMINATION

Shadow Rendering EDA101 Advanced Shading and Rendering

Rain. Sarah Tariq

Real-Time Hair Rendering on the GPU NVIDIA

Deus Ex is in the Details

How to Work on Next Gen Effects Now: Bridging DX10 and DX9. Guennadi Riguer ATI Technologies

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

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

Optimizing and Profiling Unity Games for Mobile Platforms. Angelo Theodorou Senior Software Engineer, MPG Gamelab 2014, 25 th -27 th June

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

Lecture 9: Deferred Shading. Visual Computing Systems CMU , Fall 2013

8K Earth, Moon and Mars Shaders Asset V Documentation

Dominic Filion, Senior Engineer Blizzard Entertainment. Rob McNaughton, Lead Technical Artist Blizzard Entertainment

Computer Graphics (CS 563) Lecture 4: Advanced Computer Graphics Image Based Effects: Part 1. Prof Emmanuel Agu

CS427 Multicore Architecture and Parallel Computing

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

Rendering Grass with Instancing in DirectX* 10

There are many kinds of surface shaders, from those that affect basic surface color, to ones that apply bitmap textures and displacement.

INFOGR Computer Graphics. Jacco Bikker - April-July Lecture 3: Ray Tracing (Introduction) Welcome!

Topic 12: Texture Mapping. Motivation Sources of texture Texture coordinates Bump mapping, mip-mapping & env mapping

Transcription:

Real-time Atmospheric Effects in Games Reisited Carsten Wenel

The deal Follow up to a talk I gae at SIGGRAPH 2006 Coers material presented at the time plus recent additions and improements

Oeriew Introduction Scene depth based rendering Atmospheric effects breakdown Sky light rendering Fog approaches Soft particles Cloud rendering (updated/new) Volumetric lightning approximation Rier and Ocean rendering (updated/new) Scene depth based rendering and MSAA (new) Conclusions

Introduction Atmospheric effects are important cues of realism (especially outdoors) Why Create sense of depth Increase leel of immersion

Motiation Atmospheric effects are mathematically complex (so far usually coarsely approximated if any) Programmability and power of today s GPUs allow implementation of sophisticated models How to can these be mapped efficiently?

Related Work Deferred Shading (Hargreaes 2004) Atmospheric Scattering (Nishita et al 1993) Cloud Rendering (Wang 2003) Real-time Atmospheric Effects in Games (Wenel 2006)

Scene Depth Based Rendering: Motiation Many atmospheric effects require accessing scene depth Similar to Deferred Shading [Hargreaes04] Mixes well with traditional style rendering Deferred shading is not a must! Think of it as writing a pixel shader with scene depth aailable Requires laying out scene depth first and making it aailable to following rendering passes

Scene Depth Based Rendering: Benefits Decouple rendering of opaque scene geometry and application of other effects Atmospheric effects Post-processing More Apply complex models while keeping the shading cost moderate Features are implemented in separate shaders Helps aoiding hardware shader limits (can support older HW)

Scene Depth Based Rendering: Challenges Alpha-transparent objects Only one color / depth alue stored Howeer, per-pixel oerdraw due to alpha transparent objects potentially unbound Workaround for specific effects needed (will be mentioned later)

Scene Depth Based Rendering: API and Hardware Challenges Usually cannot directly bind Z-Buffer and reerse map Write linear eye-space depth to texture instead Float format s. RGBA8 Supporting Multi-Sample Anti-Aliasing is tricky (more on that later)

Recoering World Space Position from Depth Many deferred shading implementations transform a pixel s homogenous clip space coordinate back into world space 3 dp4 or mul/mad instructions There s often a simpler / cheaper way For full screen effects hae the distance from the camera s position to its four corner points at the far clipping plane interpolated Scale the pixel s normalied linear eye space depth by the interpolated distance and add the camera position (one mad instruction)

Sky Light Rendering Mixed CPU / GPU implementation of [Nishita93] Goal: Best quality possible at reasonable runtime cost Trading in flexibility of camera moement Assumptions and constraints: Camera is always on the ground Sky infinitely far away around camera Win: Sky update is iew-independent, update only oer time

Sky Light Rendering: CPU Sole Mie / Rayleigh in-scattering integral For 128x64 sample points on the sky hemisphere sole P h b ( ( ) ( )) ( ) ( ) ( ) ( ) H 0 t PPc, λ t PPa, λ I λ = I s λ K λ F θ, g e e (1) Pa Using the current time of day, sunlight direction, Mie / Rayleigh scattering coefficients Store the result in a floating point texture Distribute computation oer seeral frames Each update takes seeral seconds to compute

Sky Light Rendering: GPU Map float texture onto sky dome Problem: low-res texture produces blocky results een when filtered Solution: Moe application of phase function to GPU (F(θ,g) in Eq.1) High frequency details (sun spot) now computed per-pixel SM3.0/4.0 could sole Eq.1 ia pixel shader and render to texture Integral is a loop of ~200 asm instructions iterating 32 times Final execution ~6400 instructions to compute in-scattering for each sample point on the sky hemisphere

Global Volumetric Fog Nishita s model still too expensie to model fog/aerial perspectie Want to proide an atmosphere model To apply its effects on arbitrary objects in the scene Deeloped a simpler method to compute height/distance based fog with exponential fall-off

Global Volumetric Fog f ( ) ) T x, y, () t = o + td f = 1 be c ( ) T ( () t ) dt = f ( o + td, o + td, o + td ) 0 x x y y d dt = F be co d 2 x + d f () t ( () t ) = e 2 y ( )dt + d 2 1 e cd cd (2) f fog density distribution c height fall-off b global density F fog density along iew ray from camera (o) to target pos (o+d), t=1

Global Volumetric Fog: Shader Implementation Eq.2 translated into HLSL float ComputeVolumetricFog( in float3 cameratoworldpos ) { // NOTE: cvolfogheightdensityatviewer = exp( -cheightfalloff * cviewpos. ); float fogint = length( cameratoworldpos ) * cvolfogheightdensityatviewer; const float cslopethreshold = 0.01; if( abs( cameratoworldpos. ) > cslopethreshold ) { float t = cheightfalloff * cameratoworldpos.; fogint *= ( 1.0 - exp( -t ) ) / t; } } return exp( -cglobaldensity * fogint );

Combining Sky Light and Fog Sky is rendered along with scene geometry To apply fog Draw a full screen quad Reconstruct each pixel s world space position Pass position to olumetric fog formula to retriee fog density along iew ray What about fog color?

Combining Sky Light and Fog Fog color Aerage in-scattering samples along the horion while building texture Combine with per-pixel result of phase function to yield approximate fog color Use fog color and density to blend against back buffer

Combining Sky Light and Fog: Results *

Fog Volumes Fog olumes ia ray-tracing in the shader Currently two primities supported: Box, Ellipsoid Generalied form of Global Volumetric Fog Exhibits same properties (additionally, direction of height no longer restricted to world space up ector, gradient can be shifted along height dir) Ray-trace in object space: Unit box, unit sphere Transform results back to sole fog integral Render bounding hull geometry Front faces if outside, otherwise back faces For each pixel Determine start and end point of iew ray to plug into Eq.2

Fog Volumes Start point Either camera pos (if iewer is inside) or ray s entry point into fog olume (if iewer is outside) End point Either ray s exit point out of the fog olume or world space position of pixel depending which one of the two is closer to the camera Render fog olumes back to front Sole fog integral and blend with back buffer

Fog Volumes Rendering of fog olumes: Box (top left/right), Ellipsoid (bottom left/right)

Fog and Alpha-Transparent Objects Shading of actual object and application of atmospheric effect can no longer be decoupled Need to sole both and combine results in same pass Global Volumetric Fog Approximate per ertex Computation is purely math op based (no lookup textures required) Maps well to older HW Shader Models 2.x Shader Model 3.0 for performance reasons / due to lack of ertex texture fetch (IHV specific)

Fog and Alpha-Transparent Objects Fog Volumes Approximate per object, computed on CPU Sounds awful but it s possible when designers know limitation and how to work around it Alpha-Transparent objects shouldn t become too big, fog gradient should be rather soft Compute weighted contribution by processing all affecting of fog olumes back to front w.r.t camera

Soft Particles Simple idea Instead of rendering a particle as a regular billboard, treat it as a camera aligned olume Use per-pixel depth to compute iew ray s trael distance through olume and use the result to fade out the particle Hides jaggies at intersections with other geometry Some recent publications use a similar idea and treat particles as spherical olumes We found a olume box to be sufficient (saes shader instructions; important as particles are fill-rate hungry) GS can setup interpolators so point sprites are finally feasible

Soft Particles: Results Comparisons shots of particle rendering with soft particles disabled (left) and enabled (right) *

Clouds Rendering Using Per- Pixel Depth Follow approach similar to [Wang03], Gradient-based lighting Use scene depth for soft clipping (e.g. rain clouds around mountains) similar to Soft Particles Added rim lighting based on cloud density

Cloud Shadows Cloud shadows are cast in a single full screen pass Use depth to transform pixel position into shadow map space

Distance Clouds Dynamic sky and pre-baked sky box clouds don t mix well Real 3D cloud imposters can be expensie and are often not needed Limited to 2D planes aboe the camera clouds can be rendered with olumetric properties Sample a 2D texture (cloud density) along the iew dir For each sample point sample along the direction to sun Adjust number of samples along both directions to fit into shader limits, sae fill-rate, etc.

Distance Clouds Use the accumulated density to calc attenuation and factor in current sun / sky light Distance Clouds at different times of day *

Volumetric Lightning Using Per- Pixel Depth Similar to Global Volumetric Fog Light is emitted from a point falling off radially Need to carefully select attenuation function to be able to integrate it in a closed form Can apply this lighting model just like global olumetric fog Render a full screen pass

Volumetric Lightning Model ( ) ( ) ( ) () () ( ) ( ) ( ) () ( ) t F uw uw uw w d d d i dt d td o td o td o f dt t f td o t y x l a i y x f y x T y y x x T T = + + + = + + + = + = + = 2 2 2 2 2 2 1 0 2 4 4 arctan 4 2 arctan 2,,,, 1,, f light attenuation function i source light intensity l lightning source pos a global attenuation control alue iew ray from camera (o) to target pos (o+d), t=1 F amount of light gathered along (3)

Volumetric Lightning Using Per- Pixel Depth: Results *

Rier shading Riers (and water areas in general) Special fog olume type: Plane Under water fog rendered as described earlier (using a simpler uniform density fog model though) Shader for water surface enhanced to softly blend out at rierside (difference between pixel depth of water surface and preiously stored scene depth)

Rier shading: Results Rier shading Screens taken from a hidden section of the E3 2006 demo *

Ocean shading Very similar to rier shading, howeer Underwater part uses more complex model for light attenuation and inscattering Assume horiontal water plane, uniform density distribution and light always falling in top down Can be described as follows

Ocean shading ( ) ( ) ( ) ( ) () o p l o p o p d td o t e e e t y x f t s c ct s c T = = + = = = +,,, () ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) = = = = = + + c d e e c d e e dt e e dt d e dt t t f inscatter cl d o s c l ct d o s c l d ct o s c l t td o s c 1 1 1, 1 0 1 0 1 0 ( ) l p s c e l p f attenuation + = = ) (, enlightcol inscatter scenecol attenuation finalcol + = (4)

Ocean shading: Results Underwater iew: from ground up (1 st row), from underneath the surface down (2 nd row). Same lighting settings apply. Higher density on the right column. *

Scene depth based rendering and MSAA Seeral problems Cannot bind multi-sampled RT as texture Shading per pixel and not per sample Need to resole depth RT which produces wrong alues at silhouettes potentially causes outlines in later shading steps Two problems we ran into Fog Rier / Ocean

Scene depth based rendering and MSAA: Fog Fog color doesn t changed drastically for neighboring pixel while density does Hae fog density computed while laying out depth (two channel RT) During olumetric fog full screen pass only compute fog color and read density from resoled RT Aeraging density during resole works reasonably well compared to depth

Scene depth based rendering and MSAA: Rier / Ocean Shader assumes dest depth > plane depth (otherwise pixel would hae be rejected by - test) With resoled depth RT this cannot be guaranteed (depends on pixel coerage of object silhouettes) Need to enforce original assumption by finding max depth of current pixel and all neighbors (direct neighbors suffice)

Scene depth based rendering and MSAA: Results Fog full screen pass with MSAA disabled (left) / enabled (right) Rier / Ocean shading artifact (left) and fix (right)

Conclusion Depth Based Rendering offers lot s of opportunities Demonstrated seeral ways of how it is used in CryEngine2 Integration issues (alpha-transparent geometry, MSAA) Kualoa Ranch on Hawaii Real world photo (left), internal replica rendered with CryEngine2 (right)

References [Hargreaes04] Shawn Hargreaes, Deferred Shading, Game Deelopers Conference, D3D Tutorial Day, March, 2004. [Nishita93] Tomoyuki Nishita, et al., Display of the Earth Taking into Account Atmospheric Scattering, In Proceedings of SIGGRAPH 1993, pages 175-182. [Wang03] Niniane Wang, Realistic and Fast Cloud Rendering in Computer Games, In Proceedings of SIGGRAPH 2003. [Wenel06] Carsten Wenel, Real-time Atmospheric Effects in Games, SIGGRAPH 2006.

Acknowledgements Crytek R&D / Crysis de team

Questions???