Skip to content

Commit

Permalink
Nodes: Only use PMREM for background when blurriness is configured. (#…
Browse files Browse the repository at this point in the history
…29089)

* Nodes: Only use PMREM for background when blurriness is used.

* E2E: Update screenshots.

* CubeRenderTarget: Fix MRT support.

* E2E: Update screenshot.
  • Loading branch information
Mugen87 authored Aug 8, 2024
1 parent f71cb7a commit 94a841b
Show file tree
Hide file tree
Showing 16 changed files with 32 additions and 2 deletions.
Binary file modified examples/screenshots/webgpu_clearcoat.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/screenshots/webgpu_cubemap_adjustments.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/screenshots/webgpu_cubemap_dynamic.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/screenshots/webgpu_lightprobe.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/screenshots/webgpu_loader_gltf.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/screenshots/webgpu_loader_gltf_iridescence.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/screenshots/webgpu_loader_gltf_sheen.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/screenshots/webgpu_loader_materialx.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/screenshots/webgpu_materials_basic.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/screenshots/webgpu_materials_envmaps.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/screenshots/webgpu_materials_transmission.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/screenshots/webgpu_mrt.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/screenshots/webgpu_parallax_uv.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/screenshots/webgpu_postprocessing_3dlut.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions src/renderers/common/CubeRenderTarget.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,14 @@ class CubeRenderTarget extends WebGLCubeRenderTarget {
if ( texture.minFilter === LinearMipmapLinearFilter ) texture.minFilter = LinearFilter;

const camera = new CubeCamera( 1, 10, this );

const currentMRT = renderer.getMRT();
renderer.setMRT( null );

camera.update( renderer, scene );

renderer.setMRT( currentMRT );

texture.minFilter = currentMinFilter;
texture.currentGenerateMipmaps = currentGenerateMipmaps;

Expand Down
28 changes: 26 additions & 2 deletions src/renderers/common/nodes/Nodes.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import DataMap from '../DataMap.js';
import ChainMap from '../ChainMap.js';
import NodeBuilderState from './NodeBuilderState.js';
import { cubeMapNode } from '../../../nodes/utils/CubeMapNode.js';
import { NodeFrame, objectGroup, renderGroup, frameGroup, cubeTexture, texture, rangeFog, densityFog, reference, viewportBottomLeft, normalWorld, pmremTexture, viewportTopLeft } from '../../../nodes/Nodes.js';

import { EquirectangularReflectionMapping, EquirectangularRefractionMapping } from '../../../constants.js';
Expand Down Expand Up @@ -264,13 +265,35 @@ class Nodes extends DataMap {

if ( background ) {

if ( sceneData.background !== background ) {
const forceUpdate = ( scene.backgroundBlurriness === 0 && sceneData.backgroundBlurriness > 0 ) || ( scene.backgroundBlurriness > 0 && sceneData.backgroundBlurriness === 0 );

if ( sceneData.background !== background || forceUpdate ) {

let backgroundNode = null;

if ( background.isCubeTexture === true || ( background.mapping === EquirectangularReflectionMapping || background.mapping === EquirectangularRefractionMapping ) ) {

backgroundNode = pmremTexture( background, normalWorld );
if ( scene.backgroundBlurriness > 0 ) {

backgroundNode = pmremTexture( background, normalWorld );

} else {

let envMap;

if ( background.isCubeTexture === true ) {

envMap = cubeTexture( background );

} else {

envMap = texture( background );

}

backgroundNode = cubeMapNode( envMap );

}

} else if ( background.isTexture === true ) {

Expand All @@ -284,6 +307,7 @@ class Nodes extends DataMap {

sceneData.backgroundNode = backgroundNode;
sceneData.background = background;
sceneData.backgroundBlurriness = scene.backgroundBlurriness;

}

Expand Down

0 comments on commit 94a841b

Please sign in to comment.