Multiple textures, single texture unit

Hi all.
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.
Cheers,
Andy

No you don’t send a texture to a shader. Each sampler in GLSL shaders have to be bound to a texture unit not a texture. So you can bind another texture to the 1st unit without notifying the shader program.