瀏覽代碼

Improving postprocess pipeline thoughness

David catuhe 9 年之前
父節點
當前提交
41dcdc2fed

文件差異過大導致無法顯示
+ 7 - 7
dist/preview release/babylon.core.js


文件差異過大導致無法顯示
+ 809 - 804
dist/preview release/babylon.d.ts


文件差異過大導致無法顯示
+ 13 - 13
dist/preview release/babylon.js


+ 59 - 9
dist/preview release/babylon.max.js

@@ -17905,6 +17905,13 @@ var BABYLON;
                 }
             }
         };
+        Object.defineProperty(Effect.prototype, "isSupported", {
+            get: function () {
+                return this._compilationError === "";
+            },
+            enumerable: true,
+            configurable: true
+        });
         Effect.prototype._bindTexture = function (channel, texture) {
             this._engine._bindTexture(this._samplers.indexOf(channel), texture);
         };
@@ -22574,6 +22581,13 @@ var BABYLON;
                 this._currentRenderTextureInd = (this._currentRenderTextureInd + 1) % 2;
             }
         };
+        Object.defineProperty(PostProcess.prototype, "isSupported", {
+            get: function () {
+                return this._effect.isSupported;
+            },
+            enumerable: true,
+            configurable: true
+        });
         PostProcess.prototype.apply = function () {
             // Check
             if (!this._effect.isReady())
@@ -24466,6 +24480,18 @@ var BABYLON;
             this._renderPasses = {};
             this._renderEffectAsPasses = {};
         }
+        Object.defineProperty(PostProcessRenderEffect.prototype, "isSupported", {
+            get: function () {
+                for (var index in this._postProcesses) {
+                    if (!this._postProcesses[index].isSupported) {
+                        return false;
+                    }
+                }
+                return true;
+            },
+            enumerable: true,
+            configurable: true
+        });
         PostProcessRenderEffect.prototype._update = function () {
             for (var renderPassName in this._renderPasses) {
                 this._renderPasses[renderPassName]._update();
@@ -24603,6 +24629,18 @@ var BABYLON;
             this._renderEffectsForIsolatedPass = {};
             this._cameras = [];
         }
+        Object.defineProperty(PostProcessRenderPipeline.prototype, "isSupported", {
+            get: function () {
+                for (var renderEffectName in this._renderEffects) {
+                    if (!this._renderEffects[renderEffectName].isSupported) {
+                        return false;
+                    }
+                }
+                return true;
+            },
+            enumerable: true,
+            configurable: true
+        });
         PostProcessRenderPipeline.prototype.addEffect = function (renderEffect) {
             this._renderEffects[renderEffect._name] = renderEffect;
         };
@@ -24623,7 +24661,8 @@ var BABYLON;
         PostProcessRenderPipeline.prototype._attachCameras = function (cameras, unique) {
             var _cam = BABYLON.Tools.MakeArray(cameras || this._cameras);
             var indicesToDelete = [];
-            for (var i = 0; i < _cam.length; i++) {
+            var i;
+            for (i = 0; i < _cam.length; i++) {
                 var camera = _cam[i];
                 var cameraName = camera.name;
                 if (this._cameras.indexOf(camera) === -1) {
@@ -24633,7 +24672,7 @@ var BABYLON;
                     indicesToDelete.push(i);
                 }
             }
-            for (var i = 0; i < indicesToDelete.length; i++) {
+            for (i = 0; i < indicesToDelete.length; i++) {
                 cameras.splice(indicesToDelete[i], 1);
             }
             for (var renderEffectName in this._renderEffects) {
@@ -24653,7 +24692,8 @@ var BABYLON;
             var _this = this;
             var _cam = BABYLON.Tools.MakeArray(cameras || this._cameras);
             var pass = null;
-            for (var renderEffectName in this._renderEffects) {
+            var renderEffectName;
+            for (renderEffectName in this._renderEffects) {
                 pass = this._renderEffects[renderEffectName].getPass(passName);
                 if (pass != null) {
                     break;
@@ -24662,7 +24702,7 @@ var BABYLON;
             if (pass === null) {
                 return;
             }
-            for (var renderEffectName in this._renderEffects) {
+            for (renderEffectName in this._renderEffects) {
                 this._renderEffects[renderEffectName]._disable(_cam);
             }
             pass._name = PostProcessRenderPipeline.PASS_SAMPLER_NAME;
@@ -24699,6 +24739,9 @@ var BABYLON;
                 }
             }
         };
+        PostProcessRenderPipeline.prototype.dispose = function () {
+            // Must be implemented by children 
+        };
         PostProcessRenderPipeline.PASS_EFFECT_NAME = "passEffect";
         PostProcessRenderPipeline.PASS_SAMPLER_NAME = "passSampler";
         return PostProcessRenderPipeline;
@@ -24759,7 +24802,14 @@ var BABYLON;
         };
         PostProcessRenderPipelineManager.prototype.update = function () {
             for (var renderPipelineName in this._renderPipelines) {
-                this._renderPipelines[renderPipelineName]._update();
+                var pipeline = this._renderPipelines[renderPipelineName];
+                if (!pipeline.isSupported) {
+                    pipeline.dispose();
+                    delete this._renderPipelines[renderPipelineName];
+                }
+                else {
+                    pipeline._update();
+                }
             }
         };
         return PostProcessRenderPipelineManager;
@@ -34682,7 +34732,7 @@ var BABYLON;
             this.addEffect(new BABYLON.PostProcessRenderEffect(scene.getEngine(), this.LensChromaticAberrationEffect, function () { return _this._chromaticAberrationPostProcess; }, true));
             this.addEffect(new BABYLON.PostProcessRenderEffect(scene.getEngine(), this.HighlightsEnhancingEffect, function () { return _this._highlightsPostProcess; }, true));
             this.addEffect(new BABYLON.PostProcessRenderEffect(scene.getEngine(), this.LensDepthOfFieldEffect, function () { return _this._depthOfFieldPostProcess; }, true));
-            if (this._highlightsGain == -1) {
+            if (this._highlightsGain === -1) {
                 this._disableEffect(this.HighlightsEnhancingEffect, null);
             }
             // Finish
@@ -34712,7 +34762,7 @@ var BABYLON;
             this._highlightsGain = amount;
         };
         LensRenderingPipeline.prototype.setHighlightsThreshold = function (amount) {
-            if (this._highlightsGain == -1) {
+            if (this._highlightsGain === -1) {
                 this._highlightsGain = 1.0;
             }
             this._highlightsThreshold = amount;
@@ -34777,12 +34827,12 @@ var BABYLON;
                 effect.setFloat('screen_width', _this._scene.getEngine().getRenderingCanvas().width);
                 effect.setFloat('screen_height', _this._scene.getEngine().getRenderingCanvas().height);
                 effect.setFloat('distortion', _this._distortion);
-                effect.setBool('dof_enabled', (_this._dofDistance != -1));
+                effect.setBool('dof_enabled', (_this._dofDistance !== -1));
                 effect.setFloat('screen_distance', 1.0 / (0.1 - 1.0 / _this._dofDistance));
                 effect.setFloat('aperture', _this._dofAperture);
                 effect.setFloat('darken', _this._dofDarken);
                 effect.setFloat('edge_blur', _this._edgeBlur);
-                effect.setBool('highlights', (_this._highlightsGain != -1));
+                effect.setBool('highlights', (_this._highlightsGain !== -1));
                 effect.setFloat('near', _this._scene.activeCamera.minZ);
                 effect.setFloat('far', _this._scene.activeCamera.maxZ);
             };

文件差異過大導致無法顯示
+ 13 - 13
dist/preview release/babylon.noworker.js


+ 7 - 0
src/Materials/babylon.effect.js

@@ -216,6 +216,13 @@ var BABYLON;
                 }
             }
         };
+        Object.defineProperty(Effect.prototype, "isSupported", {
+            get: function () {
+                return this._compilationError === "";
+            },
+            enumerable: true,
+            configurable: true
+        });
         Effect.prototype._bindTexture = function (channel, texture) {
             this._engine._bindTexture(this._samplers.indexOf(channel), texture);
         };

+ 4 - 0
src/Materials/babylon.effect.ts

@@ -266,6 +266,10 @@
             }
         }
 
+        public get isSupported(): boolean {
+            return this._compilationError === "";
+        }
+
         public _bindTexture(channel: string, texture: WebGLTexture): void {
             this._engine._bindTexture(this._samplers.indexOf(channel), texture);
         }

+ 12 - 0
src/PostProcess/RenderPipeline/babylon.postProcessRenderEffect.js

@@ -12,6 +12,18 @@ var BABYLON;
             this._renderPasses = {};
             this._renderEffectAsPasses = {};
         }
+        Object.defineProperty(PostProcessRenderEffect.prototype, "isSupported", {
+            get: function () {
+                for (var index in this._postProcesses) {
+                    if (!this._postProcesses[index].isSupported) {
+                        return false;
+                    }
+                }
+                return true;
+            },
+            enumerable: true,
+            configurable: true
+        });
         PostProcessRenderEffect.prototype._update = function () {
             for (var renderPassName in this._renderPasses) {
                 this._renderPasses[renderPassName]._update();

+ 9 - 0
src/PostProcess/RenderPipeline/babylon.postProcessRenderEffect.ts

@@ -34,6 +34,15 @@ module BABYLON {
             this._renderEffectAsPasses = {};
         }
 
+        public get isSupported(): boolean {
+            for (var index in this._postProcesses) {
+                if (!this._postProcesses[index].isSupported) {
+                    return false;
+                }
+            }
+            return true;
+        }
+
         public _update(): void {
             for (var renderPassName in this._renderPasses) {
                 this._renderPasses[renderPassName]._update();

+ 21 - 4
src/PostProcess/RenderPipeline/babylon.postProcessRenderPipeline.js

@@ -8,6 +8,18 @@ var BABYLON;
             this._renderEffectsForIsolatedPass = {};
             this._cameras = [];
         }
+        Object.defineProperty(PostProcessRenderPipeline.prototype, "isSupported", {
+            get: function () {
+                for (var renderEffectName in this._renderEffects) {
+                    if (!this._renderEffects[renderEffectName].isSupported) {
+                        return false;
+                    }
+                }
+                return true;
+            },
+            enumerable: true,
+            configurable: true
+        });
         PostProcessRenderPipeline.prototype.addEffect = function (renderEffect) {
             this._renderEffects[renderEffect._name] = renderEffect;
         };
@@ -28,7 +40,8 @@ var BABYLON;
         PostProcessRenderPipeline.prototype._attachCameras = function (cameras, unique) {
             var _cam = BABYLON.Tools.MakeArray(cameras || this._cameras);
             var indicesToDelete = [];
-            for (var i = 0; i < _cam.length; i++) {
+            var i;
+            for (i = 0; i < _cam.length; i++) {
                 var camera = _cam[i];
                 var cameraName = camera.name;
                 if (this._cameras.indexOf(camera) === -1) {
@@ -38,7 +51,7 @@ var BABYLON;
                     indicesToDelete.push(i);
                 }
             }
-            for (var i = 0; i < indicesToDelete.length; i++) {
+            for (i = 0; i < indicesToDelete.length; i++) {
                 cameras.splice(indicesToDelete[i], 1);
             }
             for (var renderEffectName in this._renderEffects) {
@@ -58,7 +71,8 @@ var BABYLON;
             var _this = this;
             var _cam = BABYLON.Tools.MakeArray(cameras || this._cameras);
             var pass = null;
-            for (var renderEffectName in this._renderEffects) {
+            var renderEffectName;
+            for (renderEffectName in this._renderEffects) {
                 pass = this._renderEffects[renderEffectName].getPass(passName);
                 if (pass != null) {
                     break;
@@ -67,7 +81,7 @@ var BABYLON;
             if (pass === null) {
                 return;
             }
-            for (var renderEffectName in this._renderEffects) {
+            for (renderEffectName in this._renderEffects) {
                 this._renderEffects[renderEffectName]._disable(_cam);
             }
             pass._name = PostProcessRenderPipeline.PASS_SAMPLER_NAME;
@@ -104,6 +118,9 @@ var BABYLON;
                 }
             }
         };
+        PostProcessRenderPipeline.prototype.dispose = function () {
+            // Must be implemented by children 
+        };
         PostProcessRenderPipeline.PASS_EFFECT_NAME = "passEffect";
         PostProcessRenderPipeline.PASS_SAMPLER_NAME = "passSampler";
         return PostProcessRenderPipeline;

+ 20 - 6
src/PostProcess/RenderPipeline/babylon.postProcessRenderPipeline.ts

@@ -23,6 +23,16 @@ module BABYLON {
             this._cameras = [];
         }
 
+        public get isSupported(): boolean {
+            for (var renderEffectName in this._renderEffects) {
+                if (!this._renderEffects[renderEffectName].isSupported) {
+                    return false;
+                }
+            }
+
+            return true;
+        }
+
         public addEffect(renderEffect: PostProcessRenderEffect): void {
             this._renderEffects[renderEffect._name] = renderEffect;
         }
@@ -59,8 +69,8 @@ module BABYLON {
             var _cam = Tools.MakeArray(cameras || this._cameras);
 
             var indicesToDelete = [];
-
-            for (var i = 0; i < _cam.length; i++) {
+            var i: number;
+            for (i = 0; i < _cam.length; i++) {
                 var camera = _cam[i];
                 var cameraName = camera.name;
 
@@ -72,7 +82,7 @@ module BABYLON {
                 }
             }
 
-            for (var i = 0; i < indicesToDelete.length; i++) {
+            for (i = 0; i < indicesToDelete.length; i++) {
                 cameras.splice(indicesToDelete[i], 1);
             }
 
@@ -101,8 +111,8 @@ module BABYLON {
             var _cam = Tools.MakeArray(cameras || this._cameras);
 
             var pass = null;
-
-            for (var renderEffectName in this._renderEffects) {
+            var renderEffectName;
+            for (renderEffectName in this._renderEffects) {
                 pass = this._renderEffects[renderEffectName].getPass(passName);
 
                 if (pass != null) {
@@ -114,7 +124,7 @@ module BABYLON {
                 return;
             }
 
-            for (var renderEffectName in this._renderEffects) {
+            for (renderEffectName in this._renderEffects) {
                 this._renderEffects[renderEffectName]._disable(_cam);
             }
 
@@ -163,5 +173,9 @@ module BABYLON {
                 }
             }
         }
+
+        public dispose() {
+           // Must be implemented by children 
+        }
     }
 }

+ 8 - 1
src/PostProcess/RenderPipeline/babylon.postProcessRenderPipelineManager.js

@@ -51,7 +51,14 @@ var BABYLON;
         };
         PostProcessRenderPipelineManager.prototype.update = function () {
             for (var renderPipelineName in this._renderPipelines) {
-                this._renderPipelines[renderPipelineName]._update();
+                var pipeline = this._renderPipelines[renderPipelineName];
+                if (!pipeline.isSupported) {
+                    pipeline.dispose();
+                    delete this._renderPipelines[renderPipelineName];
+                }
+                else {
+                    pipeline._update();
+                }
             }
         };
         return PostProcessRenderPipelineManager;

+ 7 - 1
src/PostProcess/RenderPipeline/babylon.postProcessRenderPipelineManager.ts

@@ -84,7 +84,13 @@ module BABYLON {
 
         public update(): void {
             for (var renderPipelineName in this._renderPipelines) {
-                this._renderPipelines[renderPipelineName]._update();
+                var pipeline = this._renderPipelines[renderPipelineName];
+                if (!pipeline.isSupported) {
+                    pipeline.dispose();
+                    delete this._renderPipelines[renderPipelineName];
+                } else {
+                    pipeline._update();
+                }
             }
         }
     }

+ 4 - 4
src/PostProcess/babylon.lensRenderingPipeline.js

@@ -91,7 +91,7 @@ var BABYLON;
             this.addEffect(new BABYLON.PostProcessRenderEffect(scene.getEngine(), this.LensChromaticAberrationEffect, function () { return _this._chromaticAberrationPostProcess; }, true));
             this.addEffect(new BABYLON.PostProcessRenderEffect(scene.getEngine(), this.HighlightsEnhancingEffect, function () { return _this._highlightsPostProcess; }, true));
             this.addEffect(new BABYLON.PostProcessRenderEffect(scene.getEngine(), this.LensDepthOfFieldEffect, function () { return _this._depthOfFieldPostProcess; }, true));
-            if (this._highlightsGain == -1) {
+            if (this._highlightsGain === -1) {
                 this._disableEffect(this.HighlightsEnhancingEffect, null);
             }
             // Finish
@@ -121,7 +121,7 @@ var BABYLON;
             this._highlightsGain = amount;
         };
         LensRenderingPipeline.prototype.setHighlightsThreshold = function (amount) {
-            if (this._highlightsGain == -1) {
+            if (this._highlightsGain === -1) {
                 this._highlightsGain = 1.0;
             }
             this._highlightsThreshold = amount;
@@ -186,12 +186,12 @@ var BABYLON;
                 effect.setFloat('screen_width', _this._scene.getEngine().getRenderingCanvas().width);
                 effect.setFloat('screen_height', _this._scene.getEngine().getRenderingCanvas().height);
                 effect.setFloat('distortion', _this._distortion);
-                effect.setBool('dof_enabled', (_this._dofDistance != -1));
+                effect.setBool('dof_enabled', (_this._dofDistance !== -1));
                 effect.setFloat('screen_distance', 1.0 / (0.1 - 1.0 / _this._dofDistance));
                 effect.setFloat('aperture', _this._dofAperture);
                 effect.setFloat('darken', _this._dofDarken);
                 effect.setFloat('edge_blur', _this._edgeBlur);
-                effect.setBool('highlights', (_this._highlightsGain != -1));
+                effect.setBool('highlights', (_this._highlightsGain !== -1));
                 effect.setFloat('near', _this._scene.activeCamera.minZ);
                 effect.setFloat('far', _this._scene.activeCamera.maxZ);
             };

+ 4 - 4
src/PostProcess/babylon.lensRenderingPipeline.ts

@@ -109,7 +109,7 @@ module BABYLON {
             this.addEffect(new PostProcessRenderEffect(scene.getEngine(), this.HighlightsEnhancingEffect, () => { return this._highlightsPostProcess; }, true));
             this.addEffect(new PostProcessRenderEffect(scene.getEngine(), this.LensDepthOfFieldEffect, () => { return this._depthOfFieldPostProcess; }, true));
 
-            if (this._highlightsGain == -1) {
+            if (this._highlightsGain === -1) {
                 this._disableEffect(this.HighlightsEnhancingEffect, null);
             }
 
@@ -142,7 +142,7 @@ module BABYLON {
             this._highlightsGain = amount;
         }
         public setHighlightsThreshold(amount: number) {
-            if (this._highlightsGain == -1) {
+            if (this._highlightsGain === -1) {
                 this._highlightsGain = 1.0;
             }
             this._highlightsThreshold = amount;
@@ -226,14 +226,14 @@ module BABYLON {
 
                 effect.setFloat('distortion', this._distortion);
 
-                effect.setBool('dof_enabled', (this._dofDistance != -1));
+                effect.setBool('dof_enabled', (this._dofDistance !== -1));
                 effect.setFloat('screen_distance', 1.0 / (0.1 - 1.0 / this._dofDistance));
                 effect.setFloat('aperture', this._dofAperture);
                 effect.setFloat('darken', this._dofDarken);
 
                 effect.setFloat('edge_blur', this._edgeBlur);
 
-                effect.setBool('highlights', (this._highlightsGain != -1));
+                effect.setBool('highlights', (this._highlightsGain !== -1));
 
                 effect.setFloat('near', this._scene.activeCamera.minZ);
                 effect.setFloat('far', this._scene.activeCamera.maxZ);

+ 7 - 0
src/PostProcess/babylon.postProcess.js

@@ -70,6 +70,13 @@ var BABYLON;
                 this._currentRenderTextureInd = (this._currentRenderTextureInd + 1) % 2;
             }
         };
+        Object.defineProperty(PostProcess.prototype, "isSupported", {
+            get: function () {
+                return this._effect.isSupported;
+            },
+            enumerable: true,
+            configurable: true
+        });
         PostProcess.prototype.apply = function () {
             // Check
             if (!this._effect.isReady())

+ 4 - 0
src/PostProcess/babylon.postProcess.ts

@@ -99,6 +99,10 @@
             }
         }
 
+        public get isSupported(): boolean {
+            return this._effect.isSupported;
+        }
+
         public apply(): Effect {
             // Check
             if (!this._effect.isReady())

+ 1 - 0
src/babylon.engine.ts

@@ -1272,6 +1272,7 @@
             this._gl.attachShader(shaderProgram, fragmentShader);
 
             this._gl.linkProgram(shaderProgram);
+
             var linked = this._gl.getProgramParameter(shaderProgram, this._gl.LINK_STATUS);
 
             if (!linked) {