Optimisation : shaders and draw calls

Hello,

i have a question about draw calls. We are making a web app using BJS that will be used on smartphones. Our scene will only display one subject : a rigged robots made of different parts, and that’s all. My question is about the shader / draw call optimization. There will be 50 sub parts that i want to be :

  • highlightable
  • Dynamic in color (calling a color layer above each one that could be “animated” by changing color.)

I don’t want to use 50 different shaders to limit the draw calls. For the highlight part there is a very usefull function, but i can’t find anything for “coloring” an object above it’s shader by just calling it like highlight function do.

Is this possible ?

Thank you very much.

the draws calls wont necessarilly be limited in this case.

To limit them all the sub parts needs to be part of the same mesh. In this case you d have only one draw call.

In order to keep one draw call and if you intent to change the color of some areas, you could probably rely on vertex colors but you would have to update the buffer yourself to reflect the color changes.

Knowing the effect could be the same for all parts except highlights, the draw calls won t be as expensive as the shader program won t switch. I guess you could simply do the 50 calls without a huge overhead in this case.

Thank you very much for your answer.
Just to be curious how could we change color per vertex ? Could it possible to creat vertex groups ?