Skip to content

MeshBasicNodeMaterial: Add lightMap support.#28821

Merged
sunag merged 3 commits intomrdoob:devfrom
Mugen87:dev72
Jul 6, 2024
Merged

MeshBasicNodeMaterial: Add lightMap support.#28821
sunag merged 3 commits intomrdoob:devfrom
Mugen87:dev72

Conversation

@Mugen87
Copy link
Copy Markdown
Collaborator

@Mugen87 Mugen87 commented Jul 5, 2024

Related issue: #28785

Description

This PR implements lightMap support to MeshBasicNodeMaterial.

MeshBasicNodeMaterial should not react on other source of irradiance like AmbientLight so it was necessary to add BasicLightMapNode to handle this exception.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jul 5, 2024

📦 Bundle size

Full ESM build, minified and gzipped.

Filesize dev Filesize PR Diff
683.5 kB (169.2 kB) 683.5 kB (169.2 kB) +0 B

🌳 Bundle size after tree-shaking

Minimal build including a renderer, camera, empty scene, and dependencies.

Filesize dev Filesize PR Diff
460.6 kB (111.1 kB) 460.6 kB (111.1 kB) +0 B

@Mugen87 Mugen87 added this to the r167 milestone Jul 6, 2024

if ( builder.material.lightMap ) {

node = new IrradianceNode( materialLightMap );
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we sould move this to StandardMeshNodeMaterial like setupEnvironment()?

Copy link
Copy Markdown
Collaborator Author

@Mugen87 Mugen87 Jul 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've asked this myself this as well but then I've realized when I do this setupLightMap() in NodeMaterial will be empty. The basic and standard materials share no common code in context of light maps like the setup of the environment map node in NodeMaterial.setupEnvironment(). Besides, we would have to implement setupLightMap() in phong, lambert and toon not just in MeshStandardNodeMaterial.

The light map handling in MeshBasicNodeMaterial is quite an exception and I thought it's more clear to completely overwrite the standard implementation from NodeMaterial .

That said, I'm not feeling strong about this issue. If you think it's more consistent to follow the approach of env maps, I'll create a setupLightMap() method for each material that supports light maps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants