I’ve been looking at a lot of GLSL examples and am getting close to what I want.
It seems to me that generally there are two approaches to assignment:
1)Assign the python script anywhere in the scene and check an object list and an index list to see where to apply the shader. I hear this is most efficient as the shader is used once per scene or some such.)
2)Assign the python script to each object you want to add the shader to and apply to the specified index. (less efficient because the shader would now be used once per object rather than per scene)
Neither seems ideal to me.
In an iteratative pipeline I want to assign the shaders pretty early. If I merge and split meshes often it’s possible that the material index could change often and it’s a pain to re-order.
as a solution Would it be possible to provide a list of material names rather than object names in the script, get the material name from blender through python and from that work out all the objects and index numbers to apply the shader to?
I’m guessing that the problem may arise when different objects have the same material on different index numbers