Jitter in shadow map while moving light

Hello, I have an issue with the shadow map that jitters when it moves.
The project is the same as discussed there :shaderMaterial and 300es imports in MRT - #37 by Mikael
So I have a an MRT as target rendering for the whole scene and the meshes of the scenery is made of thin instances.
My goal is to reduce the frustum to the part that are supposed to be viewed and then move it with the character. (so narrower then finer shadow map)
I’m not done with the maths of evaluating the ortho top, bottom,… yet that I already see that moving the light source or its angle makes the shadow jitter.
I’ve recorded it:

So I create a playground to try reproducing it:
but in vain, the jittering doesn’t appear and weirdly while the sphere’s instances cast shadow it seem that only one sphere in the middle renders, weird.

Dunno if you guys might have leads to what produces it so I can reproduce it in the playground and maybe fix it.

For info I’m using the 5.0.0-alpha-44 but I think it happened with the 4.2 too.

Thanks in advance!

You need to add some includes in your custom vertex shader to support instances / thin instances:


indeed thanks!
ok but in the example the textures are rendered on planes but my goal is that the main MRT is the target render so I use the pipeline effect to bring it back to the main buffer which is the way I render on my game thus I think that way might reproduce the jittering.
but I have an e is undefined and I don’t know where it comes from.

Couple things:

  1. When you construct your renderPass, you want zoneMaterialPass, not this.zoneMaterialPass. That’s why your post process is undefined.
  2. You reference the constant ZONE_RENDER_TEXTURE but you haven’t defined it anywhere.

Does that help?

1 Like

yes I forgot that this copy pasting, so I managed to reproduce the jittering effect!
Now we have the real bug I’m trying to fix.
you notice I’ve putted slow updated to put emphasis to that jitter, it shows more by flashing at the beginning of the animation.

1 Like

Yep, I definitely see the jittering. @Evgeni_Popov any ideas?

It’s an ordering problem because the MRT is generated before the shadow map is (re)generated for the new light position, so it’s using the old shadow map from the previous frame. Push the MRT in the camera.customRenderTargets array instead of scene.customRenderTargets:


That way, the MRT will be generated after the shadow map.


It works, nice thanks!
Is there any documentation on the rendering orders such as that one to have a deeper understanding?

1 Like

No, the best debugging tool to use here is Spector.js: Spector.js - Chrome Web Store


Holly… @Evgeni_Popov you are the best !!!