파이썬에서 알파 변환 노드는 어디에 있습니까?
Aug 19 2020
이미지를 저장할 때 알파가 미리 곱해지는 것을 원하지 않습니다. 블렌더에서 컴포 지터 Alpha Convert Node 를 사용하여 Premultiplied에서 Straight로 변환 할 수 있습니다 . Python API 에서이 노드를 찾을 수없는 것 같습니다 .
답변
3 brockmann Aug 19 2020 at 20:13
CompositorNodePremulKey
여기 에서 사용 가능한 합성기 노드 유형 의 전체 목록을 찾을 수 있습니다 .https://docs.blender.org/api/current/bpy.types.CompositorNode.html.
alpha_convert = tree.nodes.new(type='CompositorNodePremulKey')
alpha_convert.mapping = 'PREMUL_TO_STRAIGHT'
그러나 때로는 이름이 실제로 일치하지 않기 때문에 알아 내기가 매우 어렵습니다. 손으로 컴포 지터에서 노드를 만들고 type콘솔에 인쇄 하여 아이디어를 얻는 것이 좋습니다.
import bpy
class NodeOperator(bpy.types.Operator):
"""Tooltip"""
bl_idname = "node.simple_operator"
bl_label = "Simple Node Operator"
@classmethod
def poll(cls, context):
space = context.space_data
return space.type == 'NODE_EDITOR'
def execute(self, context):
space = context.space_data
node_tree = space.node_tree
node_active = context.active_node
print (node_active.type)
return {'FINISHED'}
def register():
bpy.utils.register_class(NodeOperator)
def unregister():
bpy.utils.unregister_class(NodeOperator)
if __name__ == "__main__":
register()
또는Node.bl_rna
실제 구조체를 반환하는 속성을 사용 합니다 (이름을 복사하기 위해) :
>>> node_active.bl_rna
<bpy_struct, Struct("CompositorNodePremulKey")>
관련 : 파이썬으로 합성기 제어