Controlling Displacement Maps
This tutorial will cover the basics of nodes in Maya, the Hypershade and finally how to use the Multiply-Divide node to control the intensity of a displacement map. It assumes you know the basics of Maya, though this tutorial will describe in detail every step
Maya, Nodes and the Hypershade - The Basics
Maya is Nodes! Everything that is made in Maya is a node. For example, if you create a sphere, Maya creates a Transform Node that stores the data of that sphere. Nodes also have many other functions. They are most often manipulated in the Hypershade for creating connections between objects, shaders and controlling they way they look and feel.
Lets get our hands dirty.
First lets open up the Hypershade and have a quick look around
Behold! The Almighty Hypershade
The left side of the Hypershade lists all the different nodes that you can create. The top pane shows what materials, textures, etc. are in the scene. The bottom pane shows your work area. This is where you build all those fancy connections.
Lets start by creating a Lambert shader. Click and hold down the middle mouse button on the Lambert Icon and drag it into the Work Area. Note, if you don't see the work area, the small red arrow points to where you can change the view setup. The two boxes on top of each other is the below setup.
Now you have a Lambert shader. Its rather boring right now; a dull grey, no prettiness. Lets make it a checker board. If you scroll down the left pane, you will find Checker. Alternatively, you can go to Create - 2D Textures - Checker. Your work area should now look like this
Select checker1 and middle-mouse button drag the checker onto the Lambert we created. A menu should pop up like this
Select color to create a connection between the checker1 node and the lambert2 node. Technically, what this does is create a connection between the checker1.outColor attribute to the lambert2.color attribute
You will get a line in between checker1 and lambert2 saying they are connected. If you put your cursor over the line, it will tell you the connection Well this is terrific. Now we have a wonderful Checkered Lambert shader. A lot of good that does us when its not applied to anything. Lets create a nurbs plane and apply the shader to it
With the newly created plane selected, you can right click on the lambert2 in the Hypershade and choose Apply Material To Selection
Now if you can't see the checker pattern on your plane in the view port, the most likely you need to be in the Texture mode. You can get there just by pushing the number 6 on your number row. If you render, you should see a checkered plane.
Terrific! So now you know the very basics of the Hypershade and nodes. How about I show ya'll the coolness of Displacement
Displacement in Maya is actually a shader node that gets plugged into the shader group and actually moves the vertices of the object around. The whiter the map is, the farther out it pushes the geometry, and the blacker the map is, the farther in it pushes the geometry.
Now that we have a shader that has a black and white color map applied, we can also use the checker map as a displacement map. The white will be pushed out, and the black will be pushed in. Here is an example of what I mean (and what you will make in a few minutes).
Many of you, I'm sure have used displacement in textures in Maya, if not in another package. If you've used the displacement map in Maya before, you may have noticed that you can't change its intensity, except by changing the contrast of your displacement map. We will create a node structure to allow us to adjust the intensity of the displacement. We will first create the shader without a multiplyDivide node to illustrate its downside, then add it into the network. This should give you a full understanding of how the node structure is working together to build the final rendered output.
Here's a preview of the final node structure.
You'll note that there are 3 nodes that I haven't discussed yet. The far right colorful one is the Shading group (SG). It is, as Maya's help says, "a collection of materials, textures, and lights that efficiently describe all the necessary attributes required to shade or render an image affect the final render of the surface". Geometry without a SG is just a wireframe. You already have this node in your structure. To view it, select checker1 and go to Graph - Input and Output Connections. Alternatively, you can right click on checker1 and choose Graph Network.
The other two nodes are the multiply-divide node, which conveniently looks like multiply and divide symbols, and the displacementShader1 node, which is the one that looks like a checker plane with displacement!
Here's a small diagram showing the upstream and downstream connections to checker1.
You may have noticed that the displacement is connected into the Shading Group. This is because displacement is a shader. The SG has a specific connection for the displacement. You can see that by selecting the SG and looking at it in the attribute editor (ctrl+a).
Lets create the displacement node and connect it in to our shader network. In the Hypergraph, scroll down the left side pane to Displacement.
Middle-mouse drag the icon into your work area. Our input into displacement is the outAlpha attribute of the checker1 node. Lets open up the Connection Editor to connect the checker into the displacement. Note, in Maya, there is a gazillion and one ways to do any one thing, so I'm showing you a few different ways to create connections
Wow. It's the connection editor
Checker1 will go on the left, because it is outputting outAlpha. DisplacementShader1 will go on the right, because it is receiving outAlpha into displacement. Select checker1 and click the Reload Left button. Now select displacementShader1 and click Reload Right
Now is the easy part. Click first on Out Alpha, then click on Displacement. If you look back in your Hypergraph you'll note that there is a connection line drawn between them. The checker is now connected to the displacement, but the displacement isn't connected to the actual shader. To do this, select displacementShader1 and Reload Left. Select lambert2SG (the shading group) and Reload Right. Once both are loaded, click first on Displacement, then on Displacement Shader. This will technically connect displacementShader1.displacement into lambert2SG.displacementShader.
Now if you render, you should get an image like the example at the beginning of this section.
Ok! Woohoo! We have a cool checkered plane thing with holes and stuff. Wow! Well, what if I want the white higher? How can I change that? Short answer, you can't. Long answer, you can. Since the outAlpha is mapped directly into the displacement shader, we can't control or change the amount or intensity of the map without making the white a bit darker or brighter. What if this was a detailed displacement map for a face? You don't want to go through your map and keep adjusting the levels and contrast in Photoshop, then go back into Maya, render, then go back into Photoshop, adjust, etc.
So what we will do is create a multiplyDivide node. What it does is take in any inputs and multiply, divide or power it by a value you set, then send the result as the output .
checker1.outAlpha into multiplyDivide.input1X multiplyDivide.ouputX into displacementShader1.displacement.
Let's create the multiplyDivide node.
Back in the Connection Editor, select first checker1 and press Reload Left, then select multiplyDivide1 and Reload Right. Connect "Out Alpha" into "Input1 X"
Select multiplyDivide1 and Reload Left, then select displacementShader1 and Reload Right. Connect "Output X" to Displacement
If you render now, you should see exactly the same thing as before. We need to change the value that the outAlpha is being multiplied/divided by. Select multiplyDivide1 and go to the Attribute Editor. Notice that the first box of Input1 is yellow. That means it has an incoming connection. The first box of Input2 is where we change the intensity of the displacement. If I change it to 10 instead of 1, there will be 10 times as much displacement. If I change it to .5, there will be half as much displacement. Go ahead and try it
Pretty cool, huh? Try doing the same thing only using images you've made. Here is a quick examples using an image made in Photoshop. Instant mountains, no modeling