Skip to content

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.

@github-actions
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

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
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