Skip to content

XRManager: Add MSAA support. #30378

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
Binary file modified examples/screenshots/webgpu_xr_cubes.jpg
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting that it's the MSAA what breaks the lines in these screenshots.

SwiftShader seems to be kind of deprecated though...

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
Loading