I have a volume rendering engine that works as follows:
A 3D texture bound to texture unit 0 with a lookup table bound to texture unit 1. Lookup is performed with a shader and it all works just fine.
I am now expanding the system to cope with multiple volumes but the target machine only supports 2 texture units.
What I want to do is “swap out” the texture bound to texture unit0 at various stages of the rendering cycle to account for the multiple volume textures.
glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_3D, volume1); // render code ... ... glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_3D, volume2); // render code
Implementing the above code does work, but the first time the scene is rendered, only the last texture is drawn. Subsequent render cycles seem to work ok (which suggests to me I am on the right track but doing something wrong somewhere).
Do I need to send the texture to the shader each time I change the binding? Or am I doing something completely wrong here?
Any thoughts gratefully appreciated.