Stack类

类substance_painter.textureset.堆叠(堆叠id: int |无=无) substance_painter.textureset.Stack

可喷漆堆叠。

一个堆叠可以包含多个与该材料对应的通道(基色、Specular、粗糙度等)。 该堆叠属于一个纹理集,它可能包含一个或多个堆叠。

通常,只使用一个堆叠,该堆叠对用户是透明的。 选择纹理集将选择其堆叠。 但是,纹理集可以将分层材料与自定义着色器结合使用,在这种情况下需要选择特定堆叠。

如果纹理集不使用材料图层,则可以按如下方式检索其堆叠:

import substance_painter.textureset

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

# Alternatively, get the stack from a Texture Set instance:
my_texture_set = substance_painter.textureset.TextureSet.from_name("TextureSetName")
paintable_stack = my_texture_set.get_stack()

如果纹理集确实使用材料图层,则可以按如下方式检索其堆叠:

import substance_painter.textureset

# Get the stack called "Mask1" from the Texture Set "TextureSetName":
paintable_stack = substance_painter.textureset.Stack.from_name("TextureSetName",
                                                               "Mask1")

# Alternatively, get the stack from a Texture Set instance:
my_texture_set = substance_painter.textureset.TextureSet.from_name("TextureSetName")
paintable_stack = my_texture_set.get_stack("Mask1")

# Show the name of the stack:
print(paintable_stack.name())

可以查询、添加、删除或编辑堆叠的通道:

import substance_painter.textureset

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

# List all the channels of the "TextureSetName" Texture Set:
for k,v in paintable_stack.all_channels().items():
    print("{0}: {1}".format(k, str(v.format())))

# Add a scattering channel to the "TextureSetName" Texture Set:
paintable_stack.add_channel(substance_painter.textureset.ChannelType.Scattering,
                            substance_painter.textureset.ChannelFormat.L8)

# Query details of the added scattering channel:
if paintable_stack.has_channel(substance_painter.textureset.ChannelType.Scattering):
    channel = paintable_stack.get_channel(
        substance_painter.textureset.ChannelType.Scattering)
    print("The Texture Set now has a scattering channel with {0} bits per pixel."
        .format(channel.bit_depth()))

# Change the scattering channel to 16 bits inside the "TextureSetName" Texture Set:
paintable_stack.edit_channel(
    channel_type = substance_painter.textureset.ChannelType.Scattering,
    channel_format = substance_painter.textureset.ChannelFormat.L16)

# Remove the scattering channel from "TextureSetName":
paintable_stack.remove_channel(substance_painter.textureset.ChannelType.Scattering)
TIP
另请参阅: TextureSet,纹理集文档。

参数: 堆叠_id (int)

static from_name(纹理集名称:str,堆叠名称:str = ") substance_painter.textureset.Stack.from_name

从其名称获取堆叠。

参数:

  • 纹理_set_name (str) -纹理集名称。
  • 堆叠_name (str) -堆叠名称。 如果纹理集不使用材料分层,请留空。
NOTE
纹理集和堆叠名称区分大小写。

引发:

  • ProjectError — 如果未打开项目。
  • ServiceNotFoundError — 如果Substance 3D Painter尚未启动其所有服务。
  • ValueError — 如果texture_set_name不是字符串。
  • ValueError — 如果没有名为texture_set_name的纹理集。
  • ValueError — 如果没有名为stack_name的堆叠。

参数:

  • 纹理_set_name (str)
  • 堆叠_name (str)

name() -> str substance_painter.textureset.Stack.name

获取堆叠名称。 如果堆叠所属的纹理集使用材料分层,则文档名称为空。

返回:​堆叠名。

返回类型: str

引发:

  • ProjectError — 如果未打开项目。
  • ServiceNotFoundError — 如果Substance 3D Painter尚未启动其所有服务。
  • ValueError — 如果栈栈无效。

材料() substance_painter.textureset.Stack.material

获取此栈栈所属的纹理集。

返回:​此堆叠所属的纹理集。

返回类型: TextureSet

引发:

  • ProjectError — 如果未打开项目。
  • ServiceNotFoundError — 如果Substance 3D Painter尚未启动其所有服务。
  • ValueError — 如果栈栈无效。
TIP
另请参阅: TextureSet,all_texture_sets()。

all_channels() -> Dict[ChannelType, Channel] substance_painter.textureset.Stack.all_channels

列出堆叠的所有声道。

返回:​堆叠所有声道的映射。

返回类型: dict[ChannelType,Channel]

引发:

TIP
另请参阅: Stack.add_channel(),Stack.remove_channel()。

add_channel(channel_type: ChannelType, channel_format: ChannelFormat,标签: str |无=无) ->通道 substance_painter.textureset.Stack.add_channel

将新频道添加到堆叠。

NOTE
add_channel不适用于材料图层。

参数:

  • channel_type (ChannelType) — 通道类型。
  • channel_format (ChannelFormat) — 新通道的纹理格式。
  • 标签 (str*,* 可选) — 如果频道为类型,则为频道的标签。

返回:​创建的频道。

返回类型: 通道

引发:

  • ProjectError — 如果未打开项目。
  • ValueError — 如果此纹理集中已存在类型为channel_type的通道。
  • ValueError — 如果提供了标签,但channel_type不是用户类型。 标准渠道类型具有固定标签。
  • ValueError — 如果堆叠无效。
  • ValueError — 如果纹理集使用材料分层。

remove_channel(channel_type: ChannelType) ->无 substance_painter.textureset.Stack.remove_channel

从堆叠中删除声道。

NOTE
移除_channel不适用于材料图层。

参数: channel_type (ChannelType) — 通道类型。

引发:

  • ProjectError — 如果未打开项目。
  • ValueError — 如果此纹理集中没有类型为channel_type的通道。
  • ValueError — 如果堆叠无效。
  • ValueError — 如果纹理集使用材料分层。

返回类型:​无

edit_channel(channel_type: ChannelType, channel_format: ChannelFormat,标签: str |无=无) ->无 substance_painter.textureset.Stack.edit_channel

更改声道的纹理格式和标签。

参数:

  • channel_type (ChannelType) — 通道类型。
  • channel_format (ChannelFormat) — 通道的新纹理格式。
  • 标签 (str*,* 可选) — 如果频道为类型,则为频道的标签。

引发:

  • ProjectError — 如果未打开项目。
  • ValueError — 如果此纹理集中没有标记为stack_id的堆叠。
  • ValueError — 如果此纹理集中没有类型为channel_type的通道。
  • ValueError — 如果提供了标签,但channel_type不是用户类型。 标准渠道类型具有固定标签。
  • ValueError — 如果堆叠无效。

返回类型:​无

TIP
另请参阅: Stack.add_channel(),Stack.remove_channel()。

has_channel(channel_type: ChannelType) -> bool substance_painter.textureset.Stack.has_channel

检查堆叠中是否存在声道。

参数: channel_type (ChannelType) — 通道类型。

如果堆叠具有给定类型的声道,则返回: True,否则返回False。

返回类型: bool

引发:

  • ProjectError — 如果未打开项目。
  • ValueError — 如果堆叠无效。
TIP
另请参阅: Stack.add_channel(),Stack.remove_channel()。

get_channel(channel_type: ChannelType) ->通道 substance_painter.textureset.Stack.get_channel

从其类型获取现有通道。

参数: channel_type (Channel) — 通道类型。

返回:​通道。

返回类型: 通道

引发:

  • ProjectError — 如果未打开项目。
  • ServiceNotFoundError — 如果Substance 3D Painter尚未启动其所有服务。
  • ValueError — 如果通道不存在。
recommendation-more-help
substance-3d-dev-help-painter-python-guide