Compare Mask effect
CompareMaskEffectNode is an effect that allows to quickly and easily compare two channels and produce a mask as a result. It can only be used in a mask effect stack.
Compare Mask effect documentation.
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_base = sp.layerstack.insert_fill(position_stack_top)
my_fill_layer_base.set_name("Base")
# Set a material in the Fill layer
aluminium_material = sp.resource.search("s:starterassets "
"u:substance "
"n:Clay")[0]
my_fill_layer_base.set_material_source(aluminium_material.identifier())
# Insert second Fill Layer
my_fill_layer_snow = sp.layerstack.insert_fill(position_stack_top)
my_fill_layer_snow.set_name("Snow")
# Add a mask and a Compare Mask in the mask stack
my_fill_layer_snow.add_mask(sp.layerstack.MaskBackground.Black)
inside_mask = sp.layerstack.InsertPosition.inside_node(
my_fill_layer_snow, sp.layerstack.NodeStack.Mask)
my_compare_mask_effect = sp.layerstack.insert_compare_mask_effect(inside_mask)
# Update the Compare Mask parameters
parameters = my_compare_mask_effect.get_parameters()
parameters.channel = sp.layerstack.ChannelType.Roughness
parameters.hardness = 0.5
my_compare_mask_effect.set_parameters(parameters)
# Select the Compare Mask effect
sp.layerstack.set_selected_nodes([my_compare_mask_effect])
Functions and classes
substance_painter.layerstack.insert_compare_mask_effect(position: InsertPosition) -> CompareMaskEffectNode substance_painter.layerstack.insert_compare_mask_effect
Insert a compare mask effect with default parameters.
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: CompareMaskEffectNode
class substance_painter.layerstack.CompareMaskEffectNode(uid) substance_painter.layerstack.CompareMaskEffectNode
Bases: Node
A node allowing manipulation of a Compare Mask effect.
Compare Mask effect documentation
get_parameters() -> CompareMaskEffectParams substance_painter.layerstack.CompareMaskEffectNode.get_parameters
Get the current parameters of this compare mask effect.
Returns: The current parameters of this compare mask effect.
Return type: CompareMaskEffectParams
set_parameters(params: CompareMaskEffectParams) -> None substance_painter.layerstack.CompareMaskEffectNode.set_parameters
Set new parameters of this compare mask effect.
Parameters: params (CompareMaskEffectParams) – The new parameters.
Return type: None
Params
class substance_painter.layerstack.CompareMaskEffectParams(channel: ChannelType, left_operand: CompareMaskEffectOperand, right_operand: CompareMaskEffectOperand, operation: CompareMaskEffectOperation, constant: float, tolerance: float, hardness: float) substance_painter.layerstack.CompareMaskEffectParams
A compare mask effect parameters.
Parameters:
- channel (ChannelType) – The channel to compare between the source and the target to create a
mask from. Only used when some operands refers to Layers. - left_operand (CompareMaskEffectOperand) – The left operand of the comparison.
- right_operand (CompareMaskEffectOperand) – The right operand of the comparison.
- operation (CompareMaskEffectOperation) – The comparison operation to perform.
- constant (float) – Value to compare against when some operand is
CompareMaskEffectOperand.Constant. Between 0.0 and 1.0. - tolerance (float) – Tolerance value to use when operation is
CompareMaskEffectOperation.WithinTolerance.
Between 0.0 and 1.0. - hardness (float) – Controls the smoothness/hardness of the resulting mask comparison.
Between 0.0 and 1.0.
class substance_painter.layerstack.CompareMaskEffectOperand(value) substance_painter.layerstack.CompareMaskEffectOperand
See Compare Mask effect documentation for a complete
description of the compare mask effect.
Members:
LayersBelowThisLayerThisMaskConstantclass substance_painter.layerstack.CompareMaskEffectOperation(value) substance_painter.layerstack.CompareMaskEffectOperation
Members:
LesserThanWithinToleranceGreaterThan