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

Fix light conservation also affecting ambient (diffuse) light. #4961

Merged
merged 1 commit into from
Jan 10, 2023

Conversation

GSterbrant
Copy link
Contributor

@GSterbrant GSterbrant commented Jan 10, 2023

Fixes issue where the energy conservation option didn't apply to ambient lights. This PR pertains to the issue here: https://forum.playcanvas.com/t/changes-to-how-diffuse-specular-is-combined-since-v1-55/28984/10.

In 1.55 we used to combine the diffuse and specular light with a linear interpolation at the end of the shader, which aimed to preserve the energy on the material, however when refactoring the specular lighting code, this code was removed.

This PR reimplements it more correctly, by separately multiplying the diffuse and specular components with the weight factor, instead of doing it twice as we did before.

Before:
image

After:
image

Disabling conserveEnergy on the material would make the change appear as in the Before picture.

@GSterbrant GSterbrant added bug area: graphics Graphics related issue labels Jan 10, 2023
@GSterbrant GSterbrant self-assigned this Jan 10, 2023
@GSterbrant GSterbrant marked this pull request as ready for review January 10, 2023 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: graphics Graphics related issue bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants