Original Post
I am working on optimizing my rendering engine and implementing shaders. I want to know if it is valid to do the following with a render pass to minimize the switching of the shader programs. Lets say I have a vertex buffer that is drawing the same object in different locations with different shader parameters. It seems to me that it would be faster to do the following(If things are not going to get messed up): Set the source stream of the vertex buffer. Set the shader for the current pass. for all of the different instances. { Set the instances shader parameters. Render the pass. } Do the next pass. Compared to doing it this way: Set the source stream of the vertex buffer. for all of the different instances. { Set the shader for the current pass. Set the instances shader parameters. Render the pass. Do the next pass. } I'm not sure if doing it the first way is going to screw stuff up at all, it seems faster but I have a feeling I should keep it the second way. Any ideas?