playMaker

Author Topic: Set Material Index Value  (Read 3653 times)

qholmes

  • 1.2 Beta
  • Hero Member
  • *
  • Posts: 509
Set Material Index Value
« on: August 18, 2011, 12:19:47 PM »
What exactly is the SetMaterial Index Value for?

I opened the Action for it and i get that you can have multiple materials on an object and they are stored in an array... ok so i just learned that 1 min ago..   So is it like switching between multiple materials? I assume that there is only one active one at a time? Or can you have multiple materials set an object with UVWs like in Max?

Is there some benefit to doing it like that?

I am just switching materials for performance and depth sorting reasons so that when i go to fade an object to see what is underneath i switch to the transparent material shader.. So i am not running the transparent shader all the time costing me draw calls and depth sorting issues.

Q

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Set Material Index Value
« Reply #1 on: August 18, 2011, 02:56:59 PM »
Hi,

 You can have multiple materials on a mesh when it's been designed with sub meshes. This is defined during the modeling of that mesh in 3ds max, maya etc.

 So each index in the materials list correspond to a sub mesh.

I personally never do that, and make sure each mesh is sole with no sub meshes, It creates all sorts of problems and constraints. It also affects rendering on mobile big time, so I kind of blindly design my models to always be unique, whole and single meshed, exporting, and working with that simple rule makes really a lot of difference in the long run. I even come back to models that are not mine to remove sub meshes. They  then appears properly in the hierarchy of models and you can work with them properly.

note: You can modify this list and if a sub mesh doesn't find its corresponding material in this list, it takes the first one. You can do that especially if the sub meshes uses the same materials...

 Bye,

 Jean

qholmes

  • 1.2 Beta
  • Hero Member
  • *
  • Posts: 509
Re: Set Material Index Value
« Reply #2 on: August 18, 2011, 03:09:25 PM »
Cool thanks. good to know. I was staying away from using sub meshes as well.. I was not totally sure why but i thought i had read something somewhere that it was a good idea.

Q

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Set Material Index Value
« Reply #3 on: August 19, 2011, 01:47:36 AM »
Hi,

 It might make sense in certain situation especially in projects with a proper management and strong executive decision, else you face a lot of issues if one of your 3d modeler( hired, or if you buy assets of the web that ba essence are very different in modeling technics, etc) has no experience in real time modeling ( not necessarly low poly modeling, jus the general pit fall to avoid when modeling for real time engines).

 I appreciate that it might allow the engine to be more effective in certain areas, but the drawbacks I am facing outweight the benefits so far.

 Bye,

 Jean

qholmes

  • 1.2 Beta
  • Hero Member
  • *
  • Posts: 509
Re: Set Material Index Value
« Reply #4 on: August 19, 2011, 04:22:04 AM »
Good to know.. I would probably be the modeler too... i wear a lot of hats. my head gets hot.

Q

dshad44

  • Junior Playmaker
  • **
  • Posts: 55
Re: Set Material Index Value
« Reply #5 on: August 22, 2017, 02:27:49 PM »
But what about the Material Index? What is it and how does it work? Can an index be assigned through global variables and then be switched out through Events?