Fix light conservation also affecting ambient (diffuse) light. #4961
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
After:
Disabling
conserveEnergy
on the material would make the change appear as in the Before picture.