I have a script that generates OSL shaders, so I’m trying to compile them from Python, but it seems impossible right now.
I only found the operator by hovering the “update” button, in the OSL script node. But I can’t get the right context :spin:
Didn’t find anything in the online doc or this forum either.
Is it even possible ?
Or planned maybe ?
You might check peter casseta’s online material library script because I think it compiles osl nodes (it’s in the addons_contrib directory of the scripts that come bundled w. Blender )
If I look at his code, simply setting the filepath of a scriptnode will apparently trigger a compile:
new_node = context.active_object.active_material.node_tree.nodes.new('SCRIPT')
new_node.mode = 'EXTERNAL'
new_node.filepath = script_path
Is this any help?
Ah yes, it’s that simple … :rolleyes:
D.materials[‘Material’].node_tree.nodes[‘Script’].script = D.texts[‘Text’]
does recompile the OSL shader !