Real-Time Rendering Intro to Shadows

Slides:



Advertisements
Similar presentations
Exploration of advanced lighting and shading techniques
Advertisements

An Optimized Soft Shadow Volume Algorithm with Real-Time Performance Ulf Assarsson 1, Michael Dougherty 2, Michael Mounier 2, and Tomas Akenine-Möller.
Technische Universität München Computer Graphics SS 2014 Graphics Effects Rüdiger Westermann Lehrstuhl für Computer Graphik und Visualisierung.
Graphics Pipeline.
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
Real-Time Rendering Self-Shadowing
Course Note Credit: Some of slides are extracted from the course notes of prof. Mathieu Desburn (USC) and prof. Han-Wei Shen (Ohio State University). CSC.
Projective Texture Mapping
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
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.
Practical and Robust Stenciled Shadow Volumes for Hardware-Accelerated Rendering Cass Everitt and Mark J. Kilgard Speaker: Alvin Date: 5/28/2003 NVIDIA.
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.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
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.
Computer Graphics Mirror and Shadows
1 Computer Graphics Week13 –Shading Models. Shading Models Flat Shading Model: In this technique, each surface is assumed to have one normal vector (usually.
CS 638, Fall 2001 Today Light Mapping (Continued) Bump Mapping with Multi-Texturing Multi-Pass Rendering.
COMP 175: Computer Graphics March 24, 2015
Technology and Historical Overview. Introduction to 3d Computer Graphics  3D computer graphics is the science, study, and method of projecting a mathematical.
09/09/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Event management Lag Group assignment has happened, like it or not.
Advanced Computer Graphics Depth & Stencil Buffers / Rendering to Textures CO2409 Computer Graphics Week 19.
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.
Image-based Rendering. © 2002 James K. Hahn2 Image-based Rendering Usually based on 2-D imagesUsually based on 2-D images Pre-calculationPre-calculation.
1 Shadows (2) ©Anthony Steed Overview n Shadows – Umbra Recap n Penumbra Analytical v. Sampling n Analytical Aspect graphs Discontinuity meshing.
Shadows. Shadows is important in scenes, consolidating spatial relationships “Geometric shadows”: the shape of an area in shadow Early days, just pasted.
Shadow Mapping Chun-Fa Chang National Taiwan Normal University.
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.
Advanced Computer Graphics Shadow Techniques CO2409 Computer Graphics Week 20.
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.
Ray Tracing Fall, Introduction Simple idea  Forward Mapping  Natural phenomenon infinite number of rays from light source to object to viewer.
11/5/2002 (c) University of Wisconsin, CS 559 Last Time Local Shading –Diffuse term –Specular term –All together –OpenGL brief overview.
What are shaders? In the field of computer graphics, a shader is a computer program that runs on the graphics processing unit(GPU) and is used to do shading.
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.
09/23/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Reflections Shadows Part 1 Stage 1 is in.
Rendering Pipeline Fall, 2015.
Discrete Techniques.
Real-Time Soft Shadows with Adaptive Light Source Sampling
CS-378: Game Technology Lecture #7: More Mapping Prof. Okan Arikan
Week 7 - Monday CS361.
Photorealistic Rendering vs. Interactive 3D Graphics
Chapter X Advanced Texturing
Week 2 - Friday CS361.
Game Programming (Mapping)
Modeling 101 For the moment assume that all geometry consists of points, lines and faces Line: A segment between two endpoints Face: A planar area bounded.
Deferred Lighting.
3D Graphics Rendering PPT By Ricardo Veguilla.
The Graphics Rendering Pipeline
Jim X. Chen George Mason University
© University of Wisconsin, CS559 Fall 2004
(c) 2002 University of Wisconsin
Introduction to Computer Graphics with WebGL
Real-time Rendering Shadow Maps
Lecture 13 Clipping & Scan Conversion
CS5500 Computer Graphics May 29, 2006
Last Time Presentation of your game and idea Environment mapping
Computer Graphics Material Colours and Lighting
Presentation transcript:

Real-Time Rendering Intro to Shadows CSE 5542 Prof. Roger Crawfis

Shadows can be Wonderful!

Importance of Shadows Trapezoid?

Importance of Shadows Cue to object-object relationship. Provides additional depth cue.

Importance of Shadows 5

Importance of Shadows 6

Importance of Shadows 7

Importance of Shadows Without shadows With shadows 8

Importance of Shadows 9

Definition Shadow: Darkness caused when part or all of the illumination from a light source is blocked by an occluder. light occluder shadow 10

Terminology (area) light source occluder penumbra umbra receiver shadow umbra – fully shadowed region penumbra – partially shadowed region

Terminology

Definition: Shadow Volume Volume formed by extruding the occluder from the light source. Open and infinite Space inside the volume is in shadow. Space outside the volume is not.

Hard and soft shadows Hard shadow Soft shadow extended light point light penumbra umbra umbra Hard shadow Soft shadow 14

Soft Shadows Shadow is a function of the area of the light source and the distance.

Hard shadow creation For every pixel, light source is either visible or occluded

Soft shadow creation

Issues Affecting Shadows Scene Complexity Number of light sources Types of light sources Number of occluders Number of receivers Position, size and strength of lights Static vs. dynamic Objects Lighting Self-shadowing Opaque vs. transparent objects Precision or realism of shadows

Current Shadow Methods There exist a very large number of methods We are interested in methods suitable for interactive walkthroughs, speed is crucial We will classify them on complexity: no shadows Sharp shadows Soft shadows Special effects

Sharp Shadows Point or directional light sources Fake Hardware Assisted Pre-computed Ray tracing Fast but often inadequate Billboard Projected object Use of specialized hardware to generate shadows  Shadow texture  Shadow volumes Shadows are pre-computed and stored for repeated use  Detail polygons Rather slow for large scenes

Soft Shadows Area light sources Pre-computed Radiosity Ray-based Hardware Assisted Mainly treat the light source as a collection of points  Accumulation buffer  Shadow volumes  Shadow textures Mainly analytical computation on the geometry of the source  Light maps  Discontinuity Meshing  Distributed ray tracing  Cone Tracing This is also pre-computed  Hemi-cube  Ray casing

Approaches Ad-hoc / Custom Analytical Sampling Artist directed shadows Very simple and constrained conditions. Analytical Find all boundaries within the umbra / penumbra. Precise. Sampling Probabilistic sampling of whether a particular fragment is within the umbra / penumbra. With enough samples can be made precise.

Shadows and Illumination Given a point is in shadow, how do we change the illumination? Light Source Viewer Point is in shadow Occluder Point is lit

Shadows and Illumination Illumination model with included visibility term: Visibility term determines if a light can “see” the point If point is in shadow, only ambient term applies For all lights Visibility Term: 0 or 1 for point/directional lights

Shadows and OpenGL In OpenGL we send the geometry for a model through the pipeline. The Visibility function, V, is not a constant in our illumination model. Per vertex information? Per fragment using a texture map? Some per-pixel masking function? Recall that we need a V for each light.

Shadows and Illumination Note, we can re-write our illumination equation: Negative light. ci

Masking in OpenGL OpenGL provides several ways of masking pixels Stencil buffer with stencil test Alpha test with fragment’s alpha values Blending with fragment’s and framebuffer’s alpha values. Texture sampling and shaders.

Negative Light Algorithm (single light) Render receivers with full illumination For each occluder Project occluder from the light to the receivers Darken (set to black or ambient) the illumination.

Negative Light With multiple light sources this technique does not work. If the algorithm simply sets the pixels to black (or ambient), then it will erases the contributions from all light sources.

Positive Light Algorithm Render scene with ambient illumination only For each light source Render scene with illumination from this light only Scale illumination by shadow mask Add contribution to frame buffer

Real-Time Rendering Ad-hoc Shadows CSE 5542 Prof. Roger Crawfis

Ad-Hoc and Custom Shadows Fake proxy geometry. Projection of model to a plane. Projection of a texture to a plane.

Fake Proxy Shadow Shadows are simple hand-drawn polygons or textures. Images from TombRaider. ©Eidos Interactive.

Fake Proxy Shadow Neither static lighting or dynamic lighting – it is faked. Do not care whether it is a static or dynamic occluder. Typically a single object (occluder) to a single, and simple, object (receiver). Hard and soft (fake) shadows are easily supported. For certain cases works great!

Fake Proxy Shadow Approximation of shadow position and shape based on object’s typical use. Typically assumes overhead lighting. Typically assumes a single flat ground plane as a receiver. E.g., draw the bottom of the bounding box.

Fake Proxy Shadow Consider this model of a desk with a fake shadow using an ellipse: Know where the shadow is going to be. Will change some depending on the light placement in the room, but good enough! The ellipse is part of the model.

Fake Proxy Shadow

Fake Proxy Shadow Quite complex model. Know it will sit on a flat floor. Will fail if we place another object behind or underneath it.

Projected Occluder Shadows for large planar receivers Ground plane Walls Use mathematics to flatten (splat) the object to the plane.

Projected Occluder Works for: Static or dynamic occluders. Only planar receivers. A wall and a floor can be shadowed separately. Static or dynamic light sources. Mainly hard shadows. Usually a single light source.

Projected Occluder Projection of a vertex, v, to a plane with normal, n, and coefficient d. Could be done in shader, but also leads to a 4x4 matrix.

Projected Occluder Example: xz plane at y=0 l=(lx,ly,lz) y v p y=0

Projected Occluder Transformation as a 4 by 4 matrix

Projected Occluder Basic algorithm Render scene (full lighting) For each receiver plane Compute projection matrix M Multiply with actual transformation (modelview) Note, even though this is a projection. Need to flatten it in world space. Render selected (occluder) geometry Darken/Black

Projected Occluder Problems Z-Fighting Use bias when rendering shadow polygons Use stencil buffer (no depth test) Z fighting

Projected Occluder Problems Bounded receiver polygon Use stencil buffer (restrict drawing to receiver area) extends off ground region

Projected Occluder Problems Shadow polygon overlap Use stencil count (only the first pixel gets through) double blending

Projected Occluder - Fixed

Projected Occluder Algorithm Stencil buffer algorithm (1bit stencil) Render scene without receiver polygon Clear stencil buffer Render receiver plane Set the stencil buffer for all visible pixels Render occluder polygons No depth testing Check if stencil buffer is set Use the stencil operation ‘clear’ Blend in the polygons (darken)

Projected Occluder Problems Wrong Shadows & Anti-Shadows Objects behind light source Objects behind receiver occluder behind receiver receiver light occluder behind light receiver light

Projected Occluder Summary Only practical for very few, large receivers Easy to implement Use stencil buffer (z fighting, overlap, receiver) Requires occluder geometry to be redrawn for each light source. Can use a simplified model (proxy occluder geometry).

Projected Shadow Texture Sky layers Cast shadows

Source: Wolfgang Heidrich [99] Projective Textures Textures can be projected like a slide projector. Before we talk about this projective textures let’s look at texture interpolation. Source: Wolfgang Heidrich [99]

Perspective-Correct Texturing While we think of 2D texture mapping using only the (s, t) coordinates, doing this will lead to errors. The texture will swim. A fix for this is needed for regular 2D texture mapping.

Perspective-Correct Texturing Interpolation in screen space is not the same as interpolation in 3-space Problem is perspective Need to interpolate in the plane of the triangle. Interpolation in screen space Interpolation in plane

Visualizing the Problem Notice that uniform steps on the image plane do not correspond to uniform steps along the edge.

Perspective-Correct Texturing 2D perspective-correct texture mapping (s, t) should be interpolated linearly in eye-space. Compute per-vertex s/w, t/w, and 1/w Linearly interpolate these three parameters over the polygon. Per-fragment compute: s’ = (s/w) / (1/w) t’ = (t/w) / (1/w) There is an OpenGL hint to indicate perspective texture interpolation. This is on by default with modern hardware.

Projective Textures Similar to projecting objects to the screen. Now project the scene to the light source. Use this projection from the receivers as their texture coordinates (a texture parameterization). Receiver geometry image plane camera Slide projector

Projective Textures Texture Coordinates – Project the objects to the “image plane” of the projector and use the projector’s NDC to calculate the texture coordinates objects objects Texture Projection projector projector

Projective Textures The receiver’s need to know about the projected texture, the light does not automatically apply to objects and is not an OpenGL state. OpenGL allows 4D texture coordinates, which can handle the projection.

Projective Texturing Tricking hardware into doing projective textures By interpolating q/w (perspective correction), hardware computes per-fragment (s/w) / (q/w) = s/q (t/w) / (q/w) = t/q Net result: Projective texturing OpenGL (glTexGen) or a vertex shader, specifies the texture parameterization. Typically want this in world space, but like headlights can be done in eye space.

Projective Texture Shadows Light’s point-of-view Shadow projective texture (modulation image or light-map) Eye’s point-of-view, projective texture applied to ground-plane

Projective Texture Shadows Two-pass approach For each light source: Create a light camera that encloses shadowed area (bounding box of the occluder). Render shadow casting objects into light’s view. Use a simple shader (set fragment color to black). Create projective texture from light’s view Render Scene using the projective textures. Render fully-lit shadow receiving objects. Modulate light contribution with the projective-texture for that light. Render fully-lit shadow casting objects

Projected Texture Problems Similar problems to the projected occluders: Receiver is behind the projector. Occluder is behind receiver. Projected Texture Mapping, Cass Everitt, nVidia

Projected Texture Problems Precision issues: Occluder very close to light (wide frustum). Projector frustum faces the viewing frustum (sampling rate needed varies greatly). Projected Texture Mapping, Cass Everitt, nVidia

Projective Texture Shadows Texture can easily be projected onto multiple receivers. Receivers do not need to be planar. Static scenes only or you need to regenerate textures. A sky layer can however move its shadow image with the clouds. No self shadowing. No area light sources (you can blur the texture though for a fake effect).

Ad-Hoc Shadow Summary A common theme of these methods is that the occluders and/or receivers were predetermined. For Fake shadows, the occluder was part of the model. Any receiver rendered before it would be darkened. For the projection-based techniques, either the occluder had a priori knowledge of the receiver (projected occluders) or the receiver had a priori knowledge of the occluder(s) (projected shadow textures). The occluder must also be different than the receiver (no self-shadowing).