Computer Graphics (CS 543) Lecture 9b: Shadows and Shadow Maps. Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

Similar documents
Recall: Indexing into Cube Map

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

Shading. Slides by Ulf Assarsson and Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology

Computer Graphics. - Shading & Texturing -

Computer Graphics (CS 543) Lecture 8c: Environment Mapping (Reflections and Refractions)

Slide 1 Lecture 18 Copyright

Shadow Rendering EDA101 Advanced Shading and Rendering

CS451Real-time Rendering Pipeline

CS Computer Graphics: Hidden Surface Removal

Computer Graphics (CS 543) Lecture 13b Ray Tracing (Part 1) Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

Computer Graphics CS 543 Lecture 1 (Part I) Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

Computer Graphics (CS 543) Lecture 10: Normal Maps, Parametrization, Tone Mapping

Shadows. Prof. George Wolberg Dept. of Computer Science City College of New York

Lecture outline Graphics and Interaction Scan Converting Polygons and Lines. Inside or outside a polygon? Scan conversion.

Computer Graphics (CS 4731) Lecture 16: Lighting, Shading and Materials (Part 1)

Computer Graphics (CS 4731) Lecture 11: Implementing Transformations. Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

Rasterization Overview

Computer Graphics (CS 543) Lecture 1 (Part 1): Introduction to Computer Graphics

Computer Graphics (CS 543) Lecture 7b: Intro to lighting, Shading and Materials + Phong Lighting Model

In- Class Exercises for Shadow Algorithms

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

Ulf Assarsson Department of Computer Engineering Chalmers University of Technology

Models and Architectures

Computer Graphics (CS 4731) Lecture 11: Implementing Transformations. Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

A Two-Step Approach for Interactive Pre-Integrated Volume Rendering of Unstructured Grids

Nonphotorealism. Christian Miller CS Fall 2011

Computer Graphics. Shadows

Computer Graphics 10 - Shadows

Computer Graphics (CS 543) Lecture 8a: Per-Vertex lighting, Shading and Per-Fragment lighting

Transforms 3: Projection Christian Miller CS Fall 2011

CS 4620 Program 3: Pipeline

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

CS 381 Computer Graphics, Fall 2012 Midterm Exam Solutions. The Midterm Exam was given in class on Tuesday, October 16, 2012.

Graphics for VEs. Ruth Aylett

CS Computer Graphics: Introduction to Ray Tracing

CS Computer Graphics: Introduction to Ray Tracing

Computer Graphics (4731) Lecture 4: 2D Graphics Systems (Drawing Polylines, tiling, & Aspect Ratio)

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

RASTERISED RENDERING

Revisions for VISRAD

Painter s HSR Algorithm

lecture 18 - ray tracing - environment mapping - refraction

Computer Graphics (CS 543) Lecture 1 (Part 2): Introduction to OpenGL/GLUT (Part 1)

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

Intro to Programming & C Why Program? 1.2 Computer Systems: Hardware and Software. Why Learn to Program?

Fog example. Fog is atmospheric effect. Better realism, helps determine distances

Advanced Lighting Techniques Due: Monday November 2 at 10pm

LOD and Occlusion Christian Miller CS Fall 2011

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

Chapter 7 - Light, Materials, Appearance

Graphics for VEs. Ruth Aylett

Getting fancy with texture mapping (Part 2) CS559 Spring Apr 2017

Computergrafik. Matthias Zwicker. Herbst 2010

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

lecture 19 Shadows - ray tracing - shadow mapping - ambient occlusion Interreflections

Comp 410/510 Computer Graphics Spring Programming with OpenGL Part 4: Three Dimensions

Computer Graphics CS 543 Lecture 4 (Part 2) Building 3D Models (Part 2)

Computer Graphics CS 543 Lecture 5 (Part 2) Implementing Transformations

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

Shadows. COMP 575/770 Spring 2013

Computer Graphics Shadow Algorithms

CSE4030 Introduction to Computer Graphics

Ulf Assarsson Department of Computer Engineering Chalmers University of Technology

COMP371 COMPUTER GRAPHICS

CHAPTER 1 Graphics Systems and Models 3

Illumination & Shading I

CS559 Computer Graphics Fall 2015

Computer Graphics (CS 543) Lecture 9 (Part 2): Clipping. Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

Pipeline Operations. CS 4620 Lecture 14

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

Introduction to Computer Graphics with WebGL

CS452/552; EE465/505. Intro to Lighting

Lecture 17: Shading in OpenGL. CITS3003 Graphics & Animation

Mathematics in Computer Graphics and Games. Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

Computer Graphics (CS 4731) OpenGL/GLUT(Part 1)

Computer Graphics Introduction. Taku Komura

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

Shaders. Slide credit to Prof. Zwicker

Intro to Programming & C Why Program? 1.2 Computer Systems: Hardware and Software. Hardware Components Illustrated

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

Computer Graphics (CS 543) Lecture 4a: Introduction to Transformations

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

Advanced Deferred Rendering Techniques. NCCA, Thesis Portfolio Peter Smith

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

Computer Graphics Coursework 1

The Projection Matrix

Computer Graphics. Lecture 02 Graphics Pipeline. Edirlei Soares de Lima.

CS 354R: Computer Game Technology

Analytic Spherical Harmonic Coefficients for Polygonal Area Lights

Building Models. CS 537 Interactive Computer Graphics Prof. David E. Breen Department of Computer Science

Computer Science 426 Midterm 3/11/04, 1:30PM-2:50PM

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

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

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

DETERMINING INTUITIONISTIC FUZZY DEGREE OF OVERLAPPING OF COMPUTATION AND COMMUNICATION IN PARALLEL APPLICATIONS USING GENERALIZED NETS

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

EECS 487: Interactive Computer Graphics

Computer Graphics (CS 4731) Lecture 18: Lighting, Shading and Materials (Part 3)

Shading 1: basics Christian Miller CS Fall 2011

Objectives Shading in OpenGL. Front and Back Faces. OpenGL shading. Introduce the OpenGL shading methods. Discuss polygonal shading

Transcription:

Computer Graphics (CS 543) Lecture 9b: Shadows and Shadow Maps Prof Emmanue Agu Computer Science Dept. Worcester Poytechnic Institute (WPI)

Introduction to Shadows Shadows give information on reative positions of objects Use ambient + diffuse + specuar components Use just ambient component

Image courtesy of BioWare Why shadows? More reaism and atmosphere Neverwinter Nights

Types of Shadow Agorithms Project shadows as separate objects (ike Peter Pan's shadow) Projective shadows As voumes of space that are dark Shadow voumes [Frankin Crow 77] As paces not seen from a ight source ooking at the scene Shadow maps [Lance Wiiams 78] Fourth method used in ray tracing

Projective Shadows Odest method: Used in eary fight simuators Projection of poygon is poygon caed shadow poygon Actua poygon Shadow poygon

Projective Shadows Works for fat surfaces iuminated by point ight For each face, project vertices V to find V of shadow poygon Object shadow = union of projections of faces

Projective Shadow Agorithm Project ight-object edges onto pane Agorithm: First, draw ground pane/scene using specuar+diffuse+ambient components Then, draw shadow projections (face by face) using ony ambient component

Projective Shadows for Poygon. If ight is at (x, y, z ) 2. Vertex at (x, y, z) 3. Woud ike to cacuate shadow poygon vertex V projected onto ground at (x p,, z p ) (x,y,z) (x p,,z p ) Ground pane: y =

Projective Shadows for Poygon If we move origina poygon so that ight source is at origin Matrix M projects a vertex V to give its projection V in shadow poygon y m

Buiding Shadow Projection Matrix. Transate source to origin with T(-x, -y, -z ) 2. Perspective projection 3. Transate back by T(x, y, z ) z y x z y x M y Fina matrix that projects Vertex V onto V in shadow poygon

Code snippets? Set up projection matrix in OpenGL appication foat ight[3]; // ocation of ight mat4 m; // shadow projection matrix initiay identity M[3][] = -./ight[]; y M

Projective Shadow Code Set up object (e.g a square) to be drawn point4 square[4] = {vec4(-.5,.5, -.5,.} {vec4(-.5,.5, -.5,.} {vec4(-.5,.5, -.5,.} {vec4(-.5,.5, -.5,.} Copy square to VBO Pass modeview, projection matrices to vertex shader

What next? Next, we oad mode_view as usua then draw origina poygon Then oad shadow projection matrix, change coor to back, re-render poygon. Load modeview draw poygon as usua 2. Modify modeview with Shadow projection matrix Re-render as back (or ambient)

Shadow projection Dispay( ) Function void dispay( ) { mat4 mm; // cear the window gcear(gl_color_buffer_bit GL_DEPTH_BUFFER_BIT); // render red square (origina square) using modeview // matrix as usua (previousy set up) guniform4fv(coor_oc,, red); gdrawarrays(gl_triangle_strip,, 4);

Shadow projection Dispay( ) Function // modify modeview matrix to project square // and send modified mode_view matrix to shader mm = mode_view * Transate(ight[], ight[], ight[2] *m * Transate(-ight[], -ight[], -ight[2]); guniformmatrix4fv(matrix_oc,, GL_TRUE, mm); //and re-render square as // back square (or using ony ambient component) guniform4fv(coor_oc,, back); gdrawarrays(gl_triangle_strip,, 4); gutswapbuffers( ); } z y x z y x M y

Shadow Buffer Theory Aong each path from ight Ony cosest object is it Other objects on that path in shadow Shadow buffer stores cosest object on each path Lit In shadow

Shadow Map Iustrated Second dept buffer caed the shadow map is used Point v a stored in eement a of shadow map: it! Point v b NOT in eement b of shadow map: In shadow Not imited to panes

Shadow Map: Depth Comparison

OpenGL Depth Buffer (Z Buffer) Depth: Whie drawing objects, depth buffer stores distance of each poygon from viewer Why? If mutipe poygons overap a pixe, ony cosest one poygon is drawn Depth......3.3. Z =.5 Z =.3.5.3.3..5.5.. eye

Setting up OpenGL Depth Buffer Note: You did this in order to draw soid cube, meshes. gutinitdispaymode(glut_depth GLUT_RGB) instructs opengl to create depth buffer 2. genabe(gl_depth_test) enabes depth testing 3. gcear(gl_color_buffer_bit GL_DEPTH_BUFFER_BIT) Initiaizes depth buffer every time we draw a new picture

Shadow Map Approach Rendering in two stages: Loading shadow Map Render the scene

Loading Shadow Map Initiaize each eement to. Position a camera at ight source Rasterize each face in scene updating cosest object Shadow map (buffer) tracks smaest depth on each path

Shadow Map (Rendering Scene) Render scene using camera as usua Whie rendering a pixe find: pseudo-depth D from ight source to P Index ocation [i][j] in shadow buffer, to be tested Vaue d[i][j] stored in shadow buffer If d[i][j] < D (other object on this path coser to ight) point P is in shadow ighting = ambient Otherwise, not in shadow Lighting = amb + diffuse + specuar D[i][j] D In shadow

Loading Shadow Map Shadow map cacuation is independent of eye position In animations, shadow map oaded once If eye moves, no need for recacuation If objects move, recacuation required

References Interactive Computer Graphics (6 th edition), Ange and Shreiner Computer Graphics using OpenGL (3 rd edition), Hi and Keey Rea Time Rendering by Akenine-Moer, Haines and Hoffman