Benjamin Guignabert 4 anni fa
parent
commit
0715892f79

+ 1 - 1
src/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.ts

@@ -442,7 +442,7 @@ export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
         this._ssaoCombinePostProcess.onApply = (effect: Effect) => {
             let viewport = this._scene.activeCamera!.viewport;
             effect.setVector4("viewport", TmpVectors.Vector4[0].copyFromFloats(viewport.x, viewport.y, viewport.width, viewport.height));
-            effect.setTextureFromPostProcess("originalColor", this._originalColorPostProcess);
+            effect.setTextureFromPostProcessOutput("originalColor", this._originalColorPostProcess);
         };
         this._ssaoCombinePostProcess.samples = this.textureSamples;
 

+ 22 - 3
src/Rendering/prePassRenderer.ts

@@ -259,7 +259,7 @@ export class PrePassRenderer {
     public _afterCameraDraw() {
         if (this._enabled) {
             const firstCameraPP = this._scene.activeCamera && this._scene.activeCamera._getFirstPostProcess();
-            if (firstCameraPP) {
+            if (firstCameraPP && this._postProcesses.length) {
                 this._scene.postProcessManager._prepareFrame();
             }
             this._scene.postProcessManager.directRender(this._postProcesses, firstCameraPP ? firstCameraPP.inputTexture : null);
@@ -425,7 +425,19 @@ export class PrePassRenderer {
             this._createCompositionEffect();
         }
 
-        this._postProcesses.push(this.imageProcessingPostProcess);
+        let isIPPAlreadyPresent = false;
+        if (this._scene.activeCamera?._postProcesses) {
+            for (let i = 0; i < this._scene.activeCamera._postProcesses.length; i++) {
+                if (this._scene.activeCamera._postProcesses[i] instanceof ImageProcessingPostProcess) {
+                    isIPPAlreadyPresent = true;
+                }
+            }
+
+        }
+
+        if (!isIPPAlreadyPresent) {
+            this._postProcesses.push(this.imageProcessingPostProcess);
+        }
         this._bindPostProcessChain();
         this._setState(true);
     }
@@ -464,7 +476,14 @@ export class PrePassRenderer {
     }
 
     private _bindPostProcessChain() {
-        this._postProcesses[0].inputTexture = this.prePassRT.getInternalTexture()!;
+        if (this._postProcesses.length) {
+            this._postProcesses[0].inputTexture = this.prePassRT.getInternalTexture()!;
+        } else {
+            const pp = this._scene.activeCamera?._getFirstPostProcess();
+            if (pp) {
+                pp.inputTexture = this.prePassRT.getInternalTexture()!;
+            }
+        }
     }
 
     /**