Benjamin Guignabert 5 år sedan
förälder
incheckning
861ec3bab7

+ 10 - 2
src/Engines/thinEngine.ts

@@ -1343,8 +1343,16 @@ export class ThinEngine {
         // If MSAA, we need to bitblt back to main texture
         var gl = this._gl;
         if (texture._MSAAFramebuffer) {
-            this.unBindMultiColorAttachmentFramebuffer(texture._textureCount!, texture._textureArray!, disableGenerateMipMaps, onBeforeUnbind);
-            return;
+            if (texture._textureArray) {
+                // This texture is part of a MRT texture, we need to treat all attachments
+                this.unBindMultiColorAttachmentFramebuffer(texture._textureCount!, texture._textureArray!, disableGenerateMipMaps, onBeforeUnbind);
+                return;
+            }
+            gl.bindFramebuffer(gl.READ_FRAMEBUFFER, texture._MSAAFramebuffer);
+            gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, texture._framebuffer);
+            gl.blitFramebuffer(0, 0, texture.width, texture.height,
+                0, 0, texture.width, texture.height,
+                gl.COLOR_BUFFER_BIT, gl.NEAREST);
         }
 
         if (texture.generateMipMaps && !disableGenerateMipMaps && !texture.isCube) {

+ 0 - 2
src/Materials/PBR/pbrSubSurfaceConfiguration.ts

@@ -43,7 +43,6 @@ export interface IMaterialSubSurfaceDefines {
     _areTexturesDirty: boolean;
 }
 
-
 /**
  * Define the code related to the sub surface parameters of the pbr material.
  */
@@ -378,7 +377,6 @@ export class PBRSubSurfaceConfiguration {
                 }
             }
 
-
             if (this.isScatteringEnabled) {
                 uniformBuffer.updateFloat("scatteringDiffusionProfile", this.scatteringDiffusionProfileIndex);
             }

+ 2 - 4
src/Materials/material.ts

@@ -229,7 +229,6 @@ export class Material implements IAnimatable {
     @serialize()
     public state = "";
 
-
     /**
      * If the material should be rendered to several textures with MRT extension
      */
@@ -1248,15 +1247,14 @@ export class Material implements IAnimatable {
         }
 
         const prePassRenderer = this.getScene().enablePrePassRenderer();
-        
         if (prePassRenderer) {
             prePassRenderer.markAsDirty();
         }
     }
 
     /**
- * Indicates that we need to re-calculated for all submeshes
- */
+     * Indicates that we need to re-calculated for all submeshes
+     */
     protected _markAllSubMeshesAsAllDirty() {
         this._markAllSubMeshesAsDirty(Material._AllDirtyCallBack);
     }

+ 5 - 6
src/Rendering/prePassRenderer.ts

@@ -87,8 +87,8 @@ export class PrePassRenderer {
             this._multiRenderAttachments.push((<any>gl)["COLOR_ATTACHMENT" + i]);
 
             if (i > 0) {
-                this._clearAttachments.push((<any>gl)["COLOR_ATTACHMENT" + i])
-                this._defaultAttachments.push(gl.NONE)
+                this._clearAttachments.push((<any>gl)["COLOR_ATTACHMENT" + i]);
+                this._defaultAttachments.push(gl.NONE);
             }
         }
     }
@@ -103,7 +103,7 @@ export class PrePassRenderer {
             if (effect._multiTarget) {
                 this._engine.renderToAttachments(this._multiRenderAttachments);
             } else {
-                this._engine.renderToAttachments(this._defaultAttachments);      
+                this._engine.renderToAttachments(this._defaultAttachments);
             }
         }
     }
@@ -203,7 +203,6 @@ export class PrePassRenderer {
         }
     }
 
-
     public addDiffusionProfile(color: Color3) : number {
         if (this.ssDiffusionD.length >= 5) {
             // We only suppport 5 diffusion profiles
@@ -213,8 +212,8 @@ export class PrePassRenderer {
 
         // Do not add doubles
         for (let i = 0; i < this.ssDiffusionS.length / 3; i++) {
-            if (this.ssDiffusionS[i * 3] === color.r && 
-                this.ssDiffusionS[i * 3 + 1] === color.g && 
+            if (this.ssDiffusionS[i * 3] === color.r &&
+                this.ssDiffusionS[i * 3 + 1] === color.g &&
                 this.ssDiffusionS[i * 3 + 2] === color.b) {
                 return i;
             }