Prechádzať zdrojové kódy

added pp.aspectRatio and better alpha management

David Catuhe 8 rokov pred
rodič
commit
d3146519dd

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 712 - 710
dist/preview release/babylon.d.ts


Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 31 - 31
dist/preview release/babylon.js


+ 19 - 6
dist/preview release/babylon.max.js

@@ -15246,6 +15246,7 @@ var BABYLON;
         function Scene(engine) {
             // Members
             this.autoClear = true;
+            this.autoClearDepthAndStencil = true;
             this.clearColor = new BABYLON.Color4(0.2, 0.2, 0.3, 1.0);
             this.ambientColor = new BABYLON.Color3(0, 0, 0);
             this.forceWireframe = false;
@@ -17627,7 +17628,9 @@ var BABYLON;
                 BABYLON.Tools.EndPerformanceCounter("Procedural textures", this._proceduralTextures.length > 0);
             }
             // Clear
-            this._engine.clear(this.clearColor, this.autoClear || this.forceWireframe || this.forcePointsCloud, true, true);
+            if (this.autoClearDepthAndStencil || this.autoClear) {
+                this._engine.clear(this.clearColor, this.autoClear || this.forceWireframe || this.forcePointsCloud, this.autoClearDepthAndStencil, this.autoClearDepthAndStencil);
+            }
             // Shadows
             if (this.shadowsEnabled) {
                 for (var lightIndex = 0; lightIndex < this.lights.length; lightIndex++) {
@@ -43792,11 +43795,6 @@ var BABYLON;
             if (this._reusable) {
                 this._currentRenderTextureInd = (this._currentRenderTextureInd + 1) % 2;
             }
-            // Alpha
-            this._engine.setAlphaMode(this.alphaMode);
-            if (this.alphaConstants) {
-                this.getEngine().setAlphaConstants(this.alphaConstants.r, this.alphaConstants.g, this.alphaConstants.b, this.alphaConstants.a);
-            }
         };
         Object.defineProperty(PostProcess.prototype, "isSupported", {
             get: function () {
@@ -43805,6 +43803,16 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
+        Object.defineProperty(PostProcess.prototype, "aspectRatio", {
+            get: function () {
+                if (this._shareOutputWithPostProcess) {
+                    return this._shareOutputWithPostProcess.aspectRatio;
+                }
+                return this.width / this.height;
+            },
+            enumerable: true,
+            configurable: true
+        });
         PostProcess.prototype.apply = function () {
             // Check
             if (!this._effect || !this._effect.isReady())
@@ -43814,6 +43822,11 @@ var BABYLON;
             this._engine.setState(false);
             this._engine.setDepthBuffer(false);
             this._engine.setDepthWrite(false);
+            // Alpha
+            this._engine.setAlphaMode(this.alphaMode);
+            if (this.alphaConstants) {
+                this.getEngine().setAlphaConstants(this.alphaConstants.r, this.alphaConstants.g, this.alphaConstants.b, this.alphaConstants.a);
+            }
             // Texture            
             var source = this._shareOutputWithPostProcess ? this._shareOutputWithPostProcess.outputTexture : this.outputTexture;
             this._effect._bindTexture("textureSampler", source);

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 712 - 710
dist/preview release/babylon.module.d.ts


Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 31 - 31
dist/preview release/babylon.worker.js


+ 14 - 6
src/PostProcess/babylon.postProcess.ts

@@ -265,17 +265,19 @@
             if (this._reusable) {
                 this._currentRenderTextureInd = (this._currentRenderTextureInd + 1) % 2;
             }
-
-            // Alpha
-            this._engine.setAlphaMode(this.alphaMode);
-            if (this.alphaConstants) {
-                this.getEngine().setAlphaConstants(this.alphaConstants.r, this.alphaConstants.g, this.alphaConstants.b, this.alphaConstants.a);
-            }
         }
 
         public get isSupported(): boolean {
             return this._effect.isSupported;
         }
+
+        public get aspectRatio(): number {
+            if (this._shareOutputWithPostProcess) {
+                return this._shareOutputWithPostProcess.aspectRatio;
+            }
+
+            return this.width / this.height;
+        }
         
         public apply(): Effect {
             // Check
@@ -288,6 +290,12 @@
             this._engine.setDepthBuffer(false);
             this._engine.setDepthWrite(false);
 
+            // Alpha
+            this._engine.setAlphaMode(this.alphaMode);
+            if (this.alphaConstants) {
+                this.getEngine().setAlphaConstants(this.alphaConstants.r, this.alphaConstants.g, this.alphaConstants.b, this.alphaConstants.a);
+            }            
+
             // Texture            
             var source = this._shareOutputWithPostProcess ? this._shareOutputWithPostProcess.outputTexture : this.outputTexture;
             this._effect._bindTexture("textureSampler", source);

+ 4 - 1
src/babylon.scene.ts

@@ -186,6 +186,7 @@
 
         // Members
         public autoClear = true;
+        public autoClearDepthAndStencil = true;
         public clearColor: Color4 = new Color4(0.2, 0.2, 0.3, 1.0);
         public ambientColor = new Color3(0, 0, 0);
 
@@ -2956,7 +2957,9 @@
             }
 
             // Clear
-            this._engine.clear(this.clearColor, this.autoClear || this.forceWireframe || this.forcePointsCloud, true, true);
+            if (this.autoClearDepthAndStencil || this.autoClear) {
+                this._engine.clear(this.clearColor, this.autoClear || this.forceWireframe || this.forcePointsCloud, this.autoClearDepthAndStencil, this.autoClearDepthAndStencil);
+            }
 
             // Shadows
             if (this.shadowsEnabled) {