Skip to content

Commit 0fb4b68

Browse files
authored
XRManager: Add MSAA support. (#30378)
* XRManager: Add MSAA support. * E2E: Update screenshot. * E2E: Update screenshot.
1 parent a7ed16e commit 0fb4b68

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed
-61.4 KB
Loading

examples/webgpu_xr_cubes.html

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

9797
raycaster = new THREE.Raycaster();
9898

99-
renderer = new THREE.WebGPURenderer( { forceWebGL: true } );
99+
renderer = new THREE.WebGPURenderer( { antialias: true, forceWebGL: true } );
100100
renderer.setPixelRatio( window.devicePixelRatio );
101101
renderer.setSize( window.innerWidth, window.innerHeight );
102102
renderer.setAnimationLoop( animate );

src/renderers/common/XRManager.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,8 @@ class XRManager extends EventDispatcher {
632632
type: UnsignedByteType,
633633
colorSpace: renderer.outputColorSpace,
634634
depthTexture: new DepthTexture( glProjLayer.textureWidth, glProjLayer.textureHeight, depthType, undefined, undefined, undefined, undefined, undefined, undefined, depthFormat ),
635-
stencilBuffer: attributes.stencil
635+
stencilBuffer: attributes.stencil,
636+
samples: attributes.antialias ? 4 : 0
636637
} );
637638

638639
this._xrRenderTarget.hasExternalTextures = true;

src/renderers/webgl-fallback/WebGLBackend.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,11 +334,15 @@ class WebGLBackend extends Backend {
334334
*/
335335
setXRRenderTargetTextures( renderTarget, colorTexture, depthTexture = null ) {
336336

337-
this.set( renderTarget.texture, { textureGPU: colorTexture } );
337+
const gl = this.gl;
338+
339+
this.set( renderTarget.texture, { textureGPU: colorTexture, glInternalFormat: gl.RGBA8 } ); // see #24698 why RGBA8 and not SRGB8_ALPHA8 is used
338340

339341
if ( depthTexture !== null ) {
340342

341-
this.set( renderTarget.depthTexture, { textureGPU: depthTexture } );
343+
const glInternalFormat = renderTarget.stencilBuffer ? gl.DEPTH24_STENCIL8 : gl.DEPTH_COMPONENT24;
344+
345+
this.set( renderTarget.depthTexture, { textureGPU: depthTexture, glInternalFormat: glInternalFormat } );
342346

343347
renderTarget.autoAllocateDepthBuffer = false;
344348

0 commit comments

Comments
 (0)