the outColor of the file node is connected to the inrgb of a smear node.. the outu of the smear node is connected to the offsetu of the place2dtexture node of a ramp texture node.. the o
Trang 1the smear utility allows one texture to be distorted by another if smear is combined
with a ramp texture, it creates a stylized vision effect that might be appropriate for an
alien, a monster, or a robot For example, in Figure 6.24 a sequence of video images
is loaded into a File texture the use image sequence attribute is checked so that the
images are automatically loaded as the timeline moves forward the outColor of
the file node is connected to the inrgb of a smear node the outu of the smear node
is connected to the offsetu of the place2dtexture node of a ramp texture node the
outV of the smear node is also connected to the offsetV of the place2dtexture node of
the ramp node the outColor of the ramp node is finally connected to the outColor of
a surfaceshader material node, which is assigned to a primitive plane the ramp has
three handles: one red and two orange the higher the values are in the video image
bitmaps, the farther the smear node “pulls” the ramp down in the V direction For
instance, if a bitmap provides a pixel with rgB values 0.5, 0.5, 0.5, the ramp is pulled
downward so that the top rests at the center of the ramp field if a bitmap provides a
pixel with rgB values 0.9, 0.9, 0.9, the ramp is pulled downward so that the top rests
Trang 2outColor inRgb
outColor outColor
Figure 6.24 An image sequence and a Ramp texture are combined with the Smear utility This scene is included on the CD as
smear.ma A QuickTime movie is included as smear.mov
internally, the smear utility converts the input rgB to HsV new uV nates are generated by plotting values on an HsV color wheel For another example of the smear utility, see the tutorial at the end of this chapter
coordi-Correcting Gamma
gamma correction is the adjustment of an image to compensate for the physical tations of a computer monitor With a monitor, the intensity (brightness) of a screen pixel does not linearly increase with the application of additional voltage Because of this, uncorrected images may appear inappropriately dark or washed-out gamma correction solves this by applying a complementary intensity curve to the image to negate the monitor’s intensity curve different operating systems apply gamma cor-rection in different ways, whether through hardware or software controls microsoft-based systems generally operate with a gamma value set to 2.2, whereas macintosh
Trang 3systems operate with a gamma value set to of 1.8 some programs, like adobe
photo-shop, allow you to apply different gamma values to the system on the fly
gamma correction is applied to the image with the following standard formula:
new pixel value = image pixel value ^ (1.0 / gamma value)thus, if an image pixel has a value of 0.5, 0.5, 0.5 and the gamma value is set
to 2.2, the new pixel value, which is sent to the screen, is roughly 0.73, 0.73, 0.73
maya’s gamma Correct utility also applies the standard gamma formula:
outValue = value ^ (1.0 / Gamma)
in this case, the gamma Correct utility adjusts the values of the value input and outputs the result through outValue no other node is affected as a rule of thumb,
the higher the gamma attribute values are, the more washed out the mid-range values
become High- and low-range values (white whites and black blacks) are affected to a
lesser degree
an interesting side effect of the gamma Correct utility is the increase or decrease
of saturation For example, in Figure 6.25 face.tif is loaded into a File texture the
outColor of the file node is connected to the value of a gammaCorrect node as a test,
the outValue of the gammaCorrect node is connected to the inputs[0].color of a
lay-eredtexture node the gamma attribute of the gammaCorrect node is set to 0.5, 0.5,
0.5 as a result, the washed-out bitmap gains a good deal of saturation raising the
gamma above 1 would have the opposite effect—less saturation
outColor value
outValue inputs[0].color
Figure 6.25 A washed-out face bitmap is given extra saturation with a Gamma Correct utility This shading network
is included on the CD as gamma_correct.ma
to view the custom shading network, follow these steps:
1. open the gamma_correct.ma file from the Cd open the Hypershade window
2. switch to the utilities tab mmB-drag the gammaCorrect node into the work area
3. With the gammaCorrect node selected, click the input and output
Connec-tions button the network becomes visible
(for example, Gamma) These fields are read left to right when representing color (red, green, blue) or position (X, Y, Z) When one of these fields is used in a custom shading network, the connection is made
to a single channel of the attribute (for example, gammaX)
Trang 4For example, in Figure 6.26 face_2.tif is loaded into a File texture the outColor of
the file node is connected to the value of a contrast node as a test, the outValue of the contrast node is connected to the inputs[0].color of a layeredtexture node the Con-trast attribute of the contrast node is set to 4, 4, 4 the Bias attribute is set to 0.4, 0.4, 0.4 the resulting image has extremely white whites and black blacks and few colors
in the mid-ranges
outColor value
outValue inputs[0].color
Figure 6.26 A washed-out face bitmap is given a great deal of contrast with the Contrast utility This shading network
is included on the CD as contrast.ma
a Contrast value of 1 and a Bias value of 0.5 leaves the texture unchanged
lowering the Contrast value reduces the contrast raising the Bias value darkens the texture overall
A Note on Sliders and Super-White
in maya, many sliders that include number fields can readjust themselves For instance,
a diffuse attribute slider normally runs from 0 to 1 However, if you enter 2 into the
field, the slider automatically readjusts itself to run between 0 and 4 For the diffuse attribute, higher values result in a predictably brighter surface other sliders, when pushed past their default range, will not display a perceptible change any maya color channel can exceed the standard bounds of 0 to 1 although it’s not possible to do this directly through the attribute editor, you can enter extra-high values into the fields of the Color Chooser window to do so, follow these steps:
1. in the attribute editor tab, click the color swatch of an attribute the Color Choose window opens
2. Choose either rgB or HsV from the color space drop-down menu if you choose rgB, enter a value into the red, green, or Blue field there is no practi-cal limit to the size of the number you enter if you choose HsV, enter a value into the Hue, saturation, or Value field although Hue and saturation accept large numbers, the Value field is generally the most useful for custom values
3. Click the accept button to close the window
Trang 5uninten-Color attributes of a grid texture node are set to 0.5, 0.5, 0.5 in rgB, creating a solid
gray (see Figure 6.27) the outColor of the grid node is connected to the input1 of a
multiplydivide node (see Chapter 8 for a description) the output of the first
multiply-divide node is connected to the input1 of a second multiplymultiply-divide node the output
of the second multiplydivide node is connected to a blinn material node the input2
attribute of the first multiplydivide node is set to 4, 4, 4 the end result, as seen in the
second multiplydivide node, is an rgB color with values of 2, 2, 2 these
inappro-priately high values are often referred to as super-white From a practical standpoint,
maya simply clamps any color over 1.0 to 1.0 when rendering standard images even
though the rgB is 2, 2, 2, it’s rendered as if it’s 1, 1, 1 (as seen on the blinn icon)
nevertheless, the super-white values can cause problems with custom connections if
they are not taken into account Fortunately, the Clamp utility can solve this problem
(see the next section)
Super-white values
outColor
input1
output input1
output color
Figure 6.27 A shading network designed to test super-white values This network is included on the CD as superwhite.ma
to view the custom shading network, follow these steps:
1. open the superwhite.ma file from the Cd open the Hypershade window
2. switch to the utilities tab mmB-drag the multiplydivide1 node into the
work area
3. With the multiplydivide1node selected, click the input and output
Connec-tions button the network becomes visible
super-white values See Chapter 13 for details
Trang 6defini-tion of video white (100 IRE units in YUV color space) and the RGB color space used by Maya and other digital-imaging programs Basically, Maya creates whites that are 9 percent above the color range that
a television can actually display For more details on color space and monitor calibration, see Chapter 1
For a discussion of 8-bit versus 16-bit rendering, see Chapter 10
Clamping Values
the Clamp utility is designed to keep a value within a particular range if a value is too low or too high, it “clamps” it as an example, table 6.2 shows what happens to inputr values if minr is set to 0.3 and maxr is set to 1.0
in this example, if the inputr value is less than 0.3, the outputr value is 0.3
if inputr is greater than 1.0, outputr is 1.0 if inputr is between 0.3 and 1.0, putr is the same value the Clamp utility has three inputs and three output channels (inputr, inputg, inputB, outputr, outputg, and outputB); you can connect single attributes to any of these otherwise, you can connect vector attributes directly to input or output in a similar fashion, min and max, which set the clamp range, are vector attributes that carry three channels each (minr, ming, minB, maxr, maxg, and maxB) you can enter negative or positive values into the min and max fields
of the Additional_Techniques.pdf file on the CD For an example of the Clamp utility used to create disco ball glitter, see Chapter 7
Reading Surface Luminance
during a render, the surface luminance utility automatically reads the luminance of every single rendered point on the surface assigned to a material that is part of the same shading network that is, the utility can determine the total amount of light a point on a polygon face receives and outputs a value from 0 to 1 that represents this
as an example, in Figure 6.28, a custom crosshatch material is applied to a medallion model the crosshatch pattern is generated by a ramp texture and a sur-face luminance utility
the outValue of a surfaceluminance node is connected to the colorentrylist[0]
position of a ramp texture node the colorentrylist[n].position attribute controls the
vertical position of a color handle in a ramp texture in this case, the surfaceluminance
Trang 7node drives the black color handle up and down the ramp based on how much light
a surface point receives if a surface point receives the maximum amount of light, the
outValue of the surfaceluminance node is 1, which forces the black handle up to the
top of the ramp (leaving the entire ramp field white) if a surface point receives a little
light, the outValue is a lower value, which allows the black handle to stay low, thus
creating a mix of black and white within the ramp color field
outValue colorEntryList[0].position
outC olor outC olor
outUV
uvC oord
outUvFilterSiz
e uvFilterSiz e
Figure 6.28 A crosshatch material is created with a standard Ramp texture and a Surface
Luminance utility This material is included on the CD as crosshatch.ma A QuickTime
movie is included as crosshatch.mov
the ramp’s type attribute is set to uV ramp; this allows the pattern to repeat
on the surface vertically and horizontally the ramp’s interpolation attribute is set to
none, giving the rendered lines a hard edge the ramp’s noise attribute is set to 0.1
and noise Freq is set to 0.05 in order to give the lines some squiggle the ramp node
has a standard place2dtexture node with a repeat uV set to 25, 25 Higher repeat
values will produce finer lines the place2dtexture node also has its rotate Frame set
to 45 in order to angle the pattern last, the outColor of the ramp node is connected
to the outColor of a surfaceshader material node, which is assigned to the medallion
Trang 8Additional_Techniques.pdf file on the CD In Section 6.2, a stylized metal is created with super-white values.
Chapter Tutorial: Creating a Custom Paint Material
in this tutorial, you will create a custom material that transforms a photo into a ized painting (see Figure 6.29) you will use the smear, remap Hsv, and Contrast utilities
styl-Figure 6.29 (Left) A digital photo (Right) The same photo after the application of a custom paint material.
1. Create a new maya scene open the Hypershade window
2. mmB-drag a new layered texture utility (located in the other textures tion of the Create maya nodes menu) into the work area
sec-3 mmB-drag two remap Hsv utilities (located in the Color utilities section of
the Create maya nodes menu) place them to the left on the layeredtexture node
use Figure 6.30 as a reference rename the top remapHsv node remapHsvA
rename the bottom remapHsv node remapHsvB.
4. Connect the outColor of remapHsva to inputs[1].color of the layeredtexture node (For a review of how to create custom connections, refer to the beginning
of this chapter.)
5. Connect the outColor of the remapHsvB to inputs[0].color of the texture node
Trang 9Figure 6.30 The shading network of the custom paint material
6. select remapHsva and open its attribute editor tab Click the Color
check-ered map button and select a File texture from the Create render node dow a place2dtexture node is automatically created along with a file texture
win-node rename this place2dtexture node place2dTextureA rename the file node FileA.
7. select remapHsvB and open its attribute editor tab Click the Color checkered
map button and select a File texture from the Create render node window a second place2dtexture is automatically created along with a second file texture
node rename the new place2dtexture node place2dTextureB rename the new file node FileB.
8. select Filea and open its attribute editor tab Click the File Browse button
beside image name and choose greyhound.tif from the Chapter 6 textures folder on the Cd
9. select FileB and open its attribute editor tab Click the File Browse button
beside image name and choose greyhound.tif from the Chapter 6 textures folder on the Cd
10. mmB-drag a smear utility (located in the Color utilities section of the Create
maya nodes menu) into the work area place it to the left of place2dtextureB
11. Connect the outu of the smear node to the offsetu of place2dtextureB
Con-nect the outV of the smear node to the offsetV of place2dtextureB
12. select the smear node and open its attribute editor tab Click the in rgb
check-ered map button and choose a Fractal texture from the Create render node window a new place2dtexture node is automatically created name this latest
place2dtexture node place2dTextureC.
13. select the fractal node and open its attribute editor tab Change the amplitude
attribute to 0.7 and the threshold attribute to 0.2 this will wash out the
Trang 1014. select place2dtextureC and open its attribute editor tab Change the repeat
uV attribute to 0.6, 0.6 When the repeat uV value is reduced, the blobs with the Fractal become larger; this, in turn, creates larger waves in the smear node’s distortion try different repeat uV values to see different variations of the effect
15. select remapHsva and open its attribute editor tab Change the Hue, ration, and Value gradients to roughly match the left side of Figure 6.31 to move points on a gradient, select the little circles and lmB-drag to insert new points, click inside the dark gray area of each gradient to delete a point, click the × box below it these adjustments are shifting the hue, saturation, and value of the undistorted greyhound bitmap
satu-Figure 6.31 (Left) The gradients of the remapHsvA node (Right) The gradients of the remapHsvB node.
16. select remapHsvB and open its attribute editor tab Change the Hue, tion, and Value gradients to roughly match the right side of Figure 6.31 these adjustments are shifting the hue, saturation, and value of the distorted grey-hound bitmap
satura-17. select the layeredtexture node and open its attribute editor tab Click the leftmost purple box this displays the options for remapHsvB Change the alpha attribute to 0.5 this allows a 50-50 mix between the remapHsva and remapHsvB nodes (the Blend mode attribute should be set to over.)
Trang 1118. mmB-drag a Contrast utility (located in the Color utilities section of the
Cre-ate maya nodes menu) into the work area place it to the right of the texture node Connect the outColor of the layeredtexture node to the value of the contrast node
layered-19. mmB-drag a new Blinn material into the work area place it to the right of the
contrast node Connect the outValue of the contrast node to the color of the blinn node select the contrast node and open its attribute editor tab Change the Contrast attribute to 1.5, 1.5, 1.5 and the Bias attribute to 0.7, 0.7, 0.5
this adjusts the contrast of the layeredtexture node try different numbers to see different results
20. select place2dtextureB and open its attribute editor tab Change the translate
Frame attribute to 0, 0.1 this raises the FileB up a tiny amount in the V tion, which counteracts the downward pull of the smear node
direc-21. mmB-drag a Bump 2d utility (located in the general utilities section of the
Create maya nodes menu) into the work area Connect outalpha of FileB to the bumpValue of the bump2d node Connect outnormal of the bump2d to normalCamera of the blinn node since outnormal is not a default attribute of
a Blinn material, you will have to use the Connection editor select the bump2d node and open its attribute editor tab Change the Bump depth value to 0.3
this bump mapping will give the smear distortion a sense of thickness
22. the custom paint material is complete! assign the blinn material node to a
primitive nurBs plane; add a directional, point, or spot light and render out a test it should look similar to Figure 6.29 if you get stuck, a finished version of the material is saved as paint.ma in the Chapter 6 scene folder on the Cd
Trang 127
Trang 13Sampler utilities can automate a render
They can evaluate every surface point for every frame and return unique values that other nodes can use At the same time, you can connect cameras, lights, and geometry for unique shading networks Along similar lines, the Studio Clear Coat plug-in utility creates surface qualities unavailable to standard materials
7
Trang 14the Sampler info, light info, particle Sampler, and distance Between utilities can all
be described as samplers they sample surface points, object transforms, or particle transforms automatically throughout the duration of an animation You can find the Sampler info, light info, and distance Between utilities in the general utilities sec-tion of the create maya nodes menu in the hypershade window You can find the particle Sampler utility in the particle utilities section Before i discuss the Sampler info or light info utilities, however, a look at the ramp Shader material and a review
of coordinate space is warranted
A Review of the Ramp Shader Material
the ramp Shader material has a color input attribute that has light Angle, Facing Angle, Brightness, and normalized Brightness options (see Figure 7.1)
Figure 7.1 (Left) The Selected Color gradient and Color Input attribute of a Ramp Shader
material (Right) The resulting material assigned to a primitive sphere lit from screen right
To see a larger version of the gradient, click the large button to the gradient’s right This scene is included on the CD as ramp_shader.ma
the color input attribute allows the ramp Shader to sample different points along the Selected color gradient based on feedback from the environment with light Angle, the material compares the angle of the surface normal to the direction of the light if the angle between the two is small, a high value is returned and the right side of the gradient is sampled if the angle between the two is large, a small value is returned and the left side of the gradient is sampled on a technical level, the surface normal vector and the light direction vector are put through a dot product calculation, producing the cosine of the angle between the two vectors For a deeper discussion on vectors and vector math, see chapter 8
this technique is also used for the Facing Angle option, whereby the angle of the surface normal is compared to the camera direction the Brightness option, on the other hand, calculates the luminous intensity of a surface point if the surface receives the maximum amount of light, the right side of the gradient is sampled if the surface receives a moderate amount of light, the middle of the gradient is sampled the gradi-ent runs 0 to 1 from left to right the light Angle, Facing Angle, and Brightness cal-culations are normalized to fit to that scale
Trang 15calculations cannot be fine-tuned Sampler info, light info, and Surface luminance
utilities solve this problem by functioning as separate nodes the Sampler info
util-ity replaces the Facing Angle option the light info utilutil-ity replaces the light Angle
option the Surface luminance utility, as detailed in the previous chapter, replaces
the Brightness option Although the normalized Brightness option normalizes all
the light intensities in the scene, its basic function is identical to Brightness and can
be replicated with the Surface luminance utility in a custom shading network most
important, the Sampler info, light info, and Surface luminance utilities provide a
wide array of supplementary attributes
Coordinate Space Refresher
in general, four coordinate spaces are used in 3d software—object, world, camera,
and screen the term coordinate space simply signifies a system that uses coordinates
to establish a position For a surface to be rendered, it must pass through the
follow-ing spaces in the followfollow-ing order:
Object space A polygon surface is defined by the position of its vertices relative to
its center By default, the center is at 0, 0, 0 in object space (sometimes called model
space) A nurBS spline has its origin point at 0, 0, 0 in object space the axes of a
surface in object space are rotated with the surface
World space world space represents the virtual “world” in which the animator
manip-ulates objects A surface is moved, rotated, and scaled in this space to do this, the
vertex positions defined in object space must be converted to positions in world space
through a world matrix A matrix is a table of values, generally laid out in rows and
columns
Camera space world space must be transformed into camera space (sometimes called
view space) in order to appear as if it is viewed from a particular position in maya’s
camera space, the camera is at 0, 0, 0 with an “up” vector of 0, 1, 0 (positive Y) while
looking down the negative Z axis
Screen space three-dimensional camera space must be “flattened” so that it can be
seen in 2d screen space on a monitor
in addition, maya uses local space, parametric space, and raster space local space (sometimes called parent space) is similar to object space, but uses the axes and
origin of a parent node this is feasible due to maya’s dAg node system (See the
sec-tion “A transform and Shape node refresher” later in this chapter.)
to determine the color of a particular pixel when rendering a surface assigned
to a material that uses a texture map, the renderer compares the parametric spaces
of both the texture and the surface texture and surface parametric spaces are
com-monly referred to as uV texture space For more information on uVs and uV texture
space, see chapter 9