Help us understand the problem. What is going on with this article?

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 
sketchbooks99
電通大の情報系学生です。趣味でopenFrameworksやGLSLを使ってデジタルアート作ったりしてます。 CGに関する知識共有していけたらと思います.
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
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  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
ユーザーは見つかりませんでした