Skip to content

Commit

Permalink
WebGPURenderer: sync environmentIntensity (#27958)
Browse files Browse the repository at this point in the history
  • Loading branch information
susiwen8 committed Mar 22, 2024
1 parent 05a1c42 commit 39dfb46
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
3 changes: 2 additions & 1 deletion examples/jsm/nodes/lighting/EnvironmentNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ class EnvironmentNode extends LightingNode {

//

const intensity = reference( 'envMapIntensity', 'float', builder.material ); // @TODO: Add materialEnvIntensity in MaterialNode
const envMap = builder.material.envMap;
const intensity = envMap ? reference( 'envMapIntensity', 'float', builder.material ) : reference( 'environmentIntensity', 'float', builder.scene ); // @TODO: Add materialEnvIntensity in MaterialNode

const radiance = context( envNode, createRadianceContext( roughness, transformedNormalView ) ).mul( intensity );
const irradiance = context( envNode, createIrradianceContext( transformedNormalWorld ) ).mul( Math.PI ).mul( intensity );
Expand Down
25 changes: 17 additions & 8 deletions examples/webgpu_cubemap_dynamic.html
Original file line number Diff line number Diff line change
Expand Up @@ -110,21 +110,23 @@
metalness: 1
} );

const gui = new GUI();
gui.add( material, 'roughness', 0, 1 );
gui.add( material, 'metalness', 0, 1 );
gui.add( renderer, 'toneMappingExposure', 0, 2 ).name( 'exposure' );

sphere = new THREE.Mesh( new THREE.IcosahedronGeometry( 15, 8 ), material );
scene.add( sphere );

const material2 = new THREE.MeshStandardMaterial( {
const material1 = new Nodes.MeshStandardNodeMaterial( {
map: uvTexture,
roughness: 0.1,
metalness: 0,
} );

const material2 = new Nodes.MeshStandardNodeMaterial( {
map: uvTexture,
roughness: 0.1,
metalness: 0
metalness: 0,
envMap: texture,
} );

cube = new THREE.Mesh( new THREE.BoxGeometry( 15, 15, 15 ), material2 );
cube = new THREE.Mesh( new THREE.BoxGeometry( 15, 15, 15 ), material1 );
scene.add( cube );

torus = new THREE.Mesh( new THREE.TorusKnotGeometry( 8, 3, 128, 16 ), material2 );
Expand All @@ -135,6 +137,13 @@
controls = new OrbitControls( camera, renderer.domElement );
controls.autoRotate = true;

const gui = new GUI();
gui.add( material, 'roughness', 0, 1 );
gui.add( material, 'metalness', 0, 1 );
gui.add( renderer, 'toneMappingExposure', 0, 2 ).name( 'exposure' );
gui.add( scene, 'environmentIntensity', 0, 1 );
gui.add( material2, 'envMapIntensity', 0, 1 );

}

function onWindowResized() {
Expand Down

0 comments on commit 39dfb46

Please sign in to comment.