Skip to content

Commit

Permalink
Fix light conservation also affecting ambient (diffuse) light. (#4961)
Browse files Browse the repository at this point in the history
  • Loading branch information
GSterbrant authored Jan 10, 2023
1 parent 7bd4697 commit d57ca2e
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/scene/shader-lib/programs/lit-shader.js
Original file line number Diff line number Diff line change
Expand Up @@ -1015,6 +1015,9 @@ class LitShader {

if (addAmbient) {
code += " addAmbient();\n";
if (options.conserveEnergy && options.useSpecular) {
code += ` dDiffuseLight = mix(dDiffuseLight, vec3(0), dSpecularity);`;
}

// move ambient color out of diffuse (used by Lightmapper, to multiply ambient color by accumulated AO)
if (options.separateAmbient) {
Expand Down

0 comments on commit d57ca2e

Please sign in to comment.