Share this post

Link to post

Share on other sites

For me it seems that something with the sampler bindings is not how you think it is. When you get changes by commenting out something arbitrary and it works, most likely you do a binding with this call, that does affect the gl state where you don't expect it. Could you make sure that your two textures are bound to different texture units? Or could you post your code where you actually do the binding? Do you bind samplers as well? Because I can't find any "glActiveTexture" statements in your code.

2

Share this post

Link to post

Share on other sites

For me it seems that something with the sampler bindings is not how you think it is. When you get changes by commenting out something arbitrary and it works, most likely you do a binding with this call, that does affect the gl state where you don't expect it. Could you make sure that your two textures are bound to different texture units? Or could you post your code where you actually do the binding? Do you bind samplers as well? Because I can't find any "glActiveTexture" statements in your code.

'SHADER_SHADOW_MAP_TEXTURE_START' is a constant set to 20. Since there's only one spotlight and one directional light in the example scene, 'idxSpot' and 'idxDirectional' are both 0. 'MAX_ACTIVE_LIGHTS_PER_ENTITY' is a constant set to 8.

So, in essence, the texture unit for the spotlight shadow is (GL_TEXTURE0 +20) and for the directional shadow it's (GL_TEXTURE0 +28).

I'm not using any samplers either.

0

Share this post

Link to post

Share on other sites

And you evaluate all lights in a single draw call (forward rendering), so you use your texture array and the single depth texture in the same fragment shader? What exactly are you doing with the sample from the single depth texture? Because in your code snippet, you don't use the sample, so the compiler will most likely throw this statement away. If possible, just post the complete fragment shader code - maybe then, things will clear up - or else I'm afraid I cant find your mistake either :)

2

Share this post

Link to post

Share on other sites

And you evaluate all lights in a single draw call (forward rendering), so you use your texture array and the single depth texture in the same fragment shader? What exactly are you doing with the sample from the single depth texture? Because in your code snippet, you don't use the sample, so the compiler will most likely throw this statement away. If possible, just post the complete fragment shader code - maybe then, things will clear up - or else I'm afraid I cant find your mistake either

I trimmed the fragment shader down to the essential parts (Which still cause the issue):

Share this post

Link to post

Share on other sites

Puh, I tried to find any mistake for half an hour, but it should work as it is... so I have to continue with stupid questions:

Can you remove the spot light shadow map sample completely and replace it with a hardcoded 0.5 or something, so that we can be sure you don't have a sampling instruction in your compiled shader? When you have the spotlight activated (but now without shadows), does it work?

I hope at least this works - if not, could you try to rename one of your shadow-sample-methods, so that is doesn't use overloaded methods any more?

Sorry for my stupid assumptions, but in the past, I had so many unbelievable stupid compile- and runtime errors with opengl.

2

Share this post

Link to post

Share on other sites

Can you remove the spot light shadow map sample completely and replace it with a hardcoded 0.5 or something, so that we can be sure you don't have a sampling instruction in your compiled shader? When you have the spotlight activated (but now without shadows), does it work?

All I have to do to make it work is remove the lookup into the shadow map ('shadow2DProj').

As soon as there's ANY lookup into the shadow map, the problem occurs. I've tried other lookup-functions instead of 'shadow2DProj' (e.g. 'texture2D'), however that didn't help either.

The shadow map itself is not at fault either, it's the same if I use any other depth texture. If I use an additional RGB texture instead, the problem doesn't occur.

I hope at least this works - if not, could you try to rename one of your shadow-sample-methods, so that is doesn't use overloaded methods any more?

I tried renaming one of the functions, but the result is still the same.

Share this post

Link to post

Share on other sites

Sorry I'm afraid I'm not able to follow you. What do you mean by "binding the shadow map of my spotlight to ALL samplers in the shadow map array" ? I thought you didn't use texture arrays for your spotlight depth maps? You have to bind your array texture from your cascaded shadow map for your directional light and then, you bind some regular textures to some other units, you got that, or did I miss the point?