Pārlūkot izejas kodu

Improved clear buffer algorithm

David Catuhe 9 gadi atpakaļ
vecāks
revīzija
9f81aa0ecf

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 5 - 5
dist/preview release/babylon.core.js


Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 1234 - 1234
dist/preview release/babylon.d.ts


Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 5 - 5
dist/preview release/babylon.js


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

@@ -5570,15 +5570,19 @@ var BABYLON;
         };
         Engine.prototype.clear = function (color, backBuffer, depthStencil) {
             this.applyStates();
-            this._gl.clearColor(color.r, color.g, color.b, color.a !== undefined ? color.a : 1.0);
-            if (this._depthCullingState.depthMask) {
+            if (backBuffer) {
+                this._gl.clearColor(color.r, color.g, color.b, color.a !== undefined ? color.a : 1.0);
+            }
+            if (depthStencil && this._depthCullingState.depthMask) {
                 this._gl.clearDepth(1.0);
             }
             var mode = 0;
-            if (backBuffer)
+            if (backBuffer) {
                 mode |= this._gl.COLOR_BUFFER_BIT;
-            if (depthStencil && this._depthCullingState.depthMask)
+            }
+            if (depthStencil && this._depthCullingState.depthMask) {
                 mode |= this._gl.DEPTH_BUFFER_BIT;
+            }
             this._gl.clear(mode);
         };
         /**
@@ -11862,7 +11866,7 @@ var BABYLON;
             this._currentRenderParticles = renderParticles;
             this._currentRenderSprites = renderSprites;
             for (var index = 0; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {
-                this._depthBufferAlreadyCleaned = false;
+                this._depthBufferAlreadyCleaned = index == 0;
                 var renderingGroup = this._renderingGroups[index];
                 var needToStepBack = false;
                 this._currentIndex = index;

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 5 - 5
dist/preview release/babylon.noworker.js


+ 1 - 1
src/Rendering/babylon.renderingManager.js

@@ -63,7 +63,7 @@ var BABYLON;
             this._currentRenderParticles = renderParticles;
             this._currentRenderSprites = renderSprites;
             for (var index = 0; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {
-                this._depthBufferAlreadyCleaned = false;
+                this._depthBufferAlreadyCleaned = index == 0;
                 var renderingGroup = this._renderingGroups[index];
                 var needToStepBack = false;
                 this._currentIndex = index;

+ 1 - 1
src/Rendering/babylon.renderingManager.ts

@@ -89,7 +89,7 @@
             this._currentRenderSprites = renderSprites;
 
             for (var index = 0; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {
-                this._depthBufferAlreadyCleaned = false;
+                this._depthBufferAlreadyCleaned = index == 0;
                 var renderingGroup = this._renderingGroups[index];
                 var needToStepBack = false;
 

+ 8 - 4
src/babylon.engine.js

@@ -778,15 +778,19 @@ var BABYLON;
         };
         Engine.prototype.clear = function (color, backBuffer, depthStencil) {
             this.applyStates();
-            this._gl.clearColor(color.r, color.g, color.b, color.a !== undefined ? color.a : 1.0);
-            if (this._depthCullingState.depthMask) {
+            if (backBuffer) {
+                this._gl.clearColor(color.r, color.g, color.b, color.a !== undefined ? color.a : 1.0);
+            }
+            if (depthStencil && this._depthCullingState.depthMask) {
                 this._gl.clearDepth(1.0);
             }
             var mode = 0;
-            if (backBuffer)
+            if (backBuffer) {
                 mode |= this._gl.COLOR_BUFFER_BIT;
-            if (depthStencil && this._depthCullingState.depthMask)
+            }
+            if (depthStencil && this._depthCullingState.depthMask) {
                 mode |= this._gl.DEPTH_BUFFER_BIT;
+            }
             this._gl.clear(mode);
         };
         /**

+ 9 - 4
src/babylon.engine.ts

@@ -881,17 +881,22 @@
         public clear(color: any, backBuffer: boolean, depthStencil: boolean): void {
             this.applyStates();
 
-            this._gl.clearColor(color.r, color.g, color.b, color.a !== undefined ? color.a : 1.0);
-            if (this._depthCullingState.depthMask) {
+            if (backBuffer) {
+                this._gl.clearColor(color.r, color.g, color.b, color.a !== undefined ? color.a : 1.0);
+            }
+
+            if (depthStencil && this._depthCullingState.depthMask) {
                 this._gl.clearDepth(1.0);
             }
             var mode = 0;
 
-            if (backBuffer)
+            if (backBuffer) {
                 mode |= this._gl.COLOR_BUFFER_BIT;
+            }
 
-            if (depthStencil && this._depthCullingState.depthMask)
+            if (depthStencil && this._depthCullingState.depthMask) {
                 mode |= this._gl.DEPTH_BUFFER_BIT;
+            }
 
             this._gl.clear(mode);
         }