GlUseProgram Efficiency

Hello, I’m writing a GL program at the moment, and using shaders for the first time, and I have a small Efficiency question.

If I have 3 objects with different colours, but using effectively the same shader with different variables, is it better to have several shaders and flick between them for rendering, or to have one shader and change the variables for each object?


  • Jorj

Use one shader and change the variables per object. If you want to improve performance, sort the objects by “material”, such that you need to set the shaders / variables as few as possible.