What happens if you bind (different textures) to both GL_TEXTURE_2D and GL_TEXTURE_CUBE_MAP in the same texture image unit?
For example, suppose I bind one texture to GL_TEXTURE0‘s GL_TEXTURE_2D target and another texture to the same texture unit’s GL_TEXTURE_CUBE_MAP target. Can I then have two uniform variables, one a sampler2D and the other a samplerCube and set both to 0 (to refer to GL_TEXTURE0)?
I suspect the answer is “no” (or that the result is undefined) but I haven’t found anything in the spec that specifically prohibits using multiple texture targets in the same texture image unit.
I haven’t found anything that describes if you can bind a 2D texture and a cube map texture in the same texture unit, but (or so) I guess this is perfectly possible. It makes sense to allow it, since all texture modification functions require you to specify the texture target to operate on, anyway.
But the OpenGL ES 2 spec explicitly disallows to use both at the same time in a shader, as chapter 2.10 says:
So you cannot use both a
sampler2Dand asamplerCubereferring to the same texture unit to bend your implementation’s texture unit limits.