瀏覽代碼

Garbage collect

sebavan 6 年之前
父節點
當前提交
d99141e5ca
共有 2 個文件被更改,包括 8 次插入1 次删除
  1. 8 1
      src/Rendering/depthRenderer.ts
  2. 二進制
      tests/validation/ReferenceImages/depthRenderer.png

+ 8 - 1
src/Rendering/depthRenderer.ts

@@ -26,6 +26,7 @@ export class DepthRenderer {
     private _depthMap: RenderTargetTexture;
     private _effect: Effect;
     private readonly _storeNonLinearDepth: boolean;
+    private readonly _clearColor: Color4;
 
     /** Get if the depth renderer is using packed depth or not */
     public readonly isPacked: boolean;
@@ -56,6 +57,12 @@ export class DepthRenderer {
         this._scene = scene;
         this._storeNonLinearDepth = storeNonLinearDepth;
         this.isPacked = type === Constants.TEXTURETYPE_UNSIGNED_BYTE;
+        if (this.isPacked) {
+            this._clearColor = new Color4(1.0, 1.0, 1.0, 1.0);
+        }
+        else {
+            this._clearColor = new Color4(1.0, 0.0, 0.0, 1.0);
+        }
 
         DepthRenderer._SceneComponentInitialization(this._scene);
 
@@ -80,7 +87,7 @@ export class DepthRenderer {
 
         // set default depth value to 1.0 (far away)
         this._depthMap.onClearObservable.add((engine) => {
-            engine.clear(new Color4(1.0, 1.0, 1.0, 1.0), true, true, true);
+            engine.clear(this._clearColor, true, true, true);
         });
 
         // Custom render function

二進制
tests/validation/ReferenceImages/depthRenderer.png