浏览代码

Various fixes

David Catuhe 10 年之前
父节点
当前提交
8ced0d6db9

+ 1 - 1
Babylon/Lights/Shadows/babylon.shadowGenerator.js

@@ -4,7 +4,7 @@ var BABYLON;
         function ShadowGenerator(mapSize, light) {
             var _this = this;
             // Members
-            this.filter = ShadowGenerator.FILTER_VARIANCESHADOWMAP;
+            this.filter = ShadowGenerator.FILTER_NONE;
             this._darkness = 0;
             this._transparencyShadow = false;
             this._viewMatrix = BABYLON.Matrix.Zero();

+ 1 - 1
Babylon/Lights/Shadows/babylon.shadowGenerator.ts

@@ -18,7 +18,7 @@
         }
 
         // Members
-        public filter = ShadowGenerator.FILTER_VARIANCESHADOWMAP;
+        public filter = ShadowGenerator.FILTER_NONE;
 
         public get useVarianceShadowMap(): boolean {
             return this.filter === ShadowGenerator.FILTER_VARIANCESHADOWMAP;

+ 2 - 2
Babylon/Materials/Textures/Procedurals/babylon.customProceduralTexture.js

@@ -21,7 +21,7 @@ var BABYLON;
             var _this = this;
             var that = this;
             function noConfigFile() {
-                BABYLON.Tools.Log("No config file found in " + jsonUrl + " trying to use ShaderStore or DOM element");
+                BABYLON.Tools.Log("No config file found in " + jsonUrl + " trying to use ShadersStore or DOM element");
                 try {
                     that.setFragment(that._texturePath);
                 }
@@ -50,7 +50,7 @@ var BABYLON;
                     noConfigFile();
                 }
             }, false);
-            xhr.addEventListener("error", function (event) {
+            xhr.addEventListener("error", function () {
                 noConfigFile();
             }, false);
             try {

+ 5 - 5
Babylon/Materials/Textures/Procedurals/babylon.customProceduralTexture.ts

@@ -18,12 +18,12 @@
             var that = this;
 
             function noConfigFile() {
-                BABYLON.Tools.Log("No config file found in " + jsonUrl + " trying to use ShaderStore or DOM element");
+                Tools.Log("No config file found in " + jsonUrl + " trying to use ShadersStore or DOM element");
                 try {
                     that.setFragment(that._texturePath);
                 }
                 catch (ex) {
-                    BABYLON.Tools.Error("No json or ShaderStore or DOM element found for CustomProceduralTexture");
+                    Tools.Error("No json or ShaderStore or DOM element found for CustomProceduralTexture");
                 }
             }
 
@@ -32,7 +32,7 @@
 
             xhr.open("GET", configFileUrl, true);
             xhr.addEventListener("load", () => {
-                if (xhr.status === 200 || BABYLON.Tools.ValidateXHRData(xhr, 1)) {
+                if (xhr.status === 200 || Tools.ValidateXHRData(xhr, 1)) {
                     try {
                         this._config = JSON.parse(xhr.response);
 
@@ -52,7 +52,7 @@
                 }
             }, false);
 
-            xhr.addEventListener("error", event => {
+            xhr.addEventListener("error", () => {
                 noConfigFile();
             }, false);
 
@@ -60,7 +60,7 @@
                 xhr.send();
             }
             catch (ex) {
-                BABYLON.Tools.Error("CustomProceduralTexture: Error on XHR send request.");
+                Tools.Error("CustomProceduralTexture: Error on XHR send request.");
             }
         }
 

+ 5 - 5
Babylon/Materials/Textures/babylon.renderTargetTexture.js

@@ -99,8 +99,6 @@ var BABYLON;
             if (!useCameraPostProcess || !scene.postProcessManager._prepareFrame(this._texture)) {
                 engine.bindFramebuffer(this._texture);
             }
-            // Clear
-            engine.clear(scene.clearColor, true, true);
             this._renderingManager.reset();
             var currentRenderList = this.renderList ? this.renderList : scene.getActiveMeshes().data;
             for (var meshIndex = 0; meshIndex < currentRenderList.length; meshIndex++) {
@@ -121,12 +119,14 @@ var BABYLON;
                     }
                 }
             }
-            if (!this._doNotChangeAspectRatio) {
-                scene.updateTransformMatrix(true);
-            }
             if (this.onBeforeRender) {
                 this.onBeforeRender();
             }
+            // Clear
+            engine.clear(scene.clearColor, true, true);
+            if (!this._doNotChangeAspectRatio) {
+                scene.updateTransformMatrix(true);
+            }
             // Render
             this._renderingManager.render(this.customRenderFunction, currentRenderList, this.renderParticles, this.renderSprites);
             if (useCameraPostProcess) {

+ 8 - 7
Babylon/Materials/Textures/babylon.renderTargetTexture.ts

@@ -114,9 +114,6 @@
                 engine.bindFramebuffer(this._texture);
             }
 
-            // Clear
-            engine.clear(scene.clearColor, true, true);
-
             this._renderingManager.reset();
 
             var currentRenderList = this.renderList ? this.renderList : scene.getActiveMeshes().data;
@@ -143,14 +140,18 @@
                 }                
             }
 
-            if (!this._doNotChangeAspectRatio) {
-                scene.updateTransformMatrix(true);
-            }
-
             if (this.onBeforeRender) {
                 this.onBeforeRender();
             }
 
+            // Clear
+            engine.clear(scene.clearColor, true, true);
+
+
+            if (!this._doNotChangeAspectRatio) {
+                scene.updateTransformMatrix(true);
+            }
+
             // Render
             this._renderingManager.render(this.customRenderFunction, currentRenderList, this.renderParticles, this.renderSprites);
 

文件差异内容过多而无法显示
+ 53 - 658
Babylon/Math/babylon.math.js


+ 13 - 8
Babylon/Math/babylon.math.ts

@@ -1428,15 +1428,20 @@
             return this;
         }
 
+        public fromRotationMatrix(matrix: Matrix): Quaternion {
+            Quaternion.FromRotationMatrixToRef(matrix, this);
+            return this;
+        }
+
         // Statics
 
-        public static FromRotationMatrix(matrix: Matrix) : Quaternion {
+        public static FromRotationMatrix(matrix: Matrix): Quaternion {
             var result = new Quaternion();
             Quaternion.FromRotationMatrixToRef(matrix, result);
             return result;
         }
 
-        public static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion) : void {
+        public static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void {
             var data = matrix.m;
             var m11 = data[0], m12 = data[4], m13 = data[8];
             var m21 = data[1], m22 = data[5], m23 = data[9];
@@ -1556,7 +1561,7 @@
                 num2 = flag ? ((-Math.sin(num * num5)) * num6) : ((Math.sin(num * num5)) * num6);
             }
 
-            return new Quaternion((num3 * left.x) + (num2 * right.x),(num3 * left.y) + (num2 * right.y),(num3 * left.z) + (num2 * right.z),(num3 * left.w) + (num2 * right.w));
+            return new Quaternion((num3 * left.x) + (num2 * right.x), (num3 * left.y) + (num2 * right.y), (num3 * left.z) + (num2 * right.z), (num3 * left.w) + (num2 * right.w));
         }
     }
 
@@ -1771,9 +1776,9 @@
         public equals(value: Matrix): boolean {
             return value &&
                 (this.m[0] === value.m[0] && this.m[1] === value.m[1] && this.m[2] === value.m[2] && this.m[3] === value.m[3] &&
-                    this.m[4] === value.m[4] && this.m[5] === value.m[5] && this.m[6] === value.m[6] && this.m[7] === value.m[7] &&
-                    this.m[8] === value.m[8] && this.m[9] === value.m[9] && this.m[10] === value.m[10] && this.m[11] === value.m[11] &&
-                    this.m[12] === value.m[12] && this.m[13] === value.m[13] && this.m[14] === value.m[14] && this.m[15] === value.m[15]);
+                this.m[4] === value.m[4] && this.m[5] === value.m[5] && this.m[6] === value.m[6] && this.m[7] === value.m[7] &&
+                this.m[8] === value.m[8] && this.m[9] === value.m[9] && this.m[10] === value.m[10] && this.m[11] === value.m[11] &&
+                this.m[12] === value.m[12] && this.m[13] === value.m[13] && this.m[14] === value.m[14] && this.m[15] === value.m[15]);
         }
 
         public clone(): Matrix {
@@ -2821,7 +2826,7 @@
             return new Vector3(point.x, 0, point.y);
         }
 
-        public moveAhead(step: number = 0.002): PathCursor  {
+        public moveAhead(step: number = 0.002): PathCursor {
             this.move(step);
 
             return this;
@@ -2981,4 +2986,4 @@
             return new Path2(x, y);
         }
     }
-}
+}

+ 38 - 0
Babylon/PostProcess/babylon.ssaoRenderingPipeline.js

@@ -8,15 +8,42 @@ var BABYLON;
 (function (BABYLON) {
     var SSAORenderingPipeline = (function (_super) {
         __extends(SSAORenderingPipeline, _super);
+        /**
+         * @constructor
+         * @param {string} name - The rendering pipeline name
+         * @param {BABYLON.Scene} scene - The scene linked to this pipeline
+         * @param {number} ratio - The size of the postprocesses (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5)
+         * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
+         */
         function SSAORenderingPipeline(name, scene, ratio, cameras) {
             var _this = this;
             if (ratio === void 0) { ratio = 1.0; }
             _super.call(this, scene.getEngine(), name);
             // Members
+            /**
+            * The PassPostProcess id in the pipeline that contains the original scene color
+            * @type {string}
+            */
             this.SSAOOriginalSceneColorEffect = "SSAOOriginalSceneColorEffect";
+            /**
+            * The SSAO PostProcess id in the pipeline
+            * @type {string}
+            */
             this.SSAORenderEffect = "SSAORenderEffect";
+            /**
+            * The horizontal blur PostProcess id in the pipeline
+            * @type {string}
+            */
             this.SSAOBlurHRenderEffect = "SSAOBlurHRenderEffect";
+            /**
+            * The vertical blur PostProcess id in the pipeline
+            * @type {string}
+            */
             this.SSAOBlurVRenderEffect = "SSAOBlurVRenderEffect";
+            /**
+            * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
+            * @type {string}
+            */
             this.SSAOCombineRenderEffect = "SSAOCombineRenderEffect";
             this._firstUpdate = true;
             this._scene = scene;
@@ -50,12 +77,23 @@ var BABYLON;
                 scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(name, cameras);
         }
         // Public Methods
+        /**
+         * Returns the horizontal blur PostProcess
+         * @return {BABYLON.BlurPostProcess} The horizontal blur post-process
+         */
         SSAORenderingPipeline.prototype.getBlurHPostProcess = function () {
             return this._blurHPostProcess;
         };
+        /**
+         * Returns the vertical blur PostProcess
+         * @return {BABYLON.BlurPostProcess} The vertical blur post-process
+         */
         SSAORenderingPipeline.prototype.getBlurVPostProcess = function () {
             return this._blurVPostProcess;
         };
+        /**
+         * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
+         */
         SSAORenderingPipeline.prototype.dispose = function () {
             this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras);
             this._originalColorPostProcess = undefined;

+ 39 - 0
Babylon/PostProcess/babylon.ssaoRenderingPipeline.ts

@@ -1,10 +1,31 @@
 module BABYLON {
     export class SSAORenderingPipeline extends PostProcessRenderPipeline {
         // Members
+
+        /**
+        * The PassPostProcess id in the pipeline that contains the original scene color
+        * @type {string}
+        */
         public SSAOOriginalSceneColorEffect: string = "SSAOOriginalSceneColorEffect";
+        /**
+        * The SSAO PostProcess id in the pipeline
+        * @type {string}
+        */
         public SSAORenderEffect: string = "SSAORenderEffect";
+        /**
+        * The horizontal blur PostProcess id in the pipeline
+        * @type {string}
+        */
         public SSAOBlurHRenderEffect: string = "SSAOBlurHRenderEffect";
+        /**
+        * The vertical blur PostProcess id in the pipeline
+        * @type {string}
+        */
         public SSAOBlurVRenderEffect: string = "SSAOBlurVRenderEffect";
+        /**
+        * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
+        * @type {string}
+        */
         public SSAOCombineRenderEffect: string = "SSAOCombineRenderEffect";
 
         private _scene: Scene;
@@ -19,6 +40,13 @@
 
         private _firstUpdate: boolean = true;
 
+        /**
+         * @constructor
+         * @param {string} name - The rendering pipeline name
+         * @param {BABYLON.Scene} scene - The scene linked to this pipeline
+         * @param {number} ratio - The size of the postprocesses (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5)
+         * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
+         */
         constructor(name: string, scene: Scene, ratio: number = 1.0, cameras?: Camera[]) {
             super(scene.getEngine(), name);
 
@@ -48,14 +76,25 @@
         }
 
         // Public Methods
+        /**
+         * Returns the horizontal blur PostProcess
+         * @return {BABYLON.BlurPostProcess} The horizontal blur post-process
+         */
         public getBlurHPostProcess(): BlurPostProcess {
             return this._blurHPostProcess;
         }
 
+        /**
+         * Returns the vertical blur PostProcess
+         * @return {BABYLON.BlurPostProcess} The vertical blur post-process
+         */
         public getBlurVPostProcess(): BlurPostProcess {
             return this._blurVPostProcess;
         }
 
+        /**
+         * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
+         */
         public dispose(): void {
             this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras);
 

+ 66 - 15
Babylon/PostProcess/babylon.volumetricLightScatteringPostProcess.js

@@ -6,19 +6,36 @@ var __extends = this.__extends || function (d, b) {
 };
 var BABYLON;
 (function (BABYLON) {
-    var GodRaysPostProcess = (function (_super) {
-        __extends(GodRaysPostProcess, _super);
-        function GodRaysPostProcess(name, ratio, camera, samplingMode, engine, reusable) {
+    var VolumetricLightScatteringPostProcess = (function (_super) {
+        __extends(VolumetricLightScatteringPostProcess, _super);
+        /**
+         * @constructor
+         * @param {string} name - The post-process name
+         * @param {number} ratio - The size of the postprocesses (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5)
+         * @param {BABYLON.Camera} camera - The camera that the post-process will be attached to
+         * @param {BABYLON.Mesh} mesh - The mesh used to create the light scattering
+         * @param {number} samplingMode - The post-process filtering mode
+         * @param {BABYLON.Engine} engine - The babylon engine
+         * @param {boolean} reusable - If the post-process is reusable
+         */
+        function VolumetricLightScatteringPostProcess(name, ratio, camera, mesh, samplingMode, engine, reusable) {
             var _this = this;
             _super.call(this, name, "volumetricLightScattering", ["lightPositionOnScreen"], ["lightScatteringSampler"], ratio, camera, samplingMode, engine, reusable);
             this._screenCoordinates = BABYLON.Vector2.Zero();
+            /**
+            * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
+            * @type {boolean}
+            */
+            this.useCustomLightPosition = false;
+            /**
+            * If the post-process should inverse the light scattering direction
+            * @type {boolean}
+            */
             this.invert = true;
             var scene = camera.getScene();
             this._viewPort = new BABYLON.Viewport(0, 0, 1, 1).toGlobal(scene.getEngine());
-            // Create billboard
-            this.mesh = BABYLON.Mesh.CreatePlane("VolumetricLightScatteringMesh", 2, scene);
-            this.mesh.billboardMode = BABYLON.AbstractMesh.BILLBOARDMODE_ALL;
-            this.mesh.material = new BABYLON.StandardMaterial('VolumetricLightScatteringMaterial', scene);
+            // Configure mesh
+            this.mesh = (mesh !== null) ? mesh : VolumetricLightScatteringPostProcess.CreateDefaultMesh("VolumetricLightScatteringMesh", scene);
             // Configure
             this._createPass(scene);
             this.onApply = function (effect) {
@@ -27,7 +44,7 @@ var BABYLON;
                 effect.setVector2("lightPositionOnScreen", _this._screenCoordinates);
             };
         }
-        GodRaysPostProcess.prototype.isReady = function (subMesh, useInstances) {
+        VolumetricLightScatteringPostProcess.prototype.isReady = function (subMesh, useInstances) {
             var mesh = subMesh.getMesh();
             var scene = mesh.getScene();
             var defines = [];
@@ -72,15 +89,36 @@ var BABYLON;
             }
             return this._godRaysPass.isReady();
         };
-        GodRaysPostProcess.prototype.dispose = function (camera) {
+        /**
+         * Sets the new light position for light scattering effect
+         * @param {BABYLON.Vector3} The new custom light position
+         */
+        VolumetricLightScatteringPostProcess.prototype.setLightPosition = function (position) {
+            this._customLightPosition = position;
+        };
+        /**
+         * Returns the light position for light scattering effect
+         * @return {BABYLON.Vector3} The custom light position
+         */
+        VolumetricLightScatteringPostProcess.prototype.getLightPosition = function () {
+            return this._customLightPosition;
+        };
+        /**
+         * Disposes the internal assets and detaches the post-process from the camera
+         */
+        VolumetricLightScatteringPostProcess.prototype.dispose = function (camera) {
             this._godRaysRTT.dispose();
             _super.prototype.dispose.call(this, camera);
         };
-        GodRaysPostProcess.prototype.getPass = function () {
+        /**
+         * Returns the render target texture used by the post-process
+         * @return {BABYLON.RenderTargetTexture} The render target texture used by the post-process
+         */
+        VolumetricLightScatteringPostProcess.prototype.getPass = function () {
             return this._godRaysRTT;
         };
         // Private methods
-        GodRaysPostProcess.prototype._createPass = function (scene) {
+        VolumetricLightScatteringPostProcess.prototype._createPass = function (scene) {
             var _this = this;
             var engine = scene.getEngine();
             this._godRaysRTT = new BABYLON.RenderTargetTexture("volumetricLightScatteringMap", { width: engine.getRenderWidth(), height: engine.getRenderHeight() }, scene, false, true, BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT);
@@ -141,16 +179,29 @@ var BABYLON;
                 }
             };
         };
-        GodRaysPostProcess.prototype._updateScreenCoordinates = function (scene) {
+        VolumetricLightScatteringPostProcess.prototype._updateScreenCoordinates = function (scene) {
             var transform = scene.getTransformMatrix();
-            var pos = BABYLON.Vector3.Project(this.mesh.position, BABYLON.Matrix.Identity(), transform, this._viewPort);
+            var pos = BABYLON.Vector3.Project(this.useCustomLightPosition ? this._customLightPosition : this.mesh.position, BABYLON.Matrix.Identity(), transform, this._viewPort);
             this._screenCoordinates.x = pos.x / this._viewPort.width;
             this._screenCoordinates.y = pos.y / this._viewPort.height;
             if (this.invert)
                 this._screenCoordinates.y = 1.0 - this._screenCoordinates.y;
         };
-        return GodRaysPostProcess;
+        // Static methods
+        /**
+        * Creates a default mesh for the Volumeric Light Scattering post-process
+        * @param {string} The mesh name
+        * @param {BABYLON.Scene} The scene where to create the mesh
+        * @return {BABYLON.Mesh} the default mesh
+        */
+        VolumetricLightScatteringPostProcess.CreateDefaultMesh = function (name, scene) {
+            var mesh = BABYLON.Mesh.CreatePlane(name, 1, scene);
+            mesh.billboardMode = BABYLON.AbstractMesh.BILLBOARDMODE_ALL;
+            mesh.material = new BABYLON.StandardMaterial(name + "Material", scene);
+            return mesh;
+        };
+        return VolumetricLightScatteringPostProcess;
     })(BABYLON.PostProcess);
-    BABYLON.GodRaysPostProcess = GodRaysPostProcess;
+    BABYLON.VolumetricLightScatteringPostProcess = VolumetricLightScatteringPostProcess;
 })(BABYLON || (BABYLON = {}));
 //# sourceMappingURL=babylon.volumetricLightScatteringPostProcess.js.map

+ 68 - 8
Babylon/PostProcess/babylon.volumetricLightScatteringPostProcess.ts

@@ -1,25 +1,47 @@
 module BABYLON {
-    export class GodRaysPostProcess extends PostProcess {
+    export class VolumetricLightScatteringPostProcess extends PostProcess {
         // Members
         private _godRaysPass: Effect;
         private _godRaysRTT: RenderTargetTexture;
         private _viewPort: Viewport;
         private _screenCoordinates: Vector2 = Vector2.Zero();
         private _cachedDefines: string;
-
+        private _customLightPosition: Vector3;
+
+        /**
+        * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
+        * @type {boolean}
+        */
+        public useCustomLightPosition: boolean = false;
+        /**
+        * If the post-process should inverse the light scattering direction
+        * @type {boolean}
+        */
         public invert: boolean = true;
+        /**
+        * The internal mesh used by the post-process
+        * @type {boolean}
+        */
         public mesh: Mesh;
 
-        constructor(name: string, ratio: number, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean) {
+        /**
+         * @constructor
+         * @param {string} name - The post-process name
+         * @param {number} ratio - The size of the postprocesses (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5)
+         * @param {BABYLON.Camera} camera - The camera that the post-process will be attached to
+         * @param {BABYLON.Mesh} mesh - The mesh used to create the light scattering
+         * @param {number} samplingMode - The post-process filtering mode
+         * @param {BABYLON.Engine} engine - The babylon engine
+         * @param {boolean} reusable - If the post-process is reusable
+         */
+        constructor(name: string, ratio: number, camera: Camera, mesh?: Mesh, samplingMode?: number, engine?: Engine, reusable?: boolean) {
             super(name, "volumetricLightScattering", ["lightPositionOnScreen"], ["lightScatteringSampler"], ratio, camera, samplingMode, engine, reusable);
             var scene = camera.getScene();
 
             this._viewPort = new Viewport(0, 0, 1, 1).toGlobal(scene.getEngine());
 
-            // Create billboard
-            this.mesh = BABYLON.Mesh.CreatePlane("VolumetricLightScatteringMesh", 2, scene);
-            this.mesh.billboardMode = BABYLON.AbstractMesh.BILLBOARDMODE_ALL;
-            this.mesh.material = new StandardMaterial('VolumetricLightScatteringMaterial', scene);
+            // Configure mesh
+            this.mesh = (mesh !== null) ? mesh : VolumetricLightScatteringPostProcess.CreateDefaultMesh("VolumetricLightScatteringMesh", scene);
 
             // Configure
             this._createPass(scene);
@@ -90,11 +112,34 @@
             return this._godRaysPass.isReady();
         }
 
+        /**
+         * Sets the new light position for light scattering effect
+         * @param {BABYLON.Vector3} The new custom light position
+         */
+        public setLightPosition(position: Vector3): void {
+            this._customLightPosition = position;
+        }
+
+        /**
+         * Returns the light position for light scattering effect
+         * @return {BABYLON.Vector3} The custom light position
+         */
+        public getLightPosition(): Vector3 {
+            return this._customLightPosition;
+        }
+
+        /**
+         * Disposes the internal assets and detaches the post-process from the camera
+         */
         public dispose(camera: Camera): void {
             this._godRaysRTT.dispose();
             super.dispose(camera);
         }
 
+        /**
+         * Returns the render target texture used by the post-process
+         * @return {BABYLON.RenderTargetTexture} The render target texture used by the post-process
+         */
         public getPass(): RenderTargetTexture {
             return this._godRaysRTT;
         }
@@ -181,7 +226,7 @@
 
         private _updateScreenCoordinates(scene: Scene): void {
             var transform = scene.getTransformMatrix();
-            var pos = Vector3.Project(this.mesh.position, Matrix.Identity(), transform, this._viewPort);
+            var pos = Vector3.Project(this.useCustomLightPosition ? this._customLightPosition : this.mesh.position, Matrix.Identity(), transform, this._viewPort);
 
             this._screenCoordinates.x = pos.x / this._viewPort.width;
             this._screenCoordinates.y = pos.y / this._viewPort.height;
@@ -189,5 +234,20 @@
             if (this.invert)
                 this._screenCoordinates.y = 1.0 - this._screenCoordinates.y;
         }
+
+        // Static methods
+        /**
+        * Creates a default mesh for the Volumeric Light Scattering post-process
+        * @param {string} The mesh name
+        * @param {BABYLON.Scene} The scene where to create the mesh
+        * @return {BABYLON.Mesh} the default mesh
+        */
+        public static CreateDefaultMesh(name: string, scene: Scene): Mesh {
+            var mesh = BABYLON.Mesh.CreatePlane(name, 1, scene);
+            mesh.billboardMode = AbstractMesh.BILLBOARDMODE_ALL;
+            mesh.material = new StandardMaterial(name + "Material", scene);
+
+            return mesh;
+        }
     }
 }  

+ 1 - 1
Babylon/Shaders/default.fragment.fx

@@ -284,7 +284,7 @@ float computeShadowWithVSM(vec4 vPositionFromLight, sampler2D shadowSampler)
 	vec4 texel = texture2D(shadowSampler, uv);
 
 	vec2 moments = vec2(unpackHalf(texel.xy), unpackHalf(texel.zw));
-	return clamp(1.3 - ChebychevInequality(moments, depth.z), 0., 1.0);
+	return clamp(1.0 - ChebychevInequality(moments, depth.z), 0., 1.0);
 }
 #endif
 

文件差异内容过多而无法显示
+ 145 - 49
babylon.2.0-beta.debug.js


文件差异内容过多而无法显示
+ 8 - 8
babylon.2.0-beta.js