Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Adding Shadows to Computer Graphics: Projective Shadows and Shadow Maps, Study notes of Computer Graphics

The addition of shadows to computer graphics using projective shadows and shadow maps. It covers the basics of shadows, the structure of shadows, and the derivation of linear equations for projected shadow points. The document also explores practical issues, such as drawing projective shadows and using the opengl stencil buffer. Furthermore, it introduces the concept of soft shadows and area light sources.

Typology: Study notes

Pre 2010

Uploaded on 03/16/2009

koofers-user-fnw-1
koofers-user-fnw-1 🇺🇸

10 documents

1 / 4

Toggle sidebar

Related documents


Partial preview of the text

Download Adding Shadows to Computer Graphics: Projective Shadows and Shadow Maps and more Study notes Computer Graphics in PDF only on Docsity! Adding Shadows to the World Our illumination model does not incorporate shadows • only diffuse, specular, and ambient reflection • we always incorporate contribution of light sources • even if there’s an object in the way How do we get shadows? • more advanced rendering methods – e.g., ray tracing and radiosity • or do some clever things cos cosnL d L s a aI I k I k I kθ φ= + + The Structure of Shadows Point Light Source Occluder or Blocker Shadow Starting with a Restricted Solution Let’s make some simplifying assumptions about the world • the world contains objects + a ground plane • only care about shadows on this ground plane • so we are willing to ignore – shadows of one object on another – self-shadowing by a single object What problem do we need to solve? • given a point and a plane • project an object onto this plane • sounds kind of familiar Projective Shadows The point p lies at the intersection of Substitute ray into plane equation • solve for t • substitute back into ray equation for p This gives us a linear equation for p 0plane: d⋅ + =n u L v p ( ) 0ray and plane t d+ − ⋅ + =L v L n u ( )( ) 0t d⋅ + − + =n L v L ( ) ( ) d L + ⋅ = − − ⋅ −  np L v L n v L Projective Shadows We’ve derived a linear equation for a projected shadow point From this, we can derive a corresponding projection matrix • given a point v on the object • compute its projection p on the ground plane • where ( ) ( ) d L + ⋅ = − − ⋅ −  np L v L n v L =p Mv x x x y x z x y x y y y z y z x z y z z z x y z d L n L n L n L d L n d L n L n L d L n L n d L n L d n n n ⋅ + − − − −   − ⋅ + − − − =  − − ⋅ + − −   − − − ⋅   n L n L M n L n L Drawing Projective Shadows Requires an extra drawing pass for every light • first, we draw everything the normal way • and for each light, draw every object using shadow projection – load our special transformation – turn off lighting, and draw in a very dark color Need to resolve some practical issues to make sure this works • must make sure shadow is always on top of ground plane – can use glPolygonOffset() for that – or draw plane, then shadow (with Z-buffer off), then world • must make sure shadow doesn’t extend past edges of ground – our transformation projects onto an infinite plane – but the ground may have boundaries – can solve this by using the stencil buffer The OpenGL Stencil Buffer Another buffer, alongside the frame buffer and depth buffer • typically <= 8 bits per pixel • can subject fragments to a stencil test during rasterization – those that fail the test don’t get written to frame buffer • turned on with glEnable(GL_STENCIL_TEST) • test selected with glStencilFunc() • control writing into stencil buffer with glStencilOp() Among other things, can be used to mask drawing operations • fill in the stencil pixels where drawing is allowed (say with 1) • draw scene with glStencilFunc(GL_EQUAL, 1, 1) • fragments where stencil is not 1 are discarded • see Red Book for more details What Points are in Shadow? All points for which rays to/from light source are blocked In other words: all the points that the light can’t see • this sounds like visible surface determination
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved