Automatic Shader Assignement


#1

I get a lot of CAD models as FBX or Maya files which alread have shaders assigned (usually lambert or some other standard Maya shader). Now I need to swap those shaders out with our own V-Ray or Maxwell shaders. Right now this is a manual process which I like to automate.

Prerequisites:

  • Shaders are only assigned per object and not per face.
  • Shader names are the same. So I want to replace a Lambert shader with the name metalAluminum with the V-Ray or Maxwell shader of the same name.

My general idea would be to:

  • add a custom attribute to each mesh which contains the shader name.
  • assign standard shader to all meshes
  • import or reference the production shader
  • read the custom attribute and then assign the shader with the same name.

Any thoughts on this approach? Is there a better way to store the shader names? Or a better way to address this whole problem?

Any hints or tips would be appreciated.

Cheers, Florian


#2

We use same technique to assign materials in render scenes to alembic geometry with attributes which contains material names. Here is our tools for shader assignment (the render engine does not meter). The Attribute Manager will allow to create custom attribute and set attribute value with material name. Shader Manager reads attribute and assign materials.


#3

As an alternative, you can put all geometry using one shader into a set and later assign the imported shaders to all elements of a corresponding set. This way you do only have to work with one set instaed of using an attribute for every mesh.


#4

Or… you can write a procedure for converting shaders from Maya materials to Vray(Maxwell).


#5

Thanks for the input. I’ll look into sets as well.

Writing a converter is probably a lot more work and not really needed since I mostly want to reuse existing shaders and the shaders that come with the model are not good enough anyway.


#6

We are using sets as well. Fairly good approach…


#7

Sets work well so far. Just gotta work around some referencing issues.