Jump to content

Blender 3D: Noob to Pro/Texture Nodes

From Wikibooks, open books for an open world

Texture nodes allow you to produce textures that are the result of complex computations. This tutorial will just scratch the surface of what’s possible.

A Simple “Rainbow” Texture

[edit | edit source]

Start with a new Blender document. Delete the default cube. Add a new plane object. In the Material context in the Object Properties window, click the icon to the left of the material name to assign a material to the plane (there should already be a default unused one called “Material”). In the Texture context, there should already be a texture called “Tex” assigned to this material. Now split the area showing the 3D view into two side-by-side areas. In the right-hand area, bring up the Node Editor. In its area header, you should see a group of 3 little icons next to the menu ; click on the middle one for Texture Nodes. You will see appear, further along the area header, a popup menu containing the names of the textures so far created in your document: this should be showing the name “Tex” of the texture you assigned to the material for your plane object. And to the right of that, there should be a checkbox titled “Use Nodes”. Check that, and you should see a pair of initial nodes immediately appear in the editor: an input node titled “Checker” and an output node titled “Output”, with an editable field in it containing “Default”.

There must be at least one output node in the texture definition; the data fed to this will make up the final texture. The names you assign in the Name field will appear in the Texture context in the Object Properties window, in a popup menu titled “Output:”, with one item for each output node. Initially this may show “Not Specified”: change it to “Default”.

Note:

Navigation in the Node Editor: As in most Blender windows, you can scroll around by dragging with  MMB , and zoom the view in and out with the mouse wheel.

Each node window has little coloured circles (terminals) on its left and right edges; the ones on the left edge (if any) are inputs for feeding data from other nodes, and the ones on the right edge (if any) are for supplying data to other nodes. Thus, output nodes have no outputs (they’re the final destination for the data), while input nodes have no inputs. Other node types represent intermediate stages in the processing, so they will have both inputs and outputs.

Back in the Node Editor, click on the titlebar of the “Checker” node window and use either  X  or  DEL  to delete it. Note that, unlike deleting objects in the 3D view, there is no confirmation popup: the node immediately disappears. (Of course, you can use  CTRL + Z  to undo operations in the usual way.)

Now go to the “Add” menu (or use the usual  SHIFT + A  shortcut), find the “Input” submenu, and select the “Coordinates” item. This will add a new input node, which just produces the unadorned texture coordinates as its data. The newly-added node will follow the mouse around; press  LMB  once you have moved it to a convenient place. You will see the new node has one output terminal, titled “Coordinates”. Left-click on this, and drag to the input terminal in the Output window with the word “Color” and a small rectangular colour swatch next to it. Voilà! A line (effectively a wire) should appear connecting the two terminals, and you should see the big square colour swatch in the Output window change from black to a whole rainbow of colours. That’s your texture!

If you make a wrong connection, you can move or cut it by dragging the output end of the wire away from the input terminal it is attached to with  LMB , to either a new input terminal or simply into an unoccupied space between nodes; when you let go the button, the wire will attach to the new input terminal in the former case, or disappear in the latter case.

At this point, you should be able to hit  F12  to render, and you will see your plane object with the rainbow texture applied. You can see why I chose a Plane object: being flat, the entire texture is visible from one camera angle.

Scalars Versus Vectors

[edit | edit source]

The wires carry numbers between nodes. These numbers can be of two kinds: a scalar is a single real quantity, like “0.5”, while a vector can consist of two, three or four scalars in a sequence, like “(0.5, 0.75, 0.2, 1.0)”. The number of components in a vector is also known as the dimension of the vector. Two-dimensional vectors can be used to represent texture coordinates, while three-dimensional vectors can represent positions in space. Colours can be represented with 3 dimensions (R, G,B or H, S, V) or 4 dimensions (RGB or HSV plus alpha channel).

Some nodes operate on scalars, while others operate on vectors. And there are nodes where some terminals input or output scalars, while others input or output vectors.

Try this. To the above Coordinates and Output nodes, add a “Separate RGBA” node (under the “Color” submenu of the “Add” menu). Feed the output from the Coordinates node to the “Color” input node of the Separate node. Now connect just the “Red” output terminal from the Separate node to the output node (if you move the newly-created node on top of the existing wire, this should happen automatically):

See how the Output swatch shows just a greyscale ramp running from black on the left to white on the right? This shows how the first dimension of a vector is interpreted as the red component in an RGB colour, but as the X coordinate in a position. Remove the output from the Red terminal (delete the existing wire), and take it from the Green terminal instead (by dragging a new wire from Green to the Color terminal on the Output node); now you will see the ramp going from black at the bottom to white at the top. The second dimension of a vector is the green component in an RGB colour, and the Y coordinate in a position.

The terminals have different colours to remind you what type of data they should be used for (purplish for coordinates, yellow for colours, grey for scalars), but as far as Blender’s Node Editor is concerned, colours and positions are not actually different types. Both are vectors, and one can be interpreted as the other. This can be (ab)used for some creative effects! For example, the name of the “Separate RGBA” node says it’s for separating an RGBA colour into its components, but here we are using it to take apart a coordinate vector instead.

Note also in the above, that the Color terminal on the Output node expects a vector RGB colour, but when you feed it a single colour component (i.e. a scalar), it simply replicates it the necessary number of times to make a vector of the required dimension. Since all components of the RGB colour are the same, you get a shade of grey.