堆疊類別

類別 substance_painter.textureset.Stack(stack_id: int |None = None) substance_painter.textureset.Stack

一個 Substance 3D Painter 可上色的堆疊。

一個堆疊可以包含多個通道(BaseColor、Specular、Roughness 等),這些通道對應於材質。 堆疊屬於一個紋理集,該材質集可能包含一個或多個堆疊。

通常只會使用一個堆疊,且該堆疊對使用者是透明的。 選擇貼圖集後,會選擇其堆疊。 然而,貼圖集可以使用帶有自訂著色器的分層材質,這時需要選擇特定的堆疊。

如果材質集沒有使用材質分層,你可以用以下方式取回它的堆疊:

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紋理集文件。

參數:​stack_id (int)

靜態from_name(texture_set_name: str, stack_name: str = ‘’) substance_painter.textureset.Stack.from_name

從名字中取出一個層疊。

參數:

  • texture_set_name (str) – 材質集名稱。
  • stack_name (str) – stack 名稱。 如果材質集沒有使用材質分層,請留空。
NOTE
材質集和堆疊名稱是區分大小寫的。

加薪:

  • ProjectError – 如果沒有專案被開啟。
  • ServiceNotFoundError – 如果 Substance 3D Painter 尚未啟動所有服務。
  • ValueError – 如果 texture_set_name 不是字串。
  • ValueError – 若沒有名為 texture_set_name的貼圖集。
  • ValueError – 若沒有名為 stack_name的堆疊。

參數:

  • 材質_set_name (力量)
  • Stack_name (力量)

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

取得那個堆疊名稱。 如果該堆疊名稱屬於材質,則該堆疊名稱為空的貼圖集。

退貨: 堆疊名稱。

回傳類型: 力量

加薪:

  • ProjectError – 如果沒有專案被開啟。
  • ServiceNotFoundError – 如果 Substance 3D Painter 尚未啟動所有服務。
  • ValueError – 如果堆疊無效。

material() 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]

加薪:

add_channel(channel_type:ChannelType,channel_format:ChannelFormat,標籤:str |None = None) -> 頻道 substance_painter.textureset.Stack.add_channel

新增一個頻道到堆疊中。

NOTE
加成與_channel不支援材質分層功能。

參數:

  • channel_type (ChannelType) – 通道類型。
  • channel_format​(ChannelFormat)— 新通道的貼圖格式。
  • label (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 |None = None) -> None substance_painter.textureset.Stack.edit_channel

改變頻道的材質格式和標籤。

參數:

  • channel_type (ChannelType) – 通道類型。
  • channel_format​(ChannelFormat)– 頻道的新材質格式。
  • label (str*,* 可選) – 使用者通道為類型時的標籤。

加薪:

  • ProjectError – 如果沒有專案被開啟。
  • ValueError – 如果此材質集中沒有標記 stack_id 的堆疊。
  • ValueError – 如果此紋理集中沒有 的通道 channel_type 。
  • ValueError – 如果標籤已提供但 channel_type 非使用者類型。 標準頻道類型有固定標籤。
  • ValueError – 如果堆疊無效。

返回類型: 無

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

檢查堆疊中是否有通道存在。

參數:​ channel_type ​(ChannelType)– 通道類型。

回傳:True若堆疊中有該類型的通道,False否則。

回傳類型: bool

加薪:

  • ProjectError – 如果沒有專案被開啟。
  • ValueError – 如果堆疊無效。

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

從現有頻道類型取得。

參數:​ channel_type ​(通道)– 通道類型。

回來: 頻道。

回傳類型:​通道

加薪:

  • ProjectError – 如果沒有專案被開啟。
  • ServiceNotFoundError – 如果 Substance 3D Painter 尚未啟動所有服務。
  • ValueError – 如果該通道不存在。
recommendation-more-help
substance-3d-dev-help-painter-python-guide