Skip to content

Commit e49cd3f

Browse files
authored
Renderer: Rename .getColorBufferType() -> .getOutputBufferType() (#32501)
1 parent 1246386 commit e49cd3f

File tree

5 files changed

+39
-17
lines changed

5 files changed

+39
-17
lines changed

examples/webgpu_xr_rollercoaster.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
let mesh, material, geometry;
3434

35-
const renderer = new THREE.WebGPURenderer( { antialias: true, forceWebGL: true, colorBufferType: THREE.UnsignedByteType, multiview: false } );
35+
const renderer = new THREE.WebGPURenderer( { antialias: true, forceWebGL: true, outputBufferType: THREE.UnsignedByteType, multiview: false } );
3636
renderer.setPixelRatio( window.devicePixelRatio );
3737
renderer.setSize( window.innerWidth, window.innerHeight );
3838
renderer.setAnimationLoop( animate );

src/nodes/display/PassNode.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,7 @@ class PassNode extends TempNode {
736736

737737
this.renderTarget.samples = this.options.samples === undefined ? renderer.samples : this.options.samples;
738738

739-
this.renderTarget.texture.type = renderer.getColorBufferType();
739+
this.renderTarget.texture.type = renderer.getOutputBufferType();
740740

741741
return this.scope === PassNode.COLOR ? this.getTextureNode() : this.getLinearDepthNode();
742742

src/renderers/common/Renderer.js

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class Renderer {
6464
* @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
6565
* to overwrite the default.
6666
* @property {?Function} [getFallback=null] - This callback function can be used to provide a fallback backend, if the primary backend can't be targeted.
67-
* @property {number} [colorBufferType=HalfFloatType] - Defines the type of color buffers. The default `HalfFloatType` is recommend for best
67+
* @property {number} [outputBufferType=HalfFloatType] - Defines the type of output buffers. The default `HalfFloatType` is recommend for best
6868
* quality. To save memory and bandwidth, `UnsignedByteType` might be used. This will reduce rendering quality though.
6969
* @property {boolean} [multiview=false] - If set to `true`, the renderer will use multiview during WebXR rendering if supported.
7070
*/
@@ -97,7 +97,7 @@ class Renderer {
9797
antialias = false,
9898
samples = 0,
9999
getFallback = null,
100-
colorBufferType = HalfFloatType,
100+
outputBufferType = HalfFloatType,
101101
multiview = false
102102
} = parameters;
103103

@@ -584,15 +584,15 @@ class Renderer {
584584
this.onDeviceLost = this._onDeviceLost;
585585

586586
/**
587-
* Defines the type of color buffers. The default `HalfFloatType` is recommend for
587+
* Defines the type of output buffers. The default `HalfFloatType` is recommend for
588588
* best quality. To save memory and bandwidth, `UnsignedByteType` might be used.
589589
* This will reduce rendering quality though.
590590
*
591591
* @private
592592
* @type {number}
593593
* @default HalfFloatType
594594
*/
595-
this._colorBufferType = colorBufferType;
595+
this._outputBufferType = outputBufferType;
596596

597597
/**
598598
* A cache for shadow nodes per material
@@ -1084,13 +1084,27 @@ class Renderer {
10841084
}
10851085

10861086
/**
1087-
* Returns the color buffer type.
1087+
* Returns the output buffer type.
10881088
*
1089-
* @return {number} The color buffer type.
1089+
* @return {number} The output buffer type.
10901090
*/
1091-
getColorBufferType() {
1091+
getOutputBufferType() {
10921092

1093-
return this._colorBufferType;
1093+
return this._outputBufferType;
1094+
1095+
}
1096+
1097+
/**
1098+
* Returns the output buffer type.
1099+
*
1100+
* @deprecated since r182. Use `.getOutputBufferType()` instead.
1101+
* @return {number} The output buffer type.
1102+
*/
1103+
getColorBufferType() { // @deprecated, r182
1104+
1105+
warnOnce( 'Renderer: ".getColorBufferType()" has been renamed to ".getOutputBufferType()".' );
1106+
1107+
return this.getOutputBufferType();
10941108

10951109
}
10961110

@@ -1266,7 +1280,7 @@ class Renderer {
12661280
frameBufferTarget = new RenderTarget( width, height, {
12671281
depthBuffer: depth,
12681282
stencilBuffer: stencil,
1269-
type: this._colorBufferType,
1283+
type: this._outputBufferType,
12701284
format: RGBAFormat,
12711285
colorSpace: ColorManagement.workingColorSpace,
12721286
generateMipmaps: false,

src/renderers/webgpu/WebGPURenderer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class WebGPURenderer extends Renderer {
4040
* @property {boolean} [forceWebGL=false] - If set to `true`, the renderer uses a WebGL 2 backend no matter if WebGPU is supported or not.
4141
* @property {boolean} [multiview=false] - If set to `true`, the renderer will use multiview during WebXR rendering if supported.
4242
* @property {number} [outputType=undefined] - Texture type for output to canvas. By default, device's preferred format is used; other formats may incur overhead.
43-
* @property {number} [colorBufferType=HalfFloatType] - Defines the type of color buffers. The default `HalfFloatType` is recommend for best
43+
* @property {number} [outputBufferType=HalfFloatType] - Defines the type of output buffers. The default `HalfFloatType` is recommend for best
4444
* quality. To save memory and bandwidth, `UnsignedByteType` might be used. This will reduce rendering quality though.
4545
*/
4646

src/renderers/webgpu/utils/WebGPUUtils.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,23 +220,31 @@ class WebGPUUtils {
220220
*/
221221
getPreferredCanvasFormat() {
222222

223-
const outputType = this.backend.parameters.outputType;
223+
const parameters = this.backend.parameters;
224224

225-
if ( outputType === undefined ) {
225+
let bufferType = parameters.outputBufferType;
226+
227+
if ( bufferType === undefined ) {
228+
229+
bufferType = parameters.outputType;
230+
231+
}
232+
233+
if ( bufferType === undefined ) {
226234

227235
return navigator.gpu.getPreferredCanvasFormat();
228236

229-
} else if ( outputType === UnsignedByteType ) {
237+
} else if ( bufferType === UnsignedByteType ) {
230238

231239
return GPUTextureFormat.BGRA8Unorm;
232240

233-
} else if ( outputType === HalfFloatType ) {
241+
} else if ( bufferType === HalfFloatType ) {
234242

235243
return GPUTextureFormat.RGBA16Float;
236244

237245
} else {
238246

239-
throw new Error( 'Unsupported outputType' );
247+
throw new Error( 'Unsupported output buffer type.' );
240248

241249
}
242250

0 commit comments

Comments
 (0)