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

Similar documents
Robust Stencil Shadow Volumes. CEDEC 2001 Tokyo, Japan

Lecture 17: Shadows. Projects. Why Shadows? Shadows. Using the Shadow Map. Shadow Maps. Proposals due today. I will mail out comments

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

Shadow Volume History (1) Shadow Volumes. Shadow Volume History (2) Shadow Volume History (3) Shadow Volume Basics. Shadow Volume History (4)

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

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

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

Reflections, Shadows, Transparency, and Fog

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

Computer Graphics Shadow Algorithms

Real-Time Shadows. Last Time? Schedule. Questions? Today. Why are Shadows Important?

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

Real-Time Shadows. MIT EECS 6.837, Durand and Cutler

What for? Shadows tell us about the relative locations. Vienna University of Technology 2

Shadows. Shadows. Spatial relationship between objects. Shadows as depth cue. Spatial relationship between objects

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

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

Computer Graphics. Shadows

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

Shadow Rendering EDA101 Advanced Shading and Rendering

Shadows in the graphics pipeline

Shadows. Real-Time Hard Shadows. Collected by Ronen Gvili. Most slides were taken from : Fredu Durand Stefan Brabec

Shadow Algorithms. CSE 781 Winter Han-Wei Shen

Computergrafik. Matthias Zwicker. Herbst 2010

Computer Graphics 10 - Shadows

Optimized Stencil Shadow Volumes. Cass Everitt & Mark J. Kilgard

Shadows. Shadows. Thanks to: Frédo Durand and Seth Teller MIT. Realism Depth cue

Shadows. Shadows. Spatial relationship between objects. Shadows as depth cue. Spatial relationship between objects

Pipeline Operations. CS 4620 Lecture 10

The Traditional Graphics Pipeline

Texture Mapping II. Light maps Environment Maps Projective Textures Bump Maps Displacement Maps Solid Textures Mipmaps Shadows 1. 7.

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

Deferred Rendering Due: Wednesday November 15 at 10pm

Shadow Techniques. Sim Dietrich NVIDIA Corporation

Advanced Shading and Texturing

Shadow Mapping. Render Scene and Access the Depth Texture. What is Projective Texturing? About Projective Texturing (1) About Projective Texturing (3)

The Traditional Graphics Pipeline

Shadow Mapping. Marc Stamminger, University of Erlangen-Nuremberg

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

Computer Graphics. Bing-Yu Chen National Taiwan University The University of Tokyo

Simpler Soft Shadow Mapping Lee Salzman September 20, 2007

CS4620/5620: Lecture 14 Pipeline

Computer Graphics (CS 543) Lecture 10: Soft Shadows (Maps and Volumes), Normal and Bump Mapping

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

CS 498 VR. Lecture 18-4/4/18. go.illinois.edu/vrlect18

The Traditional Graphics Pipeline

Advanced Shading I: Shadow Rasterization Techniques

CEng 477 Introduction to Computer Graphics Fall 2007

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

Motivation. Culling Don t draw what you can t see! What can t we see? Low-level Culling

Shadows. COMP 575/770 Spring 2013

Computing Visibility. Backface Culling for General Visibility. One More Trick with Planes. BSP Trees Ray Casting Depth Buffering Quiz

Visibility and Occlusion Culling

Rasterization Overview

Abstract. 2 Description of the Effects Used. 1 Introduction Phong Illumination Bump Mapping

Volume Shadows Tutorial Nuclear / the Lab

Lecture 13: Reyes Architecture and Implementation. Kayvon Fatahalian CMU : Graphics and Imaging Architectures (Fall 2011)

Stencil Shadow Volumes

A Shadow Volume Algorithm for Opaque and Transparent Non-Manifold Casters

GUERRILLA DEVELOP CONFERENCE JULY 07 BRIGHTON

Pipeline Operations. CS 4620 Lecture 14

Illumination and Geometry Techniques. Karljohan Lundin Palmerius

Parallelizing Graphics Pipeline Execution (+ Basics of Characterizing a Rendering Workload)

CHAPTER 1 Graphics Systems and Models 3

Orthogonal Projection Matrices. Angel and Shreiner: Interactive Computer Graphics 7E Addison-Wesley 2015

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

Ray Tracing. Computer Graphics CMU /15-662, Fall 2016

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

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

Shadow Volumes Revisited

Hidden surface removal. Computer Graphics

Practical Shadow Mapping

Triangle Rasterization

Direct Rendering of Trimmed NURBS Surfaces

VISIBILITY & CULLING. Don t draw what you can t see. Thomas Larsson, Afshin Ameri DVA338, Spring 2018, MDH

3D Rasterization II COS 426

LOD and Occlusion Christian Miller CS Fall 2011

Real Time Rendering of Expensive Small Environments Colin Branch Stetson University

FAST SELF-SHADOWING USING OCCLUDER TEXTURES. A Thesis CHRISTOPHER RYAN COLEMAN

Page 1. Area-Subdivision Algorithms z-buffer Algorithm List Priority Algorithms BSP (Binary Space Partitioning Tree) Scan-line Algorithms

Computer Graphics. Bing-Yu Chen National Taiwan University

Accelerated Ambient Occlusion Using Spatial Subdivision Structures

Intro to OpenGL II. Don Fussell Computer Science Department The University of Texas at Austin

Computer Graphics. Lecture 9 Hidden Surface Removal. Taku Komura

Projective Textures & Shadow Mapping. Prof. Aaron Lanterman School of Electrical and Computer Engineering Georgia Institute of Technology

Shadow Volumes. Why Shadow Volumes?

In- Class Exercises for Shadow Algorithms

Render-To-Texture Caching. D. Sim Dietrich Jr.

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

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

Parallelizing Graphics Pipeline Execution (+ Basics of Characterizing a Rendering Workload)

9. Illumination and Shading

Shadows in Computer Graphics. by Björn Kühl im/ve University of Hamburg, Germany

DEFERRED RENDERING STEFAN MÜLLER ARISONA, ETH ZURICH SMA/

Werner Purgathofer

Practical Shadows. Outline

Lecturer Athanasios Nikolaidis

OpenGl Pipeline. triangles, lines, points, images. Per-vertex ops. Primitive assembly. Texturing. Rasterization. Per-fragment ops.

Shadow and Environment Maps

Transcription:

Shadows Acknowledgement: Images and many slides from presentations by Mark J. Kilgard and other Nvidia folks, from slides on developer.nvidia.com Practical & Robust Stenciled Shadow Volumes for Hardware-Accelerated Rendering, Cass Everitt & Mark J. Kilgard, GDC 2002 Shadow Mapping with Today s OpenGL Hardware, Mark Kilgard, CEDEC 2001, Tokyo, Japan Robust Stencil Shadow Volumes, Mark Kilgard, CEDEC 2001, Tokyo, Japan Shadow Mapping, Cass Everitt Reflections, Shadows,Transparency, and Fog, Mark Kilgard, GDC 2000 Tutorial Shadow Mapping with Todays OpenGL Hardware, Mark Kilgard, GDC 2000 Tutorial Shadows Important visual cue All real world scenes have shadows Occlusion from light s point-of-view instead of viewer s Cue for light-object-object relationships CS 4451 Fall 2002 1

Local Illumination & Shadows Typically lack shadow support Ignore occlusion of lights that creates shadows Global lighting models account for shadows Too expensive for interactive use Interactive shadow algorithms typically operate independent of local lighting models Interactive Shadow Simplifications True shadows are expensive, cut corners Simple geometry tricks Projection Volume intersection Pre-compute static shadow results where possible Make simplifying assumptions Treat area light sources as points Exploit hardware features such as stencil CS 4451 Fall 2002 2

Common Real-time Shadow Techniques Projected planar shadows Shadow volumes Hybrid approaches Light maps Problems with Common Techniques Mostly tricks with lots of limitations Light maps totally unsuited for dynamic shadows Projected planar shadows well works only on flat surfaces Stenciled shadow volumes determining the shadow volume is hard work Shadow Maps only works with spotlight frustums shadow acne artifacts CS 4451 Fall 2002 3

Pre-computed Shadow Textures (Light maps, 8.5 in book) Lightmaps are static shadow textures Compute lightmaps off-line with radiosity solver local lighting models evaluated on tight grid can work too Lightmaps with soft shadows can be built faster with convolution approach, accelerated using the Fast Fourier Transform [Soler & Silion 98] Pre-computed shadow textures work well for building interior with lots of diffuse surfaces Aside: Stencil Buffers An extra test for fine-grain pixel control Standard OpenGL and DirectX 6 feature Per-pixel test similar to depth buffering Tests fragment against pixel s stencil value, rejects fragments that fail Also, can modify pixel s stencil buffer value based on stencil/depth test results Hardware accelerates stencil testing Typically free when depth testing too CS 4451 Fall 2002 4

Stencil Testing Similar to Depth Testing but Compares current reference value to pixel s stencil buffer value Same comparison functions as depth test Stencil values controlled by stencil ops stencil side effects of stencil & depth tests Possible operations Increment, Decrement Keep, Replace, Zero, Invert Projected Planar Shadows CS 4451 Fall 2002 5

Projected Planar Shadows Classic computer graphics trick Given Ground plane equation, Ax + By + Cz + D = 0 Light position (x, y, z, w) Construct projective transform that squishes vertices into ground plane based on light position Concatenate this with view transform Rendering 3D object creates shadow-like pile of polygons in ground plane Projected Planar Shadow Issues Shadow must be cast on infinite planes Pile of polygons creates Z-fighting artifacts Polygon offset fixes this, but disturbs Z values Difficult to blend shadow with ground texture Just blending creates double blends Specular highlights can show in shadow Stencil testing can fix most of these issues CS 4451 Fall 2002 6

Projected Planar Shadow Artifacts Bad Good extends off ground region Z fighting double blending Shadow Volumes CS 4451 Fall 2002 7

The Shadow Volume Concept Volumetric shadows, not just planar A single point light source splits the world in two shadowed regions unshadowed regions A shadow volume is the boundary between these shadowed and unshadowed regions First described by [Crow 77] Visualizing the Shadow Volume Occluders and light source cast out a shadow volume Objects within the volume should be shadowed Light source CS 4451 Fall 2002 8

Shadow Volume Result Objects within the volume are shadowed Shadow Volume Algorithm High-level view of the algorithm Given the scene and a light source position, determine the shadow volume Render the scene in two passes Draw scene with the light enabled, updating only fragments in unshadowed region Draw scene with the light disabled, updated only fragments in shadowed region But how to control update of regions? CS 4451 Fall 2002 9

2D Cutaway of a Shadow Volume Light source Shadowing object Surface outside shadow volume (illuminated) Shadow volume (infinite extent) Eye position (note that shadows are independent of the eye position) Partially shadowed object Surface inside shadow volume (shadowed) Counting Shadow Volume Enter/Leaves With a Stencil Buffer Render scene to initialize depth buffer Depth values indicate the closest visible fragments Use a stencil enter/leave counting approach Draw shadow volume twice using face culling 1st pass: render front faces and increment when depth test passes 2nd pass: render back faces and decrement when depth test passes Don t update depth or color Afterward, pixel s stencil is non-zero if pixel in shadow, and zero if illuminated CS 4451 Fall 2002 10

Why Eye-to-Object Stencil Enter/Leave Counting Approach Works Light source Shadowing object zero +1 zero Eye position +1 +2 +2 +3 Illuminated, Behind Shadow Volumes Light source Shadowing object zero +1 zero Eye position + + + - - - +2 +2 +1 +3 Unshadowed object Shadow Volume Count = +1+1+1-1-1-1 = 0 CS 4451 Fall 2002 11

Shadowed, Nested in Shadow Volumes Light source Shadowing object zero +1 zero + + + - Eye position +1 +2 +2 +3 Shadowed object Shadow Volume Count = +1+1+1-1 = 2 Illuminated, In Front of Shadow Volumes Light source Shadowing object zero +1 zero Eye position +1 +2 +2 +3 Shadowed object Shadow Volume Count = 0 CS 4451 Fall 2002 12

Problems Created by Near Plane Clipping Missed shadow volume intersection due to near clip plane clipping; leads to mistaken count zero Far clip plane +1 +3 +2 +2 +1 zero Near clip plane Visualizing the Stencil Buffer Counts Shadowed scene Stencil buffer contents Stencil counts beyond 1 are possible for multiple or complex occluders. GLUT shadowvol example credit: Tom McReynolds red = stencil value of 1 green = stencil value of 0 CS 4451 Fall 2002 13

Computing Shadow Volumes Harder than you might think Easy for a single triangle, just project out three infinite polygons from the triangle, opposite the light position For complex objects, projecting object s 2D silhouette is a good approximation (flat objects are easy) Static shadow volumes can be pre-compiled Stenciled Shadow Volumes in Practice (1) Scene with shadows. Yellow light is embedded in the green three-holed object. P inf is used for all the following scenes. Same scene visualizing the shadow volumes. CS 4451 Fall 2002 14

Stenciled Shadow Volumes in Practice (2) Details worth noting... Fine details: Shadows of the A, N, and T letters on the knight s armor and shield. Hard case: The shadow volume from the front-facing hole would definitely intersect the near clip plane. Stenciled Shadow Volumes in Practice (3) Alternate view of same scene with shadows. Yellow lines indicate previous view s view frustum boundary. Recall shadows are view-independent. Shadow volumes from the alternate view. CS 4451 Fall 2002 15

Shadow Volume Issues Practical considerations [Bergeron 86] If eye is in shadow volume, need to determine this and flip enabled & disabled lighting passes Shadow volume only as good as its tessellation Shadows tend to magnify limited tessellation of curved surfaces Must cap the shadow volume s intersection with the near clipping plane Open models and non-planar polygons Reconstructing Shadow Volume From a Depth Buffer Very clever idea [McCool 98] Render scene from light source with depth testing Read back the depth buffer Use computer vision techniques to reconstruct the shadow volume geometry from the depth buffer image Very reasonable results for complex scenes CS 4451 Fall 2002 16

Multiple Lights and Shadow Volumes Requires still more rendering passes, but can work! Shadows from different light sources overlap correctly Shadow Volumes from Area Light Sources Make soft shadows Shadow volumes work for point light sources Area light sources are common and make soft shadows Model an area light source as a collection of point light sources [Brotman & Badler 84] Use accumulation buffer or additive blending to accumulate soft shadow Linear cost per shadow volume sample CS 4451 Fall 2002 17

Soft Shadow Example Eight samples (more would be better) Note the banding artifacts Combined Shadow Algorithm Example: Shadow Volume + Planar Projection just logo shadow volume logo lacks shadow on the teapot teapot lacks shadow on the floor combined approach just planar projected shadows CS 4451 Fall 2002 18

Shadow Volume Advantages Omni-directional approach Not just spotlight frustums as with shadow maps Automatic self-shadowing Everything can shadow everything, including self Without shadow acne artifacts as with shadow maps Window-space shadow determination Shadows accurate to a pixel Or sub-pixel if multisampling is available Required stencil buffer broadly supported today OpenGL support since version 1.0 (1991) Direct3D support since DX6 (1998) Shadow Volume Disadvantages Ideal light sources only Limited to local point and directional lights No area light sources for soft shadows Requires polygonal models with connectivity Models must be closed (2-manifold) Models must be free of non-planar polygons Silhouette computations are required Can burden CPU Particularly for dynamic scenes Inherently multi-pass algorithm Consumes lots of GPU fill rate CS 4451 Fall 2002 19

Shadow Mapping Shadow Mapping Image-space shadow determination Lance Williams published the basic idea in 1978 Completely image-space algorithm no knowledge of scene s geometry is required must deal with aliasing artifacts Well known software rendering technique Pixar s RenderMan uses the algorithm Basic shadowing technique for Toy Story, etc. CS 4451 Fall 2002 20

The Shadow Mapping Concept (1) Depth testing from the light s point-of-view Two pass algorithm First, render depth buffer from the light s point-ofview the result is a depth map or shadow map essentially a 2D function indicating the depth of the closest pixels to the light This depth map is used in the second pass The Shadow Mapping Concept (2) Shadow determination with the depth map Second, render scene from the eye s point-of-view For each rasterized fragment determine fragment s XYZ position relative to the light compare the depth value at light position XY in the depth map to fragment s light position Z CS 4451 Fall 2002 21

The Shadow Mapping Concept (3) The Shadow Map Comparison Two values A = Z value from depth map at fragment s light XY position B = Z value of fragment s XYZ light position If B is greater than A, then there must be something closer to the light than the fragment then the fragment is shadowed If A and B are approximately equal, the fragment is lit Shadow Mapping in 2D (1) The A < B shadowed fragment case depth map image plane light source depth map Z = A eye position eye view image plane, a.k.a. the frame buffer fragment s light Z = B CS 4451 Fall 2002 22

Shadow Mapping in 2D (2) The A B unshadowed fragment case depth map image plane light source depth map Z = A eye position fragment s light Z = B eye view image plane, a.k.a. the frame buffer Visualizing the Shadow Mapping Technique (1) A fairly complex scene with shadows the point light source CS 4451 Fall 2002 23

Visualizing the Shadow Mapping Technique (2) Compare with and without shadows with shadows without shadows Visualizing the Shadow Mapping Technique (3) The scene from the light s point-of-view FYI: from the eye s s point-of-view again CS 4451 Fall 2002 24

Visualizing the Shadow Mapping Technique (4) The depth buffer from the light s point-of-view FYI: from the light s s point-of-view again Visualizing the Shadow Mapping Technique (5) Projecting the depth map onto the eye s view FYI: depth map for light s s point-of-view again CS 4451 Fall 2002 25

Visualizing the Shadow Mapping Technique (6) Projecting light s planar distance onto eye s view Visualizing the Shadow Mapping Technique (6) Comparing light distance to light depth map Green is where the light planar distance and the light depth map are approximately equal Non-green is where shadows should be CS 4451 Fall 2002 26

Visualizing the Shadow Mapping Technique (7) Scene with shadows Notice how specular highlights never appear in shadows Notice how curved surfaces cast shadows on each other More Examples Smooth surfaces with object self-shadowing Note object self-shadowing CS 4451 Fall 2002 27

More Examples Complex objects all shadow More Examples Even the floor casts shadow Note shadow leakage due to infinitely thin floor Could be fixed by giving floor thickness CS 4451 Fall 2002 28

Luxo Jr. in Real-time using Shadow Mapping Steve Jobs at MacWorld 2001 Japan shows this on a Mac with OpenGL using hardware shadow mapping Luxo Jr. Demo Details Luxo Jr. has two animated lights and one overhead light Three shadow maps dynamically generated per frame Complex geometry (cords and lamp arms) all correctly shadowed User controls the view, shadowing just works Real-time Luxo Jr. is technical triumph for OpenGL Only available in OpenGL. (Images are from web cast video of Apple s MacWorld Japan announcement.) CS 4451 Fall 2002 29