浏览代码

remove autoclear in default rendering pipeline

Benjamin Guignabert 4 年之前
父节点
当前提交
ed326c4c58

+ 10 - 1
src/Engines/engine.ts

@@ -1156,7 +1156,16 @@ export class Engine extends ThinEngine {
      * @param postProcess defines the source postprocess
      */
     public setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void {
-        this._bindTexture(channel, postProcess ? postProcess._textures.data[postProcess._currentRenderTextureInd] : null);
+        let postProcessInput = null;
+        if (postProcess) {
+            if (postProcess._textures.data[postProcess._currentRenderTextureInd]) {
+                postProcessInput = postProcess._textures.data[postProcess._currentRenderTextureInd];
+            } else if (postProcess._forcedOutputTexture) {
+                postProcessInput = postProcess._forcedOutputTexture;
+            }
+        }
+        
+        this._bindTexture(channel, postProcessInput);
     }
 
     /**

+ 1 - 8
src/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.ts

@@ -501,7 +501,6 @@ export class DefaultRenderingPipeline extends PostProcessRenderPipeline implemen
             postProcess.autoClear = false;
         } else {
             postProcess.autoClear = true;
-            this._scene.autoClear = false;
             this._hasCleared = true;
         }
 
@@ -525,7 +524,6 @@ export class DefaultRenderingPipeline extends PostProcessRenderPipeline implemen
         if (!this._buildAllowed) {
             return;
         }
-        this._scene.autoClear = true;
 
         var engine = this._scene.getEngine();
 
@@ -630,11 +628,6 @@ export class DefaultRenderingPipeline extends PostProcessRenderPipeline implemen
             this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name, this._cameras);
         }
 
-        // In multicamera mode, the scene needs to autoclear in between cameras.
-        if (this._scene.activeCameras && this._scene.activeCameras.length > 1) {
-            this._scene.autoClear = true;
-        }
-
         if (!this._enableMSAAOnFirstPostProcess(this.samples) && this.samples > 1) {
             Logger.Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0");
         }
@@ -724,7 +717,7 @@ export class DefaultRenderingPipeline extends PostProcessRenderPipeline implemen
         this.onBuildObservable.clear();
         this._disposePostProcesses(true);
         this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras);
-        this._scene.autoClear = true;
+
         if (this._resizeObserver) {
             this._scene.getEngine().onResizeObservable.remove(this._resizeObserver);
             this._resizeObserver = null;

+ 2 - 1
src/PostProcesses/postProcess.ts

@@ -194,7 +194,8 @@ export class PostProcess {
     protected _indexParameters: any;
     private _shareOutputWithPostProcess: Nullable<PostProcess>;
     private _texelSize = Vector2.Zero();
-    private _forcedOutputTexture: Nullable<InternalTexture>;
+    /** @hidden */
+    public _forcedOutputTexture: Nullable<InternalTexture>;
 
     /**
     * Prepass configuration in case this post process needs a texture from prepass