Layerstack 버전
레이어 스택 모듈을 사용하면 레이어 및 효과를 삽입 및 삭제할 수 있습니다.
예
import substance_painter as sp
# Get the currently displayed stack
stack = sp.textureset.get_active_stack()
# Get all Layer nodes at the root of the stack
stack_root_nodes = sp.layerstack.get_root_layer_nodes(stack)
# Find the layer at the very bottom
bottom_layer = stack_root_nodes[len(stack_root_nodes) - 1]
# Create the position where to insert the Group
# Get the very bottom Layer Position
position_stack_bottom = sp.layerstack.InsertPosition.below_node(bottom_layer)
# Insert the Group Layer
my_group = sp.layerstack.insert_group(position_stack_bottom)
my_group.set_name("My Group")
my_group.set_collapsed(False)
# Insert a Fill Layer into the group and assign a Material from the starter asset library
position_group_content = sp.layerstack.InsertPosition.inside_node(
my_group, sp.layerstack.NodeStack.Substack)
# Insert Fill Layer
my_fill_layer = sp.layerstack.insert_fill(position_group_content)
my_fill_layer.set_name("My Fill Layer")
# Search and isolate a Substance material
fill_layer_resource = sp.resource.search("s:starterassets "
"u:substance "
"n:Paper\\ Grainy=")[0]
# Apply material from the library Substance ID in the Fill Layer
my_fill_layer.set_material_source(fill_layer_resource.identifier())
# Insert Fill effect into the "my_fill_layer"'s effect stack
position_effect_stack = sp.layerstack.InsertPosition.inside_node(
my_fill_layer, sp.layerstack.NodeStack.Content)
my_fill_effect = sp.layerstack.insert_fill(position_effect_stack)
my_fill_effect.set_name("My Fill Effect")
# Insert Fill effect into the "my_fill_layer"'s mask effects stack
if not my_fill_layer.has_mask(): # If Layer has no Mask, create it
mask_background = sp.layerstack.MaskBackground.White # Create Background Color for the mask
my_fill_layer.add_mask(mask_background) # Add a mask to the Fill Layer
position_mask_effect_stack = sp.layerstack.InsertPosition.inside_node(
my_fill_layer, sp.layerstack.NodeStack.Mask)
my_mask_fill_effect = sp.layerstack.insert_fill(position_mask_effect_stack)
my_mask_fill_effect.set_name("My Mask Fill Effect")
# We can notice, in the lines above, that the same 'insert_fill()' method
# is called to create either a Fill Layer, a Fill Effect or a mask fill effect.
# Paint Layers insertion will work the same using 'insert_paint()'
# Insert a Blur Filter Effect in "my_fill_layer" stack
filter_resource = sp.resource.search("s:starterassets "
"u:filter "
"n:Blur=")[0]
sp.layerstack.insert_filter_effect(position_effect_stack, filter_resource.identifier())
# Insert a Smart Material from the library into "My Group"
# Get the first Smart Material named 'Bronze Armor' in the starter asset library
smart_mat_resource = sp.resource.search("s:starterassets "
"u:smartmaterial "
"n:Bronze\\ Armor=")[0]
# Insert smart material in the group and connect a resource found into the library
sp.layerstack.insert_smart_material(position_group_content, smart_mat_resource.identifier())
삽입
레이어 또는 효과의 삽입은 다음 함수 중 하나를 사용하여 수행할 수 있습니다. 자세한 내용은 레이어 및 효과를 참조하세요.
substance_painter.layerstack.insert_paint()substance_painter.layerstack.insert_fill()substance_painter.layerstack.insert_generator_effect()substance_painter.layerstack.insert_filter_effect()substance_painter.layerstack.insert_levels_effect()substance_painter.layerstack.insert_compare_mask_effect()substance_painter.layerstack.insert_color_selection_effect()substance_painter.layerstack.insert_group()substance_painter.layerstack.instantiate()substance_painter.layerstack.insert_anchor_point_effect()substance_painter.layerstack.insert_smart_mask()substance_painter.layerstack.insert_smart_material()
class substance_painter.layerstack.InsertPosition(node_id: int, node_stack: int | 없음) substance_painter.layerstack.InsertPosition
InsertPosition은(는) 모든 삽입 메서드에서 레이어 스택 계층 구조에서 삽입하려는 위치를 나타내는 데 사용되는 개체입니다.
수행할 작업에 따라 적절한 정적 메서드를 사용하여 인스턴스를 만듭니다. 다음 예제를 참조하십시오.
예
import substance_painter as sp
# Insert at the top of the given textureset layer stack
insert_position = sp.layerstack.InsertPosition.from_textureset_stack(
sp.textureset.get_active_stack())
new_layer = sp.layerstack.insert_fill(insert_position)
new_layer.set_name("First layer")
# Insert a layer above new_layer
insert_position = sp.layerstack.InsertPosition.above_node(new_layer)
sp.layerstack.insert_fill(insert_position)
# Insert an effect in the content stack of new_layer
insert_position = sp.layerstack.InsertPosition.inside_node(
new_layer, sp.layerstack.NodeStack.Content)
new_effect = sp.layerstack.insert_fill(insert_position)
new_effect.set_name("First effect")
# Insert an effect below new_effect
insert_position = sp.layerstack.InsertPosition.below_node(new_effect)
sp.layerstack.insert_fill(insert_position)
매개 변수:
- 노드_id(int)
- 노드_스택 (int | 없음)
static from_textureset_stack(stack: Stack) -> InsertPosition substance_painter.layerstack.InsertPosition.from_textureset_stack
스택 맨 위에 InsertPosition을(를) 생성합니다.
스택 맨 위에 LayerNode만 삽입할 수 있습니다. 자세한 내용은 노드가 LayerNode인 경우 삽입 규칙을 참조하세요.
병렬 스택: 삽입할 스택입니다.
매개 변수: 스택(스택)
반환 형식: InsertPosition
static above_node(node: 노드) -> InsertPosition substance_painter.layerstack.InsertPosition.above_node
지정된 노드 위에 삽입할 InsertPosition을(를) 생성합니다.
LayerNode만 LayerNode 위에 삽입할 수 있습니다. EffectNode만 EffectNode 위에 삽입할 수 있습니다. 자세한 내용은 노드가 LayerNode인 경우 삽입 규칙 및 노드가 EffectNode인 경우 삽입 규칙을 참조하십시오.
매개 변수: 노드(노드) - 노드입니다.
반환 형식: InsertPosition
static below_node(node: Node) -> InsertPosition substance_painter.layerstack.InsertPosition.below_node
지정된 노드 아래에 삽입할 InsertPosition을(를) 생성합니다.
LayerNode만 LayerNode 위에 삽입할 수 있습니다. EffectNode만 EffectNode 위에 삽입할 수 있습니다. 자세한 내용은 노드가 LayerNode인 경우 삽입 규칙 및 노드가 EffectNode인 경우 삽입 규칙을 참조하십시오.
매개 변수: 노드(노드) - 노드입니다.
반환 형식: InsertPosition
static inside_node(node: Node, node_stack: NodeStack) -> InsertPosition substance_painter.layerstack.InsertPosition.inside_node
노드의 지정된 스택 내부에 삽입할 InsertPosition을(를) 생성합니다.
node_stack이 NodeStack.Substack인 경우 LayerNode만 GroupLayerNode 내에 삽입할 수 있습니다. node_stack이 NodeStack.Content 또는 NodeStack.Mask인 경우 EffectNode만 LayerNode 내에 삽입할 수 있습니다. 자세한 내용은 노드가 LayerNode인 경우 삽입 규칙 및 노드가 EffectNode인 경우 삽입 규칙을 참조하십시오.
매개 변수:
반환 형식: InsertPosition
노드가 LayerNode인 경우 삽입 규칙
노드가 EffectNode인 경우 삽입 규칙
class substance_painter.layerstack.ScopedModification(name) substance_painter.layerstack.ScopedModification
ScopedModification을(를) 사용하여 여러 layerstack 수정 호출을 단일 실행 불가능한 명령에서 그룹화할 수 있습니다.
이름이 소프트웨어 기록에 표시됩니다.
이 개체는 다음 작업에 유용합니다.
- 고유한 이름 뒤에 논리적으로 layerstack 수정 사항을 그룹화하여 작업 내역을 오염시키지 마십시오.
- 계산은
with문을 떠나야만 발생합니다. 즉, 필요 없는 중간 결과를 계산하는 데 시간을 낭비하지 않습니다.
이 개체는 python with 문과 함께 사용할 수 있는 컨텍스트 관리자입니다.
예
import substance_painter as sp
def insert_many_fills():
# Insert many layers inside the current texture set layer stack
# and set their projection mode to tri-planar
insert_position = sp.layerstack.InsertPosition.from_textureset_stack(
sp.textureset.get_active_stack())
fill = sp.layerstack.insert_fill(insert_position)
fill.set_projection_mode(sp.layerstack.ProjectionMode.Triplanar)
fill = sp.layerstack.insert_fill(insert_position)
fill.set_projection_mode(sp.layerstack.ProjectionMode.Triplanar)
fill = sp.layerstack.insert_fill(insert_position)
fill.set_projection_mode(sp.layerstack.ProjectionMode.Triplanar)
# Calling this method will generate many history entries (1 for each
# inserted fill and 1 for each projection mode update) and
# Substance Painter will compute the textures each time a modification
# happens.
#
# Expected history:
# * Add fill
# * Update projection mode
# * Add fill
# * Update projection mode
# * Add fill
# * Update projection mode
#
# Potential texture update in the viewport: 6 (one for each modification)
insert_many_fills()
# With the ScopedModification below, only one entry will be added to Painter
# history. A single undo will remove all the fill inserted inside the
# Calling this method inside a ScopedModification will only generate one history
# entry and Substance Painter will compute the textures only once.
#
# Expected history:
# * Insert many layers
#
# Potential texture update in the viewport: 1
with sp.layerstack.ScopedModification("Insert many layers"):
insert_many_fills()
class substance_painter.layerstack.NodeStack(value) substance_painter.layerstack.NodeStack
삽입할 노드 스택을 지정합니다.
구성원:
SubstackContentMask삭제
substance_painter.layerstack.delete_node(노드: 노드) substance_painter.layerstack.delete_node
지정된 노드를 삭제합니다.
매개 변수: 노드(노드) - 삭제할 노드입니다.