if the connection between a shading group node and material is deleted, the assigned surface appears solid green in the workspace view and is skipped by the renderer see Figure 4.1.. Sha
Trang 1Chapter Tutorial: Lighting a Flickering Fire Pit with Shadows
in this tutorial, you will create a fire with soft, flickering shadows (see Figure 3.29)
you will use paint effects fire with a volume, ambient, and directional light
Figure 3.29 Fire created with a Paint Effects brush and lit with a directional, ambient, and volume light A QuickTime movie is
included on the CD as fire_pit.mov
directional light open its attribute editor tab Change the Color to a pale blue this will serve as the scene’s moonlight
2 Move the directional light above the set and to screen right rotate it toward
the fire pit render out a test frame adjust the light’s intensity and Color until satisfactory although this light will not be the key light, the sand and rocks should be appropriately visible for nighttime
Set resolution to 512 and Filter Size to 6 this combination of medium tion and moderate Filter Size will create a slightly soft shadow render a test frame experiment with different light positions and shadow settings
resolu-4 Create an ambient light and open its attribute editor tab Set the intensity
attri-bute to 0.2, or approximately 1/10th the intensity value of the directional tint the ambient light’s Color to pale blue Move the ambient light to screen left, just above the set this light serves as a low fill that will prevent the backside of the rocks from becoming too black
Cylinder Change the Color to a deep orange in the penumbra section, click the
Trang 26 Move the volume light to the center of the fire pit Scale the light so that it is approximately twice the length, width, and height of the fire pit in this case, the volume light will look oval from the top and short and squat from the side
render a test frame to see how far the light from the volume light is traveling
resolution to 128 and Filter Size to 6 this creates a soft shadow emanating from the center of the pit render out a test frame the rocks should produce shadows similar to the shadows in Figure 3.29
8 Select the cone-shaped ash geometry, which lies in the center of the fire pit
Choose paint effects > Make paintable Choose paint effects > get Brush the Visor window opens in the paint effects tab, click the brush category folder named fire Several fire brush icons become visible Click the largeFlames icon
Close the Visor window in the top view, click-drag the pencil mouse icon over the ash geometry when the mouse button is released, a paint effects stroke is created keep the stroke fairly short
9 render out a test frame Fire will appear where the stroke is drawn initially, the fire is too small to be seen over the top of the sticks and rocks Select the stroke curve and open its attribute editor tab (which is labeled largeFlames1)
Change the global Scale attribute to 60 render out a test frame the flame should be clearly visible if the flames appear too bright or saturated, adjust the stroke’s Color1 and Color2 attributes (found in the Shading section of the stroke’s attribute editor tab) in addition, you can darken the glow Color (found in the glow section of the stroke’s attribute editor tab) initially, the flames will move too slowly to speed up the fire, change the Flow Speed attri-bute to 0.8 you can find Flow Speed in the Flow animation section of the stroke’s attribute editor tab
10 Following the process detailed in steps 8 and 9, paint additional paint effects strokes on the ash geometry Multiple strokes are necessary to make the fire convincing experiment with different fire styles with different scales the ver-sion illustrated in Figure 3.29 uses three strokes and employs the following brushes: largeFlames and flameMed
11 paint effects fire is preanimated and will automatically change scale and shape
in a convincing manner to match this animation, you can keyframe the sity, translateX, and translateZ of the volume light to do this, move the time-line slider to frame 1 Select the volume light Set a key by pressing Crtl+S or choosing animate > Set key from the animation menu set a red key frame line will appear at frame 1 of the timeline Move the timeline slider to frame 5
inten-translate the volume light slightly in the X or Z direction (no more than 1 world unit) Set another key repeat the process through the duration of the timeline
Trang 3in a fashion similar to actual flickering fire light.
Figure 3.30 The Graph Editor view of the volume light’s Intensity curve (top) and TranslateX
and TranslateZ curves (bottom)
time-line slider to a desired frame and right-click the intensity field in the shortcut menu, choose Set key For the duration of the timeline, set intensity keys every
3 to 12 frames randomly vary the intensity from 2 to 3 (see Figure 3.30)
13 the fire pit is complete! render out a low-resolution aVi as a test the fire and
corresponding light should flicker if you get stuck, a finished version has been saved as fire_finished.ma in the Chapter 3 scene folder on the Cd
Trang 44
Trang 5Simply put, a material determines the look
of a surface Although it’s easy enough to assign a material and a texture to a surface and produce a render, many powerful attributes and options are available to you
At the same time, a rich historical legacy has determined why materials and textures work the way they do You can map a wide range of 2D textures to materials, creating
an almost infinite array of results Simple combinations of textures and materials can lead to believable reproductions of real- world objects.
Chapter Contents
Theoretical underpinnings of shading models Review of Maya materials
Review of 2D textures Descriptions of extra texture attributes Material and texture layering tricks Using common mapping techniques to reproduce real materials
4
Trang 6Reviewing Shading Models and Materials
A shader is a program used to determine the final surface quality of a 3d object A shader uses a shading model, which is a mathematical algorithm that simulates the interaction of light with a surface in common terms, surfaces are described as rough, smooth, shiny, or dull
in the Maya hypershade and Multilister windows, a shading model is referred
to as a material and is represented by a cylindrical or spherical icon ultimately, you
can use the words shader and material interchangeably
A shading group, on the other hand, is connected to the material as soon as it’s assigned the shading group’s sole function is to associate sets of surfaces with a material so that the renderer knows which surface is assigned to which material the shading group does not provide any definition of surface quality if the connection between a shading group node and material is deleted, the assigned surface appears solid green in the workspace view and is skipped by the renderer (see Figure 4.1)
When a material is MMB-dragged into the hypershade work area, it is automatically connected to a new shading group if you select a material through the Create render node window, however, you have the option to uncheck the With Shading group attribute; in this case, no new shading group is created
Shading group
Polygon shape node
Figure 4.1 A shading group network
Shading with Lambert
the lambert material carries common attributes: Color, transparency, Ambient Color, incandescence, Bump Mapping, diffuse, translucence, translucence depth, and translucence Focus in Maya, the lambert node is considered a “parent” node
that is, phong, phong e, Blinn, and Anisotropic materials inherit their common butes from the lambert material in each case, the attributes function in an identical
Trang 7manner (For a more detailed discussion of nodes and the transparency attribute, see
Chapter 6 For information on the Bump Mapping attribute, see Chapter 9.) Maya’s
lambert material uses a diffuse-reflection model in which the intensity of any given
surface point is based on the angle between the surface normal and light vector in
order for Maya’s lambert material to smoothly render across polygon faces, it
bor-rows from other shading models, such as interpolated or gouraud shading With
gouraud, the intensity of any given point on a polygon face is linearly interpolated
from the intensities of the polygon’s vertex normals and two edge points intersected
by a scan line
menu) is able to interpolate across polygon faces to produce a smooth result In contrast, the Flat Shade All option (Shading > Flat Shade All through a workspace view menu) applies a single illumination cal-culation per polygon face, which leads to faceting
NURBS surfaces, while based on Bezier splines, are converted to polygon faces at the point of render by the renderer Hence, all the shading model techniques in this chapter apply equally to NURBS surfaces
If Flat Shade All is checked through a workspace view menu, a NURBS primitive sphere appears nearly identical to its polygon counterpart
Calculations involving diffuse reflections utilize lambert’s Cosine law the
law states that the observed radiant intensity of a surface is directly proportional to
the cosine of the angle between the viewer’s line of sight and the surface normal As
a result, the radiant intensity of the surface, which is perceived as surface brightness,
does not change with the viewing angle hence, a lambertian surface is perfectly
matte and does not generate highlights or specular hot spots physically, a real-world
lambertian surface has myriad surface imperfections that scatter reflected light in a
random pattern paper and cardboard are examples of lambertian surfaces the law
was developed by Johann heinrich lambert (1728–77), who also served as the
inspi-ration for the lambert material’s name
the term diffuse refers to that which is widely spread and not concentrated
hence, the diffuse attribute of the lambert material represents the degree to which
light rays are reflected in all directions A high diffuse value produces a bright
face A low diffuse value causes light rays to be absorbed and thereby makes the
sur-face dark
the Ambient Color attribute represents diffuse reflections arriving from all other surfaces in a scene to simplify the rendering process, the diffuse reflections are
assumed to be arriving from all points in the scene with equal intensities in practical
terms, Ambient Color is the color of a surface when it receives no light A high
Ambi-ent Color value will cause the object to wash out and appear flat
the incandescence attribute, on the other hand, creates the illusion that the assigned surface is emitting light the color of the incandescence attribute is added to
the Color attribute, thus making the material appear brighter
Trang 8rendering with Final Gather For more information, see Chapter 12.
the translucence attribute simulates the diffuse penetration of light into a solid surface in the real world, you can see this effect when holding a flashlight to the back
of your hand translucence naturally occurs with hair, fur, wax, paper, leaves, and human flesh Advanced renderers, such as mental ray, are able to simulate translucence through subsurface scattering (see Chapter 12 for an example) Maya’s translucence attribute, however, is a simplified system the higher the attribute value, the more the scene’s light penetrates the surface (see Figure 4.2)
Translucence = 0.5 Translucence Depth = 0.5 Translucence Focus = 0.5
Translucence = 1 Translucence Depth = 0.1 Translucence Focus = 0
Translucence = 0.8 Translucence Depth = 10 Translucence Focus = 0.95
Figure 4.2 Different combinations of Translucence, Translucence Depth, and Translucence Focus attributes on a primitive lit from
behind This scene is included on the CD as translucence.ma
A translucence value of 1 allows 100 percent of the light to pass through the surface A value of 0 turns the translucent effect off translucence depth sets the vir-tual distance into the object to which the light is able to penetrate the attribute is measured in world units and may be raised above 5 translucence Focus controls the scattering of light through the surface A value of 0 makes the scatter of light random and diffuse high values focus the light into a point
Shading with Phong
the phong shading model uses diffuse and ambient components but also generates a specular highlight based on an arbitrary shininess in general, specularity is the con-sistent reflection of light in one direction that creates a “hot spot” on a surface With the phong model, the position and intensity of a specular highlight is determined by reading the angle between the reflection vector and the view vector (see Figure 4.3)
A vector, in this situation, is a line segment that runs between two points in 3d tesian space that represents direction (For a deeper discussion of vectors and vector math, see Chapter 8.)
Trang 9of camera)
Figure 4.3 A simplified representation of a specular shading model
if the angle between the light vector and the surface normal is 60 degrees, the angle between the reflection vector and the surface normal is also 60 degrees in this
way, the reflection vector is a mirrored version of the light vector if the angle between
the reflection vector and view vector is large, the intensity of the specular highlight is
either low or zero if the angle between the reflection vector and view vector is small,
the intensity of the specular highlight is high the speed with which the specular
high-light transitions from high intensity to no intensity is controlled by the Cosine power
attribute the higher the Cosine power value, the more rapid the falloff, and the
smaller and “tighter” the highlight
Both gouraud and phong shading models produce specular highlights ever, phong produces a higher degree of accuracy, particularly with low-resolution
how-geometry As with the gouraud technique, phong reads vertex normals phong goes
one step further, however, by interpolating new surface normals across the scan line
the angle between a surface normal at the point to be rendered (c) and the light vector
determines the intensity of that point (see Figure 4.4)
Interpolated surface normals
Vertex normal 2
Light
Vertex normal 3 Scan line
Trang 10specu-Figure 4.5 (Top left) A classic specular highlight appears on an eye (Top right) A closer look at the eye reveals that the specular
highlight is the reflection of the photographer’s light umbrella (Bottom left) A glass float with a large specular highlight (Bottom middle) With the exposure adjusted, the float’s specular highlight is revealed to be the reflection of a window (Bottom right) The window that creates the reflection
Shading with Blinn
the Blinn shading model borrows the specular shading component from the phong model but treats the specular calculations in a more mathematically efficient way
instead of determining the angle between the reflection vector and view vector, Blinn determines the angle between the view vector and a vector halfway between the light vector and view vector this frees the specular calculation from specific surface curva-ture in practical terms, you can make the Maya phong and Blinn materials produce nearly identical highlights (see Figure 4.6) Maya’s Blinn material uses the eccentricity attribute to control specular size and the Specular roll off attribute to control specu-lar intensity
When it comes to the position of the specular highlight, both phong and Blinn re-create Fresnel reflections, whereby the amount of light reflected from a surface depends on the angle of view (which is the opposite of diffuse reflections) that is, when the view changes, the highlight appears at a different point on the surface (see Figure 4.7)
Trang 11Figure 4.7 Specular highlights appear at different points on the medallion as the view changes.
highlight as the view changes, they are unable to accurately change the inherent intensity of the lar highlight The Studio Clear Coat utility plug-in, however, solves this limitation For a demonstration, see Chapter 7
specu-Shading with Phong E
Maya’s phong e material is a variation of the phong shading model phong e’s
specu-lar quality is simispecu-lar to both phong and Blinn the roughness attribute controls the
transition of the highlight core to the highlight edge A low roughness value will
cause the highlight to fade off quickly, whereas a high roughness value causes the
highlight to have a diffuse taper in the style of a Blinn material the highlight Size
Trang 12Blinn, phong, and phong e highlights will become distorted as they approach the edge of a surface with a high degree of curvature in addition, Blinn, phong, and phong e produce elongated highlights on cylindrical objects (see Figure 4.8)
Phong Blinn
theo-ries on light propagation The Gouraud shading model was presented by Henri Gouraud in 1971 The Phong shading model was created by Bui Tuong Phong in 1975 The Blinn shading model was developed
in 1977 by James Blinn, who was also a pioneer of bump and environment mapping
Trang 13Figure 4.9 (Left) Various cylindrical objects lit by a single overhead light (Right) A billiard ball with
specular reflections of windows on its top edge
Shading with the Anisotropic Material
the anisotropic shading model produces stretched reflections and specular highlights
the model simulates surfaces that have microscopic grooves, channels, scratches,
grains, or fibers running parallel to one another in such a situation, specular
high-lights tend to be elongated and run perpendicular to the direction of the grooves the
effect occurs on choppy or rippled water, brushed, coiled, or threaded metal, velvet
and like cloth, feathers, and human hair (see Figure 4.10)
Figure 4.10 Anisotropic specular highlights on water, metal, and hair
Trang 14Figure 4.11 The specular highlight of an Anisotropic material changes with translation and rotation of the assigned sphere
on the right This scene is included on the CD as anisotropic_spin.ma A QuickTime movie is included as
3 Select the new surface and assign it to a new Anisotropic material open the material’s Attribute editor tab Set Spread x to 100, Spread y to 1, roughness
to 0.8, and Fresnel index to 9.5
4 Create a point light and place it above the surface render a test At this point, the specular highlight is white to insert colors into the highlight, click the checkered Map button beside Specular Color From the Create render node window, choose ramp open the new ramp texture in the Attribute editor tab Set the interpolation to Smooth render a test the highlight now emulates the color shift of real Cds (see Figure 4.13) if the colors run in a direction opposite that of a real Cd, switch the top and bottom handles of the ramp texture
Trang 15the Anisotropic attributes work in the following way:
Angle determines the angle of the specular highlight.
Spread X Sets the width of the grooves in x direction the x direction is the u
direc-tion rotated counterclockwise by the Angle attribute.
Spread Y Sets the width of the grooves in y direction, which is perpendicular to the x
direction if Spread x and Spread y are equal, the specular highlight is fairly circular
Roughness Controls the roughness of the surface the higher the value, the larger and
the more diffuse the highlights appear
Fresnel Index Sets the intensity of the specular highlight.
Anisotropic Reflectivity if checked, bases reflectivity on the roughness attribute if
unchecked, the standard reflectivity attribute determines reflectivity
For information on raytracing and an additional example of an Anisotropic material used to create the specular highlights on glass, see Chapter 11
Shading with a Shading Map
Maya’s Shading Map material remaps the output of another material in other words,
the Shading Map discreetly replaces the colors of a material, even after the qualities
of that material have been calculated in a basic example, the out Color attribute of
a Blinn material is mapped to the Color of a Shading Map material (see Figure 4.13)
the out Color of a ramp texture is mapped to the Shading Map Color of the Shading
Map material in turn, the Shading Map material is assigned to a polygon frog Where
the Blinn material normally shades the model with a dark color, the bottom of the
ramp is sampled Where the Blinn normally shades the model with a light color, such
as a specular highlight point, the top of the ramp is sampled