Shadow mapping in DesktopGL

I’ve been working on integrating this cascaded shadow mapping sample into my deferred rendering sample. I have it working pretty well in WindowsDX builds, but I’m getting weird errors trying to build it with DesktopGL.

Solving a couple of specific problems has led me down a particular path:

  • DesktopGL doesn’t seem to support Texture2D arrays, so I’ve replaced the array with individual textures.
  • In DesktopGL, SampleCmpLevelZero gives me an error cannot map expression to pixel shader instruction set. So I guess that’s not supported. So I’m using Sample and doing the depth test manually.
  • Because I’m not using a texture array, I am instead using if statements to select which cascade to sample from. But this gives a really weird error with DesktopGL: error X3528: can't force branch with gradients on non-inputs

I’m not sure how to get around this at this point. Any thoughts?

If you’re interested in looking at the code, it’s on github: GitHub - eylvisaker/GBufferDemo-MonoGame
The master branch has working code for WindowsDX (unload the DesktopGL project before you build)
The shadowsgl branch has the non-working code for DesktopGL.