Просмотр исходного кода

Added separated kernel for mirror blur

David Catuhe 8 лет назад
Родитель
Сommit
5b08a242aa

Разница между файлами не показана из-за своего большого размера
+ 462 - 459
dist/preview release/babylon.d.ts


Разница между файлами не показана из-за своего большого размера
+ 14 - 14
dist/preview release/babylon.js


+ 31 - 11
dist/preview release/babylon.max.js

@@ -43450,7 +43450,8 @@ var BABYLON;
             _this.mirrorPlane = new BABYLON.Plane(0, 1, 0, 1);
             _this._transformMatrix = BABYLON.Matrix.Zero();
             _this._mirrorMatrix = BABYLON.Matrix.Zero();
-            _this._blurKernel = 0;
+            _this._blurKernelX = 0;
+            _this._blurKernelY = 0;
             _this._blurRatio = 1.0;
             _this.onBeforeRenderObservable.add(function () {
                 BABYLON.Matrix.ReflectionToRef(_this.mirrorPlane, _this._mirrorMatrix);
@@ -43484,14 +43485,36 @@ var BABYLON;
             configurable: true
         });
         Object.defineProperty(MirrorTexture.prototype, "blurKernel", {
+            set: function (value) {
+                this.blurKernelX = value;
+                this.blurKernelY = value;
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(MirrorTexture.prototype, "blurKernelX", {
+            get: function () {
+                return this._blurKernelX;
+            },
+            set: function (value) {
+                if (this._blurKernelX === value) {
+                    return;
+                }
+                this._blurKernelX = value;
+                this._preparePostProcesses();
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(MirrorTexture.prototype, "blurKernelY", {
             get: function () {
-                return this._blurKernel;
+                return this._blurKernelY;
             },
             set: function (value) {
-                if (this._blurKernel === value) {
+                if (this._blurKernelY === value) {
                     return;
                 }
-                this._blurKernel = value;
+                this._blurKernelY = value;
                 this._preparePostProcesses();
             },
             enumerable: true,
@@ -43499,10 +43522,10 @@ var BABYLON;
         });
         MirrorTexture.prototype._preparePostProcesses = function () {
             this.clearPostProcesses(true);
-            if (this._blurKernel) {
+            if (this._blurKernelX && this._blurKernelY) {
                 var engine = this.getScene().getEngine();
                 var textureType = engine.getCaps().textureFloatRender ? BABYLON.Engine.TEXTURETYPE_FLOAT : BABYLON.Engine.TEXTURETYPE_HALF_FLOAT;
-                this._blurX = new BABYLON.BlurPostProcess("horizontal blur", new BABYLON.Vector2(1.0, 0), this._blurKernel, this._blurRatio, null, BABYLON.Texture.BILINEAR_SAMPLINGMODE, engine, false, textureType);
+                this._blurX = new BABYLON.BlurPostProcess("horizontal blur", new BABYLON.Vector2(1.0, 0), this._blurKernelX, this._blurRatio, null, BABYLON.Texture.BILINEAR_SAMPLINGMODE, engine, false, textureType);
                 this._blurX.autoClear = false;
                 if (this._blurRatio === 1) {
                     this._blurX.outputTexture = this._texture;
@@ -43510,12 +43533,9 @@ var BABYLON;
                 else {
                     this._blurX.alwaysForcePOT = true;
                 }
-                this._blurY = new BABYLON.BlurPostProcess("vertical blur", new BABYLON.Vector2(0, 1.0), this._blurKernel, this._blurRatio, null, BABYLON.Texture.BILINEAR_SAMPLINGMODE, engine, false, textureType);
+                this._blurY = new BABYLON.BlurPostProcess("vertical blur", new BABYLON.Vector2(0, 1.0), this._blurKernelY, this._blurRatio, null, BABYLON.Texture.BILINEAR_SAMPLINGMODE, engine, false, textureType);
                 this._blurY.autoClear = false;
-                this._blurY.alwaysForcePOT = true;
-                if (this._blurRatio !== 1) {
-                    this._blurY.alwaysForcePOT = true;
-                }
+                this._blurY.alwaysForcePOT = this._blurRatio !== 1;
                 this.addPostProcess(this._blurX);
                 this.addPostProcess(this._blurY);
             }

Разница между файлами не показана из-за своего большого размера
+ 462 - 459
dist/preview release/babylon.module.d.ts


Разница между файлами не показана из-за своего большого размера
+ 14 - 14
dist/preview release/babylon.worker.js


Разница между файлами не показана из-за своего большого размера
+ 4835 - 4829
dist/preview release/customConfigurations/minimalViewer/babylon.d.ts


Разница между файлами не показана из-за своего большого размера
+ 25 - 25
dist/preview release/customConfigurations/minimalViewer/babylon.js


+ 53 - 18
dist/preview release/customConfigurations/minimalViewer/babylon.max.js

@@ -8909,7 +8909,13 @@ var BABYLON;
                 }
             }
             // Z offset
-            this._depthCullingState.zOffset = zOffset;
+            this.setZOffset(zOffset);
+        };
+        Engine.prototype.setZOffset = function (value) {
+            this._depthCullingState.zOffset = value;
+        };
+        Engine.prototype.getZOffset = function () {
+            return this._depthCullingState.zOffset;
         };
         Engine.prototype.setDepthBuffer = function (enable) {
             this._depthCullingState.depthTest = enable;
@@ -20159,7 +20165,7 @@ var BABYLON;
          * Please note that the mesh must have normals vertex data already.
          * Returns the Mesh.
          */
-        Mesh.prototype.recomputeNormals = function () {
+        Mesh.prototype.recomputeNormals = function (markDataAsUpdatable) {
             var positions = this.getVerticesData(BABYLON.VertexBuffer.PositionKind);
             var indices = this.getIndices();
             var normals;
@@ -20170,7 +20176,7 @@ var BABYLON;
                 normals = [];
             }
             BABYLON.VertexData.ComputeNormals(positions, indices, normals);
-            this.updateVerticesData(BABYLON.VertexBuffer.NormalKind, normals, false, false);
+            this.setVerticesData(BABYLON.VertexBuffer.NormalKind, normals, markDataAsUpdatable);
             return this;
         };
         /**
@@ -24715,6 +24721,7 @@ var BABYLON;
             if (flag & BABYLON.Material.MiscDirtyFlag) {
                 this._markAllSubMeshesAsMiscDirty();
             }
+            this.getScene().resetCachedMaterial();
         };
         PushMaterial.prototype._markAllSubMeshesAsDirty = function (func) {
             for (var _i = 0, _a = this.getScene().meshes; _i < _a.length; _i++) {
@@ -33225,8 +33232,9 @@ var BABYLON;
             _this.mirrorPlane = new BABYLON.Plane(0, 1, 0, 1);
             _this._transformMatrix = BABYLON.Matrix.Zero();
             _this._mirrorMatrix = BABYLON.Matrix.Zero();
-            _this._blurKernel = 0;
-            _this._blurRatio = 0.6;
+            _this._blurKernelX = 0;
+            _this._blurKernelY = 0;
+            _this._blurRatio = 1.0;
             _this.onBeforeRenderObservable.add(function () {
                 BABYLON.Matrix.ReflectionToRef(_this.mirrorPlane, _this._mirrorMatrix);
                 _this._savedViewMatrix = scene.getViewMatrix();
@@ -33259,14 +33267,36 @@ var BABYLON;
             configurable: true
         });
         Object.defineProperty(MirrorTexture.prototype, "blurKernel", {
+            set: function (value) {
+                this.blurKernelX = value;
+                this.blurKernelY = value;
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(MirrorTexture.prototype, "blurKernelX", {
             get: function () {
-                return this._blurKernel;
+                return this._blurKernelX;
             },
             set: function (value) {
-                if (this._blurKernel === value) {
+                if (this._blurKernelX === value) {
                     return;
                 }
-                this._blurKernel = value;
+                this._blurKernelX = value;
+                this._preparePostProcesses();
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(MirrorTexture.prototype, "blurKernelY", {
+            get: function () {
+                return this._blurKernelY;
+            },
+            set: function (value) {
+                if (this._blurKernelY === value) {
+                    return;
+                }
+                this._blurKernelY = value;
                 this._preparePostProcesses();
             },
             enumerable: true,
@@ -33274,15 +33304,20 @@ var BABYLON;
         });
         MirrorTexture.prototype._preparePostProcesses = function () {
             this.clearPostProcesses(true);
-            if (this._blurKernel) {
+            if (this._blurKernelX && this._blurKernelY) {
                 var engine = this.getScene().getEngine();
                 var textureType = engine.getCaps().textureFloatRender ? BABYLON.Engine.TEXTURETYPE_FLOAT : BABYLON.Engine.TEXTURETYPE_HALF_FLOAT;
-                this._blurX = new BABYLON.BlurPostProcess("horizontal blur", new BABYLON.Vector2(1.0, 0), this._blurKernel, this._blurRatio, null, BABYLON.Texture.BILINEAR_SAMPLINGMODE, engine, false, textureType);
+                this._blurX = new BABYLON.BlurPostProcess("horizontal blur", new BABYLON.Vector2(1.0, 0), this._blurKernelX, this._blurRatio, null, BABYLON.Texture.BILINEAR_SAMPLINGMODE, engine, false, textureType);
                 this._blurX.autoClear = false;
-                this._blurX.alwaysForcePOT = false;
-                this._blurY = new BABYLON.BlurPostProcess("vertical blur", new BABYLON.Vector2(0, 1.0), this._blurKernel, this._blurRatio, null, BABYLON.Texture.BILINEAR_SAMPLINGMODE, engine, false, textureType);
+                if (this._blurRatio === 1) {
+                    this._blurX.outputTexture = this._texture;
+                }
+                else {
+                    this._blurX.alwaysForcePOT = true;
+                }
+                this._blurY = new BABYLON.BlurPostProcess("vertical blur", new BABYLON.Vector2(0, 1.0), this._blurKernelY, this._blurRatio, null, BABYLON.Texture.BILINEAR_SAMPLINGMODE, engine, false, textureType);
                 this._blurY.autoClear = false;
-                this._blurY.alwaysForcePOT = true;
+                this._blurY.alwaysForcePOT = this._blurRatio !== 1;
                 this.addPostProcess(this._blurX);
                 this.addPostProcess(this._blurY);
             }
@@ -35261,11 +35296,9 @@ var BABYLON;
             if (defines._areFresnelDirty) {
                 if (StandardMaterial.FresnelEnabled) {
                     // Fresnel
-                    if (this._diffuseFresnelParameters && this._diffuseFresnelParameters.isEnabled ||
-                        this._opacityFresnelParameters && this._opacityFresnelParameters.isEnabled ||
-                        this._emissiveFresnelParameters && this._emissiveFresnelParameters.isEnabled ||
-                        this._refractionFresnelParameters && this._refractionFresnelParameters.isEnabled ||
-                        this._reflectionFresnelParameters && this._reflectionFresnelParameters.isEnabled) {
+                    if (this._diffuseFresnelParameters || this._opacityFresnelParameters ||
+                        this._emissiveFresnelParameters || this._refractionFresnelParameters ||
+                        this._reflectionFresnelParameters) {
                         defines.DIFFUSEFRESNEL = (this._diffuseFresnelParameters && this._diffuseFresnelParameters.isEnabled);
                         defines.OPACITYFRESNEL = (this._opacityFresnelParameters && this._opacityFresnelParameters.isEnabled);
                         defines.REFLECTIONFRESNEL = (this._reflectionFresnelParameters && this._reflectionFresnelParameters.isEnabled);
@@ -41280,6 +41313,8 @@ var BABYLON;
             }
             else if (this._forcedOutputTexture) {
                 target = this._forcedOutputTexture;
+                this.width = this._forcedOutputTexture._width;
+                this.height = this._forcedOutputTexture._height;
             }
             else {
                 target = this.outputTexture;

Разница между файлами не показана из-за своего большого размера
+ 4835 - 4829
dist/preview release/customConfigurations/minimalViewer/babylon.module.d.ts


+ 28 - 13
src/Materials/Textures/babylon.mirrorTexture.ts

@@ -10,7 +10,8 @@ module BABYLON {
 
         private _blurX: BlurPostProcess;
         private _blurY: BlurPostProcess;
-        private _blurKernel = 0;
+        private _blurKernelX = 0;
+        private _blurKernelY = 0;
         private _blurRatio = 1.0;
 
         public set blurRatio(value: number) {
@@ -27,18 +28,36 @@ module BABYLON {
         }
 
         public set blurKernel(value: number) {
-            if (this._blurKernel === value) {
+            this.blurKernelX = value;
+            this.blurKernelY = value;
+        }        
+
+        public set blurKernelX(value: number) {
+            if (this._blurKernelX === value) {
                 return;
             }
 
-            this._blurKernel = value;
+            this._blurKernelX = value;
             this._preparePostProcesses();
         }
 
-        public get blurKernel(): number {
-            return this._blurKernel;
+        public get blurKernelX(): number {
+            return this._blurKernelX;
         }        
 
+        public set blurKernelY(value: number) {
+            if (this._blurKernelY === value) {
+                return;
+            }
+
+            this._blurKernelY = value;
+            this._preparePostProcesses();
+        }
+
+        public get blurKernelY(): number {
+            return this._blurKernelY;
+        }             
+
         constructor(name: string, size: any, scene: Scene, generateMipMaps?: boolean, type: number = Engine.TEXTURETYPE_UNSIGNED_INT, samplingMode = Texture.BILINEAR_SAMPLINGMODE, generateDepthBuffer = true) {
             super(name, size, scene, generateMipMaps, true, type, false, samplingMode, generateDepthBuffer);
 
@@ -69,12 +88,12 @@ module BABYLON {
         private _preparePostProcesses(): void {
             this.clearPostProcesses(true);
 
-            if (this._blurKernel) {
+            if (this._blurKernelX && this._blurKernelY) {
                 var engine = this.getScene().getEngine();
 
                 var textureType = engine.getCaps().textureFloatRender ? Engine.TEXTURETYPE_FLOAT : Engine.TEXTURETYPE_HALF_FLOAT;
 
-                this._blurX = new BABYLON.BlurPostProcess("horizontal blur", new BABYLON.Vector2(1.0, 0), this._blurKernel, this._blurRatio, null, BABYLON.Texture.BILINEAR_SAMPLINGMODE, engine, false, textureType);
+                this._blurX = new BABYLON.BlurPostProcess("horizontal blur", new BABYLON.Vector2(1.0, 0), this._blurKernelX, this._blurRatio, null, BABYLON.Texture.BILINEAR_SAMPLINGMODE, engine, false, textureType);
                 this._blurX.autoClear = false;
 
                 if (this._blurRatio === 1) {
@@ -83,13 +102,9 @@ module BABYLON {
                     this._blurX.alwaysForcePOT = true;
                 }
 
-                this._blurY = new BABYLON.BlurPostProcess("vertical blur", new BABYLON.Vector2(0, 1.0), this._blurKernel, this._blurRatio, null, BABYLON.Texture.BILINEAR_SAMPLINGMODE, engine, false, textureType);
+                this._blurY = new BABYLON.BlurPostProcess("vertical blur", new BABYLON.Vector2(0, 1.0), this._blurKernelY, this._blurRatio, null, BABYLON.Texture.BILINEAR_SAMPLINGMODE, engine, false, textureType);
                 this._blurY.autoClear = false;
-                this._blurY.alwaysForcePOT = true;
-
-                if (this._blurRatio !== 1) {
-                    this._blurY.alwaysForcePOT = true;
-                }
+                this._blurY.alwaysForcePOT = this._blurRatio !== 1;
 
                 this.addPostProcess(this._blurX);
                 this.addPostProcess(this._blurY);