Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions examples/webgpu_tsl_vfx_linkedparticles.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
<script type="importmap">
{
"imports": {
"three": "../build/three.webgpu.js",
"three/tsl": "../build/three.webgpu.js",
"three": "../src/Three.WebGPU.js",
"three/tsl": "../src/Three.WebGPU.js",
"three/addons/": "./jsm/"
}
}
Expand Down Expand Up @@ -88,7 +88,7 @@

// renderer

renderer = new THREE.WebGPURenderer( { antialias: true } );
renderer = new THREE.WebGPURenderer( { antialias: true, hdr: true } );
renderer.setClearColor( 0x14171a );
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
Expand Down Expand Up @@ -369,7 +369,7 @@
const gui = new GUI();

gui.add( controls, 'autoRotate' ).name( 'Auto Rotate' );
gui.add( controls, 'autoRotateSpeed', - 10.0, 10.0, 0.01 ).name( 'Auto Rotate Speed' );
gui.add( controls, 'autoRotateSpeed', - 10.0, 10.0, 0.01 ).name( 'Auto Rotate Speed' );

const partFolder = gui.addFolder( 'Particles' );
partFolder.add( timeScale, 'value', 0.0, 4.0, 0.01 ).name( 'timeScale' );
Expand Down
7 changes: 6 additions & 1 deletion src/renderers/webgpu/WebGPUBackend.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class WebGPUBackend extends Backend {
this.parameters.alpha = ( parameters.alpha === undefined ) ? true : parameters.alpha;

this.parameters.requiredLimits = ( parameters.requiredLimits === undefined ) ? {} : parameters.requiredLimits;
this.parameters.hdr = ( parameters.hdr === true );

this.trackTimestamp = ( parameters.trackTimestamp === true );

Expand Down Expand Up @@ -107,14 +108,18 @@ class WebGPUBackend extends Backend {
this.context = context;

const alphaMode = parameters.alpha ? 'premultiplied' : 'opaque';
const hdr = parameters.hdr ? 'extended' : 'standard';

this.trackTimestamp = this.trackTimestamp && this.hasFeature( GPUFeatureName.TimestampQuery );

this.context.configure( {
device: this.device,
format: this.utils.getPreferredCanvasFormat(),
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.COPY_SRC,
alphaMode: alphaMode
alphaMode: alphaMode,
toneMapping: {
mode: hdr
}
} );

this.updateSize();
Expand Down
10 changes: 7 additions & 3 deletions src/renderers/webgpu/utils/WebGPUUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,15 @@ class WebGPUUtils {

getPreferredCanvasFormat() {

// TODO: Remove this check when Quest 34.5 is out
// https://github.com/mrdoob/three.js/pull/29221/files#r1731833949

if ( navigator.userAgent.includes( 'Quest' ) ) {
if ( this.backend.parameters.hdr === true ) {

return GPUTextureFormat.RGBA16Float;

} else if ( navigator.userAgent.includes( 'Quest' ) ) {

// TODO: Remove this check when Quest 34.5 is out
// https://github.com/mrdoob/three.js/pull/29221/files#r1731833949
return GPUTextureFormat.BGRA8Unorm;

} else {
Expand Down