I'm experimenting a strange behaviour of textures inside my shaders. Basically I need and bind two cubemap textures inside my shader but only one gets actually bound.
I've tried swapping the two textures keeping the samplers untouched and the texture that previouly I could see now I don't see it anymore, so I think the problem is related to the samplers inside my shader.
This is how I bind my two cubemaps to the shader:
int firstTextureLocation = glGetUniformLocation(programID, "ConvolutionSrc"); // returns 5
int secondTextureLocation = glGetUniformLocation(programID, "LastResult"); // returns 9
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_CUBE_MAP, _firstTextureID);
glUniform1i(firstTextureLocation, 0);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_CUBE_MAP, _secondTextureID);
glUniform1i(secondTextureLocation, 1);
And this is a portion of my shader (the parts where the cubemaps are used):
uniform samplerCube ConvolutionSrc;
uniform samplerCube LastResult;
...
vec3 Sample(vec3 R)
{
...
vec3 hdrPixel = rescaleHDR(textureLod(ConvolutionSrc, L, lod).rgb);
...
}
void main()
{
...
vec3 lastResult = textureLod(LastResult, R, ConvolutionMip).rgb;
sampledColor.rgb = mix(lastResult.xyz, importanceSampled.xyz, 1.0f / (ConvolutionSamplesOffset));
...
}
Basically only the texture at uniform location 5 of my shader gets bound.
glBindTexture(GL_TEXTURE_CUBE_MAP, 0);in another point of my application where the active texture was still the old one, so the second texture I was binding was getting overridden to 0... \$\endgroup\$