Add switches in ShaderFX using Graph Nodes

When Toggle Advanced Mode is on, you can also create Graph Nodes.

Graph Nodes let you perform custom decision making in a graph. Essentially, you can create a switch as follows:

if true
    do A
else
    do B

Some examples of graph nodes are Bool AND and Path Direction.

The Bool Graph Nodes (Graph Nodes > Code Control > Bool AND, Graph Nodes > Values > Bool Value and so forth) should not be confused with the Bool value nodes (Hw Shader Nodes > Values > Bool).

A Bool node supplies a True or False value to the shader code, while a Bool Graph Node acts as a switch and does not supply a value to the shader.

In this example, the BoolValue Graph Node is the switch that controls whether PathDir takes input A or input B. If bool is connected to PathDir, input A is used. If Not bool is connected to PathDir, input B is used. BoolValue does not directly supply any value to Diffuse color.

The V symbol in the socket indicates that an input from a Graph Node (or an output to a Graph Node) is expected.

In this example, the Color value is multiplied by 1 or 0, depending on Bool. When Bool is set to true, Color is multiplied by 1 and Diffuse Color is yellow. When Bool is set to false, Color is multiplied by 0 and Diffuse Color is black. Therefore, Bool directly supplies a value to the shader.

An example application of using the Graph Nodes is to enable or disable opacity. Since it is more expensive to render a shader with opacity than it is without, an artist can add a switch to easily enable or disable this setting for faster preview rendering results.