// // Leave a Comment

Shadow Algorithms, Depth Map Shadows and Depth Map Framing

The whole content is from the book Digital Lighting and Rendering by Jeremy Birn.
Here you will get to know about the Shadow Algorithm, Depth Map Shadow and about Depth Map Framing

So let me start with Shadow Algorithm

Shadow Algorithms


Many rendering programs let you choose between two popular techniques to calculate shadows:

  • Depth map (also called shadow map) shadows are typically the quickest and most efficient to render, but have a finite resolution and sometimes need to be adjusted (as described below) to avoid artifacts.
  • Raytraced shadows are easy to use and accurate at any resolution, but usually take more rendering time to compute.

The following sections I will discuss how to use depth map shadows and raytraced shadows, along with their advantages, disadvantages, and options for adjusting their appearance.

Depth Map Shadows


Depth map shadows are currently the most popular kind of shadows used in professional lighting work for film. This kind of shadow works by precomputing a depth map to determine where shadows will be rendered.

A depth map (sometimes abbreviated dmap; also called a shadow map) is an array of numbers representing distances. Before the renderer even begins rendering the scene viewed by the camera, it computes a depth map from the point of view of each light that will cast depth mapped shadows. For each direction that the light shines, the depth map stores the distance from the light to the nearest shadow-casting object found in that direction, as shown in Figure 3.12.

Depth-Map-Shadows

Figure 3.12 A depth map shadow is based on an array of distance measurements from the light to the nearest visible geometry, shown here as white lines.


During the rendering, the light will be cut off at the distances specified by the depth map, so that it does not shine farther than the distance stored for each angle. When rendering a surface under the apple, for example, the renderer needs to check only the depth map to see which parts of the ground are shadowed and which aren't. This saves a tremendous amount of rendering time, because the renderer doesn't need to repeatedly check through the scene to verify where objects come between the ground and the light.

Figure 3.12 shows only one row of depth measurements, as would exist in one "slice" of a depth map. A depth map would actually run both horizontally and vertically over the area illuminated by the light. For example, a depth map with a resolution of 512 would actually be 512 distance measurements wide by 512 distance measurements high.

Resolution and Memory Use

A single distance measurement within a depth map is stored as a floating point value. Floating point values can store just about any number, from tiny fractions to huge distances, but use 4 bytes to store each value. The resolution of a shadow map is used for both the horizontal and vertical dimensions of the map, meaning the number of bytes used is actually 4*(resolution^2). Table 3.1 shows the memory used by common shadow map resolutions, in megabytes.

Table 3.1. Shadow Map Memory Use



Depth Map Resolution            Memory Used

128                                           0.06 MB

256                                           0.25 MB

512                                           1 MB

1024                                         4 MB

2048                                         16 MB

4096                                         64 MB

As Table 3.1 shows, increasing your shadow map resolution will rapidly deplete your system's memory. As general defaults to start with, on a well-framed spotlight, a shadow map resolution of 512 will usually be adequate for television, and a resolution for 1024 will usually be good for final shots in a feature film.

Depth Map Framing


To make shadow maps work efficiently, you need to frame your shadow map so that it covers the geometry in the shadow and not too much extra empty space around it.

Spotlights are the lighting tools of choice for most projects that use depth map shadows. You can aim and control a spotlight to put your shadow exactly where it's needed. If you used an omnidirectional (point) light, then the software would need to calculate multiple depth maps in order to calculate the shadows cast in each direction. If you used a directional (infinite) light, then the depth map shadow might be stretched over too broad an area to optimize its resolution.

If you are lighting with a spotlight, make sure that the cone angle is focused as tightly as possible around your subject, so that you don't waste samples in your depth map shooting off into empty space. Figure 3.13 shows how a shadow map works efficiently for a narrow cone angle, but becomes lower resolution at a wider cone angle, as its samples are wasted over a wider area. If the light is very far away from your subject, you may be able to use a very narrow cone angle. You can check your framing by viewing the subject from the light's point of view, to make sure there isn't too much empty space around the subject within your shadow map.

depth-map-framing


There may be situations when it seems impossible to properly frame a depth map for everything that needs to be shadowed. For example, if the sun were lighting a very large scene including a tree, a house, and an animated character, you'd really want a depth map framed neatly around each of these things. In programmable renderers such as Mental Ray and Renderman, studios can implement solutions providing control over which objects are in each shadow map, and which shadow maps a given light uses. In most off-the-shelf 3D software, however, there is no option to specify an arbitrary list of shadow maps that will be used by a light, nor is there an option that allows you to frame each of those shadow maps differently. When you are stuck with a shadow map covering too wide an area, and can't frame it any tighter because of the number of objects it needs to light, you have several choices:


  • Replace your light with several spotlights, each covering a smaller area. This will add a little bit of natural variation to the lighting, which is often a good thing.

  • Turn off shadows in the main light, and instead use shadows-only lights (described later in this chapter) to create shadows beneath each object.

  • Use different well-focused spotlights for each shadow in a separate shadow pass, then use the shadow pass to darken the scene in compositing software. (Chapter 11, "Rendering Passes and Compositing," goes into detail about this.)

  • Raise the resolution of the shadow map as high as necessary. Be mindful of the memory and performance hit that this solution will take, though. If test renders show that you need to go above 2048 or 4096, you may even find that a raytraced shadow (discussed below) could be more efficient in some cases.

Conclusion


In this post and in the previous post I am just publishing some of the factors of lighting from the field of animation and later I will be discussing on it and I hope you all will like it. 



0 comments:

Post a Comment

Leave a comment