Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
2
Help us understand the problem. What are the problem?

More than 1 year has passed since last update.

@sketchbooks99

BlenderのShader NodesにPythonからアクセスする

BlenderのShader Nodeの値をPython側から変更したかったのですが、意外とめんどくさかったので備忘録。

環境

Blender2.81
Windows10

コード

こんな感じのshaderの値にアクセスします。
Blenderはズブの素人なので、詳しい人いたらコメントお願いします。

キャプチャ.PNG

import bpy

mat = bpy.data.materials[mat_name]           # get material
node_tree = mat.node_tree                    # node tree of material
nodes = node_tree.nodes                      # nodes array of material
bsdf = nodes.get("Principled BSDF")          # get shader node you want

bsdf.inputs['Metallic'].default_value = 1.0  # set value to inputs
bsdf.inputs['Roughness'].default_value = 0.0 
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
2
Help us understand the problem. What are the problem?