Using multiple shader programs per step
This may be answered somewhere, but I haven't found it. I'm wondering if it is possible to switch between different shader programs within a single rendering step. I'll explain what I mean with an example. I have a "ground" mesh and a "sky" mesh, and I want to use different shader code to render each one. One way to use the same code for both meshes is to pass in a value to a shader variable (for example: "ground = 1") to tell the shader program to use the part of the shader code for the ground. Then I can check this value in the shader code itself to determine whether to use the ground shader code or the sky shader code. But it's inefficiency to check this value per vertex (or per pixel).
What I'd like to do instead is use glUseProgram (or something) to use a shader program just before drawing the ground mesh and then to use a different shader program just before drawing the sky mesh. I've been able to get the shader programs to work individually, but I don't know how to switch between them in a single step. Is this possible? If so, how do I do it? I hope you understand what I'm trying to ask.
Thanks in advance for your help. (This forum has always been so very helpful to me.)
Tags for this Thread