I have a character which moves on a very large plane on which I put various models which should cast a shadow according with the orientation of a directional light. In order to avoid performance issues, I have reparented the directional light’s node path to the character and adjusted the frustum in order to cover just a small area around it. When the character stands still, everything is fine. When it starts to move, I get some unpleasant effects which, I think, are due to the continuous light repositioning. So I thought that the other way to do this would be to reposition the light only when the character gets out of the frustum. Although I haven’t tried this yet, I’m quite sure that, when the repositioning occurs, other bad light glitches would occurr…
What do you think? Do you know any technique that may be used to dynamically shade a large area according with a character position in order to avoid to continuously compute all shadows(also the ones which are cast by object which are very far away)?
BTW, I haven’t posted any code since I believe the techniques I’ve described are trivial. Nonetheless, should I be wrong, please, tell me. I’ll gladly post code snippets, images and so on.
Hello, thanks for your answer.
I’ ve tried to adapt the example’s shader(for future reference: https://github.com/el-dee/panda3d-samples/tree/main/pssm) to my solution and the result doesn’t seem that bad. What I’ve tried to do is to rewrite the shaders in order to use it on a model instead of a ShaderTerrainMesh. I’ll try to make some tests and post the results
What really makes the shimmering bad is that you are readjusting things every frame (while moving). Your intuition about reducing updates is correct. This video (around the 5 minute mark) shows the issue with frequent light updates and how reducing the frequency made the artifact far less noticeable.
@Moguri thanks for your answer. Yes, that’s exactly what I was looking for. I just have to find a way to determine wheter the camera’s frustum is contained in the light’s one. I know that it is possible to access the frustum 's Geom but I’m not sure if Panda does support boolean operations on geometries. As far as you know, which approach could I use to do this?
I believe get_bounds()/get_tight_bounds() on a NodePath to a LensNode (the base class for cameras and non-point lights) will give you an axis-aligned bounding box (AABBs) around the frustum. If so, you could get and compare the two AABBs.