代码之家  ›  专栏  ›  技术社区  ›  pookie

如何通过Python脚本为Blender材质设置着色器节点属性?

  •  0
  • pookie  · 技术社区  · 3 年前

    enter image description here

    以上是我创作的素材。我将我的模型导出到。来自搅拌器的obj。从Python脚本(我将Blender编译为Python模块)导入我的。obj文件。 然后我尝试设置 Noise Texture 'W' 财产:

    import bpy
    
    bpy.ops.import_scene.obj( filepath = PATH_TO_MY_OBJ)
    bpy.context.object.name = "obbb"
    obj = bpy.data.objects["obbb"]
    

    我的材料叫做 Material .我怎样才能进入 噪声纹理 节点并更改 W ?

    我想通过python访问“噪波纹理”节点,这样我就可以随机化“W”属性。

    0 回复  |  直到 3 年前
        1
  •  0
  •   DryFigs    3 年前
        # accessing the materials
        material = bpy.data.materials.get("Material")
        
        # accessing all the nodes in that material
        nodes = material.node_tree.nodes
                
        # you can find the specific node by it's name
        noise_node = nodes.get("Noise Texture")
    
        # available inputs of that node
        # print([x.identifier for x in noise_node.inputs])
        # ['Vector', 'W', 'Scale', 'Detail', 'Distortion']
    
        # change value of "W"
        noise_node.inputs.get("W").default_value = 1