Parcourir la source

fixing comment

Benjamin Guignabert il y a 5 ans
Parent
commit
29d5e647d8
2 fichiers modifiés avec 10 ajouts et 29 suppressions
  1. 0 27
      src/Engines/Extensions/engine.multiRender.ts
  2. 10 2
      src/Rendering/prePassRenderer.ts

+ 0 - 27
src/Engines/Extensions/engine.multiRender.ts

@@ -4,7 +4,6 @@ import { Logger } from '../../Misc/logger';
 import { Nullable } from '../../types';
 import { Constants } from '../constants';
 import { ThinEngine } from '../thinEngine';
-import { IColor4Like } from '../../Maths/math.like';
 
 declare module "../../Engines/thinEngine" {
     export interface ThinEngine {
@@ -38,14 +37,6 @@ declare module "../../Engines/thinEngine" {
         updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
 
         /**
-         * Clears attachments
-         * @param texture texture to clear
-         * @param attachments attachments to clear
-         * @param color Clear color
-         */
-        clearColorAttachments(texture: InternalTexture, attachments: number[], color?: IColor4Like) : void;
-
-        /**
          * Select a subsets of attachments to draw to.
          * @param attachments gl attachments
          */
@@ -59,24 +50,6 @@ ThinEngine.prototype.renderToAttachments = function(attachments: any[]): void {
     gl.drawBuffers(attachments);
 };
 
-ThinEngine.prototype.clearColorAttachments = function(texture: InternalTexture, attachments: number[], color?: IColor4Like): void {
-    // Default clear everything to transparent black
-    const gl = this._gl;
-
-    // We don't clear the first attachments which is cleared with the user clear color
-    gl.drawBuffers(attachments);
-    if (color) {
-        gl.clearColor(color.r, color.g, color.b, color.a);
-    } else {
-        gl.clearColor(0, 0, 0, 0);
-    }
-
-    gl.clear(gl.COLOR_BUFFER_BIT);
-
-    // Restore default attachments
-    gl.drawBuffers(texture._attachments!);
-};
-
 ThinEngine.prototype.unBindMultiColorAttachmentFramebuffer = function(textures: InternalTexture[], disableGenerateMipMaps: boolean = false, onBeforeUnbind?: () => void): void {
     this._currentRenderTarget = null;
 

+ 10 - 2
src/Rendering/prePassRenderer.ts

@@ -8,7 +8,7 @@ import { SubSurfaceScatteringPostProcess } from "../PostProcesses/subSurfaceScat
 import { Effect } from "../Materials/effect";
 import { Logger } from "../Misc/logger";
 import { _DevTools } from '../Misc/devTools';
-import { Color3 } from "../Maths/math.color";
+import { Color3, Color4 } from "../Maths/math.color";
 
 /**
  * Renders a pre pass of the scene
@@ -45,6 +45,8 @@ export class PrePassRenderer {
     private _defaultAttachments: number[];
     private _clearAttachments: number[];
 
+    private readonly _clearColor = new Color4(0, 0, 0, 0);
+
     private _ssDiffusionS: number[] = [];
     private _ssFilterRadii: number[] = [];
     private _ssDiffusionD: number[] = [];
@@ -231,11 +233,17 @@ export class PrePassRenderer {
     public clear() {
         if (this._enabled) {
             this._bindFrameBuffer();
+
+            // Regular clear color with the scene clear color of the 1st attachment
             this._engine.clear(this._scene.clearColor,
                 this._scene.autoClear || this._scene.forceWireframe || this._scene.forcePointsCloud,
                 this._scene.autoClearDepthAndStencil,
                 this._scene.autoClearDepthAndStencil);
-            this._engine.clearColorAttachments(this.prePassRT.getInternalTexture()!, this._clearAttachments);
+
+            // Clearing other attachment with 0 on all other attachments
+            this._engine.renderToAttachments(this._clearAttachments);
+            this._engine.clear(this._clearColor, true, false, false);
+            this._engine.renderToAttachments(this._multiRenderAttachments);
         }
     }