5
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

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

Last updated at Posted at 2019-12-25

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 
5
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?