After many frustrating days I've managed to get my bake script to not crash, and now I'm banging my head against a wall to have it work with the new BSDF shaders.
I knew the inputs were different, but one thing I did not expect is that the Color Mix node I now have to feed the Diffuse and Subsurface into would give me trouble.
>>> mix = bpy.data.materials["Fingernails"].node_tree.nodes["DS_Mix"]
>>> for i, o in enumerate(mix.outputs):
... 1, o.name
... i, o.name
...
(1, 'Result')
(0, 'Result')
(1, 'Result')
(1, 'Result')
(1, 'Result')
(2, 'Result')
(1, 'Result')
(3, 'Result')
The node itself only has one output you can interact with, so how does it have all these hidden ones? And how am I supposed to cal these in Python to make links?
mat.node_tree.links.new(ds_mix.outputs[2], baked_BSDF.inputs[0])
worked yesterday, but now it's not.
Update
I've made some progress after scouring around and finding the following pages:
- Lookup nodes by output name
- Someone who's had a similar problem
- An incomplete explanation of how they're now handled
And I now have a thing that makes the intended link:
tree = bpy.context.object.active_material.node_tree
#other defs
baked_BSDF = bpy.data.materials["Skin"].node_tree.nodes["Baked_BSDF"]
ds_mix = bpy.data.materials["Skin"].node_tree.nodes["Diff_Sub_Mix"]
#other stuff going on
def get_socket(sockets, identifier):
for socket in sockets:
if socket.identifier == identifier:
return socket
tree.links.new(get_socket(ds_mix.outputs, 'Result_Color'), baked_BSDF.inputs['Base Color'])
So while this will probably work for most of what I'm currently tryign to do, I may come across some other node outputs that I'm not going to know the names of, and I can't just spend days guessing at each one.
So does anybody know how I can call the actual names up so I can put them in my code?