I have two questions about shader-loading, if I may:
First, if I perform two shader-loads, each with a different vertex-shader file, is there any advantage (performance, memory-usage, caching, whatever) to their using the same fragment-shader file?
Or, to put it another way, when loading two shaders that use different vertex-shader files, is there any disadvantage to those loads also using different fragment-shader files (where it could perhaps be avoided)?
i.e. Is there any advantage to doing this:
myShader1 = Shader.load(Shader.SL_GLSL,
"myVertexShader.glsl",
"myFragmentShader.glsl")
myShader2 = Shader.load(Shader.SL_GLSL,
"myOtherVertexShader.glsl",
"myFragmentShader.glsl")
# And then presumably using them...
As opposed to this:
myShader1 = Shader.load(Shader.SL_GLSL,
"myVertexShader.glsl",
"myFragmentShader.glsl")
myShader2 = Shader.load(Shader.SL_GLSL,
"myOtherVertexShader.glsl",
"myOtherFragmentShader.glsl")
# And then presumably using them...
And second, when loading shaders multiple times from the same pair of shader-files, is it better to cache the resulting shader-object and re-use it, or–as with model-loading–is it fine to “reload” repeatedly? (Whether due to Panda caching shader-objects internally, or for some other reason.)
(The former comes from my thinking about making a slightly-variant fragment-shader for a specific purpose, in a case in which the object already uses a variant vertex-shader. But hesitating for fear of over-proliferating shaders–only to consider that I don’t know that the addition would make any difference, given that I am already using a variant vertex-shader.
The latter comes as a result of thinking about the above for this thread, and wondering whether I might be already introducing an inefficiency, since I load shaders–and often the same shaders–a fair bit.)