I was hoping to upload one brilliant commit that magically fixed everything in one go, but between me not having as much time to work on this as I'd like (which I don't understand as I've finished my degree and not got a job yet) and it being complicated (which I do understand) this looks to have been a silly idea.

I've therefore actually put some of the progress I've had made into my OpenMW fork instead of a miniature test program. It's not particularly impressive as the bug it fixes seems to be harder to replicate in OpenMW than I expected (either that, or it just looks like one of the other bugs).

The notes I've written for myself (which therefore might make no sense to anyone else) regarding what to do next are as follows:

Casts shadow and receives shadow masks are ignored.

I need to work out how to exclude nodes without a mask matching the shadow casting mask when rendering shadow maps.

Investigate what the cull traversal thingy is doing with its mask

I should investigate what happens here for the working shadow techniques

I need to disable shadow receiving on things that shouldn't receive shadows.

One possible solution would be to get the shadow receiving mask when rendering nodes and pass an appropriate uniform to the shader.

I should investigate what happens here for the working shadow techniques.

The calculation of frustums and bounding boxes is broken in some way(s).

The camera should always be within the shadow frustum to avoid singularities according to the original paper, but things sometimes work even when it isn't.

AABBs are used, and I think including the camera in these would waste a bunch of shadow map.

Sometimes the maths appears to fail completely at some point, and the light frustum isn't calculated.

This may be because of the projection matrix creation failing.

This may be because of the light view matrix creation failing.

Hopefully, someone will enjoy reading that, as it was a bit of a nuisance adding all the list tags to make the indentation stay.

I might have decided that ViewDependentShadowMap works better than LightSpacePerspectiveShadowMap now I'm in a position where I have a better idea about what various things are actually doing. While I've got it sort-of working in mini-experiments, I haven't implemented the shader changes OpenMW would need for it to work, and it crashes my graphics driver when I let OSG set up the shaders for me. It also looks like the aforementioned shader changes may be a little bit very complicated in term of making the uniforms and attributes used compatible with what OpenMW needs to use itself. It's probably going to require me to stab the C++ instead of just the GLSL.

The shader changes were maybe trivial after all, but I can't tell because something's not working.

VDSM doesn't have a complete implementation of a debug HUD, but I attempted to hack one together.

As of a few hours ago, I figured out why the debug HUD kept disappearing and figured out how to properly fix it (which was far simpler than any of the bizarre workarounds I've been trying for the last two weeks.

The debug HUD suggests that the shadow map is blank in OpenMW. If that is the case, it would certainly explain the other issues I'm seeing.

The debug HUD appears to work fine when I put it in OSG itself for a test, suggesting that my findings in OpenMW are accurate.

Either I'm doing something weird, or AMD's Vega drivers are weird, as I'm seeing lots of OpenGL errors get spammed to the console on my desktop, but not on my laptop. I have no idea if these are even related to the shadow map not rendering, though, because it doesn't render on the laptop either, but that could just be a case of NVidia's drivers shittily not reporting errors properly.

I just added shadow support to the water shader, too, but I'm not exactly sure if this is what shadows striking water looks like because it feels weird. It's quite possible that the convenient 'shadow' variable in the water shader doesn't actually mean what I think it means, so changing its value from a constant 1.0 to what I read from the shadow map may be incorrect.