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 ambientOcclusion in basic, lambert and phong. #28819

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
6 changes: 4 additions & 2 deletions src/nodes/functions/BasicLightingModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ class BasicLightingModel extends LightingModel {

}

indirectDiffuse( { reflectedLight } ) {
indirectDiffuse( { ambientOcclusion, reflectedLight } ) {

reflectedLight.indirectDiffuse.assign( diffuseColor.rgb );
reflectedLight.indirectDiffuse.addAssign( diffuseColor.rgb );

reflectedLight.indirectDiffuse.mulAssign( ambientOcclusion );
Copy link
Collaborator

Choose a reason for hiding this comment

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

I was thinking in we move this to LighthingModel.ambientOcclusion(), since we already have this function.

Copy link
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.

Um, maybe it is easier to read the code when the final computation of indirect diffuse (accumulation + modulation) happens at one place.

Although when the line is moved to LighthingModel.ambientOcclusion(), we don't have to repeat it in derived models. I'm just afraid it will make it more hard to understand the lighting models in the end...


}

Expand Down
4 changes: 3 additions & 1 deletion src/nodes/functions/PhongLightingModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,12 @@ class PhongLightingModel extends BasicLightingModel {

}

indirectDiffuse( { irradiance, reflectedLight } ) {
indirectDiffuse( { ambientOcclusion, irradiance, reflectedLight } ) {

reflectedLight.indirectDiffuse.addAssign( irradiance.mul( BRDF_Lambert( { diffuseColor } ) ) );

reflectedLight.indirectDiffuse.mulAssign( ambientOcclusion );

}

}
Expand Down