Blender 3D: Noob to Pro/Material Nodes< Blender 3D: Noob to Pro
|Applicable Blender version: 2.4x.|
Material nodes look very similar to texture nodes, and indeed there is a fair amount of overlap in functionality. Some important differences are:
- Functions for performing spatial transformations (e.g. rotation and scaling) are only available for texture nodes.
- Functions for altering diffuse versus specular colours and rendering parameters, like translucency, are only available for material nodes.
A Simple Graduated MaterialEdit
First of all, let’s set up a really basic modelling scene to show off the node-based material you’ll be creating in a moment.
Open a new Blender document, with the default cube, default light and default camera. Create a plane object. Rotate and position that so it lies behind the cube from the camera’s viewpoint. Scale the plane up to say, 4x, to form a decent-sized backdrop. Assign it a new default material, and a texture with some detail to it; I used a simple Marble with default settings, except under the “Map To” miniwindow I changed the colour to a medium grey from the default magenta, to stop it hurting my eyes.
Now select the cube. Scale it 3x in the Z-axis; the elongated proportions should show off a gradation more nicely. In the “Material” miniwindow, set the “Col” (diffuse) colour to white, and the alpha to zero. In the “Mirror Trans” miniwindow, turn on “Ray Transp” and set the “IOR” to some suitable refractive index, say 1.5 for glass.
Hit F12 to do an initial render, just to confirm you’ve got everything nicely arranged.
With the cube still selected, open the Node Editor. By default, the Material Nodes mode should already be selected, and the combo box should be showing the name of the material you assigned to the cube; select it if it’s not. Click the “Use Nodes” button, and immediately two node windows should appear, a Material one and Output one.
Click on the title of the Material node window, and use XKEY or DEL to get rid of it. Go to the “Add” menu, “Input” submenu, and add a new “Geometry” node. Also add a new “Extended Material” node. And from the “Convertor” submenu, a new “Separate RGB” node. In the middle of the Extended Material node window, there is a popup menu showing you the names of the materials in your document; select name of the material you previously assigned to the cube again.
Make sure there are no wires running between any of the nodes; now run one from the “Color” output terminal on the Material node to the “Color” input on the Output node, and one from the “Alpha” output on the former to the “Alpha” input on the latter.
Notice that, next to each of the input terminals in the Material window, there is either a field for entering a scalar value (grey terminals), or a button which pops up a little set of controls for letting you specify X, Y and Z components for a vector (blue terminals), or a colour swatch which pops up to let you pick a new colour (yellow terminals). This way, you don’t have to make connections to all the inputs, or indeed any of them; any unconnected inputs will be set to the constant value that you specify.
Anyway. connect a wire from the “Global” output of the Geometry node to the “Image” input of the Separate RGB node. “But geometry isn’t a colour!?” I hear you cry. But as explained on Texture Nodes, a vector is a vector. Feeding in a position instead of a colour to Separate RGB means its outputs are not the R, G and B components of the colour, but the X, Y and Z components of the position. So run another wire from the B (i.e. Z) output of Separate RGB to the Alpha input of the Extended Material window. The resulting layout should look like this:
Now you’re ready to render. But before hitting F12, hit JKEY to switch render buffers. That way you still have the previous render to compare with. Once the render window comes up, you can hit JKEY to alternate between the two renders.
Here’s what my node example looked like (note I turned the energy of the lamp down to 0.5, otherwise it seemed too bright):
Notice the gradation of transparency along the Z-axis, from fully transparent at the bottom to fully opaque at the top.
For added fun, try taking the material Alpha setting from the R or G outputs of the Separate RGB node instead, just to see the gradation orient along the X or Y axes.