|
@@ -21548,6 +21548,7 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
|
|
|
this.needsUpdate = false;
|
|
|
|
|
|
this.type = PCFShadowMap;
|
|
|
+ let _previousType = this.type;
|
|
|
|
|
|
this.render = function ( lights, scene, camera ) {
|
|
|
|
|
@@ -21568,6 +21569,11 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
|
|
|
_state.buffers.depth.setTest( true );
|
|
|
_state.setScissorTest( false );
|
|
|
|
|
|
+ // check for shadow map type changes
|
|
|
+
|
|
|
+ const toVSM = ( _previousType !== VSMShadowMap && this.type === VSMShadowMap );
|
|
|
+ const fromVSM = ( _previousType === VSMShadowMap && this.type !== VSMShadowMap );
|
|
|
+
|
|
|
// render depth map
|
|
|
|
|
|
for ( let i = 0, il = lights.length; i < il; i ++ ) {
|
|
@@ -21612,10 +21618,16 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
- if ( shadow.map === null ) {
|
|
|
+ if ( shadow.map === null || toVSM === true || fromVSM === true ) {
|
|
|
|
|
|
const pars = ( this.type !== VSMShadowMap ) ? { minFilter: NearestFilter, magFilter: NearestFilter } : {};
|
|
|
|
|
|
+ if ( shadow.map !== null ) {
|
|
|
+
|
|
|
+ shadow.map.dispose();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
shadow.map = new WebGLRenderTarget( _shadowMapSize.x, _shadowMapSize.y, pars );
|
|
|
shadow.map.texture.name = light.name + '.shadowMap';
|
|
|
|
|
@@ -21661,6 +21673,8 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ _previousType = this.type;
|
|
|
+
|
|
|
scope.needsUpdate = false;
|
|
|
|
|
|
_renderer.setRenderTarget( currentRenderTarget, activeCubeFace, activeMipmapLevel );
|