Trevor Baron преди 7 години
родител
ревизия
51eddca4e3

+ 44 - 0
dist/preview release/typedocValidationBaseline.json

@@ -8898,6 +8898,50 @@
         }
       }
     },
+    "DefaultRenderingPipeline": {			
+      "Property": {		
+        "BlurXPostProcessId": {		
+          "Naming": {		
+            "NotCamelCase": true		
+          }		
+        },		
+        "BlurYPostProcessId": {		
+          "Naming": {		
+            "NotCamelCase": true		
+          }		
+        },		
+        "CopyBackPostProcessId": {		
+          "Naming": {		
+            "NotCamelCase": true		
+          }		
+        },		
+        "FinalMergePostProcessId": {		
+          "Naming": {		
+            "NotCamelCase": true		
+          }		
+        },		
+        "FxaaPostProcessId": {		
+          "Naming": {		
+            "NotCamelCase": true		
+          }		
+        },		
+        "HighLightsPostProcessId": {		
+          "Naming": {		
+            "NotCamelCase": true		
+          }		
+        },		
+        "ImageProcessingPostProcessId": {		
+          "Naming": {		
+            "NotCamelCase": true		
+          }		
+        },		
+        "PassPostProcessId": {		
+          "Naming": {		
+            "NotCamelCase": true		
+          }		
+        }
+      }
+    },
     "DepthRenderer": {
       "Class": {
         "Comments": {

+ 14 - 3
src/PostProcess/RenderPipeline/Pipelines/babylon.defaultRenderingPipeline.ts

@@ -416,7 +416,9 @@
             (<any>this.depthOfField) = null;
         }
 
-        // Dispose
+        /**
+         * Dispose of the pipeline and stop all post processes
+         */
         public dispose(): void {
             this._disposePostProcesses();
 
@@ -425,7 +427,10 @@
             super.dispose();
         }
 
-        // Serialize rendering pipeline
+        /**
+         * Serialize the rendering pipeline (Used when exporting)
+         * @returns the serialized object
+         */
         public serialize(): any {
             var serializationObject = SerializationHelper.Serialize(this);
             serializationObject.customType = "DefaultRenderingPipeline";
@@ -433,7 +438,13 @@
             return serializationObject;
         }
 
-        // Parse serialized pipeline
+        /**
+         * Parse the serialized pipeline
+         * @param source Source pipeline.
+         * @param scene The scene to load the pipeline to.
+         * @param rootUrl The URL of the serialized pipeline.
+         * @returns An instantiated pipeline from the serialized object.
+         */
         public static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline {
             return SerializationHelper.Parse(() => new DefaultRenderingPipeline(source._name, source._name._hdr, scene), source, scene, rootUrl);
         }

+ 2 - 2
src/PostProcess/babylon.blurPostProcess.ts

@@ -59,8 +59,8 @@
          * @param reusable If the post process can be reused on the same frame. (default: false)
          * @param textureType Type of textures used when performing the post process. (default: 0)
          */
-        constructor(name: string, /*The direction in which to blur the image.*/public direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode: number = Texture.BILINEAR_SAMPLINGMODE, engine?: Engine, reusable?: boolean, textureType: number = Engine.TEXTURETYPE_UNSIGNED_INT) {
-            super(name, "kernelBlur", ["delta", "direction", "cameraMinMaxZ"], ["depthSampler"], options, camera, samplingMode, engine, reusable, null, textureType, "kernelBlur", {varyingCount: 0, depCount: 0}, true);
+        constructor(name: string, /** The direction in which to blur the image. */ public direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode: number = Texture.BILINEAR_SAMPLINGMODE, engine?: Engine, reusable?: boolean, textureType: number = Engine.TEXTURETYPE_UNSIGNED_INT) {
+			super(name, "kernelBlur", ["delta", "direction", "cameraMinMaxZ"], ["depthSampler"], options, camera, samplingMode, engine, reusable, null, textureType, "kernelBlur", {varyingCount: 0, depCount: 0}, true);
 			
 			this.onApplyObservable.add((effect: Effect) => {
 				effect.setFloat2('delta', (1 / this.width) * this.direction.x, (1 / this.height) * this.direction.y);

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

@@ -4,57 +4,57 @@ module BABYLON {
      * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
      */
     export class DepthOfFieldEffect extends PostProcessRenderEffect{
-        private depthOfFieldPass: PassPostProcess;
-        private circleOfConfusion: CircleOfConfusionPostProcess;
-        private depthOfFieldBlurX: DepthOfFieldBlurPostProcess;
-        private depthOfFieldBlurY: DepthOfFieldBlurPostProcess;
-        private depthOfFieldMerge: DepthOfFieldMergePostProcess;
+        private _depthOfFieldPass: PassPostProcess;
+        private _circleOfConfusion: CircleOfConfusionPostProcess;
+        private _depthOfFieldBlurX: DepthOfFieldBlurPostProcess;
+        private _depthOfFieldBlurY: DepthOfFieldBlurPostProcess;
+        private _depthOfFieldMerge: DepthOfFieldMergePostProcess;
 
         /**
          * The size of the kernel to be used for the blur
          */
         public set kernelSize(value: number){
-            this.depthOfFieldBlurX.kernel = value;
-            this.depthOfFieldBlurY.kernel = value;
+            this._depthOfFieldBlurX.kernel = value;
+            this._depthOfFieldBlurY.kernel = value;
         }
         public get kernelSize(){
-            return this.depthOfFieldBlurX.kernel;
+            return this._depthOfFieldBlurX.kernel;
         }
         /**
          * The focal the length of the camera used in the effect
          */
         public set focalLength(value: number){
-            this.circleOfConfusion.focalLength = value;
+            this._circleOfConfusion.focalLength = value;
         }
         public get focalLength(){
-            return this.circleOfConfusion.focalLength;
+            return this._circleOfConfusion.focalLength;
         }
         /**
          * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
          */
         public set fStop(value: number){
-            this.circleOfConfusion.fStop = value;
+            this._circleOfConfusion.fStop = value;
         }
         public get fStop(){
-            return this.circleOfConfusion.fStop;
+            return this._circleOfConfusion.fStop;
         }
         /**
          * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
          */
         public set focusDistance(value: number){
-            this.circleOfConfusion.focusDistance = value;
+            this._circleOfConfusion.focusDistance = value;
         }
         public get focusDistance(){
-            return this.circleOfConfusion.focusDistance;
+            return this._circleOfConfusion.focusDistance;
         }
         /**
          * Max lens size in scene units/1000 (eg. millimeter). Standard cameras are 50mm. (default: 50) The diamater of the resulting aperture can be computed by lensSize/fStop.
          */
         public set lensSize(value: number){
-            this.circleOfConfusion.lensSize = value;
+            this._circleOfConfusion.lensSize = value;
         }
         public get lensSize(){
-            return this.circleOfConfusion.lensSize;
+            return this._circleOfConfusion.lensSize;
         }
 
         /**
@@ -63,19 +63,19 @@ 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.depthOfFieldBlurY, this.depthOfFieldBlurX, 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
-            this.circleOfConfusion = new BABYLON.CircleOfConfusionPostProcess("circleOfConfusion", scene, depthMap, 1, null, BABYLON.Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false, pipelineTextureType);
+            this._circleOfConfusion = new BABYLON.CircleOfConfusionPostProcess("circleOfConfusion", scene, depthMap, 1, null, BABYLON.Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false, pipelineTextureType);
             // Capture circle of confusion texture
-            this.depthOfFieldPass = new PassPostProcess("depthOfFieldPass", 1.0, null, Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false, pipelineTextureType);
+            this._depthOfFieldPass = new PassPostProcess("depthOfFieldPass", 1.0, null, Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false, pipelineTextureType);
             // Blur the image but do not blur on sharp far to near distance changes to avoid bleeding artifacts 
             // See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
-            this.depthOfFieldBlurY = new DepthOfFieldBlurPostProcess("verticle blur", scene, new Vector2(0, 1.0), 15, 1.0, null, depthMap, this.circleOfConfusion, Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false, pipelineTextureType);
-            this.depthOfFieldBlurX = new DepthOfFieldBlurPostProcess("horizontal blur", scene, new Vector2(1.0, 0), 15, 1.0, null,  depthMap, null, Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false, pipelineTextureType);
+            this._depthOfFieldBlurY = new DepthOfFieldBlurPostProcess("verticle blur", scene, new Vector2(0, 1.0), 15, 1.0, null, depthMap, this._circleOfConfusion, Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false, pipelineTextureType);
+            this._depthOfFieldBlurX = new DepthOfFieldBlurPostProcess("horizontal blur", scene, new Vector2(1.0, 0), 15, 1.0, null,  depthMap, null, Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false, pipelineTextureType);
             // Merge blurred images with original image based on circleOfConfusion
-            this.depthOfFieldMerge = new DepthOfFieldMergePostProcess("depthOfFieldMerge", this.circleOfConfusion, this.depthOfFieldPass, 1, null, BABYLON.Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false, pipelineTextureType);
+            this._depthOfFieldMerge = new DepthOfFieldMergePostProcess("depthOfFieldMerge", this._circleOfConfusion, this._depthOfFieldPass, 1, null, BABYLON.Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false, pipelineTextureType);
         }
 
         /**
@@ -83,11 +83,11 @@ module BABYLON {
          * @param camera The camera to dispose the effect on.
          */
         public disposeEffects(camera:Camera){
-            this.depthOfFieldPass.dispose(camera);
-            this.circleOfConfusion.dispose(camera);
-            this.depthOfFieldBlurX.dispose(camera);
-            this.depthOfFieldBlurY.dispose(camera);
-            this.depthOfFieldMerge.dispose(camera);
+            this._depthOfFieldPass.dispose(camera);
+            this._circleOfConfusion.dispose(camera);
+            this._depthOfFieldBlurX.dispose(camera);
+            this._depthOfFieldBlurY.dispose(camera);
+            this._depthOfFieldMerge.dispose(camera);
         }
     }
 }

+ 78 - 7
src/PostProcess/babylon.postProcess.ts

@@ -41,10 +41,10 @@
         */
         public animations = new Array<Animation>();
 
-        /*
-            Enable Pixel Perfect mode where texture is not scaled to be power of 2.
-            Can only be used on a single postprocess or on the last one of a chain. (default: false)
-        */
+        /**
+         * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
+         * Can only be used on a single postprocess or on the last one of a chain. (default: false)
+         */
         public enablePixelPerfectMode = false;
 
         /**
@@ -70,7 +70,13 @@
         private _options: number | PostProcessOptions;
         private _reusable = false;
         private _textureType: number;
+        /**
+        * Smart array of input and output textures for the post process.
+        */
         public _textures = new SmartArray<InternalTexture>(2);
+        /**
+        * The index in _textures that corresponds to the output texture.
+        */
         public _currentRenderTextureInd = 0;
         private _effect: Effect;
         private _samplers: string[];
@@ -184,14 +190,15 @@
         }
 
         /**
-        * Gets the camera which post process is applied to
+        * Gets the camera which post process is applied to.
+        * @returns The camera the post process is applied to.
         */
         public getCamera(): Camera {
             return this._camera;
         }
 
         /**
-        * Gets the texel size of the postprocess
+        * Gets the texel size of the postprocess.
         * See https://en.wikipedia.org/wiki/Texel_(graphics)
         */
         public get texelSize(): Vector2 {
@@ -206,7 +213,24 @@
             return this._texelSize;
         }
 
-        constructor(public name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>,
+        /**
+         * Creates a new instance of @see PostProcess
+         * @param name The name of the PostProcess.
+         * @param fragmentUrl The url of the fragment shader to be used.
+		 * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
+         * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
+         * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
+         * @param camera The camera to apply the render pass to.
+         * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
+         * @param engine The engine which the post process will be applied. (default: current engine)
+         * @param reusable If the post process can be reused on the same frame. (default: false)
+         * @param defines String of defines that will be set when running the fragment shader. (default: null)
+         * @param textureType Type of textures used when performing the post process. (default: 0)
+         * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
+         * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
+         * @param blockCompilation If the shader should be compiled imediatly. (default: false) 
+         */
+        constructor(/** Name of the PostProcess. */public name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>,
             samplingMode: number = Texture.NEAREST_SAMPLINGMODE, engine?: Engine, reusable?: boolean, defines: Nullable<string> = null, textureType: number = Engine.TEXTURETYPE_UNSIGNED_INT, vertexUrl: string = "postprocess", indexParameters?: any, blockCompilation = false) {
             if (camera != null) {
                 this._camera = camera;
@@ -242,14 +266,27 @@
             }
         }
 
+        /**
+         * Gets the engine which this post process belongs to.
+         * @returns The engine the post process was enabled with.
+         */
         public getEngine(): Engine {
             return this._engine;
         }
 
+        /**
+         * The effect that is created when initializing the post process.
+         * @returns The created effect corrisponding the the postprocess.
+         */
         public getEffect(): Effect {
             return this._effect;
         }
 
+        /**
+         * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
+         * @param postProcess The post process to share the output with.
+         * @returns This post process.
+         */
         public shareOutputWith(postProcess: PostProcess): PostProcess {
             this._disposeTextures();
 
@@ -258,6 +295,15 @@
             return this;
         }
 
+        /**
+         * Updates the effect with the current post process compile time values and recompiles the shader.
+         * @param defines Define statements that should be added at the beginning of the shader. (default: null)
+         * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
+         * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
+         * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
+         * @param onCompiled Called when the shader has been compiled.
+         * @param onError Called if there is an error when compiling a shader.
+         */
         public updateEffect(defines: Nullable<string> = null, uniforms: Nullable<string[]> = null, samplers: Nullable<string[]> = null, indexParameters?: any,
             onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void) {
             this._effect = this._engine.createEffect({ vertex: this._vertexUrl, fragment: this._fragmentUrl },
@@ -272,6 +318,10 @@
             );
         }
 
+        /**
+         * The post process is reusable if it can be used multiple times within one frame.
+         * @returns If the post process is reusable
+         */
         public isReusable(): boolean {
             return this._reusable;
         }
@@ -281,6 +331,12 @@
             this.width = -1;
         }
 
+        /**
+         * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
+         * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
+         * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
+         * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
+         */
         public activate(camera: Nullable<Camera>, sourceTexture: Nullable<InternalTexture> = null, forceDepthStencil?: boolean): void {
             camera = camera || this._camera;
 
@@ -386,10 +442,17 @@
             }
         }
 
+
+        /**
+         * If the post process is supported.
+         */
         public get isSupported(): boolean {
             return this._effect.isSupported;
         }
 
+        /**
+         * The aspect ratio of the output texture.
+         */
         public get aspectRatio(): number {
             if (this._shareOutputWithPostProcess) {
                 return this._shareOutputWithPostProcess.aspectRatio;
@@ -409,6 +472,10 @@
             return this._effect && this._effect.isReady();
         }
 
+        /**
+         * Binds all textures and uniforms to the shader, this will be run on every pass.
+         * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
+         */
         public apply(): Nullable<Effect> {
             // Check
             if (!this._effect || !this._effect.isReady())
@@ -457,6 +524,10 @@
             this._textures.dispose();
         }
 
+        /**
+         * Disposes the post process.
+         * @param camera The camera to dispose the post process on.
+         */
         public dispose(camera?: Camera): void {
             camera = camera || this._camera;
 

+ 34 - 0
src/PostProcess/babylon.postProcessManager.ts

@@ -1,9 +1,17 @@
 module BABYLON {
+    /**
+	 * PostProcessManager is used to manage one or more post processes or post process pipelines
+     * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
+     */
     export class PostProcessManager {
         private _scene: Scene;
         private _indexBuffer: Nullable<WebGLBuffer>;
         private _vertexBuffers: { [key: string]: Nullable<VertexBuffer> } = {};
 
+        /**
+         * Creates a new instance of @see PostProcess
+         * @param scene The scene that the post process is associated with.
+         */
         constructor(scene: Scene) {
             this._scene = scene;
         }
@@ -39,6 +47,9 @@
             this._indexBuffer = this._scene.getEngine().createIndexBuffer(indices);
         }
 
+        /**
+         * Rebuilds the vertex buffers of the manager.
+         */
         public _rebuild(): void {
             let vb = this._vertexBuffers[VertexBuffer.PositionKind];
 
@@ -50,6 +61,12 @@
         }
 
         // Methods
+        /**
+         * Prepares a frame to be run through a post process.
+         * @param sourceTexture The input texture to the post procesess. (default: null)
+         * @param postProcesses An array of post processes to be run. (default: null)
+         * @returns True if the post processes were able to be run.
+         */
         public _prepareFrame(sourceTexture: Nullable<InternalTexture> = null, postProcesses: Nullable<PostProcess[]> = null): boolean {
             let camera = this._scene.activeCamera;
             if (!camera) {
@@ -66,6 +83,12 @@
             return true;
         }
 
+        /**
+         * Manually render a set of post processes to a texture.
+         * @param postProcesses An array of post processes to be run.
+         * @param targetTexture The target texture to render to.
+         * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
+         */
         public directRender(postProcesses: PostProcess[], targetTexture: Nullable<InternalTexture> = null, forceFullscreenViewport = false): void {
             var engine = this._scene.getEngine();
 
@@ -102,6 +125,14 @@
             engine.setDepthWrite(true);
         }
 
+        /**
+         * Finalize the result of the output of the postprocesses.
+         * @param doNotPresent If true the result will not be displayed to the screen.
+         * @param targetTexture The target texture to render to.
+         * @param faceIndex The index of the face to bind the target texture to.
+         * @param postProcesses The array of post processes to render.
+         * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
+         */
         public _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: PostProcess[], forceFullscreenViewport = false): void {
             let camera = this._scene.activeCamera;
 
@@ -153,6 +184,9 @@
             engine.setAlphaMode(Engine.ALPHA_DISABLE);
         }
 
+        /**
+         * Disposes of the post process manager.
+         */
         public dispose(): void {
             var buffer = this._vertexBuffers[VertexBuffer.PositionKind];
             if (buffer) {