09/23/03CS679 - Fall 2003 - Copyright Univ. of Wisconsin Last Time Reflections Shadows Part 1 Stage 1 is in.

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.
Optimized Stencil Shadow Volumes
Graphics Pipeline.
Game Programming 09 OGRE3D Lighting/shadow in Action
CSL 859: Advanced Computer Graphics Dept of Computer Sc. & Engg. IIT Delhi.
Computer Graphics methods
Week 10 - Monday.  What did we talk about last time?  Global illumination  Shadows  Projection shadows  Soft shadows.
10/10/02 (c) 2002 University of Wisconsin, CS 559 Last Time Finished viewing: Now you know how to: –Define a region of space that you wish to view – the.
CAP4730: Computational Structures in Computer Graphics Visible Surface Determination.
9/25/2001CS 638, Fall 2001 Today Shadow Volume Algorithms Vertex and Pixel Shaders.
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.
黃聰賢. Light Position Mesh Polygon Shadow Polygon  Clear color buffer and stencil buffer  Render the scene with ambient only.
Chapter 6: Vertices to Fragments Part 2 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley Mohan Sridharan Based on Slides.
CS 4731: Computer Graphics Lecture 18: Hidden Surface Removal Emmanuel Agu.
Practical and Robust Stenciled Shadow Volumes for Hardware-Accelerated Rendering Cass Everitt and Mark J. Kilgard Speaker: Alvin Date: 5/28/2003 NVIDIA.
A Real-Time Soft Shadow Volume Algorithm DTU Vision days Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology Sweden
Shadow Algorithms Gerald Matzka Computer Science Seminar.
CSE 872 Dr. Charles B. Owen Advanced Computer Graphics1 Other Rendering Techniques Types of rendering – Wireframe techniques – Scan-line conversion – Reyes.
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.
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.
Computer Graphics Mirror and Shadows
Shadow Algorithms Ikrima Elhassan.
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.
NVIDIA PROPRIETARY AND CONFIDENTIAL Occlusion (HP and NV Extensions) Ashu Rege.
3/4/04© University of Wisconsin, CS559 Spring 2004 Last Time Clipping Lines –Cohen-Sutherland: The use of outcodes and early reject/accept tests –Liang-Barsky:
09/09/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Event management Lag Group assignment has happened, like it or not.
09/11/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Graphics Pipeline Texturing Overview Cubic Environment Mapping.
Week 2 - Friday.  What did we talk about last time?  Graphics rendering pipeline  Geometry Stage.
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.
CS 638, Fall 2001 Today Project Stage 0.5 Environment mapping Light Mapping.
MIT EECS 6.837, Durand and Cutler Real-Time Shadows.
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.
Computer Graphics The Rendering Pipeline - Review CO2409 Computer Graphics Week 15.
CS-378: Game Technology Lecture #4: Texture and Other Maps Prof. Okan Arikan University of Texas, Austin V Lecture #4: Texture and Other Maps.
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.
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.
11/5/2002 (c) University of Wisconsin, CS 559 Last Time Local Shading –Diffuse term –Specular term –All together –OpenGL brief overview.
Computer Graphics I, Fall 2010 Implementation II.
COMPUTER GRAPHICS CS 482 – FALL 2015 SEPTEMBER 29, 2015 RENDERING RASTERIZATION RAY CASTING PROGRAMMABLE SHADERS.
Real-Time Dynamic Shadow Algorithms Evan Closson CSE 528.
1 CSCE 441: Computer Graphics Hidden Surface Removal Jinxiang Chai.
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.
Stencil Shadows Garrett Weng. What are stencil shadows? Also known as shadow volumes Relies on use of the stencil buffer Create volumes of the shadows.
CENG 477 Introduction to Computer Graphics
Game Programming (Mapping)
Jim X. Chen George Mason University
Real-Time Rendering Intro to Shadows
UMBC Graphics for Games
Lecture 13 Clipping & Scan Conversion
UMBC Graphics for Games
Frame Buffer Applications
Presentation transcript:

09/23/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Reflections Shadows Part 1 Stage 1 is in

09/23/03CS679 - Fall Copyright Univ. of Wisconsin Today Shadows part 2

09/23/03CS679 - Fall Copyright Univ. of Wisconsin Shadows in Light Maps Static shadows can be incorporated into light maps –When creating the map, test for shadows by ray-casting to the light source - quite efficient Area light sources should cast soft shadows –Interpolating the texture will give soft shadows, but not good ones, and you loose hard shadows –Sampling the light will give better results: Cast multiple rays to different points on the area light, and average the results –Should still filter for best results What about light map resolution?

09/23/03CS679 - Fall Copyright Univ. of Wisconsin Soft Shadow Example

09/23/03CS679 - Fall Copyright Univ. of Wisconsin Shadow Shape Perception Perceptual studies (or anecdotal evidence) suggests that the shape of a shadow is not important –In other words, people correctly associate shadows with the objects that cast them even if the shapes don’t correspond

09/23/03CS679 - Fall Copyright Univ. of Wisconsin Quick Dirty Shadows Blend a dark polygon into the frame-buffer in the place where the shadow should be –Cast a ray from light source, through object center, and see where it hits something –Blend a fixed shape polygon in at that location (with depth) Why dirty? –Use a fixed shape - shadow won’t match object –Use a single ray-cast to determine shadow location - no partial shadow and wrong parts of shadow may be drawn Good for things like car games for under-car shadow –Fast action and near planar receiving surfaces

09/23/03CS679 - Fall Copyright Univ. of Wisconsin Drawing Quick Dirty Shadows Z equal with hit polygon Z-buffer quantization errors Z above hit polygon Apparent shadow too big ViewerLight

09/23/03CS679 - Fall Copyright Univ. of Wisconsin Drawing Quick Dirty Shadows No depth test –Check that shadow can be seen by viewer (cast ray) –Just blend polygon in Again, shadow is too large and may be in wrong place –Test corners of shadow for visibility? –OK if polygons are flatter

09/23/03CS679 - Fall Copyright Univ. of Wisconsin Projective Shadows Create a texture (dark on white) representing the appearance of the occluder as seen by the light –Game programmers frequently call this a shadow map –Can create it by “render to texture” with the light as viewpoint Use projective texturing to apply it to receivers Works if the appearance of the occluder from the light is reasonably constant Requires work to identify occluders and receivers Resolution issues Better than quick-dirty shadows, worse than other methods

09/23/03CS679 - Fall Copyright Univ. of Wisconsin Shadow Volumes A shadow volume for an object and light is the volume of space that is shadowed –That is, all points in the volume are in shadow for that light/object pair Creating the volume: –Find silhouette edges of shadowing object as seen by the light source –Extrude these edges away from the light, forming polygons –Clip the polygons to the view volume

09/23/03CS679 - Fall Copyright Univ. of Wisconsin Shadow Volume

09/23/03CS679 - Fall Copyright Univ. of Wisconsin Practicalities For many algorithms, it is not necessary to find silhouette edges – just use all edges Silhouette edges can be found by looking at polygon normals –Silhouette edges are those between a front facing face and back facing face (from light’s point of view) –The result is a sequence of edges with common vertices Assuming convex shadowing objects Extend all the vertices of silhouette edges away from the light source Clip them to the view volume, and form the polygons that bound the shadow volume Final result are a set of shadow volume boundary polygons

09/23/03CS679 - Fall Copyright Univ. of Wisconsin Key Observation All points inside a shadow volume are in shadow Along a ray from the eye, we can track the shadow state by looking at intersections with shadow volume boundaries –Assume the eye is not in shadow –Each time the ray crosses a front facing shadow polygon, add one to a counter –Each time the ray crosses a back facing shadow polygon, subtract one from a counter –Places where the counter is zero are lit, others are shadowed We need to count the number of shadow polygons in front of a point. Which buffer can count for us?

09/23/03CS679 - Fall Copyright Univ. of Wisconsin Using Shadow Volumes

09/23/03CS679 - Fall Copyright Univ. of Wisconsin Real-Time Shadow Volumes Compute shadow volumes per frame –Not a problem for only a few moving objects –Use simplified object geometry to speed things up –Vertex programs can be used to create volumes Four pass algorithm –Render scene with ambient light only (everything shadowed) –Render front facing shadow polygons to increment stencil buffer –Render back facing shadow polygons to decrement stencil buffer –Render scene again only for non-shadowed (stencil=0) regions Horrible details follow…

09/23/03CS679 - Fall Copyright Univ. of Wisconsin Details Turn off any light sources and render scene with ambient light only, depth on, color buffer active Disable the color and depth buffers for writing, but leave the depth test active Initialize the stencil buffer to 0 or 1 depending on whether the viewer is in shadow or not (ray cast) Set the stencil test to always pass and the operation to increment if depth test passes Enable back face culling Render the shadow volumes - this will increment the stencil for every front facing polygon that is in front of a visible surface Cont…

09/23/03CS679 - Fall Copyright Univ. of Wisconsin Details Enable front face culling, disable back face culling Set the stencil operation to decrement if the depth test passes (and leave the test as always pass) Render the shadow volumes - this decrements for all the back facing shadow polygons that are in front of visible objects. The stencil buffer now has positive values for places in shadow Set the stencil function to equality with 0, operations to keep Clear the depth buffer, and enable it and the color buffer for writing Render the scene with the lights turned on Voila, we’re done

09/23/03CS679 - Fall Copyright Univ. of Wisconsin Alternate 2 Problems: Finding how many shadow volumes the viewer is in, and the near clip plane Solution: Count the number of shadow volume faces behind the visible scene –Assume shadow volumes are capped –Why does it work? New problem? –Resolved by Nvidia extension NV_depth_clamp –Resolved by smart homogeneous coordinate math –Textbook has details

09/23/03CS679 - Fall Copyright Univ. of Wisconsin Why Use Shadow Volumes? They correctly account for shadows of all surfaces on all other surfaces –No shadow where there shouldn’t be shadow –No problem with multiple light sources Adaptable quality by creating shadow volumes with approximate geometry Shadow volumes for static object/light pairs can be pre- computed and don’t change More expensive than light maps, but not too bad on current hardware –Can’t combine the techniques. Why not?

09/23/03CS679 - Fall Copyright Univ. of Wisconsin Why Not Use Shadow Volumes? Place very high demands on rendering pipeline –In particular, fill rate can be a major problem –Shadow volume polygons tend to cover very large parts of the screen –Using coarse occluder geometry won’t help this much Sharp shadows, and hard to make soft

09/23/03CS679 - Fall Copyright Univ. of Wisconsin Variant Render fully lit, then add shadows (blend a dark polygon) where the stencil buffer is set – in what cases is it wrong? –

09/23/03CS679 - Fall Copyright Univ. of Wisconsin Shadow Buffer Algorithms Compute z-buffer from light viewpoint –Put it into the shadow buffer Render normal view, compare world locations of points in the z-buffer and shadow buffer –Have to transform pts into same coordinate system Points with same location in both buffers are lit. Why? Problems: –Resolution is a big issue – both depth and spatial –Only some hardware supports the required computations

09/23/03CS679 - Fall Copyright Univ. of Wisconsin Project Stage 2 Incorporate lighting, shadows, reflections, pixel shaders, vertex shaders, other real-time techniques into your game –Use the most appropriate techniques for your game Demonstrate the technique with enough in-game art/model content to make the point –No need to have all content done now, but enough to show how your game will look Goals Monday Sept 29, Stage Due Monday Oct 13

09/23/03CS679 - Fall Copyright Univ. of Wisconsin Todo By Monday, Sept 22: Lock in Stage 1