In MaterialX, shading computations are represented via a graph of nodes. A node
can be thought of as representing an atomic unit of computation.
Each item in a graph is a node that consists of inputs, outputs and connections. Each node's definition is specified by an interface which contains 0 or more port elements or ports for short.
<inputs>
s.<output>
s.type
is one of the available types defined in the standard library. An example type is color3
which represents 3-channel colors.
The code above shows a graph using Gooch shader <gooch_shade>
nodes called default_gooch
and red_blue_gooch
. The node's name
, input value
s and / or connections can be modified.
The visual representation of the code is shown as a node graph. The nodes are connected by lines that show the flow of data. The nodes are represented by shapes that are color coded to represent the output type of node.
Gooch node graph. You can refer to the learning site for more information.
The text in the editor is in XML format and is color coded by elements, attributes and values. Elements include: nodes, inputs, outputs and the
start and end delimiter for MaterialX <materialx></materialx>
Purple is used to show elements. For example the start and end tags of the each Gooch node are: <gooch_shade></gooch_shade>
.
Yellow is used to show attributes of an element. Common attributes include: name
, type
and value
. For example the name
attribute of the Gooch node is default_gooch
.
Green is used to show the associated value(s) or connection names for an attribute. For example, the value for nodename
is a connection name.
In general only values should be modified on an existing node or input.
For example the warm_color
value on the default_gooch
node can be changed from 0.5 0.5 0.5
to 0.5 0.5 0.7
, or the specular_intensity
input value
on the red_blue_gooch
node can be changed from 1
to 0.7
.
The type of the assigned value cannot be changed to an incompatible type. For example, the specular_intensity
input value on the red_blue_gooch
node cannot be changed from 1
to false
which attempts to change from a scalare to a boolean assignment.
Changes to the name
attribute of a node nodename
means you will also need to update node name references.
In the example above the node name default_gooch
was changed to default_gooch2
. This node name is referenced by the emission_color
input on the surface_unlit
node and so the node nodename
value must be updated to default_gooch2
.
Every time an edit is made in the text editor the color of the outline on refresh button will change to orange. This indicates that the viewer needs to be updated by clicking the refresh button.
In the text editor, if there is an XML syntax error, the code will be highlighted red.
The code is validated to see if it is valid MaterialX by using the validation
button.
In the example above, we see that error messages are shown in the status window located below the code window. When the code is fixed the status window will read "Document is valid."
Shown in the picture above are the various file options for the text editor. This includes - Saving the the document to file. - Loading in from a file. - Clearing the current document. This will preserve enough text to keep the document valid.
Users can load various sample graphs / materials via the Library
menu. This example uses the sample graph Gooch
document.
The text can be copied to the clipboard using the clipboard copy button or pasted into the editor using the clipboard paste button.
The search bar can be used to search for text in the editor. It will perform a case insensitive search and highlight any text found. Search can be performed in the forward or backward direction.