Dear Blender users,
I am currently developing a script to load molecular structures into Blender.
It is based on the following code, but supports some different file formats:
Anyway, everything is working nicely and I can plot not only simple structures but also isosurfaces (molecular orbitals, electron densities, …).
Here are some images:
This is with the current default materials.
After tweaking by hand things can look quite fancy.
I am now looking for a way to implement nice default materials using python.
Currently my materials only use a BsdfPrincipled node with color and alpha taken from some dictionary that contains colors for every chemical element.
This node setup is created with the following script:
mat = bpy.data.materials.new(name) mat.use_nodes = True nodes = mat.node_tree.nodes nodes.clear() bsdf = nodes.new(type="ShaderNodeBsdfPrincipled") bsdf.inputs.default_value = color bsdf.inputs.default_value = alpha node_output = nodes.new(type="ShaderNodeOutputMaterial") node_output.location = 400, 0 links = mat.node_tree.links link = links.new(bsdf.outputs, node_output.inputs)
I am struggling to connect more nodes. Especially, I want to add an AmbientOcclusion node with a color ramp, as shown in the node setup below.
But I did not find a good tutorial that explains how to create ColorRamps in Blender (2.81).
Any suggestions on the coding part?
Also, if you have suggestions for nice material settings, do not hesitate to tell me.