Skip to content

Commit

Permalink
XRManager: Add MSAA support. (#30378)
Browse files Browse the repository at this point in the history
* XRManager: Add MSAA support.

* E2E: Update screenshot.

* E2E: Update screenshot.
  • Loading branch information
Mugen87 authored Jan 22, 2025
1 parent a7ed16e commit 0fb4b68
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
Binary file modified examples/screenshots/webgpu_xr_cubes.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion examples/webgpu_xr_cubes.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@

raycaster = new THREE.Raycaster();

renderer = new THREE.WebGPURenderer( { forceWebGL: true } );
renderer = new THREE.WebGPURenderer( { antialias: true, forceWebGL: true } );
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
renderer.setAnimationLoop( animate );
Expand Down
3 changes: 2 additions & 1 deletion src/renderers/common/XRManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,8 @@ class XRManager extends EventDispatcher {
type: UnsignedByteType,
colorSpace: renderer.outputColorSpace,
depthTexture: new DepthTexture( glProjLayer.textureWidth, glProjLayer.textureHeight, depthType, undefined, undefined, undefined, undefined, undefined, undefined, depthFormat ),
stencilBuffer: attributes.stencil
stencilBuffer: attributes.stencil,
samples: attributes.antialias ? 4 : 0
} );

this._xrRenderTarget.hasExternalTextures = true;
Expand Down
8 changes: 6 additions & 2 deletions src/renderers/webgl-fallback/WebGLBackend.js
Original file line number Diff line number Diff line change
Expand Up @@ -334,11 +334,15 @@ class WebGLBackend extends Backend {
*/
setXRRenderTargetTextures( renderTarget, colorTexture, depthTexture = null ) {

this.set( renderTarget.texture, { textureGPU: colorTexture } );
const gl = this.gl;

this.set( renderTarget.texture, { textureGPU: colorTexture, glInternalFormat: gl.RGBA8 } ); // see #24698 why RGBA8 and not SRGB8_ALPHA8 is used

if ( depthTexture !== null ) {

this.set( renderTarget.depthTexture, { textureGPU: depthTexture } );
const glInternalFormat = renderTarget.stencilBuffer ? gl.DEPTH24_STENCIL8 : gl.DEPTH_COMPONENT24;

this.set( renderTarget.depthTexture, { textureGPU: depthTexture, glInternalFormat: glInternalFormat } );

renderTarget.autoAllocateDepthBuffer = false;

Expand Down

0 comments on commit 0fb4b68

Please sign in to comment.