Computer Graphics 10 - Shadows

Similar documents
Computer Graphics. Shadows

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

Advanced Shading I: Shadow Rasterization Techniques

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

Shadow Algorithms. CSE 781 Winter Han-Wei Shen

Pipeline Operations. CS 4620 Lecture 10

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?

Computer Graphics Introduction. Taku Komura

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

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

Creating soft shadows

Shadow Rendering EDA101 Advanced Shading and Rendering

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

Computer Graphics. Lecture 9 Environment mapping, Mirroring

Computer Graphics 7 - Texture mapping, bump mapping and antialiasing

Shadows in the graphics pipeline

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

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

Computergrafik. Matthias Zwicker. Herbst 2010

Z-Buffer hold pixel's distance from camera. Z buffer

Pipeline Operations. CS 4620 Lecture 14

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

Computer Graphics. Lecture 13. Global Illumination 1: Ray Tracing and Radiosity. Taku Komura

Recall: Indexing into Cube Map

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

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

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

Shadows. COMP 575/770 Spring 2013

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

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

Computer Graphics Shadow Algorithms

Computer Graphics. Lecture 10. Global Illumination 1: Ray Tracing and Radiosity. Taku Komura 12/03/15

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

Computer Graphics 7 - Rasterisation

Models and Architectures

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

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

Graphics and Interaction Rendering pipeline & object modelling

Interpolation using scanline algorithm

TSBK03 Screen-Space Ambient Occlusion

CS 130 Final. Fall 2015

Hidden surface removal. Computer Graphics

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

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

Introduction to Computer Graphics with WebGL

Shadows and Texture Mapping

Deferred Rendering Due: Wednesday November 15 at 10pm

Texture. Texture Mapping. Texture Mapping. CS 475 / CS 675 Computer Graphics. Lecture 11 : Texture

CS 475 / CS 675 Computer Graphics. Lecture 11 : Texture

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

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

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

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

Models and Architectures. Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico

Nonphotorealism. Christian Miller CS Fall 2011

CS4620/5620: Lecture 14 Pipeline

Illumination and Geometry Techniques. Karljohan Lundin Palmerius

CS230 : Computer Graphics Lecture 4. Tamar Shinar Computer Science & Engineering UC Riverside

An Optimized Soft Shadow Volume Algorithm with Real-Time Performance

Graphics for VEs. Ruth Aylett

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

High Performance Visibility Testing with Screen Segmentation

COMP30019 Graphics and Interaction Scan Converting Polygons and Lines

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

03 RENDERING PART TWO

Robust Stencil Shadow Volumes. CEDEC 2001 Tokyo, Japan

Mach band effect. The Mach band effect increases the visual unpleasant representation of curved surface using flat shading.

Computer Graphics Lecture 11

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

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

Ray-Tracing. Misha Kazhdan

Soft Planar Shadows Using Plateaus Eric Haines Autodesk, Inc. Ithaca, New York June 18, 2001

Chapter 7 - Light, Materials, Appearance

Recollection. Models Pixels. Model transformation Viewport transformation Clipping Rasterization Texturing + Lights & shadows

Lets assume each object has a defined colour. Hence our illumination model is looks unrealistic.

Rasterization Overview

Real-Time Rendering. Tomas Möller Eric Haines. A K Peters Natick, Massachusetts

Previously... contour or image rendering in 2D

Two basic types: image-precision and object-precision. Image-precision For each pixel, determine which object is visable Requires np operations

CEng 477 Introduction to Computer Graphics Fall 2007

Volume Rendering. Computer Animation and Visualisation Lecture 9. Taku Komura. Institute for Perception, Action & Behaviour School of Informatics

Computer Graphics I Lecture 11

Introduction to Visualization and Computer Graphics

Approximate Soft Shadows on Arbitrary Surfaces using Penumbra Wedges

CHAPTER 1 Graphics Systems and Models 3

Introduction Rasterization Z-buffering Shading. Graphics 2012/2013, 4th quarter. Lecture 09: graphics pipeline (rasterization and shading)

Computer Graphics 1. Chapter 7 (June 17th, 2010, 2-4pm): Shading and rendering. LMU München Medieninformatik Andreas Butz Computergraphik 1 SS2010

COMP30019 Graphics and Interaction Rendering pipeline & object modelling

Lecture outline. COMP30019 Graphics and Interaction Rendering pipeline & object modelling. Introduction to modelling

Visibility. Tom Funkhouser COS 526, Fall Slides mostly by Frédo Durand

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

Soft Shadows: Heckbert & Herf. Soft shadows. Heckbert & Herf Soft Shadows. Cornell University CS 569: Interactive Computer Graphics.

Shadow Techniques. Sim Dietrich NVIDIA Corporation

Real Time Rendering of Expensive Small Environments Colin Branch Stetson University

CS 488. More Shading and Illumination. Luc RENAMBOT

Fast Calculation of Soft Shadow Textures Using Convolution

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

Lecture 15: Shading-I. CITS3003 Graphics & Animation

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

Transcription:

Computer Graphics 10 - Shadows Tom Thorne Slides courtesy of Taku Komura www.inf.ed.ac.uk/teaching/courses/cg

Overview Shadows Overview Projective shadows Shadow textures Shadow volume Shadow map Soft shadows

Why Shadows? Shadows tell us about relative locations and movements of objects http://gandalf.psych.umn.edu/users/kersten/kerstenlab/images/ball-in-a-box.mov

What are shadows? Shadows can be considered as areas hidden from the light source We can find shadows on a surface A due to object B by projecting B onto A, with the light source as center of projection

Soft and hard shadows Point light sources have hard edges, area lights have soft edges Soft shadows Hard shadows

Rendering shadows Rendering shadows is important, but not straightforward Precise rendering requires ray tracing or global illumination, which are computationally very expensive In order to avoid these techniques many approaches have been proposed for the rasterisation pipeline Projective Shadows Shadow textures Shadow volumes Shadow maps Soft shadows

Overview Shadows Overview Projective shadows Shadow textures Shadow volume Shadow map Soft shadows

Projective shadows L(light position) (lx,ly,lz) Shadows on planes from point light sources (xp,yp,zp) Relatively easy to compute (xsw,ysw,zsw)

Point light shadows Light source Object Floor Lecture 9

Point light shadows Blinn 88 gives a matrix that works for local point light sources (based on projection) Takes advantage of perspective transformation (and homogeneous coordinates)

Drawing shadows We have a matrix that transforms an object into it s shadow Drawing the shadow: Multiply the shadow matrix by the model transformation Redraw the object translucently in grey v 0 = M s M g l v shadow vertex shadow matrix point in local coordinates

Alpha blending A technique to render semi-transparent objects Will cover more in the following lecture

Lifting above the surface Light Viewer Light Viewer Shadow on hit polygon Shadow positioned above hit polygon Trick - lift the shadow off the plane to avoid Z-buffer quantisation errors

Point shadow problems Shadows can only be cast onto planes and not arbitrary objects The resulting shadows have hard edges If there is texturing on the plane, grey shadows look bad If we use blending, areas where multiple polygons overlapping look darker Shadows need to be re-rendered at every frame

Improving projected shadows with a stencil Turn on the stencil for pixels on the plane Only render shadows on pixels with the stencil turned on After rendering the shadow, the stencil is set to zero No overdrawing with multiple polygons No need to lift shadows above the floor Shadows are not rendered outside the plane Still only works on planes

Overview Shadows Overview Projective shadows Shadow textures Shadow volume Shadow map Soft shadows

Shadow textures Use a shadow image as a projective texture Generate an image of the occluder from the light s point of view and colour it grey Produce a shadow by texture mapping this image onto the background object

Computing the uv coordinates To map the shadow texture, we need to know the uv coordinates of the texture at every vertex of the background mesh

Computing the uv coordinates View the object from the light source Project the background object onto the projection plane used to produce the shadow texture Obtain the (x,y) coordinates and normalize These become the uv coordinates

Shadow texture pros and cons Pros The shadow does not need to be recomputed if the occluder does not move Cons?

Light mapping Producing spotlight effects Difficult in traditional graphics pipeline Multiply light map by the original diffuse texture and map onto the surface

Light maps View the objects from the light source Compute the uv coordinates by projecting the object onto the screen space

Overview Shadows Overview Projective shadows Shadow textures Shadow volume Shadow map Soft shadows

Shadow volumes In reality the shadow of an object is a volume rather than a two dimensional area on a plane Shadow volumes models shadow regions as volumes

Using shadow volumes Two stages: Compute the shadow volume formed by a light source and the shadowing objects Each triangle produces a shadow volume

Using shadow volumes Two stages: Compute the shadow volume formed by a light source and the shadowing objects Each triangle produces a shadow volume Check whether a point is inside/outside the shadow volume Inside -> shadowed Outside -> illuminated

Back face culling We do not draw polygons facing the other direction Test z component of surface normals, if it is negative then cull If N.V>0 we are viewing the back face v < 0 < 0 > 0 > 0 Culled faces > 0 Can also use to cull front faces in shadow volume rendering

Shadow volumes with stencil buffers Render the scene with ambient light Clear the stencil buffer, and render the shadow volume with the colour buffer off and back face culling on Whenever a rendered fragment of the shadow volume is closer than the depth of the other objects, increment the stencil value for that pixel Turn on the front face culling and turn off the back face culling Whenever a rendered fragment of the shadow volume is closer than the depth of the other objects, decrease the stencil value for that pixel Render the scene using diffuse and specular reflection for the area where the stencil value is 0

Stencil buffer Render the scene with ambient light

Stencil buffer Render the scene with ambient light Clear the stencil buffer, and render the shadow volume with the colour buffer off and back face culling on Whenever a rendered fragment of the shadow volume is closer than the depth of the other objects, increment the stencil value for that pixel

Stencil buffer Turn on the front face culling and turn off the back face culling Whenever a rendered fragment of the shadow volume is closer than the depth of the other objects, decrease the stencil value for that pixel Render the scene using diffuse and specular reflection for the area where the stencil value is 0

Stencil buffer Render the scene using diffuse and specular reflection for the area where the stencil value is 0

Shadow volume pros and cons Pros Do not need to manually specify the shadowed objects The occluder can shadow itself High precision Cons Bottleneck at the rasteriser Many shadow volumes covering many pixels

Overview Shadows Overview Projective shadows Shadow textures Shadow volume Shadow map Soft shadows

Shadow mapping Another method that can handle shadows of multiple objects cast onto arbitrary shaped objects Uses the z-buffer

Shadow map Preparation Prepare a depth buffer for each light Render the scene from the light position Save the depth information in the depth buffer

Shadow map Rendering the scene 1. Render the objects; whenever rendering an object, check if it is shadowed or not by transforming its coordinate into the light space 2. After the transformation, if the depth value is larger than that in the light s depth buffer it should be shadowed

Shadow map Works with multiple light sources

Shadow map - comparison Self shadows? Need to specify the occluder/occludee?

Shadow map comparison When there are many shadows this is faster compared to a shadow volume Precision is low compared to a shadow volume

Adaptive shadow mapping If the resolution of the map is lower than the rendered image, we have many artifacts Need a higher resolution shadow map Change resolution of maps according to the viewport Adaptive Shadow Maps, Fernando et al. SIGGRAPH 2001

Overview Shadows Overview Projective shadows Shadow textures Shadow volume Shadow map Soft shadows

Soft shadows Produced by area lights Umbra - totally blocked Penumbra partially blocked from the light source Can model with a collection of point light sources

Soft shadowing by multiple point light sources Additive blending is used to accumulate the contribution of each light Can apply both planar projected shadows approach or shadow volume approach Then apply convolution The softness of the shadow depends on an adequate number of samples. The time to render the scene increases linearly with the number of samples used to approximate an area light source. Artifacts are introduced if not enough samples are used Drawback: slow

Other techniques: Gooch et al. Moving the projected plane up and down instead of moving the light source The projections cast upon it are averaged Can use projective shadows: Applying the same texture multiple times to planes of different heights and overlapping them Interactive technical illustration, Gooch et al. I3D 1998

Other techniques: Haines 2001 First create a hard shadow and then paint the silhouette edges with gradients that go from dark in the center to white on the edge. The gradient areas have a width proportional to the height of the silhouette edge casting the shadow Lecture 9

Problems The umbra is too large as it is produced by a point light source Actual area light sources have a smaller umbra

References http://threejs.org/examples/#webgl_shadowmap (press t to show depth map) http://threejs.org/examples/#webgl_shadowmap_viewer Akenine-Möller, Chapter 9.1 (Shadows) Real-Time Shadows, Eric Haines, Tomas Möller, GDC 2001, CMP, 335-352 Foley, Chapter 16.4