@@ -26,7 +26,7 @@ import { Matrix4 } from '../../math/Matrix4.js';
2626import { Vector2 } from '../../math/Vector2.js' ;
2727import { Vector4 } from '../../math/Vector4.js' ;
2828import { RenderTarget } from '../../core/RenderTarget.js' ;
29- import { DoubleSide , BackSide , FrontSide , SRGBColorSpace , NoToneMapping , LinearFilter , LinearSRGBColorSpace , HalfFloatType , RGBAFormat , PCFShadowMap } from '../../constants.js' ;
29+ import { DoubleSide , BackSide , FrontSide , SRGBColorSpace , NoToneMapping , LinearFilter , LinearSRGBColorSpace , HalfFloatType , RGBAFormat , PCFShadowMap , UnsignedByteType } from '../../constants.js' ;
3030
3131/** @module Renderer **/
3232
@@ -1121,14 +1121,21 @@ class Renderer {
11211121 const { width, height } = this . getDrawingBufferSize ( _drawingBufferSize ) ;
11221122 const { depth, stencil } = this ;
11231123
1124+ // to improve performance we only want to use HalfFloatType if necessary
1125+ // HalfFloatType is required when a) tone mapping is used or b) the backend specifically requests it
1126+
1127+ const type = ( useToneMapping || this . backend . needsHalfFloatFrameBufferTarget ( ) ) ? HalfFloatType : UnsignedByteType ;
1128+
11241129 let frameBufferTarget = this . _frameBufferTarget ;
11251130
1126- if ( frameBufferTarget === null ) {
1131+ if ( frameBufferTarget === null || this . _frameBufferTarget . texture . type !== type ) {
1132+
1133+ if ( frameBufferTarget !== null ) frameBufferTarget . dispose ( ) ;
11271134
11281135 frameBufferTarget = new RenderTarget ( width , height , {
11291136 depthBuffer : depth ,
11301137 stencilBuffer : stencil ,
1131- type : HalfFloatType , // FloatType
1138+ type : type ,
11321139 format : RGBAFormat ,
11331140 colorSpace : LinearSRGBColorSpace ,
11341141 generateMipmaps : false ,
0 commit comments