I have an ATI Radeon 9600 Pro graphics card with 256 MB of VRAM, the driver version is Catalyst 6.5. My OpenGL based application uses the following code to set up two texture units and uniform variables for use in the fragment shader:
//texture setup in the application
glGenTextures(2,textureIds);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_3D,textureIds[0]);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_REPEAT);
glTexImage3D(GL_TEXTURE_3D,0,GL_RGBA,res,res,res,0,GL_RGBA,GL_FLOAT,texture_image0);
glEnable(GL_TEXTURE_3D);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D,textureIds[1]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexImage2D(GL_TEXTURE_2D,0,GL_RGB,resx,resy,0,GL_RGB,GL_FLOAT,texture_image1);
glEnable(GL_TEXTURE_2D);
//some intermediate shader program code
GLuint texLoc=glGetUniformLocation(shader_program,“Texture0”);
glUniform1i(texLoc, 0);
texLoc=glGetUniformLocation(shader_program,“Texture1”);
glUniform1i(texLoc, 1);
The (incomplete) fragment shader is roughly such (only the important part is included):
//fragment shader
uniform sampler2D Texture1;
uniform sampler3D Texture0;
void main() {
vec4 c=texture2D(Texture1,address1);
gl_FragColor = texture3D(Texture0,address0);
}
If i draw a spherewith this fragment shader on, nothing shows up. If I comment out the 2D texture access, it miraculously starts working. If a comment out the 3D texture and use 2d texture to set fragment color, it also works. But if I then turn on the 3d texture access (for any purpose), it eclipses again. Anyway, it never works if I use both textures, and it doesn’t work if i use only 3d texture, but attached to texture unit 1 (and not 0 like here).
Does anyone have the slightest clue about what could be the reason for such behaviour? Is it some sort of hardware limitation? Are 3d textures so poorly supported by older Radeon series? The same thing happens on my Radeon 9700 Mobility (laptop) card. I checked the driver caps but no limit indicates a problem of using two textures in the fragment shader.