Show frames
Go to:
Attributes.
Condition is a utility node that allows you to switch
between two colors or textures, depending on a simple mathematical
relationship between two input values. If the relationship
(Greater Than, Less Than, Equals, Is Not Equal To, etc) is
true, then the first color or texture is output. If the relationship
is false, then the second color or texture is output.
You can use Condition nodes for many different purposes.
Some examples:
- You could create a shader that changes to a different
color when an object goes above a certain height. To do this,
connect the Translate Y attribute of the object to First Term,
set Second Term to the desired height, and set Operation to
"Greater Than". Set ColorIfTrue to red and ColorIfFalse to blue,
and connect the OutColor attribute to the object's shader. Now, when the
Y value of the object goes above the desired height, it will change
color from blue to red.
- In a slight variation, you can create a texture where
the parts of the texture above a certain height are one color,
and the parts below are another color. Create a Sampler
Info utility node, and connect its Point World Y attribute to
First Term.
This will give you the position of each point on
the texture, rather than the position of the whole object.
Set Second Term to the desired height, and set
Operation to "Greater Than".
- You could create a texture that is like a marble texture, but
turns black in all the areas where the marble is too red. To do this,
connect the Marble's Out Color R attribute to First Term, and set
Second term to the desired red threshold value (say, 0.75).
Connect the Out Color attribute of a marble texture to
ColorIfFalse, and set ColorIfTrue to black. Set Operation to
"Greater Than". Connect the OutColor of the Condition
node to your shader.
See the Rendering Book for more in-depth examples.
Note: The Condition node is completely unrelated to the
"condition" command found in the MEL scripting language.
In general, the operation of the Condition Node is this:
IF ( First Term OPERATION Second Term ) THEN
Out Color = Color If True
ELSE
Out Color = Color If False
In the table below, important attributes have their names
listed in bold in the description column.
This node is MP safe
Node name | Parents | Classification | MFn type | Compatible function sets |
---|
condition | node | utility/general:drawdb/shader/operation/condition | kCondition | kBase kNamedObject kDependencyNode kCondition |
Attributes (15)
colorIfFalse, colorIfFalseB, colorIfFalseG, colorIfFalseR, colorIfTrue, colorIfTrueB, colorIfTrueG, colorIfTrueR, firstTerm, operation, outColor, outColorB, outColorG, outColorR, secondTerm
Long name (short name) | Type | Default | Flags |
---|
|
colorIfFalse
(cf )
| float3 | 1.0, 1.0, 1.0 |      |
|
| colorIfFalseR
(cfr )
| float | 0.0 |      | |
|
| colorIfFalseG
(cfg )
| float | 0.0 |      | |
|
| colorIfFalseB
(cfb )
| float | 0.0 |      | |
|
|
colorIfTrue
(ct )
| float3 | 0.0, 0.0, 0.0 |      |
|
| colorIfTrueR
(ctr )
| float | 0.0 |      | |
|
| colorIfTrueG
(ctg )
| float | 0.0 |      | |
|
| colorIfTrueB
(ctb )
| float | 0.0 |      | |
|
|
firstTerm
(ft )
| float | 0.0 |      |
|
|
operation
(op )
| enum | 0 |     |
|
|
outColor
(oc )
| float3 | 0.0, 0.0, 0.0 |   |
|
| outColorR
(ocr )
| float | 0.0 |   | |
|
| outColorG
(ocg )
| float | 0.0 |   | |
|
| outColorB
(ocb )
| float | 0.0 |   | |
|
|
secondTerm
(st )
| float | 0.0 |      |
|