Share
 
 

Create new default values for ShaderFX nodes in a Stingray Physically Based Shader

In the ShaderFX editor for your Stingray PBS node, create a node, for example, Add. Click any input attribute on the node to display its Attribute Editor. A Default value has been assigned to the node; in this case, 0 0 0 0.

You can change this default value to any of the following. The attribute port also changes color as its default value is changed to a different data type.

  • int (dark blue port)
  • float (green port)
  • float2 (yellow port)
  • float3 (light blue port)
  • float4 (magenta port)

By setting the default value on an input, you can perform operations without providing an external connection.

For example, you can set the first input of your Add node to (1, 0, 1) and the 2nd input to (0, 0, -1). Click the Render Swatch icon, and you see that the Add node swatch turns red. You have added the two input default values (1, 0, 1) + (0, 0, -1) = (1, 0, 0) without connecting any external input nodes.

As soon as you connect a node to an input, however, the default value that you specified is erased and replaced with the new connection.

Example: Vertex color channel to determine opacity

The following example demonstrates how to use the vertex color blue channel to control opacity.

  • Create an Add node and set the default value of the second input to (0, 0, 0.5, 0).
  • Connect the RGBA output of Vertex Color 0 to the first input value of the Add node.
  • Connect the Result of the Add node to the Opacity input of the Standard Base node.
  • Select the Opacity channel on the Standard Base node to show its Attribute Editor and set the Component Swizzle value to b.

    Select Transparent from the Blend Mode drop down list.

The 0.5 value added to the blue vertex color channel causes all areas with blue to be semi-transparent.

A significant amount of blue was painted on dinosaur's leg. These areas are now more opaque than other areas since it is the blue channel that determines the opacity.

Was this information helpful?