1. Trang chủ
  2. » Công Nghệ Thông Tin

Advanced Maya Texturing and Lighting- P4 potx

30 253 0
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề Creating Highquality Shadows
Trường học Standard University
Chuyên ngành Advanced Maya Texturing and Lighting
Thể loại Luận văn
Năm xuất bản 2008
Thành phố Standard City
Định dạng
Số trang 30
Dung lượng 2,12 MB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

qual-Understanding Depth Maps when the use depth Map Shadows attribute is checked for a spot, directional, point, area, or volume light, Maya creates a temporary depth map see Figure 3.1

Trang 1

High-Shadows are an inescapable part of the physical world Unless an animation is intended for a stylized look, high-quality shadows are a necessity for a professional render Depth map and raytrace shadows can be fine-tuned to match many lighting scenarios In addition, you can shadow advanced effects in Maya, including Light Fog, Maya Fur, Paint Effects, Maya Hair, nCloth, and the Toon system To make the shadow-rendering process more efficient, you can link shadows.

Chapter Contents

Depth map methodology Fine-tuning and troubleshooting depth maps Adjusting raytrace shadows

Linking and unlinking shadows Applying shadows to Light Fog Creating shadows with Paint Effects Creating shadows with Maya Fur and Hair System Using shadows with nCloth and the Toon system

3

Trang 2

Rendering Depth Maps

depth maps are easy to apply and efficient to render unfortunately, their default ity is generally poor you can improve the quality by adjusting various attributes and applying specific lighting strategies

qual-Understanding Depth Maps

when the use depth Map Shadows attribute is checked for a spot, directional, point, area, or volume light, Maya creates a temporary depth map (see Figure 3.1)

Figure 3.1 The Depth Map Shadow Attributes section of a spot light’s Attribute Editor tab

the depth map represents the distance between surfaces in the scene and the shadow-casting light from the light’s point-of-view this information is stored as a monochromatic Z-depth buffer (see Figure 3.2) objects far from the light receive dark pixels, and objects closer to the light receive light pixels

Figure 3.2 A depth map

Trang 3

com-is greater than that encoded in the depth map pixel, it’s assumed that another surface

occludes the surface point’s view of the light and the surface point is therefore

shad-owed For example, in Figure 3.2 a distant building is partially occluded by a pair of

gas pumps the gas pumps are assigned brighter pixels because they are fairly close to

the light the part of the building that’s not occluded has fairly dark pixels Since the

distance value of the dark pixels is equal to the actual distance that the surface points

are from the light, no shadows occur in that area (with the exception of self-shadowing,

which is discussed later in this section)

By default, depth maps are temporarily written to disk during a render but are not saved you can force Maya to save the depth map as a Maya iFF bitmap, however,

by switching the disk Based dmaps attribute (found in the shadow-casting light’s

attribute editor tab) from off to one of the two following options:

Reuse Existing Dmap(s) with this option, the first time a frame is rendered, the depth

map is written to the project folder with a name established by the Shadow Map File

name field (see Figure 3.3) (this attribute is called dmapname in version 8.5.) you

can automatically add suffixes to the map name by checking the add Scene name and

add light name attributes each subsequent time the same frame is rendered, the

written depth map is retrieved this option is appropriate if the light position does

not change between renders you can change light attributes, such as intensity, and

material attributes (with the exception of displacement maps) between renders with no

penalty in addition, cameras can be repositioned

Figure 3.3 The Disk Based Dmaps section of a spot light’s Attribute Editor tab

if you batch-render an animation, the reuse existing dmaps(s) option will render only

the depth map for the first frame and apply it to all the frames this is appropriate

if objects are static (however, you can animate the camera) if objects are in motion,

and their motion does not change between batch renders, check the add Frame ext

attribute add Frame ext adds a frame number to the depth map filename the first

time the animation is rendered, a depth map is rendered for each frame For each

sub-sequent render, the series of depth maps is retrieved and reused

Overwrite Existing Dmap(s) this option assumes that a depth map has been written out

at least one time the new depth map is written over the old one with the name set

by the Shadow Map File name attribute this option allows you to destroy old depth

maps without seeking out the actual files

Trang 4

when a depth map is calculated, Maya shoots a shadow ray from the light view plane through each pixel of the depth map the first surface point that the ray encoun-ters is recorded in the SM map the MIDMAP.SM map is created by the use Mid dist attribute.

Note: The depth map scene name suffix used by the batch render process differs from the scene name suffix used by the Render View window The batch render uses the temporary scene file name,

scene files to disk with every batch render, even when no depth map shadows are present This ence in suffix names can confuse the Reuse Existing Dmap(s) and Overwrite Existing Dmap(s) options

differ-Adjusting Use Mid Dist and Bias

By default, use Mid dist is checked for each light type that supports depth map ows this attribute significantly reduces self-shadowing artifacts, which often appear

shad-as bands across flat surfaces or a degradation of the shadow shad-as it wraps around a curved surface (see Figure 3.4)

Figure 3.4 Extreme to subtle depth map artifacts

the artifacts are generally caused by one of two reasons:

S

surface points this can occur when surface points are sampled within the boundary of a depth map pixel and are discovered to be farther from the light than the distance value encoded in that pixel (see Figure 3.5) Since the dis-tance value stored in a depth map pixel is based on a single sample—one taken

at the point which the shadow ray intersects the surface—this problem occurs frequently

Trang 5

Boundary of a single pixel

in the depth map

Surface point considered in shadow

Surface point considered in light

Center of depth map pixel, where shadow ray intersects the surface

Shadow ray

Figure 3.5 A simplified representation of the depth map artifacts

t

unable to accurately sample areas of high curvature in such a case, surface points are incorrectly considered “behind” or “below” adjacent surface points

in either of these situations, the artifacts are not visible in the depth map map itself the artifacts occur only during the render of the final image as a solution,

bit-you can increase the depth map resolution value unfortunately, this will reduce the

size of the artifacts but will not necessarily eradicate them

the use Mid dist attribute, on the other hand, artificially pushes the surface points closer to the light by comparing the distance from the light to the surface point

and the distance from the light to a point halfway between the first surface

encoun-tered by the shadow ray and the second surface encounencoun-tered (see Figure 3.6) the

sec-ond surface encounters are recorded in the MIDMAP.SM depth map

if a second surface is not encountered, the light’s far clipping plane value is used again, the basic depth map algorithm works in the following manner:

i

distance encoded in the depth map pixel that contains the surface point in its boundary, the surface point is in light

i

encoded in the depth map pixel that contains the surface point in its boundary, the surface point is shadowed

in this situation, use Mid dist forces the depth map to encode distances that are greater than the actual distance to the first surface encountered Hence, surface

points sampled during the render have a greater likelihood of possessing a smaller

distance value when compared to the distance encoded in the corresponding depth

map pixel

Trang 6

4x4 pixel depth mapsuperimposed over light view plane

C) Mid-distance pointemployed by Use MidDist attribute

depth map

Shadow ray

Figure 3.6 A simplified representation of the Use Mid Dist process

although use Mid dist is responsible for a huge improvement in the quality of the render, it cannot eliminate 100 percent of the artifacts the Bias attribute, which operates on similar principles, is designed to work in conjunction with use Mid dist

Bias holds true to its name and “biases” the surface points toward the light casting the shadow whereas use Mid dist forces the depth map to take its distance value from a point midway between the first encountered surface and the second, Bias simply multiplies the actual surface point position by a factor that transforms it closer

to the light For spot and point lights, the number entered into the Bias field is plied by the distance value derived from the depth map, the result of which is used to determine how far to offset the surface point in world space Hence, large Bias num-bers tend to make the shadow disappear or develop large holes For directional lights, the Bias attribute is not multiplied by the depth map values but is used as is

Trang 7

depth map artifacts appear along the edge of a convoluted surface although a 0.25

Bias value reduces the problem, a value of 0.5 removes the artifacts completely Higher

values erode the self-shadowing on the surface

Figure 3.7 Depth map artifacts are eliminated by adjusting the Bias attribute This scene is included on the CD

with most scenarios, checking use Mid dist and leaving Bias at its default value is satisfactory for a scene However, if you find it necessary to change the

Bias value, proceed with caution a Bias value that removes an artifact at one point

on a surface can introduce an artifact at another point For example, an incorrect

Bias value will often “disconnect” a surface from a ground or floor in Figure 3.8, a

thin nurBS leg loses its connection with a plane

Figure 3.8 Three Bias values affect the connection of a depth map shadow to a NURBS leg This scene is included on the CD

Trang 8

Creating Multiple Depth Maps

if necessary, you can generate more than two depth maps per spot light if a scene is large in world space or necessitates a large resolution size, you can uncheck the use only Single dmap attribute when this attribute is unchecked, six additional attri-

butes become available with the following naming convention: use Axis+/– Map (see

ShadowMapFileName.XP.iff ShadowMapFileName.MIDMAP.XP.iff

neg-ative the ability to choose direction is particularly useful for a spot light that must cover a large model For example, in Figure 3.10 a spot light with a 120-degree Cone angle value is placed close to the model of a building use X+ Map, use X– Map, and use Z– Map are checked the resulting render creates two depth maps—one stan-dard and one for use Mid dist—in each axis direction if use only Single dmap had been checked, the left and right sides of the model would have been excluded from the depth map if the spot light were moved farther from the model to avoid this problem,

a significantly larger resolution would be required to maintain the map’s detail

By default, point lights create six standard depth maps and six corresponding depth maps for use Mid dist these maps surround the point light in a virtual cube you can turn off particular directions to save render time For example, if

no critical geometry exists below the point light, you can uncheck use y– Map if

a particular direction is completely empty, the corresponding depth map is ignored automatically

Trang 9

Figure 3.10 Six depth maps are generated for one spot light.

you can view a depth map iFF file by choosing File > View image and ing for the filename the FCheck window opens press the Z key while the mouse

brows-arrow is over the window or click the Z Buffer button Since the depth information is

stored in the Z channel of the iFF file, the depth map cannot be seen in photoshop or

other standard digital-imaging program However, if you choose File > Save image in

FCheck while the depth map is visible, you can export the monochromatic image to

any of the image formats supported by Maya in this case, the information is written

as rgB unfortunately, the converted file cannot be read by a Maya renderer because

a depth map with an iFF extension and a Z channel is expected during the

shadow-casting process

Refining Depth Maps

Maya depth maps possess other attributes that are critical to the quality of their

ren-der these include resolution, Filter Size, Shadow Color, and use auto Focus in

addi-tion, a specialized mental ray depth map and area light offers an alternative approach

to creating shadows

Setting the Resolution, Filter Size, and Shadow Color

resolution sets the pixel size of the depth map Filter Size controls the amount of edge

blur applied to the shadow as a general rule of thumb, you can follow this guideline:

a

a

aside from softening the shadow’s edge, the Filter Size attribute is designed to disguise depth map limitations Since depth maps are restricted by a fixed number

of pixels, the pixels are often visible in the render For example, in Figure 3.11 three

Trang 10

Figure 3.11 A depth map with a 512 Resolution and three different Filter Size values

the blur created by Filter Size is applied to the shadow map equally at all edge points Hence, it cannot replicate a diffuse shadow that changes edge quality over distance you can overcome this limitation, however, by creating a custom shading network For a demonstration of this, see Chapter 7

Shadow Color tints the color of the shadow, thus emulating bounced light

Choosing a lighter color also creates a shadow that is less intense and gives the appearance that a greater amount of fill light is present

Setting a Light’s Focus

the use auto Focus attribute automatically fits objects in the light’s view to the lution of the depth map that is, if the objects are surrounded by empty space, the light view is “zoomed” in to maximize the number of pixels dedicated to the objects

reso-use auto Focus is available on spot, directional, and point lights area and volume lights do not possess the attribute

Note: If the cone of a spot light cuts objects out of the spot light’s view, the Use Auto Focus bute will not widen the view for the depth map To avoid this problem, you will have to increase the light’s Cone Angle, move the light backward, or manually set the light’s Focus attribute

attri-in some situations, a scene will benefit if use auto Focus is unchecked and the light’s Focus value is set manually For example, if a depth map shadow is not critical for objects on the fringe of a scene, you can choose a Focus value that allows the light

to concentrate on the scene’s most important elements

to choose an appropriate Focus value for a spot light, use the following steps:

the Focus attribute becomes available

Manipula-tor > Cone angle in a workspace view, choose panels > look through Selected

the view through the light appears

objects in the scene that require a depth map shadow do not allow the cone circle to “split” a shadow-casting object in half; the resulting shadow will come

Trang 11

Shadow Map File name field, and render out a test frame (this assumes that

no depth maps have been written out.) double-check the resulting depth map with FCheck in the workspace view used to look through the light, choose an orthographic view through the panels menu; this removes the temporary cam-era attached to the light by the look through Selected command

although directional lights possess the Focus attribute, choosing an appropriate value requires a different strategy By default, directional lights possess direction but

have no true position; despite the location of the light icon, they are considered to be

an infinite distance from the subject Hence, a directional light automatically includes

all the objects in a scene for a depth map shadow as a result, two new attributes

become available when use auto Focus is unchecked: width Focus and use light

position use the following steps to set these attributes:

Focus and check use light position

through the light appears with alt+rMB, dolly the light in or out so that the shadow-casting objects fill the view

the camera’s attribute editor tab, note the value in the orthographic width field in the orthographic Views section the orthographic width attribute represents the width of the visible scene as measured from the left side to the right side of the current view enter the value into the width Focus field of the directional light

Shadow Map File name field, and render out a test frame (this assumes that

no depth maps have been written out.) double-check the resulting depth map with FCheck if the foreground appears clipped, the light icon is below, inter-secting, or otherwise too close to the clipped surface Simply dolly the light back in the workspace view and render another test if shadow-casting objects are cut off at the left or right side of the depth map, gradually increase the width Focus value and render additional tests

the process of setting the focus for a point light is also unique the point light Focus attribute does not correspond to either the Cone angle or orthographic width

attribute you can determine an appropriate Focus value, however, by employing the

following formula:

Focus = depth map world space width * 12you can determine the world space width of a desired depth map by measuring across a scene with the distance tool (choose Create > Measure tools > distance tool)

For example, in Figure 3.12 a desired depth map includes three center cones but not

Trang 12

Point light view Resulting depth map

Figure 3.12 The Focus value of a point light is determined with the assistance of the Distance tool This scene is included on the CD

Using mental ray Shadow Maps and Area Lights

the mental ray renderer supports standard Maya depth maps in addition, mental ray can produce its own shadow map variation you can also adapt a standard spot or area light by activating the mental ray area light options (to render the mental ray light and shadow variations, switch the render using attribute, in the render Settings window, to mental ray.)

when checked, the use mental ray Shadow Map overrides attribute (found

in the Shadows subsection of the mental ray section of a spot, directional, area, or point light’s attribute editor tab) overrides the standard Maya depth map shadow

(with Maya 8.5, you must uncheck the derive From Maya attribute.) the Shadow Map Format attribute, found just above use mental ray Shadow Map overrides, con-trols the type of mental ray shadow map the regular Shadow Map option produces mental ray depth maps, which are more advanced than the Maya equivalent due to additional attributes the detail Shadow Map option supports object transparency and is discussed in Chapter 11 if you click the take Settings From Maya button, the applicable values from the depth Map Shadow attributes section are transferred to the mental ray Shadow Map overrides subsection the following attributes control the look of the resulting mental ray shadow:

Resolution Sets the pixel size of the depth map.

Samples Sets the number of subpixel samples taken per pixel low values create

grainy results

Softness Controls the spread of the light Values above 0 create a softer, more diffuse

shadow edge Higher values necessitate higher Samples values to create acceptable results (see Figure 3.13) High values tend to smear the shadow at surface corners

Trang 13

Figure 3.13 mental ray depth map shadows with two attribute settings

Bias Functions in the same manner as the default Maya depth map Bias attribute by

offsetting surface points to avoid self-shadowing artifacts this attribute, if above 0,

overrides the Shadow Map Bias attribute in the Shadow Map subsection of the render

options section of the mental ray tab in the render Settings window Maya

documen-tation recommends a Bias value that is less than the world distance between the light

and the shadowed object (additional shadow attributes, including those found in the

mental ray tab of the render Settings window, are discussed in detail in Chapter 11.)

Shadow Map File Name when a name is entered into this field, mental ray shadow maps

are written to disk in the renderData\mentalray\shadowMap folder within the project

directory the maps are overwritten with each new render the depth map files are

written in a native mental ray format and cannot be viewed with FCheck point lights

automatically produce six depth map files, while other lights produce one each

you can convert a spot light into a mental ray area light by checking the area light attribute (found in the area light subsection of the mental ray section of a spot

light’s attribute editor tab) you can convert a standard Maya area light into a mental

ray area light by checking use light Shape (found in the same subsection) in both

cases, mental ray adapts the chosen light by grafting a specialized mental ray area

light onto the light icon (see Figure 3.14)

Figure 3.14

When the Area Light attribute is checked, a mental ray light is grafted onto the spot light icon

Trang 14

Figure 3.15 (Left) Raytrace shadow with a mental ray area light grafted onto a spot light

(Right) Default raytrace shadow with same spot light This scene is included on the CD as area_spot.ma.you can adjust the resulting shadow with the following attributes:

Type determines the shape of the area light options include rectangle, disc, Sphere,

Cylinder, and user if type is set to Cylinder, the area light sends shadow rays above, below, and behind the parent light if type is set to Sphere, the area light sends shadow rays in all directions the user option allows you to apply a custom mental ray light shader to the area light

High Samples Sets the number of shadow rays emitted from the area light, as

mea-sured in the X and y direction of the light’s icon default values leave the shadow very grainy High values create an excellent result but slow the render

High Sample Limit represents the maximum number of times a shadow ray is

permit-ted to reflect or refract before it must employ the low Samples attribute By switching

to low Samples, fewer shadow light rays are involved when calculating reflections and refractions

Low Samples the number of shadow rays employed when the High Sample limit is

reached

Visible if the parent light is a Maya area light, the Visible attribute determines

whether the mental ray area light icon is visible in the render if Visible is checked, Shape intensity becomes available and controls the strength of the visibility if Shape intensity is set above 0, the icon renders as a solid white rectangle but does not affect the light striking surfaces in the scene Maya documentation recommends using the mental ray area light in conjunction with the Maya area light as it requires lower sampling levels to produce higher-quality shadows

Solving Light Gap Errors

light gaps, which look like thin, bright lines, often appear along the intersection of two surfaces For example, in Figure 3.16 two primitive planes sit at a right angle

Trang 15

and intersect slightly a spot light, placed behind the surfaces, casts a default depth

map shadow a light gap appears along the intersection seam Such gaps are due to a

mismatch of the depth map to the render of the geometry depth maps do not receive

anti-aliasing, which leads to stair-stepping (See Chapter 10 for information on render

quality issues.) in this situation, the depth map will not accurately line up with the

anti-aliased render, and the bright surface appears in the resulting “gap.” the light’s

Filter Size attribute, which blurs the shadow edge, widens the gap if raised above 0

Resolution = 512Filter Size = 0Bias = 0.001

Resolution = 512Filter Size = 8Bias = 0.001

Resolution = 512Filter Size = 8Bias = 0.01

Resolution = 1024Filter Size = 4Bias = 0.001

Figure 3.16 A light gap is visible at the intersection of two planes This scene is included on the CD as light_gap.ma

in this situation, higher Bias values make the error worse you can increase the light’s resolution, which will reduce the strength of the light gap However, the

increased resolution will not make the error disappear completely (see Figure 3.16)

Switching to raytrace shadows will solve the problem but requires a more

time-intensive render another solution involves the following steps:

attributes section, set the shadow attributes to create a satisfactory shadow

Shadow Map File name field (this assumes that no depth maps have been written out.) render a test frame the render will write the depth maps to the project folder

from the light in the example illustrated in Figure 3.16, the plane needs to be translated only 0.2 units in the Z direction when the plane is moved away from the light, the gap is covered by the geometry and is no longer visible in the render the depth map is not updated since the reuse existing dmaps(s) option retrieves the map after it has been written out the first time

Ngày đăng: 02/07/2014, 05:20

TỪ KHÓA LIÊN QUAN