How to render shadow map one time

shadow
shadow-map
#1

I found a tip of threejs about shadow rendering here:

Shadows

  1. If your scene is static, only update the shadow map when something changes, rather than every frame

Is there anyone can tell me how to achieve this? when I set the castShadow to false. the shadow map just disappear.

#2

You can do this by setting renderer.shadowMap.autoUpdate to false. If an update is required, set renderer.shadowMap.needsUpdate to true.

Demo: https://jsfiddle.net/2xbje0sn/

3 Likes
#3

Oh yes! that’s really cool!

1 Like
#4

I found this trick can’t significantly improve performance of shadow rendering on smart phone. see pictures below:

test code (most of them copied from mugen87’s jsfiddle demo): https://codepen.io/iamnotstone/pen/yWJKzx
@Mugen87 @looeee

#5

Probably because computing the shadow map is no real performance bottleneck in this simple app.

#6

But, if I disable the shadowmap, and fps value will up to 60.

#7

I think we need to differentiate between rendering a shadow map and just updating it.

#9

what do you mean by just updating it? You mean eliminate the animations and timeout ? If so, I have already do that , and it is unhelpful.

#10

There are two steps when using shadow mapping. The shadow map is generated and then used as a texture. renderer.shadowMap.autoUpdate controls the first part of this process.

#11

Does this controls the projection of a shadowMap to every surface?

#12

As I said before, it just controls the update process of the shadow map. I suggest you study in more detail how shadow mapping works, then this topic will be more clear to you.

1 Like