Procházet zdrojové kódy

WebGPURenderer: Added `lightMap` support (#28164)

sunag před 1 rokem
rodič
revize
49f142bd14

+ 1 - 0
examples/jsm/nodes/Nodes.js

@@ -158,6 +158,7 @@ export { default as LightingNode /* @TODO: lighting (abstract), light */ } from
 export { default as LightingContextNode, lightingContext } from './lighting/LightingContextNode.js';
 export { default as HemisphereLightNode } from './lighting/HemisphereLightNode.js';
 export { default as EnvironmentNode } from './lighting/EnvironmentNode.js';
+export { default as IrradianceNode } from './lighting/IrradianceNode.js';
 export { default as AONode } from './lighting/AONode.js';
 export { default as AnalyticLightNode } from './lighting/AnalyticLightNode.js';
 

+ 24 - 0
examples/jsm/nodes/lighting/IrradianceNode.js

@@ -0,0 +1,24 @@
+import LightingNode from './LightingNode.js';
+import { addNodeClass } from '../core/Node.js';
+
+class IrradianceNode extends LightingNode {
+
+	constructor( node ) {
+
+		super();
+
+		this.node = node;
+
+	}
+
+	setup( builder ) {
+
+		builder.context.irradiance.addAssign( this.node );
+
+	}
+
+}
+
+export default IrradianceNode;
+
+addNodeClass( 'IrradianceNode', IrradianceNode );

+ 8 - 1
examples/jsm/nodes/materials/NodeMaterial.js

@@ -7,7 +7,7 @@ import { modelViewProjection } from '../accessors/ModelViewProjectionNode.js';
 import { transformedNormalView } from '../accessors/NormalNode.js';
 import { instance } from '../accessors/InstanceNode.js';
 import { batch } from '../accessors/BatchNode.js';
-
+import { materialReference } from '../accessors/MaterialReferenceNode.js';
 import { positionLocal, positionView } from '../accessors/PositionNode.js';
 import { skinningReference } from '../accessors/SkinningNode.js';
 import { morphReference } from '../accessors/MorphNode.js';
@@ -19,6 +19,7 @@ import { float, vec3, vec4 } from '../shadernode/ShaderNode.js';
 import AONode from '../lighting/AONode.js';
 import { lightingContext } from '../lighting/LightingContextNode.js';
 import EnvironmentNode from '../lighting/EnvironmentNode.js';
+import IrradianceNode from '../lighting/IrradianceNode.js';
 import { depthPixel } from '../display/ViewportDepthNode.js';
 import { cameraLogDepth } from '../accessors/CameraNode.js';
 import { clipping, clippingAlpha } from '../accessors/ClippingNode.js';
@@ -345,6 +346,12 @@ class NodeMaterial extends ShaderMaterial {
 
 		}
 
+		if ( builder.material.lightMap ) {
+
+			materialLightsNode.push( new IrradianceNode( materialReference( 'lightMap', 'texture' ) ) );
+
+		}
+
 		if ( this.aoNode !== null || builder.material.aoMap ) {
 
 			const aoNode = this.aoNode !== null ? this.aoNode : texture( builder.material.aoMap );