SourceReference

SourceReference is a type of source where you can use an AnchorPointEffectNode from the layerstack.

Example

import substance_painter as sp

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

# Insert a paint layer
position = sp.layerstack.InsertPosition.from_textureset_stack(stack)
paint = sp.layerstack.insert_paint(position)

# Insert an anchor point in the content stack
position = sp.layerstack.InsertPosition.inside_node(paint, sp.layerstack.NodeStack.Content)
anchor = sp.layerstack.insert_anchor_point_effect(position, "anchor")

# Insert a fill layer with a mask
position = sp.layerstack.InsertPosition.from_textureset_stack(stack)
fill = sp.layerstack.insert_fill(position)
fill.add_mask(sp.layerstack.MaskBackground.White)

# Insert a reference on `anchor` in multi-channel context
source = fill.set_material_source(anchor)

# Edit the channel mapping
new_mapping = {
    sp.textureset.ChannelType.BaseColor: sp.textureset.ChannelType.Metallic,
    sp.textureset.ChannelType.Metallic: sp.textureset.ChannelType.BaseColor,
    sp.textureset.ChannelType.Roughness: sp.textureset.ChannelType.Height,
    sp.textureset.ChannelType.Normal: sp.textureset.ChannelType.BaseColor,
    sp.textureset.ChannelType.Height: sp.textureset.ChannelType.Metallic
}
for dst_chn, src_chn in new_mapping.items():
    source.channel_mapping[dst_chn] = src_chn

# Select the Fill layer
sp.layerstack.set_selected_nodes([fill])

class substance_painter.source.SourceReference(uid) substance_painter.source.SourceReference

A class that represents an reference to an anchor point.

property channel_mapping: ChannelMapping substance_painter.source.SourceReference.channel_mapping

The channels mapping property.

Getter: Returns the channel mapping property.

Raises:

EditionContextException – If the current context of the reference is not
multi-channel.

property referenced_channel: ChannelType substance_painter.source.SourceReference.referenced_channel

The referenced channel of the source.

Getter: Returns the referenced channel of the source.

Setter: Set the referenced channel of the source.

Raises:

EditionContextException – If the current context of the reference is not
single-channel or if the context of the target anchor point is not
multi-channel.

property anchor: AnchorPointEffectNode substance_painter.source.SourceReference.anchor

The anchor used by this source.

Getter: Returns the anchor used by the source.

property alpha_matte: AlphaMatte substance_painter.source.SourceReference.alpha_matte

The alpha matte used by this source.

Getter: Returns the alpha matte of the source.

Setter: Set the alpha matte of the source.

get_levels() -> LevelsParamsMono | LevelsParamsRGB substance_painter.source.SourceReference.get_levels

Get the parameters used by the levels of this source.

Returns: The parameters used by the levels of this source.

Return type: LevelsParamsMono | LevelsParamsRGB

set_levels(params: LevelsParamsMono | LevelsParamsRGB) -> None substance_painter.source.SourceReference.set_levels

Set the parameters used by the levels of this source.

Parameters: params (LevelsParamsMono | LevelsParamsRGB) – The parameters used by the levels of this source.

Return type: None

class substance_painter.source.ChannelMapping(uid) substance_painter.source.ChannelMapping

This class gives access to the active channels of a source reference in a dict-like fashion.
See channel_mapping property.

Example:

import substance_painter as sp
mapping = some_SourceReference_object.channel_mapping
mapping[sp.textureset.ChannelType.BaseColor] = sp.textureset.ChannelType.Specular
for channel in mapping:
    print(mapping[channel])
TIP
See also:
For more technical informations, see the official KeysView ABCs container
documentation as well as __getitem__ and
__setitem__
methods.

Enums

class substance_painter.source.AlphaMatte(value) substance_painter.source.AlphaMatte

Members:

Name
Description
KeepAlpha
Keep the alpha.
ExtractAlpha
Extract the alpha.
DefaultBackgroundColor
Matte the alpha with a default background color.
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