Shadow Rendering EDA101 Advanced Shading and Rendering

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

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

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

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

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

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. Last Time? Schedule. Questions? Today. Why are Shadows Important?

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

Computer Graphics Shadow Algorithms

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

Computer Graphics 10 - Shadows

Computer Graphics. Shadows

Shadows in the graphics pipeline

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

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

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

Advanced Shading I: Shadow Rasterization Techniques

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

Computergrafik. Matthias Zwicker. Herbst 2010

A Geometry-based Soft Shadow Volume Algorithm using Graphics Hardware

Shadows. COMP 575/770 Spring 2013

An Optimized Soft Shadow Volume Algorithm with Real-Time Performance

Robust Stencil Shadow Volumes. CEDEC 2001 Tokyo, Japan

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

Creating soft shadows

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

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

Shadow Algorithms. CSE 781 Winter Han-Wei Shen

Gaël Guennebaud Loïc Barthe, Mathias Paulin IRIT UPS CNRS TOULOUSE FRANCE Gaël Guennebaud Cyprus June 2006

Spatial Data Structures and Speed-Up Techniques. Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology

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

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

Shadow Techniques. Sim Dietrich NVIDIA Corporation

CS451Real-time Rendering Pipeline

LOD and Occlusion Christian Miller CS Fall 2011

Recall: Indexing into Cube Map

Approximate Soft Shadows on Arbitrary Surfaces using Penumbra Wedges

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

In- Class Exercises for Shadow Algorithms

Computer Graphics Introduction. Taku Komura

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

The Traditional Graphics Pipeline

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

Real-Time Shadows. André Offringa Timo Laman

Illumination and Geometry Techniques. Karljohan Lundin Palmerius

Rasterization Overview

Optimisation. CS7GV3 Real-time Rendering

Siggraph Full-Day Course #26. Real-Time Shadowing Techniques

Volume Shadows Tutorial Nuclear / the Lab

Level of Details in Computer Rendering

Fondamenti di Grafica 3D The Rasterization Pipeline.

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

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

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

Soft Shadow Maps. Soft Shadow Maps for Linear Lights

Penumbra Maps: Approximate Soft Shadows in Real-Time

Visible-Surface Detection Methods. Chapter? Intro. to Computer Graphics Spring 2008, Y. G. Shin

Stencil Shadow Volumes

SHADOW RENDERING TECHNIQUES: HARD AND SOFT

Shadow Mapping. Marc Stamminger, University of Erlangen-Nuremberg

Soft Shadow Volumes for Ray Tracing Samuli Laine, Timo Aila, Ulf Assarsson, Jaakko Lethinen, Tomas Akenine-Möller presented by Manuel Lang

Simpler Soft Shadow Mapping Lee Salzman September 20, 2007

Multi-View Soft Shadows. Louis Bavoil

CSE 167: Lecture #5: Rasterization. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2012

Triangle Rasterization

The Traditional Graphics Pipeline

The Traditional Graphics Pipeline

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

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

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

Advanced Shading and Texturing

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

Vincent Forest, Loïc Barthe, Mathias Paulin. IRIT-UPS-CNRS University of Toulouse, France

EECS 487: Interactive Computer Graphics

FRUSTUM-TRACED RASTER SHADOWS: REVISITING IRREGULAR Z-BUFFERS

INFOGR Computer Graphics. J. Bikker - April-July Lecture 10: Ground Truth. Welcome!

Projective Shadows. D. Sim Dietrich Jr.

Ulf Assarsson Department of Computer Engineering Chalmers University of Technology

Real-Time Universal Capture Facial Animation with GPU Skin Rendering

6.837 Introduction to Computer Graphics Quiz 2 Thursday November 20, :40-4pm One hand-written sheet of notes allowed

Deferred Rendering Due: Wednesday November 15 at 10pm

Multi-Threaded Shadow Volumes on Mainstream Graphics Hardware

Real-Time Volume Shadow using Visible-Non Visible Algorithm

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

Nonphotorealism. Christian Miller CS Fall 2011

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

Culling. Computer Graphics CSE 167 Lecture 12

Physically-Based Laser Simulation

Shadow and Environment Maps

Computer Graphics. Lecture 14 Bump-mapping, Global Illumination (1)

3D graphics, raster and colors CS312 Fall 2010

Efficient Image-Based Methods for Rendering Soft Shadows. Hard vs. Soft Shadows. IBR good for soft shadows. Shadow maps

Rasterization. MIT EECS Frédo Durand and Barb Cutler. MIT EECS 6.837, Cutler and Durand 1

Practical Shadow Mapping

Texture-Mapping Tricks. How Bad Does it Look? We've Seen this Sort of Thing Before. Sampling Texture Maps

Graphics Hardware and Display Devices

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

Reading. 18. Projections and Z-buffers. Required: Watt, Section , 6.3, 6.6 (esp. intro and subsections 1, 4, and 8 10), Further reading:

Basic GPU techniques Josef Pelikán CGG MFF UK Praha.

Speeding up your game

Transcription:

Shadow Rendering EDA101 Advanced Shading and Rendering 2006 Tomas Akenine-Möller 1

Why, oh why? (1) Shadows provide cues about spatial relationships among objects 2006 Tomas Akenine-Möller 2

Why, oh why? (2) Shadows increase the level of realism [Oh, well, flying bar stools may not be realistic] 2006 Tomas Akenine-Möller 3

Atmosphere... Why, oh why? (3) Neverwinter Nights Image courtesy of BioWare 2006 Tomas Akenine-Möller 4

Who s responsible? In a ray tracer, you kind of get them for free Very little coding, good results Though, soft shadows can be very expensive For real-time rendering, using, e.,g OpenGL You re responsible Often need quite a bit of coding Often need to be aware of artifacts Can be costly 2006 Tomas Akenine-Möller 5

Definitions Light sources Shadows occluder and receivers Light source Occluder Occluder and receiver Receiver N.B. Occluder could be called Creator 2006 Tomas Akenine-Möller 6

Hard vs soft shadows Two different light source types point source area source umbra penumbra umbra 2006 Tomas Akenine-Möller 7

Umbra and penumbra Point light source Area light source umbra umbra penumbra 2006 Tomas Akenine-Möller 8

Topics of today s lecture The shadow mapping algorithm The shadow volume algorithm Soft shadows A real-time soft shadow volume algorithm 2006 Tomas Akenine-Möller 9

Ways of thinking about shadows As separate objects (like Peter Pan's shadow) As volumes of space that are dark As places not seen from a light source looking at the scene 2006 Tomas Akenine-Möller 10

Shadow mapping Introduced by Lance Williams in 1978 Used by many (e.g., Pixar s Renderman) Can also be used with current graphics cards in real time Conceptually very simple: Render to Z-buffer as seen from the light source this buffer is the shadow map Render from the eye, and transform each pixel into the coordinate system of the light Compare depths shadow or lit 2006 Tomas Akenine-Möller 11

The shadow map Turn off texturing, writes to the color buffer, etc. Only write to Z-buffer Aim the frustum of the light towards the region that should contain shadows White is far, black is near 2006 Tomas Akenine-Möller 12

Using the shadow map When scene is viewed, check viewed location in light's shadow buffer If point's depth is greater than shadow depth, object is in shadow. shadow depth map For each pixel, compare distance to light with the depth stored in the shadow map 2006 Tomas Akenine-Möller 13

Shadow map The result Need to regenerate the shadow map for dynamic scenes, but it can be reused for static scenes. 2006 Tomas Akenine-Möller 14

Shadow mapping problems (1) Low resolution of shadow map Gives jagged shadow edges Lots of research, and improvements exist Image courtesy Marc Stamminger 2006 Tomas Akenine-Möller 15

Shadow mapping problems (2) Self-shadowing What if an object shadows itself? floating point imprecision (since you use a floating point matrix transform) But more importantly, a screen space pixel seldom maps exactly to the center of a shadow map pixel! 2006 Tomas Akenine-Möller 16

Shadow mapping problems (2) Choosing bias (epsilon) is not trivial! Light source One pixel in the shadowmap Depth stored in SM, d sm Depth of pixel when rendered from the eye, d eye Assume that the ellipse and rectangle is the same surface We do not want incorrect self-shadowing Solution: add bias d sm + bias < d eye shadow 2006 Tomas Akenine-Möller 17

Too low bias You need to make sure the surface seen by the light does not shadow itself Surface acne 2006 Tomas Akenine-Möller 18

Too high bias Too much bias and the shadow floats. Image also shows jaggedness of shadow boundary 2006 Tomas Akenine-Möller 19

The shadow volume algorithm Crow's (1977) idea Shadow volumes define volumes of space in shadow. From the School of Leonardo Da Vinci 2006 Tomas Akenine-Möller 20

Shadow volume concept Shadow volume concept Create volumes of space in shadow from each polygon in light. Each triangle creates 3 projecting quads 2006 Tomas Akenine-Möller 21

Using the volume To test a point, count the number of polygons between it and the eye. If we look through more frontfacing than backfacing polygons, then in shadow. backfacing frontfacing 2006 Tomas Akenine-Möller 22

The stencil buffer Used by the shadow volume algorithm Is just another buffer (often 8 bits per pixel) When rendering to it, we can add, subtract, etc Then, the resulting image can be used to mask off subsequent rendering Stencil Buffer Mask Rendered image result 2006 Tomas Akenine-Möller 23

Z-pass by example: how the stencil buffer is used What we have... What we wnat... 2006 Tomas Akenine-Möller 24

How To Do It (Z-pass) A four pass process [Heidmann91]: 1st Pass: render the scene with just ambient and emission lighting. Turn off updating Z-buffer and writing to color buffer (i.e. Z-compare, draw to stencil only). 2nd pass: render front facing shadow volume polygons to stencil buffer, incrementing count. 3rd pass: render backfacing shadow volume polygons to stencil, decrementing. 4th pass: render diffuse,ambient and specular where stencil buffer is 0. 2006 Tomas Akenine-Möller 25

Eye Location Problem If the eye location is inside one or more shadow volumes, count is wrong. Eye problem fixed by clearing stencil buffer to # of volumes eye is inside. 2006 Tomas Akenine-Möller 26

Frustum Location Problem Frustum s near (hither) plane overlaps a shadow volume, frontface counts missed Some form of capping is needed to make the shadow volume whole again (not trivial, nor robust) 2006 Tomas Akenine-Möller 27

Solution: Count Beyond Surface Z-fail-algorithm Render to stencil only when shadow volume Z >= stored Z! must cap ends of shadow volumes (or project to infinity, w=0 for vertices) 2006 Tomas Akenine-Möller 28

Why This Works (f - b) in front of plane = (b - f) in back 2-2 = 0 violet - red 2 = 2 1 = 2-1 2006 Tomas Akenine-Möller 29

Z-fail by example 2006 Tomas Akenine-Möller 30

Merging shadow volumes Edge shared by two polygons facing the light creates front and backfacing quad. This interior edge makes two quads, which cancel out Instead, use only potential silhouette edges as seen from the light: 2006 Tomas Akenine-Möller 31

Shadow maps vs shadow volumes Shadow Volumes Good: Anything can shadow anything, including self- shadowing, and the shadows are crisp. Bad: 3 or 4 passes, shadow polygons must be generated and rendered (lots of polygons & fill), CPU intensive, complicates skinning. Ugly: counting problems if view frustum overlaps. Shadow Maps Good: Anything to anything, constant cost regardless of complexity, map can sometimes be reused. Bad: Frustum limited. Ugly: Jagged shadows if res too low, biasing headaches. 2006 Tomas Akenine-Möller 32

A soft shadow volume algorithm In real time... 2006 Tomas Akenine-Möller 33

Soft shadows 2006 Tomas Akenine-Möller 34

Geometrically-correct soft shadows Light samples (L) L*R rays to test!! Receiver samples (R) T: num triangles in scene L*R rays is a lot of work For example, 200 * (1920x1080) = 400M rays Are the rays blocked? Ray tracing O(log T) soft shadows O(L*R*log T) 2006 Tomas Akenine-Möller 35

Soft shadow algorithms in general (Real-time...) Fundamental and inherently difficult problem in computer graphics 2006 Tomas Akenine-Möller 36

The general idea: Penumbra Wedges A primitive for bounding the penumbra region imposed by a silhouette edge In two dimensions A single penumbra wedge 2006 Tomas Akenine-Möller 37

Important simplification Compute potential silhoutte edges as seen from the center of the light source Use one penumbra wedge per such edge 2006 Tomas Akenine-Möller 38

A wedge for each silhouette edge 2006 Tomas Akenine-Möller 39

A wedge for each silhouette edge 2006 Tomas Akenine-Möller 40

A wedge for each silhouette edge 2006 Tomas Akenine-Möller 41

A wedge for each silhouette edge 2006 Tomas Akenine-Möller 42

A wedge for each silhouette edge 2006 Tomas Akenine-Möller 43

Rasterizing the wedges 2006 Tomas Akenine-Möller 44

Rasterizing the wedges 2006 Tomas Akenine-Möller 45

Rasterizing the wedges 2006 Tomas Akenine-Möller 46

Rasterizing the wedges 2006 Tomas Akenine-Möller 47

Rasterizing the wedges Skipping wedge construction see reading list 2006 Tomas Akenine-Möller 48

Visibility computations Really want to compute how much of the light source that we can see 2006 Tomas Akenine-Möller 49

Each silhouette edge s contribution to visibility From the point-to-be-shaded, project the edge onto the light source Compute the area, called coverage, of the dark gray region Add/subtract to a visibility buffer 2006 Tomas Akenine-Möller 50

Precomputed 4D textures 2006 Tomas Akenine-Möller 51

Used as a lookup table Due to intelligent caches fast! Can have textured lights (and animated) 32x32 light texture 3 MB Why 4D textures? 2006 Tomas Akenine-Möller 52

Some examples using textured light sources 2006 Tomas Akenine-Möller 53

Example of how it works 2006 Tomas Akenine-Möller 54

The algorithm 1st pass: Render hard shadow quads (as usual) To be sure that we register when we enter/exit umbra 2nd pass: compensate for overstated umbra 2006 Tomas Akenine-Möller 55

Combine shadow mask with lighting and texturing = = 2006 Tomas Akenine-Möller Images courtesy of Jonas Svensson and Ulf 56 Borgenstam

Disadvantages of Soft Shadow Volumes Cases handled 100% correctly: An arbitrary non selfintersecting, planar polygon If the silhouette of the object is the same from all points on the area light source There are still a few approximations Shadow volumes do in general not scale well with scene complexity 2006 Tomas Akenine-Möller 57

Artifacts: Single silhouette error Overlapping geometry is handled incorrectly 2006 Tomas Akenine-Möller 58

Comparison Hard vs Soft Hard to beat the soft! Soft is more realistic Soft contains less high frequency content Soft provides better spatial relationship cues Soft seldom gives aliasing effects But... Soft costs more More research to be done before the final answer is here!! 2006 Tomas Akenine-Möller 59

Required reading list (i.e., if you want to pass the exam, read those papers) Section 6.12 (intro), 6.12.2-6.12.4 in Real-Time Rendering, Tomas Akenine-Möller and Eric Haines, 2nd edition, 2002. Paper copies will be available. Ulf Assarsson, and Tomas Akenine-Möller, A Geometrybased Soft Shadow Volume Algorithm, ACM Transactions on Graphics (Proceedings of ACM SIGGRAPH), vol. 22, no. 3, pp. 511-520, July 2003 2006 Tomas Akenine-Möller 60