Computer Graphics. Shadows

Similar documents
Computer Graphics 10 - Shadows

Pipeline Operations. CS 4620 Lecture 10

Advanced Shading I: Shadow Rasterization Techniques

Shadow Algorithms. CSE 781 Winter Han-Wei Shen

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

Computergrafik. Matthias Zwicker. Herbst 2010

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

Computer Graphics. Lecture 9 Environment mapping, Mirroring

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

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

Shadows in the graphics pipeline

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

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

Shadow Rendering EDA101 Advanced Shading and Rendering

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

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?

Pipeline Operations. CS 4620 Lecture 14

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

Computer Graphics Introduction. Taku Komura

Hidden surface removal. Computer Graphics

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

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

Creating soft shadows

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

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

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

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

Recall: Indexing into Cube Map

Shadows. COMP 575/770 Spring 2013

Models and Architectures

Deferred Rendering Due: Wednesday November 15 at 10pm

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

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

Computer Graphics Shadow Algorithms

Interpolation using scanline algorithm

CS 130 Final. Fall 2015

Graphics and Interaction Rendering pipeline & object modelling

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

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

Illumination and Geometry Techniques. Karljohan Lundin Palmerius

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

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

Computer Graphics. Lecture 9 Hidden Surface Removal. Taku Komura

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

Shadow Techniques. Sim Dietrich NVIDIA Corporation

Introduction to Computer Graphics with WebGL

TSBK03 Screen-Space Ambient Occlusion

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

Robust Stencil Shadow Volumes. CEDEC 2001 Tokyo, Japan

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

CEng 477 Introduction to Computer Graphics Fall 2007

Shadows and Texture Mapping

High Performance Visibility Testing with Screen Segmentation

Introduction to Visualization and Computer Graphics

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

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

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

CS 4620 Program 3: Pipeline

Volume Shadows Tutorial Nuclear / the Lab

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

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

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

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

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

Graphics for VEs. Ruth Aylett

CS4620/5620: Lecture 14 Pipeline

CSE 690: GPGPU. Lecture 2: Understanding the Fabric - Intro to Graphics. Klaus Mueller Stony Brook University Computer Science Department

COMP30019 Graphics and Interaction Rendering pipeline & object modelling

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

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

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

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

CS 381 Computer Graphics, Fall 2008 Midterm Exam Solutions. The Midterm Exam was given in class on Thursday, October 23, 2008.

Assignment 6: Ray Tracing

Computer Graphics Lecture 11

CS452/552; EE465/505. Intro to Lighting

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

Hidden Surface Removal

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

03 RENDERING PART TWO

Homework #2. Shading, Ray Tracing, and Texture Mapping

CMSC427: Computer Graphics Lecture Notes Last update: November 21, 2014

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

Announcements. Written Assignment 2 is out see the web page. Computer Graphics

Photorealistic 3D Rendering for VW in Mobile Devices

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

CHAPTER 1 Graphics Systems and Models 3

Rasterization Overview

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

9. Illumination and Shading

CS559: Computer Graphics. Lecture 12: Antialiasing & Visibility Li Zhang Spring 2008

Lecture 15: Shading-I. CITS3003 Graphics & Animation

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

Visibility: Z Buffering

Adaptive Point Cloud Rendering

Surface Graphics. 200 polys 1,000 polys 15,000 polys. an empty foot. - a mesh of spline patches:

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

Projections and Hardware Rendering. Brian Curless CSE 557 Fall 2014

Transcription:

Computer Graphics Lecture 10 Shadows Taku Komura

Today Shadows Overview Projective shadows Shadow texture Shadow volume Shadow map Soft shadows

Why Shadows? Shadows tell us about the relative locations and motions of objects https://www.youtube.com/watch?v=pvtasc-czmw http://gandalf.psych.umn.edu/users/kersten/kersten-lab/images/ball-in-a-box.mov

What are shadows? Shadows can be considered as areas hidden from the light source A shadow on A due to B can be found by projecting B onto A with the light as the center of projection

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

Rendering Shadows Despite its importance, rendering shadows is not very straight forward Precise rendering of shadows require ray tracing or global illumination techniques, which are very computationally costly In order to avoid such intense computation, many techniques have been proposed for the graphics pipeline. Projective shadows Shadow texture Shadow volume Shadow map Soft shadows

Today Shadows Overview Projective shadows Shadow texture Shadow volume Shadow map Soft shadows

Projective Shadows Here I talk about shadows on planes produced by point light sources These are relatively easy to compute (x p,y p,z p ) L(light position) (l x,l y,l z ) (x sw,y sw,z sw )

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 the Shadow We now have a matrix that transforms an object into its shadow Drawing the shadow: Multiply the shadow matrix into the model transformation Redraw the object in grey with blending on (making them translucent) v = Ms Ml_to_w 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 the shadow above the surface Light Viewer Shadow height equal with hit polygon Shadow height above hit polygon Tricks: Lift the shadow a little off the plane to avoid z-buffer quantization errors

Point Light Shadows : problem????

Some review Three types of buffers: (images) Colour buffer Z-buffer Stencil buffer Color depth on/off, or integers

Improving Planar Projected Shadows with Stencil Set the stencil on for the pixels of the floor Only render the shadows on pixels that the stencil is on Once a shadow is rendered, the stencil value is set to zero subsequent pixel updates will fail No need to lift the shadows above the floor Shadows not rendered outside the floor But still we can only shadow on planes Lecture 9

Today Shadows Overview Projective shadows Shadow texture Shadow volume Shadow map Soft shadows

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

Q: How do we compute the uv coordinates? For mapping the shadow texture, we need to know the uv coordinates of the texture at every vertex of the background mesh

Q: How do we compute 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 This becomes the uv coordinates

Shadow Texture : Cons and Pros Pros How is it good compared to projective shadows? The shadow does not need to be recomputed if the occluder does not move. Cons 1.? 2.? 3.?

extra: Light Mapping Producing spotlight effects Not so easy in ordinary graphics pipeline Multiply the light map to the original diffuse texture and map to the surface

extra: Light maps by projective textures 1. View the objects from the light source 2. Compute the uv coordinates by projecting the object(s) onto the screen space

Today Shadows Overview Projective shadows Shadow texture Shadow volume Shadow map Soft shadows

Shadow Volume In the real world, the shadow cast by an object blocking a light is a volume, not merely some two-dimensional portion of a plane. An algorithm that models shadow regions as volumes.

Two stages Using Shadow Volumes to Render Shadows Compute the shadow volume formed by a light source and a set of shadowing objects. Every triangle produces a shadow volume

Two stages Using Shadow Volumes to Render Shadows Compute the shadow volume formed by a light source and a set of shadowing objects. Every triangle produces a shadow volume Check whether the point is inside / outside the shadow volume inside shadowed Outside illuminated by light source

Back Face Culling We do not draw polygons facing the other direction Test z component of surface normals. If negative cull, since normal points away from viewer. Or if N. V > 0 we are viewing the back face so polygon is obscured.

Shadow volume check by 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 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, decrement the stencil value for that pixel Render the scene using diffuse and specular reflection for the area that the stencil value is 0

Doing this using a 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 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, decrement the stencil value for that pixel Render the scene using diffuse and specular reflection for the area that the stencil value is 0

Doing this using a 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 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, decrement the stencil value for that pixel Render the scene using diffuse and specular reflection for the area that the stencil value is 0

Doing this using a 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 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, decrement the stencil value for that pixel Render the scene using diffuse and specular reflection for the area that the stencil value is 0

Doing this using a 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 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, decrement the stencil value for that pixel Render the scene using diffuse and specular reflection for the area that the stencil value is 0

Advantage / Disadvantages of Shadow Volume Advantage Do not need to manually specify the shadowed objects The occluder can shadow itself High precision Disadvantage Bottleneck at the rasterizer Many shadow volumes covering many pixels

Today Shadows Overview Projective shadows Shadow texture Shadow volume Shadow map Soft shadows

Shadow Mapping Another method that can handle the shadow of multiple objects casted onto objects of arbitrary shapes Make use of 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

Can Handle Multiple Light Source

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

Shadow Map - comparison (2) Advantage When there are many objects/light sources, it is faster than shadow volume why? Disadvantage - How is the precision compared with shadow volume?

Adaptive Shadow Mapping The resolution of the shadow maps is lower than that of the rendered image Many box shape artifacts Need to use shadow map of higher resolutions Changing the resolution of the shadow map according to the viewpoint Adaptive Shadow Maps, Fernando et al. SIGGRAPH 2001

Today Shadows Overview Projective shadows Shadow texture Shadow volume Shadow map Soft shadows

Soft Shadows Made by area light umbra totally blocked from the light source Penumbra partially blocked from the light source Can be modelled by 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 to generate soft shadow : 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 to generate soft shadow : 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 edges The gradient areas have a width proportional to the height of the silhouette edge casting the shadow Lecture 9

Problems with Gooch et al. and Haine s method The umbra ( the dark shadowed area) becomes too large as it is produced by a point light An area light usually decreases the size of the umbra

Summary Shadows need to be added with extra processing in graphics pipelines. Introduced the following methods Projective shadows Shadow texture Shadow volume Shadow map Soft shadows

Readings Real-time Rendering 2 nd Edition Chapter 6.12 Real-Time Shadows, Eric Haines, Tomas M oller, GDC 2001, CMP, 335-352 Foley, Chapter 16.4 Many OpenGL demos http://www.opengl.org/resources/code/sampl es/advanced/advanced96/programs.html