Performance: One Complex Shader vs. Multiple Simple Shaders
I keep reading that it's best to use as few master materials as possible and work with instances to reduce draw calls. I'm wondering if that's always true or if using several simple shaders rather than one complex one can be beneficial as well.
For example: I'm currently using one shader for objects that require textures, another one for objects that use flat constant3vector colors. With a couple of Add and Multiply nodes I could combine those two in a single shader which allows me to specify what I want to use in the material instance. Is there any point in doing that when it means more calculations need to take place within the shader?
In other words: In terms of performance, would it be best to combine all materials that use the same shading model in a single master material, no matter how complex it gets?
Thanks in advance for your input!
asked Apr 23 '15 at 12:40 PM in Rendering
There is no performance advantage once you have flipped a switch; it effectively becomes a new material then. The main gains there are in keeping consistency and making workflow easier. If it becomes more work to wire a bunch of complicated stuff into one material, it might be counter productive. There is also the shader compile time to consider. If everything in your game used one huge swiss army material, any change to that material will kick of a TON of shader compiles. Keeping things reasonably broken up by different types makes sense to keep thing from happening. It's all about balancing consistency and complexity. There is really no rule as to when one or the other becomes more important.
answered Apr 24 '15 at 08:58 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here