Spotlight inside view frustum with LiSPSM

Problems building or running the engine, queries about how to use features etc.
vincegdm
Gnoblar
Posts: 24
Joined: Tue Dec 06, 2016 12:59 pm

Spotlight inside view frustum with LiSPSM

Post by vincegdm »

Hi,

I am setting up my shadow system as SHADOWTYPE_TEXTURE_ADDITIVE_INTEGRATED and would like to use LiSPSM with my spotlights. I already use it successfully with directional lights and in some cases with spots it is fine too. The problem is that when the light source is located inside the view frustum no shadows or incorrect shadows are displayed.
I've looked through the forum and can't find an answer or even a hint, I don't understand exactly why it occurs either.
My guess is that the light position (through its frustum) is modified by the warping, effectively making the light look the other way (maybe?). It would be nice then to have a way of fixing the light position or cancelling the effect of the warping the closer a light is to the view frustum (similar to what the optimal adjust factor and angle threshold do), but I can't find such an option.

Any help would be super nice.
vincegdm
Gnoblar
Posts: 24
Joined: Tue Dec 06, 2016 12:59 pm

Re: Spotlight inside view frustum with LiSPSM

Post by vincegdm »

I discovered something really strange with the spotlight direction.
Whenever I had a scene with a spotlight looking at (0, -1, 0), the shadows are really broken. But as soon as I add a small offset, such that it is looking at (0.01, -1, 0) for instance, shadows reappear normally and start behaving better. Maybe there is a singularity at (0, -1, 0)?
vincegdm
Gnoblar
Posts: 24
Joined: Tue Dec 06, 2016 12:59 pm

Re: Spotlight inside view frustum with LiSPSM

Post by vincegdm »

When cast incorrectly, parts of the shadow is missing, usually drawing part of the shape of a square, which makes me think it is probably transformed or clipped incorrectly. So I tried setting mUseAggressiveFocusRegion to false, to no avail unfortunately.
vincegdm
Gnoblar
Posts: 24
Joined: Tue Dec 06, 2016 12:59 pm

Re: Spotlight inside view frustum with LiSPSM

Post by vincegdm »

Maybe I can illustrate my problem with an image:
spot_lispsm_incorrect.png
You can see the light source at the top and the border of the shadow map on the bottom of this image. It seems like the transformation is incorrect.
The original paper of LiSPSM does not mention it being able to work for lights inside the view frustum, and I wonder if it could be the case. If not, does anybody have a workaround?
You do not have the required permissions to view the files attached to this post.
vincegdm
Gnoblar
Posts: 24
Joined: Tue Dec 06, 2016 12:59 pm

Re: Spotlight inside view frustum with LiSPSM

Post by vincegdm »

I made a video to illustrate even more:

[youtube]Vebg0y1NFCM[/youtube]
vincegdm
Gnoblar
Posts: 24
Joined: Tue Dec 06, 2016 12:59 pm

Re: Spotlight inside view frustum with LiSPSM

Post by vincegdm »

Here's a quick update on the state of that.

I decided to forget about LiSPSM for spotlights and use the default camera setup instead. To alleviate the staircase edges problem I decided to soften my shadows a bit and implement VSM. Until now it's going quite well, maybe I'll give an update again once I'm completely done.