Layer RGBA


The layer_RGBA shader can be used to linearly layer up to eight shaders together, enabling you to create complex shading effects. Layers are applied in order (bottom to top) according to a blending mode specified in the operation. The layer alpha can optionally be a separate input. A use for this shader could include adding text to an image for example. 

 

Enable (1-8)

Enable/disable the layer entirely.

Swap Inputs (1-8)

Swaps the input of the current and the selected layers.

Move (1-8)

Moves the current layer in place of the selected layer, pushing the other layers up or down, changing the order of the layers. For instance if layer 2 is moved in place of layer 5, the new order is (bottom to top): layer 1, layer 3, layer 4, layer 5, layer 2, layer 6, layer 7, layer 8.

Name (1-8)

Layer name.

Input (1-8)

Input value for Layer.

Mix (1-8)

Controls the amount of blending between shaders.

You may need to insert a range shader when connecting a bitmap to mix.

Operation (1-8)

The blending mode for the current layer. They emulate all of Nuke and Photoshop's modes. In the formulas, A (layer_1) is the upstream intermediate result, and B (layer_2) is the current layer.

 Click here to view the list of operations
  • overwrite: B
  • atop: A * B.a + B * (1 - A.a)
  • average: (A + B) / 2
  • cojoint_over: A if A.a > B.a else A + B * (1 - A.a/B.a
  • color_burn1 - (1 - A) / B
  • color_dodge: A/ (1 - B)
  • difference: abs(A - B)
  • disjoint_over: A + B * (1 - A.a) / B.a, A + B if A.a + B.a < 1
  • divide: A / B, 0 if A and B < 0, else A if B < epsilon
  • exclusion: A + B - 2 * A * B
  • from: B - A
  • geometric: 2 * A * B / (A + B)
  • glow B2 / (1 - A)
  • hard_light: 1 - 2 * (1 - A) * (1 - B), 2 * A * B if A < 0.5
  • hard_mix: vivid_light(A, B) < 0.5 ? 0 : 1
  • hypot_diagonal: √(A2 + B2)
  • in: A * B.a
  • linear_light: (B0.5) ? A + 2B1A + 2 * (B - 0.5)
  • mask: B * A.a
  • matte: A * A.a + B * (1 - A.a)
  • max: max(A, B)
  • min: min(A, B)
  • minus: A - B
  • multiply: A * B, A if A and B < 0
  • negation: 1 - abs(1 - A - B)
  • out: A * (1 - B.a)
  • over: A + B * (1 - A.a)
  • overlay: hardlight(B, A)
  • phoenix: min(AB- max(AB+1
  • pin_light: B < 0.5 ? min(A2 * B) : max(A* (B - 0.5)
  • plus: A + B
  • reflectA2 / (1 - B)
  • screen: A + B - A * B if A and B in 0..1, else max(A, B)
  • soft_light: Softer version of hard_light
  • stencil: B * (1 - A.a)
  • subtract: A + B - 1
  • under: A * (1 - B.a) + B
  • vivid_light: B < 0.5 ? color_burn(AB) : color_dodge(A2* (B - 0.5)
  • xor: A * (1 - B.a) + B * (1 - A.a)

Normal Map

It is possible to blend multiple normal maps using the normal map blending operation.

Alpha Operation (1-8)

Optional alpha value for Layer. 

Result: The alpha is computed in the same way as the other color channels (follows the "operation" for the RGB channel).

Preserve: Keeps the old alpha value ( A.a ).

Overwrite: The alpha channel is overwritten by the alpha of the current layer ( B.a ).

Mask: Calculated as: A.a + B.a - A.a * B.a.

 


Clamp

Clamp all intermediate results to [0,1].

 

Example of layer_RGBA shader used to layer Arnold graffiti texture onto brick texture

  • No labels