Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I try to manage a scene with several point lights. For the moment my program works perfectly with just one point light. So I have in my fragment shader the following uniform declaration:

uniform samplerCubeShadow ShadowCubeSampler; //1 sampler

Now, to manage several point light shadows I have to deal with the following declaration:

uniform samplerCubeShadow ShadowCubeSampler[2]; //2 samplers max for example

Unfortunately, I have an error 1282 (INVALID_OPERATION) when the number of sampler(s) loaded is inferior to the max number of samplers which can be contained into my array.

Look at these 3 next situations:

CASE 1

uniform samplerCubeShadow tex_shadow[1]; //MAX POINT LIGHT = 1
for (int i=0; i < 1; i++) {tex_shadow[i];} //OK
for (int i=0; i < 1; i++) {texture(tex_shadow[i], ...);} //OK
for (int i=0; i < 1; i++) {texture(tex_shadow[0], ...);} //OK

CASE 2

uniform samplerCubeShadow tex_shadow[2]; //MAX POINT LIGHT = 2
for (int i=0; i < 1; i++) {tex_shadow[i];} //NOT OK - 1282
for (int i=0; i < 1; i++) {texture(tex_shadow[i], ...);} //NOT OK - 1282
for (int i=0; i < 1; i++) {texture(tex_shadow[0], ...);} //OK

CASE 3

uniform samplerCubeShadow tex_shadow[2]; //MAX POINT LIGHT = 2
for (int i=0; i < 2; i++) {tex_shadow[i];} //OK
for (int i=0; i < 2; i++) {texture(tex_shadow[i], ...);} //OK
for (int i=0; i < 2; i++) {texture(tex_shadow[0], ...);} //OK

Conclusion: if the max number of sampler is equal to the number of sampler loaded, I can loop over the samplers contained in my array without error. If the number is inferior, I have the 1282 error and the geometry concerned by the this shader program is not rendered!

I can use a maximum of 32 texture units for each use of shader program. I have the same problem using the samplerCube keyword. curiously, I did not have a such problem using sampler2D/sampler2DShadow when I tried to implement spot shadow mapping with the same kind of situation.

Does anyone can help me?

share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.