i try to change resolution of shadows dinamically but when change shadows disappear. The code that i execute to change resolution after scene is loaded is:
Try logging maxTextureSize and see if it’s not NaN. Considering that to create a shadow map initially you have to change it’s size on runtime - there should be absolutely no problem with changing it later on when the app is already running.
(Also take a look at three-csm - maybe it’s already doing what you’re trying to do?)
Ummm…nothing. I tried for a few hours, reading code of three-csm repo also, and i didnt found anything else to change resolution once the scene is loaded and shadows are activated at least one time with a default resolution. I thought that problem was because i didnt mark materials as “needUpdates” = true after change resolution and these are not recompiled again (refresh shaders or something else), but it didnt work either.
Here is a demo of dynamical change of shadow resolution of DirectionalLight – it is automatically changed every second. See lines 100-101. Both of them are necessary.
I am facing the same issue and for some reason setting both mapSize and map.setSize doesn’t help much. The shadows work fine when I increase the resolution, but they disappear when the resolution is set to lower value than the current.
Am I missing something? Thanks!
PS: In my case, light position is dynamic as it moves with the main camera, also I have a TAARenderPass with the dynamic sampleLevel.
Apparently, my issues were caused by the use of VSMShadowMap as shown here: https://codepen.io/SSCare/pen/JjgPXNy. I will probably start a new thread for it.