Channel class

class substance_painter.textureset.Channel(channel_id: int | None = None) {#substance_painter.textureset.Channel}

A Substance 3D Painter channel.

A channel can be one of the predefined types (BaseColor, Specular, Roughness,
etc.) or a user defined type (User0 to User31), corresponding to the material.
The channel belongs to a stack. The stack can have one or more of them, but it
can have only one channel of each ChannelType.

Example

import substance_painter.textureset

# Get the unnamed stack of "TextureSetName":
paintable_stack = substance_painter.textureset.Stack.from_name("TextureSetName")

# Get the channel "BaseColor" of that stack:
base_color_channel = paintable_stack.get_channel(
    substance_painter.textureset.ChannelType.BaseColor)

# Print the color format and bit depth of the base color channel:
print("The channel format uses {0} {1}.".format(
    "RGB" if base_color_channel.is_color() else "L",
    base_color_channel.bit_depth()))

# Change the format and bit depth of the base color channel:
base_color_channel.edit(
    channel_format = substance_painter.textureset.ChannelFormat.RGB16)

Parameters: channel_id (int)

format() -> ChannelFormat {#substance_painter.textureset.Channel.format}

Get the channel format. The format indicates both if the channel is color
or grayscale, its dynamic range, its bits per component, and if the storage
is linear or sRGB.

Returns: This channel format.

Return type: ChannelFormat

label() -> str {#substance_painter.textureset.Channel.label}

Get the user label for User channels (User0 to User31).

Returns: This channel user label. This is the empty string for non User channels.

Return type: str

[!TIP]

See also:
Channel.type(),
ChannelType.

is_color() -> bool {#substance_painter.textureset.Channel.is_color}

Check if the channel is in color or grayscale format.

Returns: True if the channel format is a color format.

Return type: bool

is_floating() -> bool {#substance_painter.textureset.Channel.is_floating}

Check if the channel is in floating point or normalized fixed point format.

Returns: True if the channel format is a floating point format.

Return type: bool

bit_depth() -> int {#substance_painter.textureset.Channel.bit_depth}

Get the number of bits per component.

Returns: The channel bit depth per component.

Return type: int

type() -> ChannelType {#substance_painter.textureset.Channel.type}

Get the channel type.

Returns: This channel type.

Return type: ChannelType

[!TIP]

See also:
Channel.label().

edit(channel_format: ChannelFormat, label: str | None = None) -> None {#substance_painter.textureset.Channel.edit}

Change the channel format and label.

Parameters:

  • channel_format (ChannelFormat) – The new texture format of the channel.
  • label (str*,* optional) – Label of the channel in case of User channel as type.

Raises:

  • ProjectError – If no project is opened.
  • ValueError – If there is no stack labeled stack_id in this Texture Set.
  • ValueError – If there is no channel of type channel_type in this Texture Set.
  • ValueError – If a label was provided but channel_type is not a user type.
    Standard channel types have fixed labels.
  • ValueError – If the channel is invalid.

Return type: None

recommendation-more-help
substance-3d-dev-help-painter-python-guide