Skip to content

Add support for foveation during additional render passes #30437

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

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from
Draft
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
8 changes: 6 additions & 2 deletions src/renderers/common/Renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1419,7 +1419,11 @@ class Renderer {

}

const currentXREnabled = this.xr.enabled;

this.xr.enabled = false;
this._renderScene( quad, quad.camera, false );
this.xr.enabled = currentXREnabled;

}

Expand Down Expand Up @@ -2017,7 +2021,7 @@ class Renderer {
*/
get currentToneMapping() {

return this._renderTarget !== null ? NoToneMapping : this.toneMapping;
return ( this._renderTarget !== null && this._renderTarget.isXRRenderTarget !== true ) ? NoToneMapping : this.toneMapping;

}

Expand All @@ -2029,7 +2033,7 @@ class Renderer {
*/
get currentColorSpace() {

return this._renderTarget !== null ? LinearSRGBColorSpace : this.outputColorSpace;
return ( this._renderTarget !== null && this._renderTarget.isXRRenderTarget !== true ) ? LinearSRGBColorSpace : this.outputColorSpace;

}

Expand Down
5 changes: 5 additions & 0 deletions src/renderers/common/XRManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,11 @@ class XRManager extends EventDispatcher {

}

foveateBoundTexture( ) {

if ( this._glBinding && this._glBinding.foveateBoundTexture ) this._glBinding.foveateBoundTexture( this._renderer.getContext().TEXTURE_2D, this.getFoveation() );

}
/**
* After a XR session has been requested usually with one of the `*Button` modules, it
* is injected into the renderer with this method. This method triggers the start of
Expand Down
5 changes: 4 additions & 1 deletion src/renderers/webgl-fallback/WebGLBackend.js
Original file line number Diff line number Diff line change
Expand Up @@ -1963,6 +1963,9 @@

if ( useMultisampledRTT ) {

state.bindTexture( gl.TEXTURE_2D, textureData.textureGPU );
this.renderer.xr.foveateBoundTexture();

multisampledRTTExt.framebufferTexture2DMultisampleEXT( gl.FRAMEBUFFER, attachment, gl.TEXTURE_2D, textureData.textureGPU, 0, samples );

} else {
Expand Down Expand Up @@ -2034,7 +2037,7 @@

const depthStyle = stencilBuffer ? gl.DEPTH_STENCIL_ATTACHMENT : gl.DEPTH_ATTACHMENT;

if ( renderTarget.autoAllocateDepthBuffer === true ) {
if ( ( renderTarget.autoAllocateDepthBuffer === true ) && !useMultisampledRTT ) {

Check failure on line 2040 in src/renderers/webgl-fallback/WebGLBackend.js

View workflow job for this annotation

GitHub Actions / Lint testing

Unary operator '!' must be followed by whitespace

const renderbuffer = renderTargetContextData.xrDepthRenderbuffer;
gl.bindRenderbuffer( gl.RENDERBUFFER, renderbuffer );
Expand Down
Loading