Now, to hook it all up, I made the following shader network. A little background -- you can get data from whatever Maya's trying to shade with the samplerInfo node. In particular, I wanted to grab the normals for whatever Maya sees with the shader attached, and add on a little tweak based on the color of my texture.
I first made a file texture node and pointed it at my noise image. This maps the texture onto the object based on its UV space, unless I do something special with a projection or something like that.
I use the connection editor to connect the file texture's outputColor node to the input of a multiplyDivide node. The reason is that I want to be able to control how much of a tweak to apply to the object's pre-existing normals by scaling the texture up and down. I used the channel box to set the input2 values manually to 0.3 for X, Y, and Z. (Playing with this number gives you more or less of an effect.)
Then, I took the output of the multiplyDivide node and plugged it into one of the input3D attributes of a plusMinusAverage node. Since the inputs to this node are arrays, you have to use MEL if you want to connect more than one. There's no way to do this in the connection editor. The MEL looked something like this:
connectAttr multiplyDivide1.output plusMinusAverage.input3D;
Then, I made a samplerInfo node. This doesn't need to be connected to anything on the input side... it just serves to spit out data about whatever surface the renderer's shading. I connected the output normalCamera attribute to the other input of plusMinusAverage using a MEL command like the above. The normalCamera attribute contains the normal direction of whatever point is currently being shaded, so we'll use the plusMinusAverage node to add this value to the scaled texture that we plugged in before:
connectAttr samplerInfo1.normalCamera plusMinusAverage.input3D;
Then, I took the output of the plusMinusAverage node (which now is outputting the original normal for whatever part of the sphere Maya's shading, plus my scaled texture) and attached it to the normalCamera attribute for the phong2 shader with the connection editor. This is the inputs that bump maps use to tweak the normals, but since bump maps are supposed to represent height and not tweaks to the normals themselves I didn't want to use a bump map for this.
Assign the phong2 shader to the sphere, and voila! :-)
Last edited by mark_wilkins : 13-02-2003 at 06:58 AM.