Skip to content

Commit

Permalink
Remove some of these mix for a 1 - spec instead, which should be chea…
Browse files Browse the repository at this point in the history
…per.
  • Loading branch information
GSterbrant committed Jan 10, 2023
1 parent d57ca2e commit 041caa6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/scene/shader-lib/programs/lit-shader.js
Original file line number Diff line number Diff line change
Expand Up @@ -1016,7 +1016,7 @@ class LitShader {
if (addAmbient) {
code += " addAmbient();\n";
if (options.conserveEnergy && options.useSpecular) {
code += ` dDiffuseLight = mix(dDiffuseLight, vec3(0), dSpecularity);`;
code += ` dDiffuseLight = dDiffuseLight * (1.0 - dSpecularity);`;
}

// move ambient color out of diffuse (used by Lightmapper, to multiply ambient color by accumulated AO)
Expand Down Expand Up @@ -1219,15 +1219,15 @@ class LitShader {

// area light - they do not mix diffuse lighting into specular attenuation
if (options.conserveEnergy && options.useSpecular) {
code += " dDiffuseLight += mix((dAttenD * dAtten) * light" + i + "_color" + (usesCookieNow ? " * dAtten3" : "") + ", vec3(0), dLTCSpecFres);\n";
code += " dDiffuseLight += ((dAttenD * dAtten) * light" + i + "_color" + (usesCookieNow ? " * dAtten3" : "") + ") * (1.0 - dLTCSpecFres);\n";
} else {
code += " dDiffuseLight += (dAttenD * dAtten) * light" + i + "_color" + (usesCookieNow ? " * dAtten3" : "") + ";\n";
}
} else {

// punctual light
if (hasAreaLights && options.conserveEnergy && options.useSpecular) {
code += " dDiffuseLight += mix(dAtten * light" + i + "_color" + (usesCookieNow ? " * dAtten3" : "") + ", vec3(0), dSpecularity);\n";
code += " dDiffuseLight += (dAtten * light" + i + "_color" + (usesCookieNow ? " * dAtten3" : "") + ") * (1.0 - dSpecularity);\n";
} else {
code += " dDiffuseLight += dAtten * light" + i + "_color" + (usesCookieNow ? " * dAtten3" : "") + ";\n";
}
Expand Down

0 comments on commit 041caa6

Please sign in to comment.