Skip to content
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
29 changes: 25 additions & 4 deletions src/nodes/display/PassNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -560,13 +560,34 @@ class PassNode extends TempNode {
updateBefore( frame ) {

const { renderer } = frame;
const { scene, camera } = this;
const { scene } = this;

this._pixelRatio = renderer.getPixelRatio();
let camera;
let pixelRatio;

const size = renderer.getSize( _size );
const outputRenderTarget = renderer.getOutputRenderTarget();

this.setSize( size.width, size.height );
if ( outputRenderTarget && outputRenderTarget.isXRRenderTarget === true ) {

pixelRatio = 1;
camera = renderer.xr.getCamera();

renderer.xr.updateCamera( camera );

_size.set( outputRenderTarget.width, outputRenderTarget.height );

} else {

camera = this.camera;
pixelRatio = renderer.getPixelRatio();

renderer.getSize( _size );

}

this._pixelRatio = pixelRatio;

this.setSize( _size.width, _size.height );

const currentRenderTarget = renderer.getRenderTarget();
const currentMRT = renderer.getMRT();
Expand Down
10 changes: 10 additions & 0 deletions src/renderers/common/PostProcessing.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,13 @@ class PostProcessing {

//

const currentXR = renderer.xr.enabled;
renderer.xr.enabled = false;

this._quadMesh.render( renderer );

renderer.xr.enabled = currentXR;

//

renderer.toneMapping = toneMapping;
Expand Down Expand Up @@ -164,8 +169,13 @@ class PostProcessing {

//

const currentXR = renderer.xr.enabled;
renderer.xr.enabled = false;

await this._quadMesh.renderAsync( renderer );

renderer.xr.enabled = currentXR;

//

renderer.toneMapping = toneMapping;
Expand Down
48 changes: 45 additions & 3 deletions src/renderers/common/Renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,15 @@ class Renderer {
*/
this._activeMipmapLevel = 0;

/**
* The current output render target.
*
* @private
* @type {?RenderTarget}
* @default null
*/
this._outputRenderTarget = null;

/**
* The MRT setting.
*
Expand Down Expand Up @@ -1206,7 +1215,7 @@ class Renderer {

const sceneRef = ( scene.isScene === true ) ? scene : _scene;

const outputRenderTarget = this._renderTarget;
const outputRenderTarget = this._renderTarget || this._outputRenderTarget;

const activeCubeFace = this._activeCubeFace;
const activeMipmapLevel = this._activeMipmapLevel;
Expand Down Expand Up @@ -2019,7 +2028,7 @@ class Renderer {
*/
get currentToneMapping() {

return this._renderTarget !== null ? NoToneMapping : this.toneMapping;
return this.isOutputTarget ? this.toneMapping : NoToneMapping;

}

Expand All @@ -2031,7 +2040,18 @@ class Renderer {
*/
get currentColorSpace() {

return this._renderTarget !== null ? LinearSRGBColorSpace : this.outputColorSpace;
return this.isOutputTarget ? this.outputColorSpace : LinearSRGBColorSpace;

}

/**
* Returns `true` if the rendering settings are set to screen output.
*
* @returns {boolean} True if the current render target is the same of output render target or `null`, otherwise false.
*/
get isOutputTarget() {

return this._renderTarget === this._outputRenderTarget;

}

Expand Down Expand Up @@ -2094,6 +2114,28 @@ class Renderer {

}

/**
* Sets the output render target for the renderer.
*
* @param {Object} renderTarget - The render target to set as the output target.
*/
setOutputRenderTarget( renderTarget ) {

this._outputRenderTarget = renderTarget;

}

/**
* Returns the current output target.
*
* @return {?RenderTarget} The current output render target. Returns `null` if no output target is set.
*/
getOutputRenderTarget() {

return this._outputRenderTarget;

}

/**
* Callback for {@link Renderer#setRenderObjectFunction}.
*
Expand Down
15 changes: 2 additions & 13 deletions src/renderers/common/XRManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,6 @@ class XRManager extends EventDispatcher {
*/
this._controllerInputSources = [];

/**
* The current render target of the renderer.
*
* @private
* @type {?RenderTarget}
* @default null
*/
this._currentRenderTarget = null;

/**
* The XR render target that represents the rendering destination
* during an active XR session.
Expand Down Expand Up @@ -567,8 +558,6 @@ class XRManager extends EventDispatcher {

if ( backend.isWebGPUBackend === true ) throw new Error( 'THREE.XRManager: XR is currently not supported with a WebGPU backend. Use WebGL by passing "{ forceWebGL: true }" to the constructor of the renderer.' );

this._currentRenderTarget = renderer.getRenderTarget();

session.addEventListener( 'select', this._onSessionEvent );
session.addEventListener( 'selectstart', this._onSessionEvent );
session.addEventListener( 'selectend', this._onSessionEvent );
Expand Down Expand Up @@ -972,7 +961,7 @@ function onSessionEnd() {
// restore framebuffer/rendering state

renderer.backend.setXRTarget( null );
renderer.setRenderTarget( this._currentRenderTarget );
renderer.setOutputRenderTarget( null );

this._session = null;
this._xrRenderTarget = null;
Expand Down Expand Up @@ -1159,7 +1148,7 @@ function onAnimationFrame( time, frame ) {

}

renderer.setRenderTarget( this._xrRenderTarget );
renderer.setOutputRenderTarget( this._xrRenderTarget );

}

Expand Down