Less shadowmap rendering

In different situations shadowmaps can be used for static objects that do not move often :

  • a procedural city (big shadow maps),
  • objects that move only when dragged….

In those situations we need shadowmap rendering, but not each frame. For example, once a part of a procedural city has been created, the buildings don’t move but the shadow rendering still uses a lot of computational power.

Here is the suggestion of a shadowMapNeedsUpdate = true parameter to the WebGLRenderer the way verticesNeedUpdate work.

Its value is checked in the ShadowMapPlugin and set to false just after :

if( _renderer.shadowMapEnabled === false || _renderer.shadowMapNeedsUpdate === false ) return;

_renderer.shadowMapNeedsUpdate = false;

This way the shadowmap is rendered once at the first render call, and if the scene requires the realtime shadowmap it has to be precised in the render loop. Otherwise it has to be precised in the functions that move/create/delete objects.

Author: Fantashit

2 thoughts on “Less shadowmap rendering

  1. Thanks for the suggestion! It was pretty easy to implement 😊

    You can now do this:

    renderer.shadowMap.autoUpdate = false;
    renderer.shadowMap.needsUpdate = true; // when your scene changes

Comments are closed.