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: Add setupOutgoingLight(). #28941

Merged
merged 5 commits into from
Jul 23, 2024
Merged

NodeMaterial: Add setupOutgoingLight(). #28941

merged 5 commits into from
Jul 23, 2024

Conversation

Mugen87
Copy link
Collaborator

@Mugen87 Mugen87 commented Jul 23, 2024

Related issue: -

Description

Lit materials like lambert, phong or standard should be black if no lights are in the scene and no emissive is defined. This is currently not true for node materials since diffuseColor.rgb is defined as the default outgoing light.

For reproduction: https://jsfiddle.net/5kat2bom/1/

This issue is solved by adding setupOutgoingLight() which checks if lights is set to true. If so, the default outgoing light is black. Otherwise it is diffuseColor.rgb. The code is not inlined but in setupOutgoingLight() so MeshBasicNodeMaterial can overwrite the implementation.

Copy link

github-actions bot commented Jul 23, 2024

📦 Bundle size

Full ESM build, minified and gzipped.

Filesize dev Filesize PR Diff
684 kB (169.4 kB) 684 kB (169.4 kB) +0 B

🌳 Bundle size after tree-shaking

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

Filesize dev Filesize PR Diff
460.9 kB (111.2 kB) 460.9 kB (111.2 kB) +0 B

@Mugen87 Mugen87 marked this pull request as draft July 23, 2024 09:15
@@ -41,7 +41,7 @@ class NodeMaterial extends Material {
this.forceSinglePass = false;

this.fog = true;
this.lights = true;
this.lights = false;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Probably better to set lights to false by default since we should not assume all custom node materials implement proper lighting models.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I totally agree.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should do this with fog too.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Let's do that in a separate PR though. The testing for such changes can take a bit time.

@Mugen87 Mugen87 marked this pull request as ready for review July 23, 2024 09:42
@sunag sunag added this to the r167 milestone Jul 23, 2024
@Mugen87 Mugen87 merged commit 5e4214d into mrdoob:dev Jul 23, 2024
12 checks passed
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