Adding Materials and Lighting Your Scene

table of contents

Next, you'll make the scene objects a little prettier than light gray. Materials not only give color , but also add surface attributes, such as shininess or transparency. By adding materials to your scene, you can create contrast among the scene elements and make them look more realistic. In this section, you'll explore Hypershade to create and apply materials. In Hypershade you can also work with "rendering nodes," which are used to modify textures, materials, lights, special effects, and other scene elements. You'll also work with adding materials and lighting the scene. You'll apply materials to objects and then do some quick renders so that you can see where you might need to make adjustments. Materials and lights go hand in hand because lighting affects the appearance of any materials you apply.

Tutorial: Adding Lights and Materials

Before you render anything, you need to create at least a simple lighting system, so for this tutorial, you'll add a Directional light to simulate sunlight. You'll then import some shaders to add texture to objects in your scene. You can continue from the previous tutorial, or load the scene file noted here.

  1. First, add a simple Directional light to the scene (Create Lights Directional). In the Channel Box, change the light's name to SunRays . You can see the effect of this light by pressing 7 on your keyboard to turn off the default lighting and using only the Directional light you added.

    graphics/ch04m_icon.gif graphics/ch04n_icon.gif
  2. Next, you'll need to change some settings for the Directional light. Its location doesn't matter because you can aim a Directional light anywhere you like, no matter where it's placed. To adjust the light's focus, in the Channel Box, set Rotate X to , Rotate Y to -132 , and Rotate Z to -38 .

  3. Next, set Scale X, Y, Z to 10 to make the Light icon bigger and therefore easier to select. With the light still selected, under Shapes in the Channel Box, change Use Ray Trace Shadows to On. You now have enough light to render the scene and view your textures, so you can move on to texturing.

  4. Maya has a predefined layout for texturing that includes Hypershade, the Render View window, and the Perspective view. To open this layout, on any viewport menu bar or in the Hotbox, click Panels Saved Layouts Hypershade/Render/Persp. The interface will change to the predefined layout (see Figure 4.20).

    Figure 4.20. Maya's predefined layout for working with textures.

    graphics/04fig20.gif

  5. Texturing is a complex process, so for this tutorial, you'll work with shaders we've already created. A shader defines the materials, volume, and other attributes for a material. To import these shaders, choose File Import option box on the menu bar. In the Import Options dialog box, select the Group check box; under the Name Clash options, it should read "Resolve clashing nodes with this string." Change both list boxes in the dialog box to match this statement. In the This String text box, enter Water , and then click the Import button. Insert the Maya Fundamentals CD, browse to the file noted previously, select it, and click the Import button. In the Materials tab in Hypershade, you should now see a shader material called OceanWater (see Figure 4.21).

    graphics/ch04o_icon.gif
    Figure 4.21. Importing OceanWater.ma into Hypershade.

    graphics/04fig21.gif

  6. In Hypershade, right-click on OceanWater, and choose Graph Network. The Work Area in Hypershade displays all the nodes used to create that shader. You can use this information to figure out how the shader works and eventually create one of your own.

  7. OceanWater is ready to be applied to the water in your scene. In the Perspective view, select WaterPlane. Then right-click on OceanWater in Hypershade, and choose Assign Material to Selection. The water is now textured!

  8. With Maya's IPR rendering, you can see how textures and lights affect the scene by automatically updating the render with each change you make. First, position your scene in the Perspective view so that you're zoomed in close on an area where you can see part of the ground and the water.

  9. Click the Play button on the Time Slider and stop about halfway through the animation. In the Render View window, click the IPR button to start the IPR render. This render takes longer than a normal test render because the IPR render has to store more information about the scene so that it can update when you make changes. When the IPR render is finished, marquee-select the entire rendered image (dragging from the upper-right to the lower-left corner) in the Render View window to be updated with IPR. You should see a green border surrounding it (see Figure 4.22).

    Figure 4.22. Selecting a region to be automatically updated with IPR rendering.

    graphics/04fig22.gif

  10. Open the Outliner, select the place3dTexture17 node, and MMB-drag it into the WaterGroup group.

  11. Next, you'll import the shaders for the ground. As you did in Step 5, choose File Import option box, change the text box from Water to Ground , and click the Import button. On the Maya Fundamentals CD, browse to the file noted here, select it, and click the Import button. A new shader named OceanGround is added to Hypershade. Select the ground plane in your scene, RMB-click on OceanGround in Hypershade, and choose Assign Material to Selection on the shortcut menu. You'll see the IPR render update and show the ground textured. Save your scene.

    graphics/ch04p_icon.gif
  12. Hide all the layers except BoatL. Import OceanBoat.ma (use the same procedure as in Step 5), and be sure to change the text box in the Import Options dialog box to Boat . After importing OceanBoat.ma, you'll see it available in Hypershade. In the Outliner, select BoatG, and then focus on BoatG in the Perspective view (hotkey: f ). With BoatG selected, RMB-click on the OceanBoat shader in Hypershade, and choose Assign Material to Selection.

    trap

    To have the textures loaded correctly, you must have the CD-ROM in the drive.

  13. Make sure the animation playback is rewound to frame 1, and IPR render the boat. The texture doesn't look right because the texture placement nodes, which show you how a texture is placed on an object, are not aligned correctly with the boat. To position the texture, in Hypershade, right-click on the OceanBoat shader, and choose Graph Network. In the network for OceanBoat is a node called place3dTexture_boat. You need to adjust the values for the position of this node (see Figure 4.23).

    graphics/ch04q_icon.gif
    Figure 4.23. The place3dTexture_boat node shows the placement of the texture on the boat.

    graphics/04fig23.gif

  14. With place3dTexture_boat selected, open the Attribute Editor (hotkey: Ctrl+a ). Under the 3D Texture Placement Attributes section, click the Fit to Group Bbox button. In the Perspective view, you'll see a green frame (the projection frame) at the side of the boat that represents how the 3D texture is placed on your object.

  15. The green projection frame is not parallel to the side of the boat because the boat is attached to a path and has been rotated to fit. You'll need to temporarily align BoatG back to zero rotation, and then apply the placement node. Select BoatG again in the Outliner, and change all the rotation values in the Channel Box to . Those values have an orange background, so you know they are keyframed, meaning that when you play the animation again, the boat will return to its proper position.

  16. Select the place3dTexture_boat node in Hypershade again, open the Attribute Editor if it's not open, and click Fit to Group Bbox again. Now the texture fits correctly on the boat (see Figure 4.24).

    Figure 4.24. Adjusting the position of the place3dTexture_boat node.

    graphics/04fig24.gif

  17. If you were to play the animation now, the boat would move but the textures would stay in the same place, giving the effect of textures sliding across the water's surface. To prevent that, you need to set BoatG as a parent of the place3dTexture_boat node. In the Outliner, expand the Group2 group to display the place3dTexture_boat item. MMB-drag Group2 on top of BoatG to parent the boat to the texture node. When you play the animation, the textures will now animate with the boat along the motion path.

  18. Now would be a good time to save your scene.



Maya 4. 5 Fundamentals
Maya 4.5 Fundamentals
ISBN: 0735713278
EAN: 2147483647
Year: 2005
Pages: 201

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net