I am relatively new to blender and its python API and I am trying to define a reflective material similar to what was described in this post: "How to make a "reflective tape" material in cycles?"
Picture from above mentioned post:
As I have understood it so far you need to define a node_tree with shader nodes and their connections:
mat = bpy.data.materials.new("reflect")
mat.use_nodes = True
tree = mat.node_tree
tree.nodes.remove(tree.nodes["Principled BSDF"]) # remove the default shader
Define nodes
Material Output
output_node = tree.nodes["Material Output"]
Mix Shader
mix_node = tree.nodes.new(type="ShaderNodeMixShader")
Diffuse BSDF shader
diffuse_node = tree.nodes.new(type="ShaderNodeBsdfDiffuse")
Glossy BSDF shader
glossy_node = tree.nodes.new(type="ShaderNodeBsdfGlossy")
(1) How to define geometry_node?
geometry_node = ???
Define node connections
(2) how to properly define a connection between geometry_node's incoming and glossy_node's normal attribute?
tree.links.new(geometry_node.outputs["Incoming"], glossy_node["Normal"]) ??
tree.links.new(glossy_node.outputs["BSDF"], mix_node.inputs[1])
tree.links.new(diffuse_node.outputs["BSDF"], mix_node.inputs[2])
tree.links.new(mix_node.outputs["Shader"], output_node.inputs["Surface"])
(3) How to define node attributes such as Roughness and Fac and set Glossy type to GGX?
For clarity here are my questions:
- How do you define a geometry node where incoming can be used as output? Similarly to what is defined by the Blender GUI graph above.
- How do you properly define a connection between
geometry_node's incoming output andglossy_node's normal input? - How do you define node attributes such as Roughness and Fac and set Glossy type to GGX?
Also, let me know if I have missed anything in the above code.
Thanks

