فهرست منبع

Avoid generating mipmaps two times when rendering to a RTT that is also using post processes

Popov72 4 سال پیش
والد
کامیت
f24e4e4250
1فایلهای تغییر یافته به همراه8 افزوده شده و 0 حذف شده
  1. 8 0
      src/Materials/Textures/renderTargetTexture.ts

+ 8 - 0
src/Materials/Textures/renderTargetTexture.ts

@@ -899,6 +899,12 @@ export class RenderTargetTexture extends Texture {
             step.action(this);
         }
 
+        const saveGenerateMipMaps = this._texture.generateMipMaps;
+
+        this._texture.generateMipMaps = false;  // if left true, the mipmaps will be generated (if this._texture.generateMipMaps = true) when the first post process binds its own RTT: by doing so it will unbind the current RTT,
+                                                // which will trigger a mipmap generation. We don't want this because it's a wasted work, we will do an unbind of the current RTT at the end of the process (see unbindFrameBuffer) which will
+                                                // trigger the generation of the final mipmaps
+
         if (this._postProcessManager) {
             this._postProcessManager._finalizeFrame(false, this._texture, faceIndex, this._postProcesses, this.ignoreCameraViewport);
         }
@@ -906,6 +912,8 @@ export class RenderTargetTexture extends Texture {
             scene.postProcessManager._finalizeFrame(false, this._texture, faceIndex);
         }
 
+        this._texture.generateMipMaps = saveGenerateMipMaps;
+
         if (!this._doNotChangeAspectRatio) {
             scene.updateTransformMatrix(true);
         }