PDA

View Full Version : GlUseProgram Efficiency



Jorj Pimm
12-21-2008, 04:21 PM
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?

Thanks
- Jorj

Jan
12-21-2008, 05:28 PM
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.

Jan.