Unformatted text preview:

•1Slide 1 Lecture 18Copyright Amitabh VarshneyShadows(Georges de la Tour)Slide 2 Lecture 18Copyright Amitabh Varshney•Shadows give us important visual cues about 3D object placement and motion•Movies are from: • http://vision.psych.umn.edu/users/kersten/kersten-lab/demos/shadows.htmlWhy Shadows?•2Slide 3 Lecture 18Copyright Amitabh VarshneyWhy Shadows ?Also, realism …Image courtesy, CodemastersGame: Blade of DarknessSlide 4 Lecture 18Copyright Amitabh VarshneyShadows just look cool•3Slide 5 Lecture 18Copyright Amitabh VarshneyAttached ShadowsCast Shadows• Attached shadows are easy to render• Because they are local.• We already have discussed this.• Cast shadows require us to determine whether the surface is visible to the light.Slide 6 Lecture 18Copyright Amitabh VarshneyHard and Soft Shadowspoint sourceumbraarea sourceumbrapenumbraImages courtesy, Eric Haines and Tomas Moeller•4Slide 7 Lecture 18Copyright Amitabh VarshneyReal-time Shadows• Assumptions: hard shadows from point light sources onto planar surfaces• Let the light source be at infinity in the direction L(xl, yl, zl), and we want to compute the shadow S(xw, yw, zw) of the point P(xp, yp, zp), on the plane z = 0• It is easy to see that S lies on the line defined by P and L orS = P –L• Since the shadow is on the plane z = 0,zw= 0 =zp/zl, andxw= xp- (zp/ zl) xlyw= yp- (zp/ zl) ylSlide 8 Lecture 18Copyright Amitabh VarshneyReal-time ShadowsRestating the equations from previous slide in a matrix form:Shadows on arbitrary planes can be performed by prefixing the abovematrix by a suitable transformation that transforms that plane to z = 0   11000000001000110pppllllwwzyxzyzxyx•5Slide 9 Lecture 18Copyright Amitabh VarshneyReal-time Shadows• Remember to set the right shadow color before drawing the shadow• Z-conflicts can ruin shadows, so remember to slightly offset the shadows to lie above the surface:glEnable(GL_POLYGON_OFFSET_FILL)glPolygonOffset(GLfloat factor, GLfloat units)// display the polygon hereglDisable(GL_POLYGON_OFFSET_FILL)• Alternatively if the scene geometry is well understood the following might be possible and simpler:Render the plane, turn off the depth test, render the shadows, turn the depth test back on, and render the rest of the scene.Slide 10 Lecture 18Copyright Amitabh VarshneyReal-time ShadowsWe assumed light source at infinity. If the light source is local at L(xl, yl, zl), we can use the following matrix [Blinn 88]:   11000000000010ppplllllwwzyxzyzxzyx•6Slide 11 Lecture 18Copyright Amitabh VarshneyWhy is this the right matrix? Let’s just work through the x coordinate. To project the point onto the z = 0 plane as a shadow, we need to move it in the direction from the light to the point, and to move it far enough so that it’s on the z = 0 plane. That means we need to add a scaled version of (xp-xl,yp-yl,zp-zl) to the point (xp,yp,zp). Our projected point will be (xp,yp,zp) + a(xp-xl,yp-yl,zp-zl) where we choose a so that the resulting z coordinate will be 0. That is, zp + a(zp-zl) = 0, or a = zp(zl-zp).The x coordinate that we wind up with, then will be xp + zp(xp-xl)/(zl-zp). We can rewrite this as:(xp(zl-zp) + zp(xp-xl))/(zl-zp) = (xp*zl – zp*xl)/(zl-zp). Notice that if we apply our matrix to (xp,yp,zp,1), we get (xp*zl – zp*xl, ?, 0, zl-zp), where we haven’t calculated the y coordinate yet. This is in homogenous coordinates, but if we divide by the fourth coordinate, we get the correct x coordinate that we have just calculated. We can check the y coordinate in the same way.Slide 12 Lecture 18Copyright Amitabh VarshneyLight Maps• Idea is to store the view-independent lighting of a scene as a 2D texture map• Light maps are reasonably effective even when used at low resolutions (since they usually don’t have high frequency detail)• Efficiency involves clustering similarly lighted polygonal patches (Zhukov et al. 1998)•7Slide 13 Lecture 18Copyright Amitabh VarshneyTexture-Mapped SceneImages courtesy, 3D Games by Watt and PolicarpoSlide 14 Lecture 18Copyright Amitabh VarshneyLight Mapped SceneImages courtesy, 3D Games by Watt and PolicarpoNo filtering of the light map•8Slide 15 Lecture 18Copyright Amitabh VarshneyLight-Mapped SceneImages courtesy, 3D Games by Watt and PolicarpoLight map with linear filteringSlide 16 Lecture 18Copyright Amitabh VarshneyTexture & Light Mapped SceneImages courtesy, 3D Games by Watt and PolicarpoTexture mapped * Filtered Light Mapped•9Slide 17 Lecture 18Copyright Amitabh VarshneyLight MapsImages courtesy, 3D Games by Watt and PolicarpoTexture + Filtered Light MappedTexture mapped Slide 18 Lecture 18Copyright Amitabh VarshneyShadow Augmented Light Maps• If light sources and scene objects are static then the shadows will be static. • Precompute the shadows as a part of the light map and apply as a texture“(The world) saw shadows black until Monet discovered they were coloured,…”Maugham, Of Human BondageImages from 3D Games by Watt and Policarpo•10Slide 19 Lecture 18Copyright Amitabh VarshneyShadow Z-Buffer• Proposed by Williams 1978• Render the scene from the light’s point of view and store the result in a shadow z-buffer • Then render the scene from the user’s view point and for each pixel that overwrites a previously written pixel:– Transform the pixel’s screen space coordinates into the light source’s coordinate frame– Index into the shadow z-buffer to see whether the rendered point’s depth is greater than the depth for the corresponding pixel in the shadow z-buffer– If the depth is greater point is in shadow and use the shadow color, otherwise render normallySlide 20 Lecture 18Copyright Amitabh VarshneyShadow Z-bufferImages from 3D Computer Graphics by Watt Low resolution shadow map Higher resolution shadow map•11Slide 21 Lecture 18Copyright Amitabh VarshneyShadow Z-bufferImages from 3D Computer Graphics by Watt Depth map from User’s View PointShadow Environment Z-buffer fromLight’s View


View Full Document

UMD CMSC 427 - Shadows

Download Shadows
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Shadows and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Shadows 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?