I am doing a texture lookup to color a surface in a GLSL fragment shader. Under a specific case, the texture coordinate must be fetched from an additional texture, which will be loaded only in this case.
This works fine on Nvidia and Intel graphic cards but not on AMD. With AMD the fragment is discarded if the 2nd texture is not loaded. No matter the result of the if statement.
What is proper way to implement this in the fragment shader to avoid this issue?
Thank you for your help.
uniform sampler3D colorMap;
uniform sampler1D zTexture;
uniform bool useZtexture;
float zTexCoord = 0.0f;
if(useZtexture == true)
// unitialized zTexture causes the fragment to be discarded
// even when useZtexture is false
zTexCoord = float(texture1D(zTexture, 0.0f));
gl_FragColor = texture3D( colorMap, vec3(gl_TexCoord.s, gl_TexCoord.t, zTexCoord));