Browse Source

WebGPURenderer: sync `environmentIntensity` (#27958)

susiwen8 1 year ago
parent
commit
39dfb463bb

+ 2 - 1
examples/jsm/nodes/lighting/EnvironmentNode.js

@@ -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 radiance = context( envNode, createRadianceContext( roughness, transformedNormalView ) ).mul( intensity );
 		const irradiance = context( envNode, createIrradianceContext( transformedNormalWorld ) ).mul( Math.PI ).mul( intensity );
 		const irradiance = context( envNode, createIrradianceContext( transformedNormalWorld ) ).mul( Math.PI ).mul( intensity );

+ 17 - 8
examples/webgpu_cubemap_dynamic.html

@@ -110,21 +110,23 @@
 					metalness: 1
 					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 );
 				sphere = new THREE.Mesh( new THREE.IcosahedronGeometry( 15, 8 ), material );
 				scene.add( sphere );
 				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,
 					map: uvTexture,
 					roughness: 0.1,
 					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 );
 				scene.add( cube );
 
 
 				torus = new THREE.Mesh( new THREE.TorusKnotGeometry( 8, 3, 128, 16 ), material2 );
 				torus = new THREE.Mesh( new THREE.TorusKnotGeometry( 8, 3, 128, 16 ), material2 );
@@ -135,6 +137,13 @@
 				controls = new OrbitControls( camera, renderer.domElement );
 				controls = new OrbitControls( camera, renderer.domElement );
 				controls.autoRotate = true;
 				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() {
 			function onWindowResized() {