Browse Source

fix order of dof pp, remove additional unneeded pp methods

Trevor Baron 7 năm trước cách đây
mục cha
commit
c6669dd901

+ 7 - 27
src/PostProcess/RenderPipeline/babylon.postProcessRenderEffect.ts

@@ -1,32 +1,28 @@
 module BABYLON {
     export class PostProcessRenderEffect {
         private _postProcesses: any;
-        private _getPostProcess: () => Nullable<PostProcess | Array<PostProcess>>;
+        private _getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>;
 
         private _singleInstance: boolean;
 
         private _cameras: { [key: string]: Nullable<Camera> };
         private _indicesForCamera: { [key: string]: number[] };
 
-        private _renderEffectAsPasses: any;
-
         // private
         public _name: string;
 
         public applyParameters: (postProcess: PostProcess) => void;
         
-        constructor(engine: Engine, name: string, getPostProcess: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean) {
+        constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean) {
             this._name = name;
             this._singleInstance = singleInstance || true;
 
-            this._getPostProcess = getPostProcess;
+            this._getPostProcesses = getPostProcesses;
 
             this._cameras = {};
             this._indicesForCamera = {};
 
             this._postProcesses = {};
-
-            this._renderEffectAsPasses = {};
         }
 
         public get isSupported(): boolean {
@@ -42,11 +38,6 @@ module BABYLON {
 
         public _update(): void {
         }
-        public addRenderEffectAsPass(renderEffect: PostProcessRenderEffect): void {
-            this._renderEffectAsPasses[renderEffect._name] = renderEffect;
-
-            this._linkParameters();
-        }
 
         // private
         public _attachCameras(cameras: Camera): void;
@@ -72,7 +63,7 @@ module BABYLON {
                 }
 
                 if(!this._postProcesses[cameraKey]){
-                    var postProcess = this._getPostProcess();
+                    var postProcess = this._getPostProcesses();
                     if(postProcess){
                         this._postProcesses[cameraKey] = Array.isArray(postProcess) ? postProcess :[postProcess];
                     }
@@ -161,16 +152,15 @@ module BABYLON {
             }
         }
 
-        public getPostProcess(camera?: Camera): Nullable<PostProcess> {
+        public getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>> {
             if (this._singleInstance) {
-                return this._postProcesses[0][0];
+                return this._postProcesses[0];
             }
             else {
-
                 if (!camera) {
                     return null;
                 }
-                return this._postProcesses[camera.name][0];
+                return this._postProcesses[camera.name];
             }
         }
 
@@ -180,18 +170,8 @@ module BABYLON {
                     if (this.applyParameters) {
                         this.applyParameters(postProcess);
                     }
-
-                    postProcess.onBeforeRenderObservable.add((effect: Effect) => {
-                        this._linkTextures(effect);
-                    });
                 });
             }
         }
-
-        private _linkTextures(effect: Effect): void {
-            for (var renderEffectName in this._renderEffectAsPasses) {
-                effect.setTextureFromPostProcess(renderEffectName + "Sampler", this._renderEffectAsPasses[renderEffectName].getPostProcess());
-            }
-        }
     }
 }

+ 1 - 1
src/PostProcess/babylon.depthOfFieldEffect.ts

@@ -63,7 +63,7 @@ module BABYLON {
          * @param pipelineTextureType The type of texture to be used when performing the post processing.
          */
         constructor(scene: Scene, pipelineTextureType = 0) {
-            super(scene.getEngine(), "depth of field", ()=>{return [this.circleOfConfusion, this.depthOfFieldPass, this.depthOfFieldBlurX, this.depthOfFieldBlurY, this.depthOfFieldMerge]}, true);
+            super(scene.getEngine(), "depth of field", ()=>{return [this.circleOfConfusion, this.depthOfFieldPass, this.depthOfFieldBlurY, this.depthOfFieldBlurX, this.depthOfFieldMerge]}, true);
             // Enable and get current depth map
             var depthMap = scene.enableDepthRenderer().getDepthMap();
             // Circle of confusion value for each pixel is used to determine how much to blur that pixel