Presentation is loading. Please wait.

Presentation is loading. Please wait.

Week 10 - Monday.  What did we talk about last time?  Global illumination  Shadows  Projection shadows  Soft shadows.

Similar presentations


Presentation on theme: "Week 10 - Monday.  What did we talk about last time?  Global illumination  Shadows  Projection shadows  Soft shadows."— Presentation transcript:

1 Week 10 - Monday

2  What did we talk about last time?  Global illumination  Shadows  Projection shadows  Soft shadows

3

4

5  Project the object onto a plane  Gives a hard shadow  Needs tricks if the object is bigger than the plane  Gets an antishadow if the light is between occluder and receiver  Soften the shadow  Render the shadow multiple times  Blur the projection  Put gradients around the edges

6  Think of shadows from the light's perspective  It "sees" whatever is not blocked by the occluder  We can render the occluder as black onto a white texture  Then, compute (u,v) coordinates of this texture for each triangle on the receiver  There is often hardware support for this  This is known as the shadow texture technique

7  Weaknesses  The program has to know which objects are occluders and which are receivers ▪ It has to be careful not to cast onto receivers that do not have the light blocked (antishadows)  Occluders cannot shadow themselves  Strengths  If the occluders do not change shape, the shadow texture can be reused  A variation of the idea can be used to make complicated shadow textures (e.g. Venetian blinds)

8

9  Shadow volumes are another technique for casting shadows onto arbitrary objects  Setup:  Imagine a point and a triangle  Extending lines from the point through the triangle vertices makes an infinite pyramid  If the point is a light, anything in the truncated pyramid under the triangle is in shadow  The truncated pyramid is the shadow volume

10  Follow a ray from the eye through a pixel until it hits the object to be displayed  Increment a counter each time the ray crosses a frontfacing face of the shadow volume  Decrement a counter each time the ray crosses a backfacing face of the shadow volume  If the counter is greater than zero, the pixel is in shadow  Idea works for multiple triangles casting a shadow

11  Calculating this geometrically is tedious and slow in software  We use the stencil buffer instead  Clear the stencil buffer  Draw the scene into the frame buffer (storing color and Z-data)  Turn off Z-buffer writing (but leave testing on)  Draw the frontfacing polygons of the shadow volumes on the stencil buffer (with incrementing done)  Then draw the backfacing polygons of the shadow values on the stencil buffer (with decrementing done)  Because of the Z-test, only the visible shadow polygons are drawn on the stencil  Finally, draw the scene but only where the stencil buffer is zero

12  It is possible to use color or alpha buffers instead  If shadow volumes don't overlap, we can do the information in one pass, with a single bit of information  If the viewer is inside a shadow volume, we have to change the algorithm  If shadow volume planes intersect the near plane of the viewing frustum, bad things happen

13  Another technique is to render the scene from the perspective of the light using the Z-buffer algorithm, but with all the lighting turned off  The Z-buffer then gives a shadow map, showing the depths of every pixel  Then, we render the scene from the viewer's perspective, and darken those pixels that are further from the light than their corresponding point in the shadow map

14 Scene without shadows Scene from the light's viewpoint Depth map from the light's viewpoint Depth of the light compared to depth of the image Depth test fails Scene with shadows

15  Strengths:  A shadow map is fast  Linear for the number of objects  Weaknesses:  A shadow map only works for a single light, but you can combine multiple maps for multiple lights  Objects can shadow themselves (a bias needs to be used)  Too high of a bias can make shadows look wrong

16  Another issue with shadow maps is that the Z-buffer map may oversample some areas and undersample others  Similar to a texture that is stretched so that some is pixelated and some is far  We can change the view direction and projection so that the Z-buffer map from the lighting better matches the sampling the eye sees  More complex methods make multiple shadow maps along the view

17  The shadow map technique does not, by itself, make soft shadows  Soft shadows can be achieved by sampling the four closest points in the shadow map and interpolating them together  Percentage-closer filtering tries to approximate area lighting with point lights by seeing how much of the nearby surface can see the point light

18

19  Ambient lighting is completely even and directionless  As a consequence, objects in ambient lighting without shadows look very flat  Ambient occlusion is an attempt to add shadowing to ambient lighting

20  Without taking occlusion into account, the ambient irradiance is constant:  But for points that are blocked in some way, the radiance will be less  We use the factor k A (p) to represent the fraction of the total irradiance available at point p

21  The ideas used for ambient occlusion can be applied to other lighting  We could use an irradiance map to give diffuse lighting that is both directed and diffuse  As the figure shows, we can weight the surface normals based on visibility to produce a bent normal  We then use the bent normal for doing lookups in the irradiance map

22  The trick, of course, is how to compute k A  The visibility function approach checks to see if a ray cast from a direction intersects any other object before reaching a point  We average over all (or many) directions to get the final value  Doesn't work (without modifications) for a closed room  Obscurance is similar, except that it is based on the distance of the intersection of the ray cast, not just whether or not it does

23  Generally, ambient occlusion makes the shadows darker than they should be  In a real global illumination situation, objects interreflect, redirecting light onto surfaces that are otherwise blocked  One way to simulate this is by changing the k A term:

24  In static scenes, k A and bent normal n bent can be precomputed  For dynamic scenes, it must be done on the fly  There are object space methods that involve casting rays from every vertex to every other vertex to determine intersections  Optimizations can be done that divide the screen up into hierarchies

25  Screen space ambient occlusion methods have become popular in recent video games such as Crysis and StarCraft 2  Scene complexity isn't an issue  In Crysis, sample points around each point are tested against the Z-buffer  More points that are behind the visible Z –buffer give a more occluded point  A very inexpensive technique is to use an unsharp mask (a filter that emphasizes edges) on the Z-buffer, and use the result to darken the image

26

27

28

29

30

31  Reflection  Transmittance  Refraction  Caustics  Subsurface scattering

32  Keep working on Project 3  Due by midnight next Thursday  Keep reading Chapter 9


Download ppt "Week 10 - Monday.  What did we talk about last time?  Global illumination  Shadows  Projection shadows  Soft shadows."

Similar presentations


Ads by Google