The material node is used to define surface properties of an object. It does this by defining a set of primitives, known as fragments. Fragments are operators that process triplets of values, very suitable for representing color but also re-usable for other properties of a surface. For colors, the standard interpretation of a value is that 0 is black and 1 is white, but values can be outside this range (at both ends) without being clipped or considered invalid.
To define e.g. color (the typical use for a material node), begin by creating an output fragment, setting its type to "color", and then create any further fragments as desired, linking them to the root and each other to form the final material tree. The tree is then evaluated for every point of each surface that uses that material, and the result used to control the final shading.
Table 2-2 enumerates the defined fragment types, and also gives the numerical value associated with each one. This number is used to identify a fragment type in the network protocol.
Table 2-2. Material Node Fragment Type Enumeration
| Name | Enum Value | Purpose |
|---|---|---|
| VN_M_FT_COLOR | 0 | Emits a constant color. |
| VN_M_FT_LIGHT | 1 | Represents light falling on a surface. |
| VN_M_FT_REFLECTION | 2 | Represents reflected light. |
| VN_M_FT_TRANSPARENCY | 3 | Represents a transparent surface. |
| VN_M_FT_VOLUME | 4 | Represents a volume diffusion. |
| VN_M_FT_VIEW | 5 | Represents the vector between camera and surface. |
| VN_M_FT_GEOMETRY | 6 | Uses data from a geometry layer to create color. |
| VN_M_FT_TEXTURE | 7 | Does look-ups in a bitmap node. |
| VN_M_FT_NOISE | 8 | Generates random noise. |
| VN_M_FT_BLENDER | 9 | Blends two inputs together. |
| VN_M_FT_CLAMP | 10 | Clamps input to a minimum or maximum value. |
| VN_M_FT_MATRIX | 11 | Transforms input through a matrix. |
| VN_M_FT_RAMP | 12 | Interpolates in a table. |
| VN_M_FT_ANIMATION | 13 | Interpolates in a table. |
| VN_M_FT_ALTERNATIVE | 14 | Allows implementation to select between two alternatives. |
| VN_M_FT_OUTPUT | 15 | The root of each material fragment graph, the final output. |
Table 2-3 presents the defined fragment types. It mentions the purpose of each one, including its input fields and what operation it performs to generate its emitted color. Click the fragment name to jump into the table below, for a more detailed explanation.
These are the types of output fragment that are currently defined:
The tree defines surface color. This is the most common use.
Displacement of a surface. Gives a displacement along the surface normal, with a displacement distance exactly equal to the average of the sum of the components of the triplet reaching the output fragment. In other words, the distance is (R+G+B)/3. This should be done in the coordinate space of the geometry being displaced.
This is pending, and has not yet been given a final interpretation.
Table 2-3. Material Node Fragment Type Descriptions
| Name | Description | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Color |
The color fragment emits a single constant floating point triplet, generally used to represent a RGB color. It is defined by three simple fields:
| ||||||||||||||||||||||||
| Light |
The light fragment represents the amount of incoming light at a given point on a surface. It does not compute any view-dependent reflective properties of the surface, unless the BRDF field is used. The normal falloff ranges from zero to one, and defines the micro-geometry of the surface. A value of zero represents a perfectly flat surface, while a value of one represents a surface whose normals are randomly distributed.
| ||||||||||||||||||||||||
| Reflection |
This fragment represents a view-dependent perfect reflection computation from the evaluation point. The normal fall-off describes the micro-geometry in the same manner used by the light fragment.
| ||||||||||||||||||||||||
| Transparency |
This fragment represents the properties of the surface that is behind the evaluation point. The refraction index represent how light is bent when passing through the surface, and the normal fall-off describes the micro-geometry just as in the light and reflection fragments.
| ||||||||||||||||||||||||
| Volume |
This fragment represents the volume of air between the light source and the point on the surface being shaded. It allows you to model non-clear air, by specifying a color that will be weighted in according to the distance travelled through the volume.
| ||||||||||||||||||||||||
| View |
This fragment simply generates a vector pointing from the point at the surface, directly towards the viewing position. It can be thought of as the surface's normal, transformed by the view matrix. For a point on the surface facing straight towards the camera, it will be (0, 0, 1). For a face facing to the left, it will be (1, 0, 0), and so on. The fragment itself is empty, i.e. it has no parameters. | ||||||||||||||||||||||||
| Geometry |
The geometry fragment allows a material to reference properties defined in a geometry node. Any layer can be referenced, integer layers will be converted to normalized floating-point (by dividing with the maximum for the type in question). If an XYZ-type layer is being referenced, the values will be mapped to the RGB data space fragments use trivially (X becomes red, Y becomes green, and Z becomes blue). These are the fields of the fragment:
There is no node reference in this fragment; this is because the layers being referenced are always (implicitly) taken to be in the current object's geometry node. This is typically the only practical approach anyway, since e.g. UV-mapping data must be closely coupled to the geometry data in order to be applicable; referencing layers in the same node helps ensure this. | ||||||||||||||||||||||||
| Texture |
The texture fragment uses the incoming color as a point in 3D space mapped onto a bitmap, and returns the value of the pixel at that point. It is used, with the geometry fragment, to express plain old texture-mapping. It has the following fields:
| ||||||||||||||||||||||||
| Noise |
The noise fragment takes a single input color, and uses it as a lookup in a noise function. These are the types of noise currently supported: Table 2-5. Noise Fragment Types
| ||||||||||||||||||||||||
| Blender |
The blender fragment takes two input colors A and B (and sometimes a control input), and blends them using a function chosen from the following list: Table 2-6. Blender Fragment Types
| ||||||||||||||||||||||||
| Clamp |
The clamp fragment limits its input value, by computing the min() or max() function on the input and a constant. It is useful for instance to eliminate negative numbers from blending equations. The function is computed separately for each of the three channels.
| ||||||||||||||||||||||||
| Matrix |
The matrix fragment runs its input values through a 4x4 transformation matrix. Since the data passed between fragments is defined to be only triplets, they are considered extended with a fourth element with the value zero for these purposes. This element is then dropped again, since the data flowing between material fragments is only three components (RGB color). Of course, you can also think of it as just ignoring the last row and column of the matrix, and doing the operation on the 3x3 upper-left sub matrix. The operation is a post-multiplication of the matrix by the color, e.g. output = matrix × color.
| ||||||||||||||||||||||||
| Ramp |
A ramp (or curve) defined as an array of (position,color) tuples. It takes a color as input, and selects a single channel. The value of that channel is then used to do an interpolating look-up in the ramp, and the resulting color is emitted. A ramp essentially maps a one-dimensional input value into the three-dimensional color space. Table 2-7. Ramp Fragment Types
Table 2-8. Ramp Channel Types
| ||||||||||||||||||||||||
| Animation |
| ||||||||||||||||||||||||
| Alternative |
This fragment specifies two inputs, and allows the parser to select one and ignore the other. The most preferable path should always be specified as the one labeled A. The intent is to allow e.g. simpler materials to be defined in an alternative path. It is not defined how a shading implementation is supposed to chose between the two, it is left up to the implementor.
| ||||||||||||||||||||||||
| Output |
The output fragment serves as the root for a material tree, and must be present in a material node in order for it to have any effect. It is defined by the following fields:
If the front field is given a valid, non-zero value, any surface using this material will show it on its forward-facing side. If the back field is given a valid, non-zero value, it will show up on the backward-facing sides. If front equals back and is the ID of a valid fragment, the material will be double-sided. Leaving either front or back set to zero (an invalid fragment ID) or set to an invalid value will make the corresponding side of surfaces invisible. |
This section contains a set of example fragment graphs, to illustrate how the various pieces of functionality can be used together to create various actual materials.
Example 2-2. Plain Gray
Figure 2-2 shows a simple two-fragment material. This is about as simple as a material can become, since a lone output fragment is of little use. The added color fragment provides a constant medium-gray color for the entire surface. This material will not be very realistic, for example it will not react to incoming light at all.
The output fragment does not specify a value for the back field; meaning it's single-sided (surfaces using this material will not be visible from their back side).