Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Silverlan

Member Since 02 May 2013
Offline Last Active Mar 08 2015 09:28 AM

Posts I've Made

In Topic: Issue using 2D depth texture array and regular depth texture in same shader

18 February 2015 - 01:37 AM

 

 

 

  • The spotlight shadow maps are regular 2D depth textures (A separate texture for each spotlight)
  • ...
  • The spotlight shadow maps are used in the shader as an array of sampler2DShadows ("shadowMaps[MAX_LIGHTS]")

 

Using an array of textures is not nearly the same as using an array texture. Of course, you have to bind every of your depth maps for itself to its own sampler. That's the whole point of array textures, because only with them, you don't need to do this. As I said in my last post.

 

 

All samplers in the 'shadowMaps'-array have different texture units bound to them, e.g.:

shadowMaps[0] = Texture Unit 21; (GL_TEXTURE_20)

shadowMaps[1] = Texture Unit 22; (GL_TEXTURE_21)

etc.

 

The spotlight shadow maps are then bound to the texture units the same way:

spotLightShadow[0] -> GL_TEXTURE_20

spotLightShadow[1] -> GL_TEXTURE_21

etc.

 

Now let's say there are only two spotlights. This means that no valid texture is bound to texture unit GL_TEXTURE_22, and thus shadowMaps[2].

This shouldn't be a problem, because shadowMaps[2] isn't being used in the shader, but it causes the issues I've been talking about.

This is what I meant by 'ALL textures inside the array need to be bound to a valid depth texture'.


In Topic: Issue using 2D depth texture array and regular depth texture in same shader

04 February 2015 - 02:24 PM

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?

Sorry, I think I was using the wrong terminology there.

I meant to say "array of samplers", not "shadow map array".

In essence:

  • The CSM shadow map is a 2D texture array
  • The spotlight shadow maps are regular 2D depth textures (A separate texture for each spotlight)
  • The CSM shadow is used in the shader as a sampler2DArrayShadow ("csmTextureArray")
  • The spotlight shadow maps are used in the shader as an array of sampler2DShadows ("shadowMaps[MAX_LIGHTS]")

During the actual rendering, I bound the CSM texture to 'csmTextureArray', and the spotlight shadow texture to 'shadowMaps[0]'.

The problem seems to be that ALL textures inside the array ('shadowMaps[MAX_LIGHTS]') need to be bound to a valid depth texture, not just the ones that are actually being used in the shader. So I ended up binding the spotlight shadow texture to not just 'shadowMaps[0]', but to ALL of the locations (0 to MAX_LIGHTS).


In Topic: Issue using 2D depth texture array and regular depth texture in same shader

04 February 2015 - 11:39 AM

err... update drivers?

My drivers are up to date and my graphics card isn't that old either (AMD Radeon HD 7870).

 

I did make some progress however.

I basically ended up binding the shadow map of my spotlight to ALL samplers in the shadow map array ('shadowMaps'), and now it works as it should:

http://puu.sh/ft0N9/8cab0af7a7.jpg

 

If just one texture in the array (Regardless of whether the texture is actually being used) is bound to an invalid texture (e.g. '0'), the problem occurs.

 

So the problem seems to be fixed now, but I don't really understand what's going on here. Is this a hardware-dependent thing, or part of the OpenGL specification?


In Topic: Issue using 2D depth texture array and regular depth texture in same shader

03 February 2015 - 01:05 PM

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.


In Topic: Issue using 2D depth texture array and regular depth texture in same shader

03 February 2015 - 01:30 AM

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 smile.png

 

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

http://pastebin.com/QcQnBtpa

 

This is the result if 'SPOTLIGHT_TEST' is set to '0' (Spotlight deactivated):

http://puu.sh/fpqij/7eeeff5906.jpg

 

This is the result if 'SPOTLIGHT_TEST' is set to '1' (Spotlight activated):

http://puu.sh/fpqgP/8bf754dce2.jpg

 

This is the result if 'SPOTLIGHT_TEST' is set to '2' (Spotlight activated, but the result of the shadow lookup is ignored):

http://puu.sh/fpqtd/d7ea652d78.jpg

 

Basically, as soon as there's any lookup for the shadow map of the spotlight, the issue occurs, even if the result is not used at all.


PARTNERS