Organizing GLSL shaders in OpenGL engine

前端 未结 3 1569
说谎
说谎 2021-01-30 10:53

Which is better ?

  1. To have one shader program with a lot of uniforms specifying lights to use, or mappings to do (e.g. I need one mesh to be pa

3条回答
  •  盖世英雄少女心
    2021-01-30 11:21

    Generally, option 2 will be faster/better unless you have a truly huge number of programs. You can also use buffer objects shared across programs so that you need not reset any values when you change programs.

    In addition, once you link a program, you can free all of the shaders that you linked into the program. This will free up all the source code and any pre-link info the driver is keeping around, leaving just the fully-linked program in memory.

提交回复
热议问题