Download presentation
Presentation is loading. Please wait.
Published byAudrey Perry Modified over 9 years ago
1
Shadow Rendering Techniques A point is in the shadow of a light source if it can not be “seen” by the light source, i.e. the line segment that connects the point and the light source intersects other objects. A point that is in the shadow of a light source is not illuminated by the light source.
2
Direct Projection Method Projection Plane Light Source Object Projected Shadow P (x, y, z) P' (x', y', z') P L (x L, y L, z L ) N P' + D = 0
3
Shadow Map Method xLxL zLzL Shadow Map Shadow Map: Texture that stores depth values when the scene is rendered from the perspective of a light source. xvxv zvzv zLzL P 0 (View Point) P L (Light Source) xLxL
4
1)Render the scene from the perspective of the light source. Save depth buffer content as shadow map. 2)Render the scene from the original view point. For each point in the scene, transform its position into light source local coordinates and use the transformed position as texture coordinates (s, t, r). 3)Sample shadow map using (s, t) coordinates, compare the result with r coordinate. If it’s less than r, then the point is in the shadow, otherwise it’s not in the shadow. Shadow rendering procedure using shadow map
5
Shadow Volume Method Light Source Object to cast shadow Shadow Volume Object Outline Shadow Volume: An enclosed region of space that is formed by extruding object outline from the light source.
6
Z-Pass Shadow Volume Algorithm Light Source 1.For each point in the scene, connect a line segment from this point to the view point; 2.Count the number of front facing and back facing shadow volume faces this line segment intersects: n f and n b ; 3.If n f = n b the point is illuminated, otherwise it is in the shadow. View Point Illuminated Shadowed Shadow Volume Object Outline Z-Path algorithm generates incorrect results when the view point itself is in the shadow.
7
Z-Fail Shadow Volume Algorithm Light Source 1.For each point in the scene, cast a ray from this point to infinity that runs away from the view point; 2.Count the number of front facing and back facing shadow volume faces this ray intersects: n f and n b ; 3.If n f = n b the point is illuminated, otherwise it is in the shadow. View Point Illuminated Shadowed Shadow Volume Object Outline Z-Fail algorithm generates correct results when the view point itself is in the shadow.
8
Generate Shadow Volume Faces Orientation of a polygon surface with respect to light source P PLPL N L Polygon Surface Light Source P L Light source position PA point on polygon surface L = P L P Direction to light vector NPolygon surface normal N L > 0, The polygon surface faces toward the light source (front facing) N L 0, The polygon surface faces away from the light source (back facing)
9
Determine object outlines with respect to light source Polygon Surfaces Light Source Polygon Edge For each polygon edge: 1.Find the two polygon surfaces that share this edge. 2.Determine the orientations of these two surfaces with respect to the light source. 3.If one is facing toward the light and the other is facing away from the light, then this polygon edge is an outline.
10
Extrude a point away from light source P P'P' PLPL d P L Light source position PPoint to be extruded P' Extruded point dExtrusion distance
11
Shadow Volume Generation Algorithm Front Face (unchanged) Light Source Outline Edge 1.All polygon surfaces that face toward the light source form the top cap of the shadow volume. 2.For all polygon surfaces that face away from the light source, extrude their vertices and the new extruded polygons form the bottom cap of the shadow volume. 3.Find all polygon edges that are outlines and extrude these outlines into quadrilaterals. These quadrilaterals form the side of the shadow volume. Back Face (extruded) Quadrilateral (Extruded from Outline)
12
Shadow Volume Using Stencil Buffer 1.Render the scene with all light sources turned off. 2.Clear Stencil Buffer 3.Turn off depth buffer and color buffer writes. 4.Render all shadow volume faces facing away from the viewer. Increase stencil buffer value by one for each point that fails the depth test. 5.Render all shadow volume faces facing towards the viewer. Decease stencil buffer value by one for each point that fails the depth test. 6.Turn on depth buffer and color buffer writes. 7.Render the scene again with light source turned on and only where the stencil buffer value is zero. 8.Repeat 2, 3, 4, 5, 6, 7 for each light source.
13
Radiosity Illumination Model Use physical laws that govern radiant energy transfer between objects. Radiant Energy Terms Total Radiant Energy E Radiant Flux (Radiant Power): Radiant energy transmitted per unit time Radiosity : Radiant flux per unit area of a surface Intensity : Radiant flux in a certain radiant direction per unit solid angle per unit projected area : Angle between radiant direction and surface normal
14
Radiosity for Lambertian Reflector x y N dd dB Radiant Direction
15
Form Factor Form Factor F jk : Fractional amount of radiant energy from surface j that reaches surface k. Surface j Surface k NjNj dd dB j NkNk dA j dA k jj kk r
16
Properties of form factors For planar surface and convex surface
17
Basic Radiosity Model The object surfaces must form an enclosed space that has no energy exchange with outside world. Assume each surface is either a Lambertian reflector, a emitter, or a combination of both. Divide each surface into small surface polygons (surface patches) and calculate form factors. Solve radiosity equations. B i Radiosity of surface i E i Energy emission rate per unit area of surface i i Reflectivity of surface i i = 1, 2, 3, …, n Radiosity equations k = 1, 2, 3, …, n
18
or Solve the above equations for B i
19
Ray-Tracing Methods Basic Ray-Tracing Algorithm Projection Reference Point Pixel Center Pixel Ray Projection Plane
20
1.Cast pixel ray from projection reference point through pixel center. 2.Each time a pixel ray intersects an object surface, it splits into two secondary rays: a reflection ray and a refraction ray. (No refraction ray for opaque object.) 3.Repeat step 2 for each pixel ray. Each intersected surface is added to a binary ray-tracing tree. 4.A pixel ray is terminated when the ray intersects no surfaces, intersects a light source that is not a reflecting surface, or the ray- tracing tree reaches maximum allowable depth. Ray Casting Procedure
21
S1S1 S2S2 S3S3 S4S4 R1R1 T1T1 R2R2 R3R3 T3T3 R4R4 Projection Reference Point S1S1 S2S2 S3S3 S4S4 T1T1 R1R1 R2R2 R3R3 T3T3 R4R4 Paths of pixel raysRay-tracing tree
22
Pixel Intensity Calculation The ray-tracing tree is processed in bottom-up order. (Trace each pixel ray backward.) For each pixel ray at the bottom of the tree, its intensity is assigned a background intensity value if it does not intersect a light source. Otherwise the intensity is assigned to the light source intensity. At each surface intersection, the intensities from reflection ray, refraction ray and intensity contributions from all the light sources are accumulated for the parent ray. Pixel ray intensity is attenuated by the distance it travels. The pixel intensity is obtained at the root of the tree.
23
N R L V H Light Source Incoming ray Reflected ray Shadow ray Refracted ray T u uUnit vector in pixel ray direction VUnit vector in direction to viewer RUnit vector in reflected ray direction TUnit vector in refracted ray direction NSurface normal LUnit vector in shadow ray direction (direction to light source) HHalfway vector IRIR ITIT I
24
k t : Transparency coefficient
25
Advantage of Ray-Tracing Algorithm Ray-tracing can produce highly realistic scenes. It automatically detects visible surfaces, renders shadows, transparency effects and generates perspective projection views. Disadvantage of Ray-Tracing Algorithm Ray-tracing calculation is highly complex and takes considerable more time to complete than basic illumination and shading models. It is not yet implemented in hardware and is not suitable for real time rendering (simulations, games, etc.) at this time. Most calculation time of ray-tracing algorithm is spent on ray-surface intersection calculations
26
Methods to Speed up Ray-Tracing Calculations Bounding Volume Enclose a group of objects within a bounding volume (sphere or box). If a pixel ray does not intersect the surface of the bounding volume, then it does not intersect the objects inside the bounding volume. Bounding SphereBounding Box Bounding Volume Tree Enclose several smaller bounding volumes with a larger bounding volume to form a hierarchical tree structure. The intersection test is done by processing the tree in top-down order.
27
Space Subdivision Methods Obtain bounding box for the entire scene Divide the bounding box into a number of sub regions (cells). Sub regions are usually rectangular solids. Each cell is associated with a list of objects it contains. For each pixel ray, trace the cells it intersects and only perform intersection tests for objects within these cells. Pixel ray
28
Distributed Ray-Tracing Use stochastic sampling method that randomly distributes rays according to various parameters. Jittering Divide a pixel area into regular grid of subpixels. Generate jittered positions by randomly perturbing the center of each subpixel by a small amount. Anti-aliasing Effect Fire subpixel rays through the jittered subpixel positions and average the intensity of these rays to obtain pixel intensity.
29
Out-of-focus Effect Place a lens in front of projection plane. Distribute subpixel rays through aperture area of the lens. Projection Reference Point Projection Plane Object Plane Lens
30
Gloss Effect Gloss: Specular highlight that is blurred. Distribute reflection rays around the specular reflection direction. N R Incoming rayReflected rays u
31
Translucency Effect Translucency: Light passing through the material is scattered so that objects behind the material appear blurred. Distribute refraction rays around the ideal refraction direction. N T Incoming ray Refracted rays u
32
Soft Shadows under Extended Light Source Extended Light Source Object UmbraPenumbra Umbra: Completely dark region Penumbra: Partially illuminated region
33
Motion Blur Effect Distribute rays over time. Motion Blur: Moving objects appear blurred on film. Distribute shadow rays over the area of the light source. N L Shadow rays Extended Light Source
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.