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

NodeMaterial: Honor lightMapIntensity. #28814

Merged
merged 1 commit into from
Jul 5, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified examples/screenshots/webgpu_materials_lightmap.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/nodes/Nodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export { default as VertexColorNode, vertexColor } from './accessors/VertexColor
export { default as CubeTextureNode, cubeTexture } from './accessors/CubeTextureNode.js';
export { default as InstanceNode, instance } from './accessors/InstanceNode.js';
export { default as BatchNode, batch } from './accessors/BatchNode.js';
export { default as MaterialNode, materialAlphaTest, materialColor, materialShininess, materialEmissive, materialOpacity, materialSpecular, materialSpecularStrength, materialReflectivity, materialRoughness, materialMetalness, materialNormal, materialClearcoat, materialClearcoatRoughness, materialClearcoatNormal, materialRotation, materialSheen, materialSheenRoughness, materialIridescence, materialIridescenceIOR, materialIridescenceThickness, materialLineScale, materialLineDashSize, materialLineGapSize, materialLineWidth, materialLineDashOffset, materialPointWidth, materialAnisotropy, materialAnisotropyVector, materialDispersion } from './accessors/MaterialNode.js';
export { default as MaterialNode, materialAlphaTest, materialColor, materialShininess, materialEmissive, materialOpacity, materialSpecular, materialSpecularStrength, materialReflectivity, materialRoughness, materialMetalness, materialNormal, materialClearcoat, materialClearcoatRoughness, materialClearcoatNormal, materialRotation, materialSheen, materialSheenRoughness, materialIridescence, materialIridescenceIOR, materialIridescenceThickness, materialLineScale, materialLineDashSize, materialLineGapSize, materialLineWidth, materialLineDashOffset, materialPointWidth, materialAnisotropy, materialAnisotropyVector, materialDispersion, materialLightMap } from './accessors/MaterialNode.js';
export { default as MaterialReferenceNode, materialReference } from './accessors/MaterialReferenceNode.js';
export { default as RendererReferenceNode, rendererReference } from './accessors/RendererReferenceNode.js';
export { default as MorphNode, morphReference } from './accessors/MorphNode.js';
Expand Down
6 changes: 6 additions & 0 deletions src/nodes/accessors/MaterialNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,10 @@ class MaterialNode extends Node {

node = this.getFloat( scope );

} else if ( scope === MaterialNode.LIGHT_MAP ) {

node = this.getTexture( scope ).rgb.mul( this.getFloat( 'lightMapIntensity' ) );

} else {

const outputType = this.getNodeType( builder );
Expand Down Expand Up @@ -368,6 +372,7 @@ MaterialNode.LINE_WIDTH = 'linewidth';
MaterialNode.LINE_DASH_OFFSET = 'dashOffset';
MaterialNode.POINT_WIDTH = 'pointWidth';
MaterialNode.DISPERSION = 'dispersion';
MaterialNode.LIGHT_MAP = 'light';

export default MaterialNode;

Expand Down Expand Up @@ -408,6 +413,7 @@ export const materialLineWidth = nodeImmutable( MaterialNode, MaterialNode.LINE_
export const materialLineDashOffset = nodeImmutable( MaterialNode, MaterialNode.LINE_DASH_OFFSET );
export const materialPointWidth = nodeImmutable( MaterialNode, MaterialNode.POINT_WIDTH );
export const materialDispersion = nodeImmutable( MaterialNode, MaterialNode.DISPERSION );
export const materialLightMap = nodeImmutable( MaterialNode, MaterialNode.LIGHT_MAP );
export const materialAnisotropyVector = uniform( new Vector2() ).onReference( function ( frame ) {

return frame.material;
Expand Down
4 changes: 2 additions & 2 deletions src/nodes/materials/NodeMaterial.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { NormalBlending } from '../../constants.js';
import { getNodeChildren, getCacheKey } from '../core/NodeUtils.js';
import { attribute } from '../core/AttributeNode.js';
import { output, diffuseColor, varyingProperty } from '../core/PropertyNode.js';
import { materialAlphaTest, materialColor, materialOpacity, materialEmissive, materialNormal } from '../accessors/MaterialNode.js';
import { materialAlphaTest, materialColor, materialOpacity, materialEmissive, materialNormal, materialLightMap } from '../accessors/MaterialNode.js';
import { modelViewProjection } from '../accessors/ModelViewProjectionNode.js';
import { transformedNormalView, normalLocal } from '../accessors/NormalNode.js';
import { instance } from '../accessors/InstanceNode.js';
Expand Down Expand Up @@ -367,7 +367,7 @@ class NodeMaterial extends Material {

if ( builder.material.lightMap ) {

materialLightsNode.push( new IrradianceNode( materialReference( 'lightMap', 'texture' ) ) );
materialLightsNode.push( new IrradianceNode( materialLightMap ) );

}

Expand Down