From 3d6e8f7e82c3ee946746429307f77388bfeff8e4 Mon Sep 17 00:00:00 2001 From: sunag Date: Sun, 7 Dec 2025 23:16:11 -0300 Subject: [PATCH 1/6] Rename `.getColorBufferType()` -> `.getOutputBufferType()` --- src/nodes/display/PassNode.js | 2 +- src/renderers/common/Renderer.js | 30 +++++++++++++++++++------- src/renderers/webgpu/WebGPURenderer.js | 2 +- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/nodes/display/PassNode.js b/src/nodes/display/PassNode.js index 1f1f6c70d68297..af65c3eac03ed7 100644 --- a/src/nodes/display/PassNode.js +++ b/src/nodes/display/PassNode.js @@ -736,7 +736,7 @@ class PassNode extends TempNode { this.renderTarget.samples = this.options.samples === undefined ? renderer.samples : this.options.samples; - this.renderTarget.texture.type = renderer.getColorBufferType(); + this.renderTarget.texture.type = renderer.getOutputBufferType(); return this.scope === PassNode.COLOR ? this.getTextureNode() : this.getLinearDepthNode(); diff --git a/src/renderers/common/Renderer.js b/src/renderers/common/Renderer.js index 510c95a1955d49..9bc935a9071b89 100644 --- a/src/renderers/common/Renderer.js +++ b/src/renderers/common/Renderer.js @@ -64,7 +64,7 @@ class Renderer { * @property {number} [samples=0] - When `antialias` is `true`, `4` samples are used by default. This parameter can set to any other integer value than 0 * to overwrite the default. * @property {?Function} [getFallback=null] - This callback function can be used to provide a fallback backend, if the primary backend can't be targeted. - * @property {number} [colorBufferType=HalfFloatType] - Defines the type of color buffers. The default `HalfFloatType` is recommend for best + * @property {number} [outputBufferType=HalfFloatType] - Defines the type of output buffers. The default `HalfFloatType` is recommend for best * quality. To save memory and bandwidth, `UnsignedByteType` might be used. This will reduce rendering quality though. * @property {boolean} [multiview=false] - If set to `true`, the renderer will use multiview during WebXR rendering if supported. */ @@ -97,7 +97,7 @@ class Renderer { antialias = false, samples = 0, getFallback = null, - colorBufferType = HalfFloatType, + outputBufferType = HalfFloatType, multiview = false } = parameters; @@ -584,7 +584,7 @@ class Renderer { this.onDeviceLost = this._onDeviceLost; /** - * Defines the type of color buffers. The default `HalfFloatType` is recommend for + * Defines the type of output buffers. The default `HalfFloatType` is recommend for * best quality. To save memory and bandwidth, `UnsignedByteType` might be used. * This will reduce rendering quality though. * @@ -592,7 +592,7 @@ class Renderer { * @type {number} * @default HalfFloatType */ - this._colorBufferType = colorBufferType; + this._outputBufferType = outputBufferType; /** * A cache for shadow nodes per material @@ -1084,13 +1084,27 @@ class Renderer { } /** - * Returns the color buffer type. + * Returns the output buffer type. * - * @return {number} The color buffer type. + * @return {number} The output buffer type. + */ + getOutputBufferType() { + + return this._outputBufferType; + + } + + /** + * Returns the output buffer type. + * + * @deprecated Use `.getOutputBufferType()` instead. + * @return {number} The output buffer type. */ getColorBufferType() { - return this._colorBufferType; + warnOnce( 'Renderer: ".getColorBufferType()" has been renamed to ".getOutputBufferType()".' ); // r182 + + return this.getOutputBufferType(); } @@ -1266,7 +1280,7 @@ class Renderer { frameBufferTarget = new RenderTarget( width, height, { depthBuffer: depth, stencilBuffer: stencil, - type: this._colorBufferType, + type: this._outputBufferType, format: RGBAFormat, colorSpace: ColorManagement.workingColorSpace, generateMipmaps: false, diff --git a/src/renderers/webgpu/WebGPURenderer.js b/src/renderers/webgpu/WebGPURenderer.js index 0b7756305e10b4..1e3ce9a2ec6e6e 100644 --- a/src/renderers/webgpu/WebGPURenderer.js +++ b/src/renderers/webgpu/WebGPURenderer.js @@ -40,7 +40,7 @@ class WebGPURenderer extends Renderer { * @property {boolean} [forceWebGL=false] - If set to `true`, the renderer uses a WebGL 2 backend no matter if WebGPU is supported or not. * @property {boolean} [multiview=false] - If set to `true`, the renderer will use multiview during WebXR rendering if supported. * @property {number} [outputType=undefined] - Texture type for output to canvas. By default, device's preferred format is used; other formats may incur overhead. - * @property {number} [colorBufferType=HalfFloatType] - Defines the type of color buffers. The default `HalfFloatType` is recommend for best + * @property {number} [outputBufferType=HalfFloatType] - Defines the type of output buffers. The default `HalfFloatType` is recommend for best * quality. To save memory and bandwidth, `UnsignedByteType` might be used. This will reduce rendering quality though. */ From b2d5982d3bcff7ac93558eb7379537fd8a16b04d Mon Sep 17 00:00:00 2001 From: sunag Date: Sun, 7 Dec 2025 23:17:22 -0300 Subject: [PATCH 2/6] Improve `getPreferredCanvasFormat()` buffer type setup --- src/renderers/webgpu/utils/WebGPUUtils.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/renderers/webgpu/utils/WebGPUUtils.js b/src/renderers/webgpu/utils/WebGPUUtils.js index de4b4f28a52349..4004312bf8e180 100644 --- a/src/renderers/webgpu/utils/WebGPUUtils.js +++ b/src/renderers/webgpu/utils/WebGPUUtils.js @@ -220,23 +220,31 @@ class WebGPUUtils { */ getPreferredCanvasFormat() { - const outputType = this.backend.parameters.outputType; + const parameters = this.backend.parameters; - if ( outputType === undefined ) { + let bufferType = parameters.outputBufferType; + + if ( bufferType === undefined ) { + + bufferType = parameters.outputType; + + } + + if ( bufferType === undefined ) { return navigator.gpu.getPreferredCanvasFormat(); - } else if ( outputType === UnsignedByteType ) { + } else if ( bufferType === UnsignedByteType ) { return GPUTextureFormat.BGRA8Unorm; - } else if ( outputType === HalfFloatType ) { + } else if ( bufferType === HalfFloatType ) { return GPUTextureFormat.RGBA16Float; } else { - throw new Error( 'Unsupported outputType' ); + throw new Error( 'Unsupported buffer type' ); } From 7278b5d5332bb85440606c88035e2726279879f6 Mon Sep 17 00:00:00 2001 From: sunag Date: Sun, 7 Dec 2025 23:17:24 -0300 Subject: [PATCH 3/6] Update webgpu_xr_rollercoaster.html --- examples/webgpu_xr_rollercoaster.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/webgpu_xr_rollercoaster.html b/examples/webgpu_xr_rollercoaster.html index 62ca09da18ca1c..0d4ce8910ba317 100644 --- a/examples/webgpu_xr_rollercoaster.html +++ b/examples/webgpu_xr_rollercoaster.html @@ -32,7 +32,7 @@ let mesh, material, geometry; - const renderer = new THREE.WebGPURenderer( { antialias: true, forceWebGL: true, colorBufferType: THREE.UnsignedByteType, multiview: false } ); + const renderer = new THREE.WebGPURenderer( { antialias: true, forceWebGL: true, outputBufferType: THREE.UnsignedByteType, multiview: false } ); renderer.setPixelRatio( window.devicePixelRatio ); renderer.setSize( window.innerWidth, window.innerHeight ); renderer.setAnimationLoop( animate ); From 20116d7a8d648fbbd4074f6a8cd54c02db3bc290 Mon Sep 17 00:00:00 2001 From: sunag Date: Mon, 8 Dec 2025 02:20:39 -0300 Subject: [PATCH 4/6] docs --- examples/webgpu_animation_retargeting.html | 6 +++--- src/renderers/common/Renderer.js | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/webgpu_animation_retargeting.html b/examples/webgpu_animation_retargeting.html index 317e7956e1388c..926664b367481d 100644 --- a/examples/webgpu_animation_retargeting.html +++ b/examples/webgpu_animation_retargeting.html @@ -22,9 +22,9 @@