SourceSubstance

SourceSubstanceは、substanceリソースを接続できるソースの種類です。

詳細については、モジュールresourceおよびcolormanagementを参照してください。

例

import substance_painter as sp

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

# Insert a fill layer
position = sp.layerstack.InsertPosition.from_textureset_stack(stack)
fill = sp.layerstack.insert_fill(position)

# Apply "Graphic to Material" in `Material` mode
graphic_to_material = sp.resource.search("s:starterassets "
                                         "u:substance "
                                         'n:"graphictomaterial"')[0]
source = fill.set_material_source(graphic_to_material.identifier())

# Substances can have image inputs which are sources themselves
# In this case, we use the input identifier instead of the channel type to query and edit the source
logo = sp.resource.search("s:starterassets "
                          "u:alpha "
                          'n:"logo painter"')[0]

assert "custom_image" in source.image_inputs
input_source = source.set_source("custom_image", logo)

# `input_source` is now a BitmapSource
# see BitmapSource example for further information on its interface

# In `Material` mode, you can specify how the outputs of the substance are plugged in the fill's channels
default_mapping = {
    sp.textureset.ChannelType.BaseColor: "basecolor",
    sp.textureset.ChannelType.Metallic: "metallic",
    sp.textureset.ChannelType.Roughness: "roughness",
    sp.textureset.ChannelType.Height: "height"
}
for dst_chn, identifier in default_mapping.items():
    assert identifier in source.image_outputs
    source.output_mapping[dst_chn] = identifier

# If not in `Material` mode, choose which output of the substance is active
# source.active_output = "basecolor"

# Retrieve and edit the substance parameters
params = source.get_parameters()
for prop_name in params.keys():
    print(prop_name)

new_params = {
    "outline_color": sp.colormanagement.Color(0.9, 0.7, 0.4),
    "roughness": params["roughness"] / 2,
    # Boolean parameters are treated as integer, if you use `True` or `False` you will get an error message:
    # >>> Bad value for property 'channel_roughness': expected value of type <int32> but got <bool>
    "channel_roughness": 1,
}
source.set_parameters(new_params)

# Query embedded presets and apply the first one
presets = source.get_preset_list()
for preset_name in presets:
    print(preset_name)

if presets:
    source.apply_preset(presets[0])

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

class substance_painter.source.SourceSubstance(uid) substance_painter.source.SourceSubstance

プロシージャルのソースを表すクラス。

property resource_id: ResourceID substance_painter.source.SourceSubstance.resource_id

ソースの現在のサブスタンスリソース。

Getter:​ソースのリソースを返します。

プロパティoutput_mapping: OutputMapping substance_painter.source.SourceSubstance.output_mapping

複数の出力コンテキストの出力マッピングプロパティ。

Getter:​出力マッピングプロパティを返します。

Setter:​出力マッピングプロパティを設定します。

プロパティactive_output: str substance_painter.source.SourceSubstance.active_output

単一出力コンテキストでのソースのアクティブな出力。

Getter:​出力識別子を返します。

Setter:​出力識別子を設定します。

property mask_output: str substance_painter.source.SourceSubstance.mask_output

複数の出力コンテキスト内のソースのマスク出力識別子。

Getter:​マスク出力識別子を返します。

設定:​マスクの出力識別子を設定します。

property image_inputs: List[str] substance_painter.source.SourceSubstance.image_inputs

画像の一覧には、現在のグラフの識別子が入力されます。

取得メソッド:​入力された画像の一覧を識別子で返します。

プロパティimage_outputs: List[str] substance_painter.source.SourceSubstance.image_outputs

現在のグラフの出力画像識別子の一覧。

Getter:​識別子の一覧を返します。

get_source(識別子: str) -> SourceUniformColor | SourceBitmap | SourceVectorial | SourceSubstance | SourceReference | SourceFont substance_painter.source.SourceSubstance.get_source

指定された入力識別子のソースを取得します。

パラメーター: 識別子 (str) – 入力識別子。

入力のソースとして​を返します。

戻り値の型: SourceUniformColor | SourceBitmap | SourceVectorial | SourceSubstance | SourceReference | SourceFont

set_source(識別子: str, source: ResourceID |カラー | AnchorPointEffectNode) -> SourceUniformColor | SourceBitmap | SourceVectorial | SourceSubstance | SourceReference | SourceFont substance_painter.source.SourceSubstance.set_source

指定された入力識別子のソースを設定します。

パラメーター:

戻り値:​入力のソース。

戻り値の型: SourceUniformColor | SourceBitmap | SourceVectorial | SourceSubstance | SourceReference | SourceFont

reset_source(識別子: str) ->なし substance_painter.source.SourceSubstance.reset_source

指定された入力識別子のソースをリセットします。

パラメーター: 識別子 (str) – 入力識別子。

戻り値の型:​なし

remove_source(識別子: str) ->なし substance_painter.source.SourceSubstance.remove_source

指定された入力識別子のソースを削除します。

パラメーター: 識別子 (str) – 入力識別子。

戻り値の型:​なし

get_parameters() -> Dict[str, bool | int | Tuple[int, int] | Tuple[int, int, int] | Tuple[int, int, int, int] |浮動小数点 |タプル[浮動小数点] |タプル[浮動小数点、浮動小数点] |カラー |タプル[カラー、浮動小数点] |タプル[浮動小数点、浮動小数点、浮動小数点] | str] substance_painter.source.SourceSubstance.get_parameters

ソースプロシージャルパラメーターを取得します。 ソースの各プロパティに対して、結果の辞書は、プロパティ名をキー、プロパティ値を値とするエントリを保持します。

返される値:​ソースプロシージャルパラメーター。

戻り値の型: Dict[str, bool | int | 組[ int, int] | 組[ int, int, int] | Tuple[ int, int, int, int] |浮動小数点 | タプル[​浮動小数点] | タプル[​浮動小数点、浮動小数点] | カラー | タプル[カラー、浮動小数点] | タプル[​浮動小数点、浮動小数点、浮動小数点] | str]

set_parameters(property_values: Dict[str, bool | int | Tuple[int, int] | Tuple[int, int, int] | Tuple[int, int, int, int] |浮動小数点 |タプル[浮動小数点] |タプル[浮動小数点、浮動小数点] |カラー |タプル[カラー、浮動小数点] |タプル[浮動小数点、浮動小数点、浮動小数点] | str]) ->なし substance_painter.source.SourceSubstance.set_parameters

ソースプロシージャルパラメーターを設定します。

パラメーター: property_values (Dict​**​str​,* bool | int | Tuple ​* [int,* int​**] | タプル​**​[int, int , int] | Tuple​ [ ​int​**, int ​**, int​**, int*]* | 浮動小数点 | 組​ [ ​浮動小数点​**, 浮動小数点*]* | 組​ [ ​浮動小数点​**, 浮動小数点*,* 浮動小数点​**] *|カラー​|* 組*​[カラー​,* 浮動小数点​**] | 組*​[​浮動小数点,* 浮動小数点​**, 浮動小数点*,* 浮動小数点​**] | str]*) – 対応する値を設定するプロパティのdict。[**

戻り値の型:​なし

WARNING
ブーリアンパラメーターは整数として扱われます。TrueまたはFalseを使用すると、次のエラーメッセージが表示されます。
>>> Bad value for property ‘<property\_name>’: expected value of type <int32> but got <bool>

get_properties() -> Dict[str,プロパティ] substance_painter.source.SourceSubstance.get_properties

ソースプロシージャルプロパティを取得します。

返される値:​ソースのプロシージャルプロパティ。

戻り値の型: Dict[str, プロパティ]

get_preset_list() ->リスト[str] substance_painter.source.SourceSubstance.get_preset_list

このソースで使用可能なすべてのプリセットのリストを取得します。

戻り値:​使用可能なすべてのプリセット名の配列。

戻り値の型: リスト[​文字列]

apply_preset(name: str) substance_painter.source.SourceSubstance.apply_preset

名前が付いたプリセットを適用します。 この名前のプリセットが見つからない場合は、何も行われません。

パラメーター: name (str) – 適用するプリセットの名前。

プロパティの解決: ResolutionOverride substance_painter.source.SourceSubstance.resolution

このサブスタンスの解像度パラメーター。

Getter:​解決パラメーターを返します。

設定者:​解像度パラメーターを設定します。

Rails:

ValueError – ソースがsubstance_painter.layerstack.FilterEffectNodeで使用されているかどうか。

class substance_painter.source.OutputMapping(uid) substance_painter.source.OutputMapping

このクラスは、dictに似た方法でプロシージャルするソースの出力マッピングにアクセスします。 output_mappingプロパティを参照してください。

例:

import substance_painter as sp
mapping = a_substance_source.output_mapping
mapping[sp.textureset.ChannelType.BaseColor] = sp.textureset.ChannelType.Specular
for channel in mapping:
    print(mapping[channel])
TIP
次も参照:​技術的な情報については、KeysView ABCsコンテナの公式ドキュメントと、__getitem__および__setitem__メソッドを参照してください。
recommendation-more-help
substance-3d-dev-help-painter-python-guide