Computer Graphics Mirror and Shadows

Slides:



Advertisements
Similar presentations
Exploration of advanced lighting and shading techniques
Advertisements

Lecture 8 Transparency, Mirroring
Technische Universität München Computer Graphics SS 2014 Graphics Effects Rüdiger Westermann Lehrstuhl für Computer Graphik und Visualisierung.
CS 352: Computer Graphics Chapter 7: The Rendering Pipeline.
Ray tracing. New Concepts The recursive ray tracing algorithm Generating eye rays Non Real-time rendering.
Game Programming 09 OGRE3D Lighting/shadow in Action
University of Sulaimani - School of Science - Computer Dept.
Computer Graphic Creator: Mohsen Asghari Session 2 Fall 2014.
CSL 859: Advanced Computer Graphics Dept of Computer Sc. & Engg. IIT Delhi.
Week 9 - Friday.  What did we talk about last time?  Area lighting  Environment mapping  Blinn and Newell's method  Sphere mapping  Cubic environmental.
Computer Graphics methods
Week 7 - Monday.  What did we talk about last time?  Specular shading  Aliasing and antialiasing.
Week 10 - Monday.  What did we talk about last time?  Global illumination  Shadows  Projection shadows  Soft shadows.
3D Graphics Rendering and Terrain Modeling
CS 551 / CS 645 Antialiasing. What is a pixel? A pixel is not… –A box –A disk –A teeny tiny little light A pixel is a point –It has no dimension –It occupies.
1 Dr. Scott Schaefer Shadows. 2/40 Shadows Shadows provide clues about depth Make scenes appear more realistic.
Real-Time Rendering SPEACIAL EFFECTS Lecture 03 Marina Gavrilova.
Skin Rendering GPU Graphics Gary J. Katz University of Pennsylvania CIS 665 Adapted from David Gosselin’s Power Point and article, Real-time skin rendering,
Shadow Algorithms Gerald Matzka Computer Science Seminar.
Introduction to 3D Graphics John E. Laird. Basic Issues u Given a internal model of a 3D world, with textures and light sources how do you project it.
Computer Graphics Shadows
09/18/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Bump Mapping Multi-pass algorithms.
9/20/2001CS 638, Fall 2001 Today Finishing Up Reflections More Multi-Pass Algorithms Shadows.
Hidden Surface Removal
Shadows Computer Graphics. Shadows Shadows Extended light sources produce penumbras In real-time, we only use point light sources –Extended light sources.
Erdem Alpay Ala Nawaiseh. Why Shadows? Real world has shadows More control of the game’s feel  dramatic effects  spooky effects Without shadows the.
Shadow Algorithms Ikrima Elhassan.
Computer Graphics Inf4/MSc Computer Graphics Lecture 9 Antialiasing, Texture Mapping.
CS 638, Fall 2001 Today Light Mapping (Continued) Bump Mapping with Multi-Texturing Multi-Pass Rendering.
Technology and Historical Overview. Introduction to 3d Computer Graphics  3D computer graphics is the science, study, and method of projecting a mathematical.
CSE 381 – Advanced Game Programming Basic 3D Graphics
Computer Graphics An Introduction. What’s this course all about? 06/10/2015 Lecture 1 2 We will cover… Graphics programming and algorithms Graphics data.
09/11/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Graphics Pipeline Texturing Overview Cubic Environment Mapping.
Game Programming (Mapping) Spring.
CHAPTER 11 Shadows © 2008 Cengage Learning EMEA. LEARNING OBJECTIVES In this chapter you will learn about: – –Shadow rendering algorithms – –Blinn’s shadow.
Advanced Computer Graphics Depth & Stencil Buffers / Rendering to Textures CO2409 Computer Graphics Week 19.
CSC 461: Lecture 3 1 CSC461 Lecture 3: Models and Architectures  Objectives –Learn the basic design of a graphics system –Introduce pipeline architecture.
MIT EECS 6.837, Durand and Cutler Real-Time Shadows.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
CS 638, Fall 2001 Multi-Pass Rendering The pipeline takes one triangle at a time, so only local information, and pre-computed maps, are available Multi-Pass.
1 10/24/ :01 UML Graphics II Shadows Session 4.
Shadows. Shadows is important in scenes, consolidating spatial relationships “Geometric shadows”: the shape of an area in shadow Early days, just pasted.
CS-378: Game Technology Lecture #8: More Mapping Prof. Okan Arikan University of Texas, Austin Thanks to James O’Brien, Steve Chenney, Zoran Popovic, Jessica.
1 Perception and VR MONT 104S, Fall 2008 Lecture 21 More Graphics for VR.
Computer graphics & visualization Shadows / Transparency.
09/16/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Environment mapping Light mapping Project Goals for Stage 1.
Global Illumination. Local Illumination  the GPU pipeline is designed for local illumination  only the surface data at the visible point is needed to.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
Lecture 6 Rasterisation, Antialiasing, Texture Mapping,
CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © Visible Surface Determination (VSD) To render or not to render, that is the question… 1 of.
Rendering Pipeline Fall, D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination.
11/24/ :45 Graphics II Shadow Maps Reflections Session 5.
Real-Time Dynamic Shadow Algorithms Evan Closson CSE 528.
Shadows David Luebke University of Virginia. Shadows An important visual cue, traditionally hard to do in real-time rendering Outline: –Notation –Planar.
1 Shadow Rendering Techniques: Hard and Soft Author: Jamiur Rahman Supervisor: Mushfiqur Rouf Department of CSE BRAC University.
01/28/09Dinesh Manocha, COMP770 Visibility Computations Visible Surface Determination Visibility Culling.
1 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac Shadows & occlusion  Shadow - occlusion duality  Floor shadows.
09/23/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Reflections Shadows Part 1 Stage 1 is in.
Visible-Surface Detection Methods. To identify those parts of a scene that are visible from a chosen viewing position. Surfaces which are obscured by.
Rendering Pipeline Fall, 2015.
Stenciling Effects Glenn G. Chappell
Discrete Techniques.
Real-Time Soft Shadows with Adaptive Light Source Sampling
Game Programming (Mapping)
3D Graphics Rendering PPT By Ricardo Veguilla.
Jim X. Chen George Mason University
Introduction to Computer Graphics with WebGL
Real-time Rendering Shadow Maps
Last Time Presentation of your game and idea Environment mapping
Frame Buffer Applications
Presentation transcript:

Computer Graphics Mirror and Shadows Taku Komura Lecture 16

Today Mirrors Shadows How to render the scene Using the stencil buffer Overview Projective shadows Shadow texture Shadow volume Shadow map Lecture 16

Planar Reflections (Flat Mirrors)‏ Basic idea: Drawing a scene with mirrors! We need to draw all the stuff around the mirror We need to draw the stuff in the mirror, reflected, without drawing over the things around the mirror Key point: You can reflect the viewpoint about the mirror to see what is seen in the mirror, or you can reflect the world about the mirror Lecture 16

Reflecting Objects If the mirror passes through the origin, and is aligned with a coordinate axis, then just negate appropriate coordinate Otherwise, transform into mirror space, reflect, transform back Wall Mirror Lecture 16

We need to use the “Stencil Buffer” The stencil buffer acts like a paint stencil - it lets some fragments through but not others It stores multi-bit values You specify two things: The test that controls which fragments get through The operations to perform on the buffer when the test passes or fails Lecture 16

Stencil Tests You give an operation, a reference value, and a mask Operations: Always let the fragment through Never let the fragment through Logical operations between the reference value and the value in the buffer: <, <=, =, !=, >, >= Lecture 16

Color Buffer, Z-Buffer Color Buffer (frame buffer)‏ The buffer in which the RGB data is saved Z-Buffer (depth buffer)‏ The depth to the object is saved Depth test can be conducted; check whether the new object is farther or closer than the depth in the buffer Only update the color buffer when the depth is smaller Lecture 16

Stencil Operations Specify three different operations Operations are: If the stencil test fails If the stencil passes but the depth test fails If the stencil passes and the depth test passes Operations are: Keep the current stencil value Zero the stencil Replace the stencil with the reference value Increment the stencil Decrement the stencil Invert the stencil (bitwise)‏ Lecture 16

Reflection Example mirror Lecture 16

Normal first, reflected area next First pass: Render the scene without the mirror For each mirror Second pass: Clear the stencil, render the mirror, setting the stencil if the depth test passes Third pass: Clear the depth buffer with the stencil active, passing things inside the mirror only Reflect the world and draw using the stencil test. Only things seen in the mirror will be drawn Combine it with the scene made during the first pass The stencil buffer after the second pass The color buffer after the second pass – the reflected scene cleared outside the stencil Lecture 16

Multiple mirrors Can manage multiple mirrors Render normal view, then do other passes for each mirror A recursive formulation exists for mirrors that see other mirrors After rendering the reflected area inside the mirror surface, render the mirrors inside the mirror surface, and so on Lecture 16

Today Mirrors Shadows How to render the scene Using the stencil buffer Overview Projective shadows Shadow texture Shadow volume Shadow map Lecture 16

Why Shadows? Shadows tell us about the relative locations and motions of objects Lecture 16

Shadows and Motion Humans conceive the motion of objects using shadows Demo movie http://gandalf.psych.umn.edu/users/kersten/kersten-lab/images/ball-in-a-box.mov Lecture 16

Facts about 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 Suggests the use of projection transformations Point lights have hard edges, and area lights have soft edges Lecture 16

Soft and hard shadows Soft shadows Hard shadows Lecture 16

Today Mirrors Shadows How to render the scene Using the stencil buffer Overview Projective shadows Shadow texture Shadow volume Lecture 16

Ground Plane Shadows L(light position)‏ Shadows cast by point light sources onto planes are an important case that is relatively easy to compute Shadows cast by objects (cars, players) onto the ground (xl,yl,zl)‏ (xp,yp,zp)‏ (xsw,ysw,zsw)‏ Lecture 16

Point Light Shadows Light source Object Floor Lecture 16

Point Light Shadows Blinn ’88 gives a matrix that works for local point light sources Takes advantage of perspective transformation (and homogeneous coordinates)‏ Lecture 16

Drawing the Shadow We now have a matrix that transforms an object into its shadow Drawing the shadow: Draw the polygon Multiply the shadow matrix into the model transformation Redraw the object in grey with blending on Tricks: Lift the shadow a little off the plane to avoid z-buffer quantization errors (can be done with extra term in matrix)‏ Lecture 16

Lifting the shadow above the surface Light Viewer Z equal with hit polygon Z-buffer quantization errors Z above hit polygon Apparent shadow too big Lecture 16

Point Light Shadows : problem shadows can only be cast onto planes and not on arbitrary objects. the resulting shadows generated have hard edges If there is a texture on the floor, grey shadows look bad If we use blending, the shadow part with multiple polygons overlapping will look darker Lecture 16

Improving Planar Projected Shadows with Stencil Only pixels tagged with the ground plane’s unique stencil value will be updated when the shadow is rendered. When a shadow is rendered, the stencil value is set to zero subsequent pixel updates will fail Lifting the shadows above the floor not necessary, stencil buffer used to avoid rendering the floor over the shadow region Lecture 16

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 Project this image onto the background and render it using texture mapping Can render shadows over curved surfaces Lecture 16

Shadow Texture : Drawbacks The occluder and receiver must be specified Occluding objects cannot shadow themselves Magnification of textures Resolution must be adapted Lecture 16

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 the shadow map according to the viewpoint [Fernando et al. 2001] Lecture 16

Today Mirrors Shadows How to render the scene Using the stencil buffer Overview Projective shadows Shadow texture Shadow volume Shadow map Lecture 16

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. Lecture 16

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

Lecture 16

How to decide inside or out Get the polygonal boundary representation for the shadow volume Render the scene with the lights enabled Clear the stencil buffer, and render the shadow volume Whenever a rendered fragment of the shadow volume is closer than the depth of the other objects, invert a bit in the stencil value for that pixel After rendering, if the bit is on, then it means the fragment is inside the shadow volume, so must be shadowed Otherwise outside the shadow Lecture 16

Advantage / Disadvantages of Shadow Volume It can be used on general-purpose graphics hardware Only using the stencil buffer Disadvantage Bottle neck at the rasterizer Many shadow volumes covering many pixels Lecture 16

Shadow Mapping A method using the Z-buffer Render the scene from the light source using the Z- buffer algorithm The Z-buffer contains the distance to the object shadow depth map / shadow buffer Render the scene from the view point If the rendered vertex is farther away from the value in the Z-buffer, it is in the shadow Lecture 16

Shadow Map Checking whether Va,Vb is closer to the light Lecture 16

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 Rendering the scene Render the objects; when ever rendering an object, check if it is shadowed or not by transforming its coordinate into the light space After the transformation, if the depth value is larger than that in the light’s depth buffer it should be shadowed Lecture 16

Shadow Map Advantage Don’t need a stencil buffer When there are many shadows, it is faster then shadow volume Disadvantage Less accurate than the shadow volume – why? Lecture 16

Soft shadowing by multiple point light sources Model an area light source as a collection of point light sources Can be used with both planar projected shadows approach or shadow volume approach Additive blending is used to accumulate the contribution of each light. 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 Lecture 16

Other techniques to generate soft shadow Using convolutions - Creating a hard edged shadow texture and render it a number of times by jittering the location, and finally filtering it Lecture 16

Summary Mirrors Shadows How to render the scene Using the stencil buffer Shadows Overview Projective shadows Shadow texture Shadow volume Shadow map Lecture 16