shadows
play

Shadows Graphics & Visualization: Principles & Algorithms - PowerPoint PPT Presentation

Graphics & Visualization Chapter 13 Shadows Graphics & Visualization: Principles & Algorithms Chapter 13 Introduction Wherever there is light, there is shadow Shadows are not just a photorealistic image


  1. Graphics & Visualization Chapter 13 Shadows Graphics & Visualization: Principles & Algorithms Chapter 13

  2. Introduction • Wherever there is light, there is shadow • Shadows are not just a photorealistic image enhancement: Help the eyes register objects relative to their surroundings  Define the direction of the incident light  Provide clues for the shape and depth of 3D objects:  Important in the case of monoscopic imaging  u Perspective cannot always give enough clues about the perceived objects u Shadows help resolve part of the depth ambiguities that may arise 2 Graphics & Visualization: Principles & Algorithms Chapter 13

  3. Introduction (2) • Size and depth clues from shadow: (a) A lit scene showing a ball in front of a staircase  (b) Size/distance ambiguity, when scene perceived from viewpoint of (a)  (c)–(e) Images rendered from the same viewpoint as (a). Shadows help us  define the object relative to its surroundings 3 Graphics & Visualization: Principles & Algorithms Chapter 13

  4. Introduction (3) • In real-time graphics applications, shadow-generation algorithms are utilized to add a complex look to an otherwise simple geometry: • Illumination transitions: help our vision system justify the lack of detail-related contrast  4 Graphics & Visualization: Principles & Algorithms Chapter 13

  5. Shadows & Light Sources • Shadows are formed on surfaces due to the blocking of direct illumination from other surfaces • A shadow consists of two zones: Umbra: surface area where shadow is cast with full light-source occlusion  Penumbra: area where shadow is partially lit by the light-emitting source  • In order for a surface to be partially in shadow, the light source needs to be of non-negligible volume compared to the size of the objects As distance affects the apparent size of objects, the apparent projection of the  light emitter on the surface needs to be non-negligible to create a penumbra 5 Graphics & Visualization: Principles & Algorithms Chapter 13

  6. Shadows & Light Sources (2) • Shadows caused by non-infinitesimal light sources & have an umbra & a penumbra are called soft shadows • Hard shadows only consist of an umbra & are caused by point-sized light sources and infinitely far light emitters • Sharpness & shape of a shadow depend on size and distance of the light source(s) (a) Point light source (hard shadow) (b) Small non-infinitesimal light source (soft shadow) (c) Large area light (soft shadow) (d) Infinite (directional) light source (hard shadow) 6 Graphics & Visualization: Principles & Algorithms Chapter 13

  7. Shadows & Light Sources (3) • Interaction of a point light source & a shadow caster produces a pyramidal shadow shaft clipped at the caster surface: • • The volume that represents the unlit space is called shadow volume • Normally a shadow volume is infinite: It extends away from the light source to infinity, unless the light source has a  local effect & a finite range: Shadow volume extends up to the range of influence of light source  7 Graphics & Visualization: Principles & Algorithms Chapter 13

  8. Shadows & Light Sources (4) • Directional lights are considered to be casting light in parallel rays toward the scene: Shadow shafts produced by directional lights are prismatic volumes with  parallel sides and the resulting shadows neither converge nor diverge 8 Graphics & Visualization: Principles & Algorithms Chapter 13

  9. Shadows Generation Algorithms • For offline photorealistic rendering, shadow generation is usually integral part of ray-tracing or global illumination procedure • In real-time computer graphics, there are 2 algorithms most commonly employed for shadow casting: Shadow volumes: works in object space and is ideal for casting hard, precise  shadows on polygonal objects Shadow mapping: works in image/texture space, it is applicable in a wide  range of geometric entity representations, can be adapted to handle semi- transparent and partially occluding media, NOT effective in producing sharp- edged shadows. 9 Graphics & Visualization: Principles & Algorithms Chapter 13

  10. Shadow Volumes GENERAL CONCEPT: • The algorithm attempts to construct in object space the frusta that are formed for each combination of light source and light-blocking piece of geometry ( occluder ) • Then, each pixel to be drawn that lies on the visible geometry is tested for containment in the shadow volumes, and its shading is determined according to this query • The shadow-volume algorithm: Requires that the occluders are polygonal  Assumes that connectivity information is available for these meshes  Or can be determined as a pre-processing step  10 Graphics & Visualization: Principles & Algorithms Chapter 13

  11. The Stencil Buffer (1) • Stencil buffer: Is a buffer, allocated in the graphics hardware or the system memory  Implements a counter and comparator unit per image pixel  Is equal in dimension to the frame buffer and usually has a resolution of 8 bpp  • The result stored in the stencil buffer can work as a mask • Perform one or more rendering passes that fill the buffer with the appropriate values and then use these results to prevent areas of the final rendering pass to be drawn in the frame buffer • Contents of the stencil buffer are compared to a reference value and depending on the stencil test, the incoming fragments are eliminated or propagated to the frame buffer • Stencil test is a comparison operator (always/never pass, ≠ , =, ≥ , ≤ , >, < ) 11 Graphics & Visualization: Principles & Algorithms Chapter 13

  12. The Stencil Buffer (2) • Example of using the stencil buffer to draw the silhouette of a group of primitives in the frame buffer, using an unconditional increment operator on the stencil values and an equality test as the stencil masking operator: (a) Stencil buffer update pass: writing to the frame buffer is disabled and the operation on the stencil values is set to always increase (b) Conditional rendering pass in the frame buffer: fragments are rendered only if the corresponding stencil values are equal to zero. 12 Graphics & Visualization: Principles & Algorithms Chapter 13

  13. The Stencil Buffer (3) • Stencil buffer can be conditionally updated • Operations on the stencil buffer include: replacing,  setting,  maintaining,  incrementing,  decrementing,  inverting the current values  13 Graphics & Visualization: Principles & Algorithms Chapter 13

  14. Stenciled Shadow Volumes • Surface-in-shadow test in the basic shadow-volume algorithm: A counter is incremented each time the eye-to-fragment line enters a shadow  volume and decremented when it exits The surface is in shadow when the counter is other than 0  If the rendered point lies within the shadow volume, surface will be hit before  ray exits one or more of the overlapping shadow volumes  counter > 0 • This procedure can be supported by graphics hardware if the counter is implemented via the stencil buffer. 14 Graphics & Visualization: Principles & Algorithms Chapter 13

  15. Stenciled Shadow Volumes (2) • Stenciled Shadow Algorithm: 1. Initialization : Clear depth and frame buffers, ignore the stencil operations 2. Shadow lighting : Render the geometry using only the indirect illumination components and emissive effects (lights off) 3. For each occluder, prepare and render the shadow volume: (a) Shadow volume construction . Construct a closed shadow volume by extruding the faces of the caster away from light source. (b) Volume Z-pass test. Render the front-facing polygons of the shadow volumes without updating frame or depth buffer. Each time a fragment successfully passes the depth test, the stencil buffer is incremented. (c) Render the back-facing polygons of the shadow volumes, without depth and frame buffer updates. This time, decrement the corresponding stencil values when fragments pass the depth test. 4. Render the lit geometry . Enable the light source and shade all pixels whose corresponding stencil value is zero. 15 Graphics & Visualization: Principles & Algorithms Chapter 13

  16. Stenciled Shadow Volumes (3) • Shadows from multiple light sources are handled by repeating Steps 3 and 4 for each light source • Step 4 should use additive blending when writing to the frame buffer and completely disable the ambient component of the light sources  mix the illumination of the shadowed areas & avoid overshooting the lit surfaces 16 Graphics & Visualization: Principles & Algorithms Chapter 13

  17. Stenciled Shadow Volumes (4) 17 Graphics & Visualization: Principles & Algorithms Chapter 13

  18. Stenciled Shadow Volumes (5) 18 Graphics & Visualization: Principles & Algorithms Chapter 13

  19. Stenciled Shadow Volumes (6) Remarks: • For one light source, 2 passes are required to render the visible geometry (shadow & diffuse / specular - passes 1 & 4) + 2 shadow- volume geometry passes (front & back faces – passes 2 & 3 ) 19 Graphics & Visualization: Principles & Algorithms Chapter 13

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend