Quellcode durchsuchen

Fix PCF Shadows rendering groups

sebavan vor 5 Jahren
Ursprung
Commit
0d718242a9
2 geänderte Dateien mit 8 neuen und 0 gelöschten Zeilen
  1. 1 0
      dist/preview release/what's new.md
  2. 7 0
      src/Lights/Shadows/shadowGenerator.ts

+ 1 - 0
dist/preview release/what's new.md

@@ -327,6 +327,7 @@
 - Fix for bug where NME would crash if frames did not have comments ([Kyle Belfort](https://github.com/belfortk))
 - Fix wrong import of _TimeToken ([Sebavan](https://github.com/sebavan/)
 - Fix shadows not rendered correctly when using point lights ([Popov72](https://github.com/Popov72))
+- Prevent depth buffer clear in shadow maps ([Sebavan](https://github.com/sebavan/)
 
 ## Breaking changes
 

+ 7 - 0
src/Lights/Shadows/shadowGenerator.ts

@@ -26,6 +26,7 @@ import "../../Shaders/depthBoxBlur.fragment";
 import { Observable } from '../../Misc/observable';
 import { _DevTools } from '../../Misc/devTools';
 import { EffectFallbacks } from '../../Materials/effectFallbacks';
+import { RenderingManager } from '../../Rendering/renderingManager';
 
 /**
  * Defines the options associated with the creation of a custom shader for a shadow generator.
@@ -916,6 +917,12 @@ export class ShadowGenerator implements IShadowGenerator {
             this._light._markMeshesAsLightDirty();
             this.recreateShadowMap();
         });
+
+        // Ensures rendering groupids do not erase the depth buffer
+        // or we would lose the shadows information.
+        for (let i = RenderingManager.MIN_RENDERINGGROUPS; i < RenderingManager.MAX_RENDERINGGROUPS; i++) {
+            this._shadowMap.setRenderingAutoClearDepthStencil(i, false);
+        }
     }
 
     protected _initializeBlurRTTAndPostProcesses(): void {