Exercise 9: Shading Networks

 
To create successful renderings in Maya an understanding of Shader Networks is a necessity. A Shader Network is the collection of nodes that make up an shader, which in turn can be applied to an object to give it material in a rendering. The Shader Network contains nodes that control color, reflectivity, specular highlights, transparency, texture placement and size, and many other attributes. This exercise will show you how to create a relatively simple shader network that will result in a brick material.

Setting up the scene

Preparing the scene




1. The first step in this exercise is to make a simple scene for testing your material. Start by creating a NURBS plane, scaling it and rotating it to create a simple wall. Add a Spotlight to the scene and position it to illuminate the wall. You should also open the scene's Render Globals and set the rendering resolution to 640x480 and the Anti-aliasing quality to Intermediate. For more information about lights and the Render Globals settings see the Lighting a Rendering exercise.




Creating the base shader network

Making a Lambert Shader



1. The begin creating a shader network you must open the Hypershader, this can be found under the Window Menu under Rendering Editors. Next, you must create a new material, this material will be the basis of your Shader Network. Since you are going to be making a brick texture, and brick is not reflective or shiny, you should create a Lambert material. To create a material, right-click in the bottom half of the Hypershader (the graph area) and choose Create->Materials->Lambert. A new Lambert material icon will appear, double click the icon to open the Attributes Editor and change the name to 'brick'.




Adding a 2D grid texture



2. The next step in creating a brick texture (this technique will also works for bathroom tile and any other ruled texture) is to create a 2D Grid Texture and attach it to the Lambert shader. Right-click again in the bottom half of the Hypershader and choose Create->2D Textures->Grid. A Grid texture node and 2D placement node will appear. Double-click the texture node (the icon one with the black-and-white grid image) to open the grid texture's Attribute Editor. In the attribute editor, change the Filler Color to a brick red. This is done by clicking on the color swatch next to Filler Color and using the color picker.




Attaching the grid texture to the color channel



3. Once the grid texture is created, you need to attach it to the Lambert material for it to have any effect. To attach the texture to the material, Right-click on the grid texture icon and with the right button held down, drag the cursor over to the Lambert icon and release. A pop-up menu will appear with a list of all the possible nodes in the Lambert shader to which the grid texture can be attached. Select 'Color' from the list of channels, this will attach the grid texture to the color of the shader, replacing the default gray with a repeating red tile. A line will be drawn from the grid to the Lambert shader illustrating this new connection.

NOTE: The icons of the material, texture and placement nodes can be rearranged for easier viewing in the Hypershader by clicking upon them with the left mouse button and dragging them. You can also zoom and pan in the Hypershader window using the same hotkeys as you use in the modelling windows.




Applying the shader and previewing



4. Next, assign the new shader network to the NURBS plane to test its' tiling and placement. Select the NURBS plane in the modelling window and then in the Hypershader, Right-click on the Lambert icon and choose Assign to Selected from the pop-up menu. To see the effects of the new shading network, return to the modelling window and select Smooth Shade All and Hardware Texturing from the Shading menu at the top of the viewport. The grid will now be visible on the plane.





Adjust the UV Repeat



5. The grid applied to the plane in your model will be 4x4 and look nothing like brick. To adjust the tiling of the grid and stagger it to appear like brick coursing you will need to adjust the placement settings in the 2D Placement node. To adjust the tiling, return to the Hypershader and double-click the 2D Placement node icon attached to the grid texture, this will open the Attribute Editor. In the editor, change the Repeat U and Repeat V. Make the Repeat V twice as large as the repeat U (so the bricks will be twice as long as they are tall) and make the U and V larger than the default of 4 so that the brick repeats more than 4 times across the surface of the plane. Also, check the box for Stagger, this will offset each row of bricks so they are staggered properly.




Make a test render



6. The Hardware Texturing in the modelling window will not be an entirely accurate representation of the the way the shading network will appear in a rendering. Make a quick rendering to check the appearance of the brick before moving on to the next step.




Extending the network to create relief

Duplicate the grid shading network



1. The brick texture so far appears flat, there is no relief to the surface as there would be with typical mortar joints. Relief joints can be easily created by adding another node and attaching it to the shaders Bump Map channel. Since you want the relief of the mortar joints to match the red-and-white color grid, the first step is to duplicate the red-and-white grid network so you have two with identical settings. Click on the Grid Texture icon in the Hypershader and select Edit->Duplicate->Shading Network from the pull-down menu at the top of the Hypershader. This will duplicate the grid texture and its attached 2D Placement node.




Adjust the color and attach to the bump channel




2. Double-click on the Grid Texture icon of the new shading network and change the Filler Color to black. Bump Map textures operate by 'bumping' the surface of an object in or out based on the lightness or darkness of the texture, so it is most predictable when the texture being used is only grayscale, or black-and-white. After you have changed the grid color, right-click on the grid icon and drag it to the Lambert material node. This time choose Bump Map from the pop-up menu. Another node will appear for controlling the Bump Map settings and lines will connect it to the new grid to the shader.




Adjust the bump depth



3. The effects of the Bump Map do not appear in the modelling window, you must perform a rendering or IPR rendering to see the effects. To see the effects and adjust the depth of the Bump Map it is easiest if you use an IPR rendering. IPR renderings adjust and update each time a texture setting is changed allowing you to dynamcially tune texture settings. Click the IPR rendering button and when the base rendering is complete, draw a marquee box around a portion of the image you would like to update while you tune the texture settings. With the marquee box drawn, double-click the Bump Map icon and adjust the Bump Depth settings until the relief on the bricks and mortar appears correct.





Modify the brick and mortar color

Attach a 2D fractal texture to the grid fill color



1. The brick texture will still appear very fake, this is primarily due to the fact that all the bricks have a uniform color. In real brick walls each brick has a slightly different and mottled color, to create this effect in a Shader Network attach a Fractal texture to the Filler Color of the grid. Double-click on the red-and-white grid texture icon to open its' Attribute Editor. In the editor, click on the map icon (the small 2x2 grid icon) next to Filler Color. A menu will appear, choose Fractal from under the 2D Texture list. The menu will disappear as well as the Attribute Editor for the grid texture and a new Attribute Editor will appear for the Fractal texture you just created. In this editor change the Default Color and Color Offset to brick red, this will make the Fractal texture redish in hue. If you now perform a rendering of your brick the individual bricks will have varying colors, the Fractal texture you have just made is now being used for the Filler Color in the grid instead of a flat red. If you look in the Hypershader view you will see that a Fractal texture node, and 2D placement node, have been connected as inputs to the red-and-white grid texture icon.





Attach another fractal texture to the line color



2. The same technique that you just used to make the brick less uniform can also be used to make the color of the mortar appear more cementitious. Open the Attribute Editor for the red-and-white grid texture again, but this time click on the Map icon next to the Line Color. Choose Fractal from the 2D Textures list in the menu that appears and when the Attribute Editor for the new 2D Fractal texture appears, do not change any of the settings.



Adjust the UV repeat for the mortar



3. To adjust the Fractal texture of the mortar to be finer and appear more cementitious you must adjust its 2D placement settings. Open the Attribute Editor for the 2D placement node attached to the Fractal texture you just created. In the editor adjust the U and V repeat, making them higher numbers, so that the texture repeats more often and the grain of the fractal is smaller. Use an IPR rendering when adjusting to see the results.





Optimizing your shading network

The shader network



1. The shader network is now complete, but it is best to make one more change so it can be more easily controlled and applied to other surfaces. Right now, the Bump Map grid and Color grid are controlled by two separate 2D Placement nodes. This means that if you want to adjust the size of the grid, you must do it in two places, this is troublesome if you are applying this brick to a different surface with different proportions. To consolidate the placement nodes first delete one of the 2D Placement nodes. Select the 2D Placement node attached to the black-and-white Bump map grid, hit the Backspace key on your keyboard and it will be deleted.



Delete one of the 2D placement nodes and connect the other to the default channel


2. To replace the 2D Placement node you just deleted, right-click on the 2D Placement node attached to the red-and-white grid and drag it to the black-and-white grid icon. Select Default from the pop-up menu and the 2D Placement node will be attached to the black-and-white grid. If you double-click the 2D placement node and adjust the settings it will affect both the Bump Map grid and the Color grid at the same time.



The final product





  • Exercise 9: Shading Networks