Pārlūkot izejas kodu

Merge pull request #3630 from TrevorDev/removeRendeEffectAsPassAndGetPP

Remove render effect as pass and get pp
David Catuhe 7 gadi atpakaļ
vecāks
revīzija
1c080276f7

+ 2 - 330
dist/preview release/typedocValidationBaseline.json

@@ -1,7 +1,7 @@
 {
-  "errors": 8631,
+  "errors": 8288,
   "babylon.typedoc.json": {
-    "errors": 8631,
+    "errors": 8288,
     "AnimationKeyInterpolation": {
       "Enumeration": {
         "Comments": {
@@ -26422,266 +26422,6 @@
         }
       }
     },
-    "PostProcessRenderEffect": {
-      "Class": {
-        "Comments": {
-          "MissingText": true
-        }
-      },
-      "Constructor": {
-        "new PostProcessRenderEffect": {
-          "Comments": {
-            "MissingText": true
-          },
-          "Parameter": {
-            "engine": {
-              "Comments": {
-                "MissingText": true
-              }
-            },
-            "name": {
-              "Comments": {
-                "MissingText": true
-              }
-            },
-            "getPostProcess": {
-              "Comments": {
-                "MissingText": true
-              }
-            },
-            "singleInstance": {
-              "Comments": {
-                "MissingText": true
-              }
-            }
-          }
-        }
-      },
-      "Property": {
-        "_name": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "applyParameters": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "isSupported": {
-          "Comments": {
-            "MissingText": true
-          }
-        }
-      },
-      "Method": {
-        "_attachCameras": {
-          "Comments": {
-            "MissingText": true
-          },
-          "Parameter": {
-            "cameras": {
-              "Comments": {
-                "MissingText": true
-              }
-            }
-          }
-        },
-        "_detachCameras": {
-          "Comments": {
-            "MissingText": true
-          },
-          "Parameter": {
-            "cameras": {
-              "Comments": {
-                "MissingText": true
-              }
-            }
-          }
-        },
-        "_disable": {
-          "Comments": {
-            "MissingText": true
-          },
-          "Parameter": {
-            "cameras": {
-              "Comments": {
-                "MissingText": true
-              }
-            }
-          }
-        },
-        "_enable": {
-          "Comments": {
-            "MissingText": true
-          },
-          "Parameter": {
-            "cameras": {
-              "Comments": {
-                "MissingText": true
-              }
-            }
-          }
-        },
-        "_update": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "addPass": {
-          "Comments": {
-            "MissingText": true
-          },
-          "Parameter": {
-            "renderPass": {
-              "Comments": {
-                "MissingText": true
-              }
-            }
-          }
-        },
-        "addRenderEffectAsPass": {
-          "Comments": {
-            "MissingText": true
-          },
-          "Parameter": {
-            "renderEffect": {
-              "Comments": {
-                "MissingText": true
-              }
-            }
-          }
-        },
-        "emptyPasses": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "getPass": {
-          "Comments": {
-            "MissingText": true
-          },
-          "Parameter": {
-            "passName": {
-              "Comments": {
-                "MissingText": true
-              }
-            }
-          }
-        },
-        "getPostProcess": {
-          "Comments": {
-            "MissingText": true
-          },
-          "Parameter": {
-            "camera": {
-              "Comments": {
-                "MissingText": true
-              }
-            }
-          }
-        },
-        "removePass": {
-          "Comments": {
-            "MissingText": true
-          },
-          "Parameter": {
-            "renderPass": {
-              "Comments": {
-                "MissingText": true
-              }
-            }
-          }
-        }
-      }
-    },
-    "PostProcessRenderPass": {
-      "Class": {
-        "Comments": {
-          "MissingText": true
-        }
-      },
-      "Constructor": {
-        "new PostProcessRenderPass": {
-          "Comments": {
-            "MissingText": true
-          },
-          "Parameter": {
-            "scene": {
-              "Comments": {
-                "MissingText": true
-              }
-            },
-            "name": {
-              "Comments": {
-                "MissingText": true
-              }
-            },
-            "size": {
-              "Comments": {
-                "MissingText": true
-              }
-            },
-            "renderList": {
-              "Comments": {
-                "MissingText": true
-              }
-            },
-            "beforeRender": {
-              "Comments": {
-                "MissingText": true
-              }
-            },
-            "afterRender": {
-              "Comments": {
-                "MissingText": true
-              }
-            }
-          }
-        }
-      },
-      "Property": {
-        "_name": {
-          "Comments": {
-            "MissingText": true
-          }
-        }
-      },
-      "Method": {
-        "_decRefCount": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "_incRefCount": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "_update": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "getRenderTexture": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "setRenderList": {
-          "Comments": {
-            "MissingText": true
-          },
-          "Parameter": {
-            "renderList": {
-              "Comments": {
-                "MissingText": true
-              }
-            }
-          }
-        }
-      }
-    },
     "PostProcessRenderPipeline": {
       "Class": {
         "Comments": {
@@ -26749,18 +26489,6 @@
             }
           }
         },
-        "_disableDisplayOnlyPass": {
-          "Comments": {
-            "MissingText": true
-          },
-          "Parameter": {
-            "cameras": {
-              "Comments": {
-                "MissingText": true
-              }
-            }
-          }
-        },
         "_disableEffect": {
           "Comments": {
             "MissingText": true
@@ -26778,23 +26506,6 @@
             }
           }
         },
-        "_enableDisplayOnlyPass": {
-          "Comments": {
-            "MissingText": true
-          },
-          "Parameter": {
-            "passName": {
-              "Comments": {
-                "MissingText": true
-              }
-            },
-            "cameras": {
-              "Comments": {
-                "MissingText": true
-              }
-            }
-          }
-        },
         "_enableEffect": {
           "Comments": {
             "MissingText": true
@@ -26921,23 +26632,6 @@
             }
           }
         },
-        "disableDisplayOnlyPassInPipeline": {
-          "Comments": {
-            "MissingText": true
-          },
-          "Parameter": {
-            "renderPipelineName": {
-              "Comments": {
-                "MissingText": true
-              }
-            },
-            "cameras": {
-              "Comments": {
-                "MissingText": true
-              }
-            }
-          }
-        },
         "disableEffectInPipeline": {
           "Comments": {
             "MissingText": true
@@ -26965,28 +26659,6 @@
             "MissingText": true
           }
         },
-        "enableDisplayOnlyPassInPipeline": {
-          "Comments": {
-            "MissingText": true
-          },
-          "Parameter": {
-            "renderPipelineName": {
-              "Comments": {
-                "MissingText": true
-              }
-            },
-            "passName": {
-              "Comments": {
-                "MissingText": true
-              }
-            },
-            "cameras": {
-              "Comments": {
-                "MissingText": true
-              }
-            }
-          }
-        },
         "enableEffectInPipeline": {
           "Comments": {
             "MissingText": true

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

@@ -41,9 +41,9 @@
 - Gulp process now supports multiple outputs when using webpack. ([RaananW](https://github.com/RaananW))
 - (Viewer) Scene Optimizer intergrated in viewer. ([RaananW](https://github.com/RaananW))
 - (Viewer) The viewer supports custom shaders in the configuration. ([RaananW](https://github.com/RaananW))
+- Documented PostProcessRenderEffect class ([trevordev](https://github.com/trevordev))
 - SPS internal storage of each solid particle rotation matrix ([jbousquie](https://github.com/jbousquie)) 
 
-
 ## Bug fixes
 - Texture extension detection in `Engine.CreateTexture` ([sebavan](https://github.com/sebavan))
 - Fixed a bug with merging vertex data ([bghgary](https://github.com/bghgary))

+ 82 - 46
src/PostProcess/RenderPipeline/babylon.postProcessRenderEffect.ts

@@ -1,34 +1,46 @@
 module BABYLON {
+    /**
+     * This represents a set of one or more post processes in Babylon.
+     * A post process can be used to apply a shader to a texture after it is rendered.
+     * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
+     */
     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
+        /**
+         * Name of the effect
+         */
         public _name: string;
-
-        public applyParameters: (postProcess: PostProcess) => void;
         
-        constructor(engine: Engine, name: string, getPostProcess: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean) {
+        /**
+         * Instantiates a post process render effect.
+         * A post process can be used to apply a shader to a texture after it is rendered.
+         * @param engine The engine the effect is tied to
+         * @param name The name of the effect
+         * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
+         * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
+         */
+        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 = {};
         }
 
+        /**
+         * Checks if all the post processes in the effect are supported.
+         */
         public get isSupported(): boolean {
             for (var index in this._postProcesses) {
                 for(var ppIndex in this._postProcesses[index]){
@@ -40,17 +52,26 @@ module BABYLON {
             return true;
         }
 
+        /**
+         * Updates the current state of the effect
+         */
         public _update(): void {
         }
-        public addRenderEffectAsPass(renderEffect: PostProcessRenderEffect): void {
-            this._renderEffectAsPasses[renderEffect._name] = renderEffect;
-
-            this._linkParameters();
-        }
 
-        // private
+        /**
+         * Attaches the effect on cameras
+         * @param cameras The camera to attach to.
+         */
         public _attachCameras(cameras: Camera): void;
+        /**
+         * Attaches the effect on cameras
+         * @param cameras The camera to attach to.
+         */
         public _attachCameras(cameras: Camera[]): void;
+        /**
+         * Attaches the effect on cameras
+         * @param cameras The camera to attach to.
+         */
         public _attachCameras(cameras: any): void {
             var cameraKey;
 
@@ -72,7 +93,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];
                     }
@@ -93,13 +114,22 @@ module BABYLON {
                 }
 
             }
-
-            this._linkParameters();
         }
 
-        // private
+        /**
+         * Detatches the effect on cameras
+         * @param cameras The camera to detatch from.
+         */
         public _detachCameras(cameras: Camera): void;
+        /**
+         * Detatches the effect on cameras
+         * @param cameras The camera to detatch from.
+         */
         public _detachCameras(cameras: Camera[]): void;
+        /**
+         * Detatches the effect on cameras
+         * @param cameras The camera to detatch from.
+         */
         public _detachCameras(cameras: any): void {
             var cams = Tools.MakeArray(cameras || this._cameras);
 
@@ -121,9 +151,20 @@ module BABYLON {
             }
         }
 
-        // private
+        /**
+         * Enables the effect on given cameras
+         * @param cameras The camera to enable.
+         */
         public _enable(cameras: Camera): void;
+        /**
+         * Enables the effect on given cameras
+         * @param cameras The camera to enable.
+         */
         public _enable(cameras: Nullable<Camera[]>): void;
+        /**
+         * Enables the effect on given cameras
+         * @param cameras The camera to enable.
+         */
         public _enable(cameras: any): void {
             var cams = Tools.MakeArray(cameras || this._cameras);
 
@@ -143,9 +184,20 @@ module BABYLON {
             }
         }
 
-        // private
+        /**
+         * Disables the effect on the given cameras
+         * @param cameras The camera to disable.
+         */
         public _disable(cameras: Camera): void;
+        /**
+         * Disables the effect on the given cameras
+         * @param cameras The camera to disable.
+         */
         public _disable(cameras: Nullable<Camera[]>): void;
+        /**
+         * Disables the effect on the given cameras
+         * @param cameras The camera to disable.
+         */
         public _disable(cameras: any): void {
             var cams = Tools.MakeArray(cameras || this._cameras);
 
@@ -161,36 +213,20 @@ module BABYLON {
             }
         }
 
-        public getPostProcess(camera?: Camera): Nullable<PostProcess> {
+        /**
+         * Gets a list of the post processes contained in the effect.
+         * @param camera The camera to get the post processes on.
+         * @returns The list of the post processes in the effect.
+         */
+        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];
-            }
-        }
-
-        private _linkParameters(): void {
-            for (var index in this._postProcesses) {
-                this._postProcesses[index].forEach((postProcess:PostProcess)=>{
-                    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());
+                return this._postProcesses[camera.name];
             }
         }
     }

+ 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