浏览代码

Now bind draw buffers correctly + removed conflict with depth renderer (gl.COLOR_ATTACHMENT_0 !== COLOR_ATTACHMENT0_WEBGL) + disable generate depth texture in geometry renderer

Julien Moreau-Mathis 8 年之前
父节点
当前提交
b2e620e107
共有 2 个文件被更改,包括 4 次插入4 次删除
  1. 1 1
      src/Rendering/babylon.geometryBufferRenderer.ts
  2. 3 3
      src/babylon.engine.ts

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

@@ -123,7 +123,7 @@ module BABYLON {
             var engine = this._scene.getEngine();
             var engine = this._scene.getEngine();
             var count = this._enablePosition ? 3 : 2;
             var count = this._enablePosition ? 3 : 2;
 
 
-            this._multiRenderTarget = new MultiRenderTarget("gBuffer", { width: engine.getRenderWidth() * this._ratio, height: engine.getRenderHeight() * this._ratio }, count, this._scene, { generateMipMaps : false, generateDepthTexture: true });
+            this._multiRenderTarget = new MultiRenderTarget("gBuffer", { width: engine.getRenderWidth() * this._ratio, height: engine.getRenderHeight() * this._ratio }, count, this._scene, { generateMipMaps : false, generateDepthTexture: false });
             if (!this.isSupported) {
             if (!this.isSupported) {
                 return null;
                 return null;
             }
             }

+ 3 - 3
src/babylon.engine.ts

@@ -1075,11 +1075,11 @@
 
 
                 if (drawBuffersExtension !== null) {
                 if (drawBuffersExtension !== null) {
                     this._caps.drawBuffersExtension = true;
                     this._caps.drawBuffersExtension = true;
-                    this._gl.drawBuffers = drawBuffersExtension.drawBuffersWEBGL;
+                    this._gl.drawBuffers = drawBuffersExtension.drawBuffersWEBGL.bind(drawBuffersExtension);
                     this._gl.DRAW_FRAMEBUFFER = this._gl.FRAMEBUFFER;
                     this._gl.DRAW_FRAMEBUFFER = this._gl.FRAMEBUFFER;
                     
                     
                     for (var i = 0; i < 16; i++) {
                     for (var i = 0; i < 16; i++) {
-                        this._gl["COLOR_ATTACHMENT" + i] = drawBuffersExtension["COLOR_ATTACHMENT" + i + "_WEBGL"];
+                        this._gl["COLOR_ATTACHMENT" + i + "_WEBGL"] = drawBuffersExtension["COLOR_ATTACHMENT" + i + "_WEBGL"];
                     }
                     }
                 } else {
                 } else {
                     this._caps.drawBuffersExtension = false;
                     this._caps.drawBuffersExtension = false;
@@ -3234,7 +3234,7 @@
                 }
                 }
 
 
                 var texture = new InternalTexture(this, InternalTexture.DATASOURCE_MULTIRENDERTARGET);
                 var texture = new InternalTexture(this, InternalTexture.DATASOURCE_MULTIRENDERTARGET);
-                var attachment = gl["COLOR_ATTACHMENT" + i];
+                var attachment = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
                 
                 
                 textures.push(texture);
                 textures.push(texture);
                 attachments.push(attachment);
                 attachments.push(attachment);