Skip to content
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

WebGLBackground: Split adding to render list and clearing of buffers #28118

Merged
merged 1 commit into from
Apr 13, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 11 additions & 9 deletions src/renderers/WebGLRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1149,6 +1149,13 @@ class WebGLRenderer {

}

const renderBackground = xr.enabled === false || xr.isPresenting === false || xr.hasDepthSensing() === false;
if ( renderBackground ) {

background.addToRenderList( currentRenderList, scene );

}

//

this.info.render.frame ++;
Expand All @@ -1165,15 +1172,6 @@ class WebGLRenderer {

if ( this.info.autoReset === true ) this.info.reset();


//

if ( xr.enabled === false || xr.isPresenting === false || xr.hasDepthSensing() === false ) {
Mugen87 marked this conversation as resolved.
Show resolved Hide resolved

background.render( currentRenderList, scene );

}

// render scene

const opaqueObjects = currentRenderList.opaque;
Expand All @@ -1197,6 +1195,8 @@ class WebGLRenderer {

}

if ( renderBackground ) background.render( scene );

for ( let i = 0, l = cameras.length; i < l; i ++ ) {

const camera2 = cameras[ i ];
Expand All @@ -1209,6 +1209,8 @@ class WebGLRenderer {

if ( transmissiveObjects.length > 0 ) renderTransmissionPass( opaqueObjects, transmissiveObjects, scene, camera );

if ( renderBackground ) background.render( scene );

renderScene( currentRenderList, scene, camera );

}
Expand Down
21 changes: 18 additions & 3 deletions src/renderers/webgl/WebGLBackground.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ function WebGLBackground( renderer, cubemaps, cubeuvmaps, state, objects, alpha,
let currentBackgroundVersion = 0;
let currentTonemapping = null;

function render( renderList, scene ) {
function getBackground( scene ) {

let forceClear = false;
let background = scene.isScene === true ? scene.background : null;

if ( background && background.isTexture ) {
Expand All @@ -38,6 +37,15 @@ function WebGLBackground( renderer, cubemaps, cubeuvmaps, state, objects, alpha,

}

return background;

}

function render( scene ) {

let forceClear = false;
const background = getBackground( scene );

if ( background === null ) {

setClear( clearColor, clearAlpha );
Expand Down Expand Up @@ -67,6 +75,12 @@ function WebGLBackground( renderer, cubemaps, cubeuvmaps, state, objects, alpha,

}

}

function addToRenderList( renderList, scene ) {
Mugen87 marked this conversation as resolved.
Show resolved Hide resolved

const background = getBackground( scene );

if ( background && ( background.isCubeTexture || background.mapping === CubeUVReflectionMapping ) ) {

if ( boxMesh === undefined ) {
Expand Down Expand Up @@ -247,7 +261,8 @@ function WebGLBackground( renderer, cubemaps, cubeuvmaps, state, objects, alpha,
setClear( clearColor, clearAlpha );

},
render: render
render: render,
addToRenderList: addToRenderList

};

Expand Down