# Advanced Maya Texturing and Lighting- P10

Chia sẻ: Cong Thanh | Ngày: | Loại File: PDF | Số trang:30

0
72
lượt xem
15

## Advanced Maya Texturing and Lighting- P10

Mô tả tài liệu

Advanced Maya Texturing and Lighting- P10: I should stress that I am self-taught. In 1994, I sat down at a spare seat of Alias PowerAnimator 5.1 and started hacking away. After several years and various trials by fire, 3D became a livelihood, a love, and an obsession. Along the way, I was fortunate enough to work with many talented artists at Buena Vista Visual Effects and Pacific Data Images. In 2000, I switched from PowerAnimator to Maya and have since logged tens of thousands of hours with the subject of this book....

Chủ đề:

Bình luận(0)

Lưu

## Nội dung Text: Advanced Maya Texturing and Lighting- P10

1. are stored as sine and cosine values. when an object is created, or has the freeze transformations tool applied to it, its transform matrix is an identity matrix. an iden- tity matrix is one that produces no change when it is multiplied by a second transform matrix. in other words, an object with an identity matrix has no translation, rotation, or increased/decreased scale. sx 0 0 0 0 sy 0 0 0 0 sz 0 tx ty tz 1 Figure 8.11 Maya’s 4 × 4 transformation matrix Converting Camera Space to World Space as an example of camera space to world space conversion, in figure 8.12 the Xform Matrix of a polygon cube is used to convert a normal Camera vector of a sampler info utility into a world space vector. the results are illustrated by applying the result- 249 ing vector to the color of a material. ■ M at H U t i l i t i e s x tri Ma rm xfo x tri ma normalCamera output input1 outColor Figure 8.12 The Xform Matrix attribute of a polygon cube drives the color of a material. This scene is included on the CD as xform_matrix.ma. A QuickTime movie is included as xform_matrix.mov.
2. the xformMatrix of the pCube1 transform node is connected to the matrix of a vectorProduct node. (pCube1 is the small gray cube in figure 8.12.) the normal- Camera of a samplerinfo node is connected to the input1 of the vectorProduct node. the vectorProduct operation value is set to Vector Matrix Product. the output of the vectorProduct node is connected directly to outColor of a surfaceshader material node, which is assigned to a second, larger polygon shape. as a result of the custom connections, the faces of the larger shape that point toward the camera render blue until pCube1 is rotated. this is a result of the normal Camera attribute existing in camera space. a normal that points directly toward the camera always has a vector of 0, 0, 1. at the same time, while pCube1 is at its rest position, its xformMatrix is an identity matrix and has no effect on the normalCam- era value. thus, the values 0, 0, 1 are passed to outColor of the surfaceshader node. when pCube1 is rotated, however, the normalCamera value is multiplied by the new xformMatrix and hence the color of the shape is affected. for instance, if pCube1 is rotated –45, –45, 0, a pale green results on the faces of the larger shape that point toward camera. the resulting math is illustrated in figure 8.13. 250 Normal Camera vector Xform Matrix Vector Matrix Product result H a r n e s s i n g t H e P ow e r o f M at H U t i l i t i e s ■ .7 0 .7 0 5 .7 –.5 0 0 0 1 1 = –5 .7 .5 1 –.5 .7 .5 0 0 0 0 1 (0 .7 .5 RGB) Figure 8.13 A matrix calculation based on pCube1’s rotation of –45, –45, 0. The matrix numbers have been rounded off for easier viewing. when representing the matrix calculation, as with figure 8.13, the extra number 1 at the right side of the normal Camera vector (and at the bottom-right corner of the Xform Matrix) is necessary for this type of math operation; however, these numbers do not change as the corresponding objects go through various transformations. 8: chapter Note: As with many custom networks, the material icon in the Hypershade window, as well as the workspace view, may not provide an accurate representation of the material. To see the correct result for the previous example, use the Render View window. Note: You can retrieve the current Xform Matrix value of a node by typing getAttr name_of_ node.xformMatrix; in the Script Editor.
3. Testing a Condition the Condition utility functions like a programming If Else statement. If Else state- ments are supported by Maya expressions and are written like so: if ($test < 10){ print “This Is True”; } else { print “This Is False”; } if the$test variable is less than 10, Maya prints “this is true” on the com- mand line. the If Else statement serves as a switch of sorts, choosing one of several possible outcomes depending on the input. the function of the Condition utility, when written in the style of an If Else statement, would look like this: if (First Term Operation Second Term){ Color If True; } else { Color If False; 251 } ■ M at H U t i l i t i e s first term and second term attributes each accept a single input or value, while the Color if true and Color if false attributes accept vector values or inputs. the operation attribute has six options: equal, not equal, greater than, less than, greater or equal, and less or equal. with the Condition utility, you can apply two different textures to a single sur- face. By default, all surfaces in Maya are double-sided but only carry a single UV tex- ture space. Hence, a plane receives the same texture on the top and bottom. You can avoid this, however, with the shading network illustrated by figure 8.14. the flippednormal of a samplerinfo node is connected to firstterm of a condi- tion node. the flipped normal attribute indicates the side of the surface that is ren- derable. if the attribute’s value is 1, then the “flipped,” or secondary, side is sampled. if the value is 0, the nonflipped, or primary, side is sampled. the nonflipped side is the side that is visible when the Double sided attribute of the surface is unchecked. returning to the network, the outColor of a checker texture node is con- nected to the coloriftrue of the condition node. the outColor of a file texture node is connected to the coloriffalse attribute of the same condition node. a bitmap image of a hundred dollar bill is loaded into the file texture node. the condition’s second term is set to 1 and operation is set to equal. last, the outColor of the con- dition node is connected to the color of a blinn material node. thus, the flipped side of a primitive plane receives the Checker texture while the nonflipped side receives the file texture.
4. ou r tCo lo lor tCo ou col e orIfF IfTru als e color 252 H a r n e s s i n g t H e P ow e r o f M at H U t i l i t i e s ■ outColor color Figure 8.14 A single surface receives two textures with the help of a Condition utility. This scene is included on the CD as condition_flipped.ma. Switching Outputs switch utilities provide multiple outputs from a single node. that is, they switch between different values in order to create different results among the geometry assigned to their shading network. since the application of a switch utility is unique in Maya, a step-by-step guide for a triple switch utility follows: 8: 1. Choose an rgB attribute of a material, such as Color, and click its checkered chapter Map button. Choose a triple switch from the switch Utilities section in the Utilities tab of the Create render node window. 2. assign the material to two or more surfaces. 3. open the attribute editor tab for the tripleshadingswitch node. Click the add surfaces button. all the surfaces assigned to the material appear in the list. 4. right-click the first surface name in the switch attributes list and choose Map from the shortcut menu. the Create render node window opens. Choose a texture. the texture node appears in the Hypershade window. the out Color attribute of the texture node (for example, stucco.outColor) appears in the intriple column of the switch attributes list. repeat this process for each of the remaining surfaces in the switch attributes list.
5. 5. render a test. each surface picks up a different texture. an example is included as figure 8.15. 253 ■ M at H U t i l i t i e s ins [0] tO ups bjG Gro inp out rou Col ut[ Obj ps[ or 0]. 0] inst inS ha ape pe nSh inp 1].i ut[ 1].i ut[ nTr inp iple outColor output input[0].inTriple color Figure 8.15 Color is controlled by a Triple Switch utility. A simplified version of this scene is included on the CD as triple_switch.ma. although these steps apply the switch to a material, you can apply them to any node. that said, triple switches are designed for vector values and are best suited for any attribute that uses rgB colors or XYZ coordinates. single switches, on the other hand, are designed for scalar values and are best suited for such attributes as Diffuse, eccentricity, reflectivity, or Bump Value. the single switch utility automatically chooses the outalpha attribute when a texture is chosen. in this case, the outalpha of each texture connects to the input[n].insingle of the singleshadingswitch node. the n in input[n].insingle corresponds to the slot number of the switch attributes list. the first slot is 0, the second is 1, and so on. although geometry is also connected to the singleshadingswitch node, the connection lines are initially hidden. nevertheless, the instobjgroups[n] of each geometry shape node must be connected to the input[n].inshape of the singleshadingswitch node. in
6. this situation, the n of the instobjgroups[n] attribute refers to the hierarchy position of an instanced attribute. (see Chapter 7 for information on attribute instancing.) in most cases, n is 0. the instobjgroups[n] convention applies equally to Double, triple, and Quad switch utilities. in addition, all the switches possess variations of the input[n].insingle input. Double switches are designed for paired or double attributes. this makes the utility well suited for controlling UVs. for example, in figure 8.16 a Cloth texture receives standard UV coordinates from a default place2dtexture node. the repeat UV values, however, are supplied by a Double switch utility. in this case, the repeatUV attributes of three additional place2dtexture nodes are connected to the input[n]. inDouble attributes of the doubleshadingswitch node. place2dtexture1 has a repeat UV value of 5, 5. place2dtexture2 has a repeat UV value of 25, 25. place2dtexture3 has a repeat UV value of 50, 50. this shading network offers the ability to adjust UVs on multiple objects without affecting the base texture or necessitating the duplication of the entire shading network. 254 H a r n e s s i n g t H e P ow e r o f M at H U t i l i t i e s ■ UV repe ut[2].in eat V tU rep ea inp atUV rep ble ou inD 1]. Dou ut[ ble 8: b inp Dou le .in t[0] chapter u inp output repeatUV Figure 8.16 Repeat UV is controlled by a Double Switch utility. A simplified version of this scene is included on the CD as double_switch.ma.
8. Stenciling Color as stencil is the third texture application radio button listed in the 2D textures sec- tion of the Create Maya nodes menu (following normal and as Projection). if a tex- ture is chosen with as stencil selected, the new texture automatically receives a stencil utility and two place2dtexture nodes. the stencil utility stencils the new texture on top of the material color. for example, in figure 8.18 a red logo is applied to a wall map with this technique. although the stencil utility produces results similar to the Blend Colors utility (see Chapter 6), its methodology is fairly different. out Col def or aul lpha 256 outA tCo lor H a r n e s s i n g t H e P ow e r o f M at H U t i l i t i e s ■ k ou mas tCo lor uv Coo im rd ag e ou tUV uvFilt outUv erSize FilterS ize outUV uvCoord outUvFilterSize uvFilterSize 8: chapter Figure 8.18 A logo is applied to a wall with a Stencil utility. This scene is included as on the CD as stencil.ma. in the example shading network, a red logo bitmap is loaded into a file tex- ture named fileColor. the outColor of fileColor is connected to image of a stencil node. standard UV connections run from the first place2dtexture node to fileColor. the second place2dtexture node is connected to the stencil node with similar (albeit fewer) standard UV connections. the outUV of the stencil’s place2dtexture node is connected to the uvCoord of fileColor’s place2dtexture node. the outUvfiltersize of the stencil’s place2dtexture node is also connected to the uvfiltersize of fileColor’s place2dtexture node. normally, this minimal set of connections will cause the fileColor texture to completely overtake the blinn’s color. to avoid this, the outalpha of a second file