Color Selection effect

ColorSelectionEffectNode is an effect that allows to extract one or more colors from a bitmap (usually a mesh based ID map) to build a black and white mask. It can only be used in a mask effect stack.

Examples

import substance_painter as sp

# Get the currently displayed Stack
stack = sp.textureset.get_active_stack()

# Get top position of the Stack
position_stack_top = sp.layerstack.InsertPosition.from_textureset_stack(stack)

# Insert Fill Layer
my_fill_layer = sp.layerstack.insert_fill(position_stack_top)
my_fill_layer.set_name("My Fill Layer")

# Add a mask and a Color Selection effect in the mask stack
my_fill_layer.add_mask(sp.layerstack.MaskBackground.Black)
inside_mask = sp.layerstack.InsertPosition.inside_node(
    my_fill_layer, sp.layerstack.NodeStack.Mask)
my_color_selection_effect = sp.layerstack.insert_color_selection_effect(inside_mask)

# Update the Color Selection effect parameters
parameters = my_color_selection_effect.get_parameters()
# Add red, green and blue colors
parameters.colors = [
    sp.colormanagement.Color(1.0, 0.0, 0.0),
    sp.colormanagement.Color(0.0, 1.0, 0.0),
    sp.colormanagement.Color(0.0, 0.0, 1.0)]
my_color_selection_effect.set_parameters(parameters)

# Select the Color Selection effect
sp.layerstack.set_selected_nodes([my_color_selection_effect])

Functions and classes

substance_painter.layerstack.insert_color_selection_effect(position: InsertPosition) -> ColorSelectionEffectNode substance_painter.layerstack.insert_color_selection_effect

Insert a color selection effect.

Parameters:

position (InsertPosition) – The insert position must be either inside
a LayerNode with NodeStack.Mask
or above/below an EffectNode in the mask stack.

Raises:

ValueError – If insertion failed due to an invalid position.
See InsertPosition.

Returns: The inserted node.

Return type: ColorSelectionEffectNode

class substance_painter.layerstack.ColorSelectionEffectNode(uid) substance_painter.layerstack.ColorSelectionEffectNode

Bases: Node

A node allowing manipulation of a Color Selection effect.

get_parameters() -> ColorSelectionEffectParams substance_painter.layerstack.ColorSelectionEffectNode.get_parameters

Get the current parameters of this color selection effect.

Returns: The current parameters of this color selection effect.

Return type: ColorSelectionEffectParams

set_parameters(params: ColorSelectionEffectParams) -> None substance_painter.layerstack.ColorSelectionEffectNode.set_parameters

Set new parameters of this compare mask effect.

Parameters: params (ColorSelectionEffectParams) – The new parameters.

Raises:

ResourceNotFoundError – If the resource params.id_mask is not found or is not of
Type.IMAGE.

Return type: None

Params

class substance_painter.layerstack.ColorSelectionEffectParams(id_mask: ResourceID | None, output_value: float, hardness: float, tolerance: float, background_color: ColorSelectionBackgroundColor, colors: List[Color]) substance_painter.layerstack.ColorSelectionEffectParams

A color selection effect parameters.

Parameters:

  • id_mask (ResourceID | None) – Which color map to use.
    Typically the ID Mask baked map. Must have
    Usage.TEXTURE and be part of the project.
  • output_value (float) – Output value when selection matches. Between 0.0 and 1.0.
  • hardness (float) – Hardness of the selection. Between 0.0 and 1.0.
  • tolerance (float) – Tolerance of the selection. Between 0.0 and 1.0.
  • background_color (ColorSelectionBackgroundColor) – Output value when selection does not match.
  • colors (List*[Color]*) – List of colors to match in the id_mask.

class substance_painter.layerstack.ColorSelectionBackgroundColor(value) substance_painter.layerstack.ColorSelectionBackgroundColor

Members:

Name
Description
Transparent
Filter background is transparent.
Black
Filter background is black.
White
Filter background is white.
Gray
Filter background is grey.
NOTE
The name used to define members is available as a string via the .name attribute (see python enum.Enum).
recommendation-more-help
substance-3d-dev-help-painter-python-guide