Quick and Dirty Intro to Node-based Shaders

Quick and Dirty Intro to Node-based Shaders

Here's a really quick intro to the material system. I apologize for the lousy audio.

Edit: I just realized I accidentally deleted my intro to the new (current) material system and have been linking to a tutorial on the OLD system. D'oh. Here's the first tutorial on the new material system from my book while I figure out how to replace the missing tutorial:

http://loewald.com/c3dbook/Video-Tutorials/simple-materials/
 
Last edited:
Glossary of Terms

Node Types

Shader: the heart of a material. Literally the software gizmo that decides what color to make a pixel (or subpixel) based on the information available (lights, texture mappings, local and global coordinates, orientation of the surface, etc. etc.).

A material can only have one shader.

Constant: a convenience object for holding a fixed value you want to pipe to other places. This can save trouble having to edit multiple objects to achieve a specific effect (e.g. if you change the scale of one thing you may need to change the scale of another to match it -- use a constant value and pipe it to both).

Filter: a mathematical function that has an obvious visual description (vs. those which don't, which are referred to as "Math".

Math: a mathematical function that takes one or more inputs, performs math on them, and produces an output (e.g. addition, average, dot product, and so forth).

Other: an oddly named placeholder for the "state" object which gives you various information about the thing being rendered and the scene it resides in for use as input into other shaders.

Textures: a software gizmo that generates texture maps somehow or other. The most popular one is the image texture which outputs an infinite plane (by default with the image tiled on it, but this can be switched off in either exis). The other filters are a combination of simple repeating functions (e.g. bricks) and various fractal noise algorithms.
 
Many thanks pod.

This will probably also help me to understand the material system in Lightwave 9 as well, which has thus far proved elusive.
:icon_thumbup:
 
Shader Nodes

Car Paint: a shader designed to emulate the qualities of car paint (which is multilayered paint with a thin transparent overlay which has interesting properties).

dielectric: naturally transparent things like glass and water.

material: the most useful shader type -- very similar to C3D's old "material material".

membrane: very similar to C3D's old membrane material.

metal: you can create most metals quite nicely using the material shader, but the metal shader gives you access to anisotropic reflection. I'm not quite sure why this wasn't just built into the material shader.

shadow: shadow catcher material (essentially just renders shadows that fall onto it using a threshold value (how dark qualifies as shadow?)

solid: solid color, as per old renderer. Now with intensity, allowing objects to function as light sources -- kind of.

toon: the new toon shader. In essence the toon shader posterizes the light value. This may not be exactly what you want, and similar results can be achieved with other shaders using the gradient filter.

velvet: again, as per the old C3D velvet material.
 
Texture Nodes

Texture nodes take a virtual 2d (or 3d!) image, sample it using UV mapping or coordinates, and give you a color to play with. The simplest and most familiar case is the image texture which (typically) uses UV coordinates to sample a 2d bitmap image.

All the other textures are procedural and generate a virtual image of infinite resolution and size. Several of them are fractal noise generators of one sort or another.

The simplest way to understand texture nodes is to play with them. Create one and plug it into the diffuse channel of the material shader to see what it "looks" like. (Ideally Martin will provide more convenient previews in a future version of C3D.)

brick: (3d) produces a simple brick pattern.

cellnoise: (3d) produces a random grid of differently colored cubes. Useful for producing "steel plate" type textures for example.

checkerboard: (3d) produces a fixed pattern of alternating cubes.

directional: (3d) converts vector direction information into color using interpolation. Useful for creating materials which change depending on the orientation of faces (e.g. mountains which have vegetation on relatively horizontal areas, and rocks on relatively vertical areas).

dots: (3d) produces a fixed grid of spheres.

fractal: (3d) fractal cloud generator.

marble: (3d) fractal marble generator (like fractal but with a much steeper tone curve).

noise: (3d) fractal noise generator.

reptile: (3d) produces a somewhat regular grid of blobs. Very useful for creating more-or-less uniformly lumpy surfaces. Actually doesn't look much like reptile scales close up. I believe it's using a variation on the Voronoi algorithm.

turbulence: (3d) more fractal noise.

voronoi: (3d) produces a somewhat regular grid of polygons. Very useful for creating more-or-less uniformly tiled surfaces, such as cobbled roads.

wireframe: (2d) renders the wireframe of the underlying model as a texture -- very nice for rendering smoothed wireframes.

wood: (3d) renders turbulent noise tuned to look a bit like the rings in a tree.
 
Constant Nodes

Color: a color!

Number: a number!

Vector: a vector!

Note that colors and vectors are, in some sense, interchangeable, and that vectors can be used as numbers (the first value is used, the others are discarded) in a pinch and vice versa (a number n gets treated as the vector (n,n,n)).
 
Filter Nodes

composite nodes allow you to blend two input colors using a blend value (which itself may be an input). Usually composite nodes aren't needed since the same thing can be achieved directly in other nodes.

gradient nodes allow you to map an input value (think of it as a black-to-white spectrum) to an output gradient. E.g. if you want black to come out as blue, and middle grey to come out as red, and white to come out as green, then you'd make the gradient blue to red to green. Each color transition in a gradient can be immediate or blended, the former allowing you to achieve (among other things) toon-render effects.

hsv2rgb and rgb2hsv lets you convert colors between the two color spaces. Note that C3D's colors are RGB natively, so you will need to convert them to HSV if you want to perform operations on them in the HSV color space.
 
Nice tutorial. Helps me get up to speed after the upgrade.

Though, I wish that the 3D view would show a preview of the material system's output. For instance, when I drag a shader to an object in Carrara, I immediately see a result in the viewer. I can see what the material looks like from a pre rendered sphere but its out of context -- thats my impression. It could just bake to texture. It appears to see the material I have to ray trace render the entire scene. If it were just a preview bake or something like that. People are going to expect when they select a material its going to show up in the 3d view -- instantly. When you demonstrated the old marble texture in the video, it did not show up in the 3d view which is different and unexpected. Often, I'm going to go through and select different materials and choose which one I like best just looking at a preliminary render in the 3d view. But now, I have to choose and render the entire scene every time.

The node editor reminds me of quartz composer. What if people could just drop in a qtz file and that could be mapped to the rendering engines inputs? I'm pretty sure cocoa will let you capture the outputs of that system?
 
The State Node

The state node serves as a container for information about the surface being rendered and the scene itself. Perhaps the most immediately useful property from the state node is time. If you're animating a scene you can use the time value to vary materials over time. E.g. you can use it to continuously vary an offset of a noise channel which in turn feeds into a bump map to make "waves" appear on the surface of an object.

The normal and eye vectors allow you to vary the appearance of a material based on the direction the surface is facing or the angle of view. (I think i.n is the incident angle, which a product of the two.) This lets you implement fresnel-type effects (e.g. most transparent surfaces are less transparent and more reflective when viewed from an angle, some change color subtley, and so forth).

postion, uv1, and uv2 are obvious. Note that normally a material uses the object's uv settings to decide its uv input values -- but you can explicitly access them from the state object and force certain values to be mapped to global position or a specific uv coordinate (taking that control out of the user's hands -- or achieving special effects, such as basing the bump map on global position, the diffuse map on UV1, and the light map on UV2).
 
Though, I wish that the 3D view would show a preview of the material system's output. ... People are going to expect when they select a material its going to show up in the 3d view -- instantly.

This works for the diffuse channel and image textures, but not procedural textures. I'm not sure if Martin is up for implementing all his shaders as pixel shaders ;-)

It would be nice, but it's not likely to happen any time soon.
 
Math Nodes

OK this is the one you've been waiting for, right? Note that most math functions will operate on both scalars and vectors (and colors, which are treated as vectors). It even works for some strange things (e.g. division) which aren't well-defined for vectors.

abs returns the "absolute value" (i.e. positive size), so abs(-2) = 2.

add adds two values

cosine and sine and tangent are your usual trig functions (they work in radians). To get an intuitive grasp of trigonometry for 3d, the cosine of an angle is a measure of how parallel the lines forming that angle are to each other: 1 means exactly parallel (the angle is 0), -1 means exactly opposite (the angle is π radians -- 180°), and 0 means perpendicular. Sine is the other way around -- perpendicular = -1 or 1, and parallel or opposite = 0.

dotprod is a scalar value telling you how parallel two vectors are. For unit vectors, the dot produce is the same as the cosine of the angle they form; for non-unit vectors multiply the cosine by the product of the vectors' magnitudes. crossproduct is the dual of dotprod, returning a vector perpendicular to the plane containing the two vectors whose magnitude is the sine of the angle they form multiplied by the product of their magnitudes.

divide divides one value by another.

float2vec and vec2float let you pull vectors apart and put them back together again.

mix blends two colors using a third value. Actually it should be in the Filter menu. Or it should be changed to accept vectors.

modulo turns an open-ended value t into a repeating value by "wrapping" it into the interval [0 .. denominator]

multiply multiplies two values

multiplyadd multiplies two values and then adds a third value

norm returns the magnitude of a vector (this is a correction). To unitize a vector scale it by the inverse of its norm.

power raises a number to a power.

pulse takes an input value and maps everything below the lower threshold or above the upper threshold and maps it to 0 (black), and maps the rest to 1 (white). Smooth makes the transition smooth rather than sudden.

pulsetrain is like pulse but it performs the mapping 1/period times across the [0,1] interval. Um, that's not very user-friendly. It's like pulse but you it scales the input by 1/period and then wraps it back to [0,1] and it only has a lower threshold value. Play with it it's trippy.

squareroot calculates square roots. Same as using power and 0.5.

step is like pulsetrain but upside down and with only one threshold value.

subtract subtracts one thing from another.
 
Last edited:
Thanks Pod, information much appreciated. But seriously, is this how we're getting the User's Manual? Through the forum??? :D:D:D
 
tonio, sincerely thanks for that.

this is at least a part of the essential information without which the possibilities of this great piece of new software remain inaccessible to most users.
the interface is intuitive, but a filter named *multiplyadd* with some empty value boxes is not.
the old v4 bumpmap had a value range from -1 to 5.
what are the value ranges in the new system ?
colors is three times 0 - 1 i guess, but the rest including the new vector thingy escapes me yet.
i'm sure if other members of the chosen test crowd would join in and share some of their superior knowledge/information right here, the rest of us could actually begin with the starting AND some pressure would be released from martin to come up with an articulate doc with more fancy icons.
so thanks again for sharing what you know,
hope to see more of this from whomever (community!)

- archie
 
thank you, podperson
both for the .mov and (specially) for the written one (already put together in a pdf...)

with kindest regards,
A
 
Back
Top