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

[BREAKING] Remove energy conservation flag in standard material #6756

Merged
merged 2 commits into from
Jun 27, 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
2 changes: 1 addition & 1 deletion examples/assets/models/playbot/26020273/Playbot_head.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"shader":"blinn","ambient":[0.588,0.588,0.588],"diffuse":[0.588,0.588,0.588],"diffuseMap":"../26020286/head_clean.png","diffuseMapOffset":[0,0],"diffuseMapTiling":[1,1],"specular":[0.9,0.9,0.9],"shininess":90.9091,"emissive":[0,0,0],"emissiveMap":"../26020277/head_E.png","emissiveMapOffset":[0,0],"emissiveMapTiling":[1,1],"normalMap":"../26020276/head_N_clean.png","normalMapOffset":[0,0],"normalMapTiling":[1,1],"bumpMapFactor":0.3,"opacity":1,"sphereMap":"../26020278/env_01.png","reflectivity":0.2,"aoMapChannel":"r","aoMapTiling":[1,1],"aoMapOffset":[0,0],"occludeSpecular":1,"diffuseMapChannel":"rgb","specularMapChannel":"rgb","specularMapTiling":[1,1],"specularMapOffset":[0,0],"specularAntialias":true,"metalnessMapChannel":"r","metalnessMapTiling":[1,1],"metalnessMapOffset":[0,0],"metalness":1,"conserveEnergy":true,"glossMapChannel":"r","glossMapTiling":[1,1],"glossMapOffset":[0,0],"emissiveMapChannel":"rgb","emissiveIntensity":1,"heightMapChannel":"r","heightMapTiling":[1,1],"heightMapOffset":[0,0],"heightMapFactor":1,"opacityMapChannel":"r","opacityMapTiling":[1,1],"opacityMapOffset":[0,0],"refractionIndex":0.6666666666666666,"cubeMapProjectionBox":{"center":[0,0,0],"halfExtents":[0.5,0.5,0.5]},"lightMapChannel":"rgb","lightMapUv":1,"lightMapTiling":[1,1],"lightMapOffset":[0,0],"depthTest":true,"depthWrite":true,"cull":1,"blendType":3,"shadowSampleType":1,"useFog":true,"useLighting":true,"useSkybox":true,"mapping_format":"path"}
{"shader":"blinn","ambient":[0.588,0.588,0.588],"diffuse":[0.588,0.588,0.588],"diffuseMap":"../26020286/head_clean.png","diffuseMapOffset":[0,0],"diffuseMapTiling":[1,1],"specular":[0.9,0.9,0.9],"shininess":90.9091,"emissive":[0,0,0],"emissiveMap":"../26020277/head_E.png","emissiveMapOffset":[0,0],"emissiveMapTiling":[1,1],"normalMap":"../26020276/head_N_clean.png","normalMapOffset":[0,0],"normalMapTiling":[1,1],"bumpMapFactor":0.3,"opacity":1,"sphereMap":"../26020278/env_01.png","reflectivity":0.2,"aoMapChannel":"r","aoMapTiling":[1,1],"aoMapOffset":[0,0],"occludeSpecular":1,"diffuseMapChannel":"rgb","specularMapChannel":"rgb","specularMapTiling":[1,1],"specularMapOffset":[0,0],"specularAntialias":true,"metalnessMapChannel":"r","metalnessMapTiling":[1,1],"metalnessMapOffset":[0,0],"metalness":1,"glossMapChannel":"r","glossMapTiling":[1,1],"glossMapOffset":[0,0],"emissiveMapChannel":"rgb","emissiveIntensity":1,"heightMapChannel":"r","heightMapTiling":[1,1],"heightMapOffset":[0,0],"heightMapFactor":1,"opacityMapChannel":"r","opacityMapTiling":[1,1],"opacityMapOffset":[0,0],"refractionIndex":0.6666666666666666,"cubeMapProjectionBox":{"center":[0,0,0],"halfExtents":[0.5,0.5,0.5]},"lightMapChannel":"rgb","lightMapUv":1,"lightMapTiling":[1,1],"lightMapOffset":[0,0],"depthTest":true,"depthWrite":true,"cull":1,"blendType":3,"shadowSampleType":1,"useFog":true,"useLighting":true,"useSkybox":true,"mapping_format":"path"}
2 changes: 1 addition & 1 deletion examples/assets/models/playbot/26020274/Playbot_body.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"shader":"blinn","ambient":[0.588,0.588,0.588],"diffuse":[0.588,0.588,0.588],"diffuseMap":"../26020287/body_clean.png","diffuseMapOffset":[0,0],"diffuseMapTiling":[1,1],"specular":[0.9,0.9,0.9],"shininess":90.9091,"emissive":[0,0,0],"emissiveMap":"../26020288/body_E.png","emissiveMapOffset":[0,0],"emissiveMapTiling":[1,1],"normalMap":"../26020280/body_N_clean.png","normalMapOffset":[0,0],"normalMapTiling":[1,1],"bumpMapFactor":0.3,"opacity":1,"sphereMap":"../26020278/env_01.png","reflectivity":0.2,"aoMapChannel":"r","aoMapTiling":[1,1],"aoMapOffset":[0,0],"occludeSpecular":1,"diffuseMapChannel":"rgb","specularMapChannel":"rgb","specularMapTiling":[1,1],"specularMapOffset":[0,0],"specularAntialias":true,"metalnessMapChannel":"r","metalnessMapTiling":[1,1],"metalnessMapOffset":[0,0],"metalness":1,"conserveEnergy":true,"glossMapChannel":"r","glossMapTiling":[1,1],"glossMapOffset":[0,0],"emissiveMapChannel":"rgb","emissiveIntensity":1,"heightMapChannel":"r","heightMapTiling":[1,1],"heightMapOffset":[0,0],"heightMapFactor":1,"opacityMapChannel":"r","opacityMapTiling":[1,1],"opacityMapOffset":[0,0],"refractionIndex":0.6666666666666666,"cubeMapProjectionBox":{"center":[0,0,0],"halfExtents":[0.5,0.5,0.5]},"lightMapChannel":"rgb","lightMapUv":1,"lightMapTiling":[1,1],"lightMapOffset":[0,0],"depthTest":true,"depthWrite":true,"cull":1,"blendType":3,"shadowSampleType":1,"useFog":true,"useLighting":true,"useSkybox":true,"mapping_format":"path"}
{"shader":"blinn","ambient":[0.588,0.588,0.588],"diffuse":[0.588,0.588,0.588],"diffuseMap":"../26020287/body_clean.png","diffuseMapOffset":[0,0],"diffuseMapTiling":[1,1],"specular":[0.9,0.9,0.9],"shininess":90.9091,"emissive":[0,0,0],"emissiveMap":"../26020288/body_E.png","emissiveMapOffset":[0,0],"emissiveMapTiling":[1,1],"normalMap":"../26020280/body_N_clean.png","normalMapOffset":[0,0],"normalMapTiling":[1,1],"bumpMapFactor":0.3,"opacity":1,"sphereMap":"../26020278/env_01.png","reflectivity":0.2,"aoMapChannel":"r","aoMapTiling":[1,1],"aoMapOffset":[0,0],"occludeSpecular":1,"diffuseMapChannel":"rgb","specularMapChannel":"rgb","specularMapTiling":[1,1],"specularMapOffset":[0,0],"specularAntialias":true,"metalnessMapChannel":"r","metalnessMapTiling":[1,1],"metalnessMapOffset":[0,0],"metalness":1,"glossMapChannel":"r","glossMapTiling":[1,1],"glossMapOffset":[0,0],"emissiveMapChannel":"rgb","emissiveIntensity":1,"heightMapChannel":"r","heightMapTiling":[1,1],"heightMapOffset":[0,0],"heightMapFactor":1,"opacityMapChannel":"r","opacityMapTiling":[1,1],"opacityMapOffset":[0,0],"refractionIndex":0.6666666666666666,"cubeMapProjectionBox":{"center":[0,0,0],"halfExtents":[0.5,0.5,0.5]},"lightMapChannel":"rgb","lightMapUv":1,"lightMapTiling":[1,1],"lightMapOffset":[0,0],"depthTest":true,"depthWrite":true,"cull":1,"blendType":3,"shadowSampleType":1,"useFog":true,"useLighting":true,"useSkybox":true,"mapping_format":"path"}
2 changes: 1 addition & 1 deletion examples/assets/models/playbot/26020283/Playbot_arm.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"shader":"blinn","ambient":[0.588,0.588,0.588],"diffuse":[0.588,0.588,0.588],"diffuseMap":"../26020279/arm_clean.png","diffuseMapOffset":[0,0],"diffuseMapTiling":[1,1],"specular":[0.9,0.9,0.9],"shininess":90.9091,"emissive":[0,0,0],"emissiveMap":"../26020281/arm_E.png","emissiveMapOffset":[0,0],"emissiveMapTiling":[1,1],"normalMap":"../26020289/arm_N_clean.png","normalMapOffset":[0,0],"normalMapTiling":[1,1],"bumpMapFactor":0.3,"opacity":1,"sphereMap":"../26020278/env_01.png","reflectivity":0.2,"aoMapChannel":"r","aoMapTiling":[1,1],"aoMapOffset":[0,0],"occludeSpecular":1,"diffuseMapChannel":"rgb","specularMapChannel":"rgb","specularMapTiling":[1,1],"specularMapOffset":[0,0],"specularAntialias":true,"metalnessMapChannel":"r","metalnessMapTiling":[1,1],"metalnessMapOffset":[0,0],"metalness":1,"conserveEnergy":true,"glossMapChannel":"r","glossMapTiling":[1,1],"glossMapOffset":[0,0],"emissiveMapChannel":"rgb","emissiveIntensity":1,"heightMapChannel":"r","heightMapTiling":[1,1],"heightMapOffset":[0,0],"heightMapFactor":1,"opacityMapChannel":"r","opacityMapTiling":[1,1],"opacityMapOffset":[0,0],"refractionIndex":0.6666666666666666,"cubeMapProjectionBox":{"center":[0,0,0],"halfExtents":[0.5,0.5,0.5]},"lightMapChannel":"rgb","lightMapUv":1,"lightMapTiling":[1,1],"lightMapOffset":[0,0],"depthTest":true,"depthWrite":true,"cull":1,"blendType":3,"shadowSampleType":1,"useFog":true,"useLighting":true,"useSkybox":true,"mapping_format":"path"}
{"shader":"blinn","ambient":[0.588,0.588,0.588],"diffuse":[0.588,0.588,0.588],"diffuseMap":"../26020279/arm_clean.png","diffuseMapOffset":[0,0],"diffuseMapTiling":[1,1],"specular":[0.9,0.9,0.9],"shininess":90.9091,"emissive":[0,0,0],"emissiveMap":"../26020281/arm_E.png","emissiveMapOffset":[0,0],"emissiveMapTiling":[1,1],"normalMap":"../26020289/arm_N_clean.png","normalMapOffset":[0,0],"normalMapTiling":[1,1],"bumpMapFactor":0.3,"opacity":1,"sphereMap":"../26020278/env_01.png","reflectivity":0.2,"aoMapChannel":"r","aoMapTiling":[1,1],"aoMapOffset":[0,0],"occludeSpecular":1,"diffuseMapChannel":"rgb","specularMapChannel":"rgb","specularMapTiling":[1,1],"specularMapOffset":[0,0],"specularAntialias":true,"metalnessMapChannel":"r","metalnessMapTiling":[1,1],"metalnessMapOffset":[0,0],"metalness":1,"glossMapChannel":"r","glossMapTiling":[1,1],"glossMapOffset":[0,0],"emissiveMapChannel":"rgb","emissiveIntensity":1,"heightMapChannel":"r","heightMapTiling":[1,1],"heightMapOffset":[0,0],"heightMapFactor":1,"opacityMapChannel":"r","opacityMapTiling":[1,1],"opacityMapOffset":[0,0],"refractionIndex":0.6666666666666666,"cubeMapProjectionBox":{"center":[0,0,0],"halfExtents":[0.5,0.5,0.5]},"lightMapChannel":"rgb","lightMapUv":1,"lightMapTiling":[1,1],"lightMapOffset":[0,0],"depthTest":true,"depthWrite":true,"cull":1,"blendType":3,"shadowSampleType":1,"useFog":true,"useLighting":true,"useSkybox":true,"mapping_format":"path"}
2 changes: 1 addition & 1 deletion examples/assets/models/playbot/26020285/Playbot_leg.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"shader":"blinn","ambient":[0.588,0.588,0.588],"diffuse":[0.588,0.588,0.588],"diffuseMap":"../26020290/leg_clean.png","diffuseMapOffset":[0,0],"diffuseMapTiling":[1,1],"specular":[0.9,0.9,0.9],"shininess":90.9091,"emissive":[0,0,0],"emissiveMap":"../26020284/leg_E.png","emissiveMapOffset":[0,0],"emissiveMapTiling":[1,1],"normalMap":"../26020282/leg_N_clean.png","normalMapOffset":[0,0],"normalMapTiling":[1,1],"bumpMapFactor":0.3,"opacity":1,"sphereMap":"../26020278/env_01.png","reflectivity":0.2,"aoMapChannel":"r","aoMapTiling":[1,1],"aoMapOffset":[0,0],"occludeSpecular":1,"diffuseMapChannel":"rgb","specularMapChannel":"rgb","specularMapTiling":[1,1],"specularMapOffset":[0,0],"specularAntialias":true,"metalnessMapChannel":"r","metalnessMapTiling":[1,1],"metalnessMapOffset":[0,0],"metalness":1,"conserveEnergy":true,"glossMapChannel":"r","glossMapTiling":[1,1],"glossMapOffset":[0,0],"emissiveMapChannel":"rgb","emissiveIntensity":1,"heightMapChannel":"r","heightMapTiling":[1,1],"heightMapOffset":[0,0],"heightMapFactor":1,"opacityMapChannel":"r","opacityMapTiling":[1,1],"opacityMapOffset":[0,0],"refractionIndex":0.6666666666666666,"cubeMapProjectionBox":{"center":[0,0,0],"halfExtents":[0.5,0.5,0.5]},"lightMapChannel":"rgb","lightMapUv":1,"lightMapTiling":[1,1],"lightMapOffset":[0,0],"depthTest":true,"depthWrite":true,"cull":1,"blendType":3,"shadowSampleType":1,"useFog":true,"useLighting":true,"useSkybox":true,"mapping_format":"path"}
{"shader":"blinn","ambient":[0.588,0.588,0.588],"diffuse":[0.588,0.588,0.588],"diffuseMap":"../26020290/leg_clean.png","diffuseMapOffset":[0,0],"diffuseMapTiling":[1,1],"specular":[0.9,0.9,0.9],"shininess":90.9091,"emissive":[0,0,0],"emissiveMap":"../26020284/leg_E.png","emissiveMapOffset":[0,0],"emissiveMapTiling":[1,1],"normalMap":"../26020282/leg_N_clean.png","normalMapOffset":[0,0],"normalMapTiling":[1,1],"bumpMapFactor":0.3,"opacity":1,"sphereMap":"../26020278/env_01.png","reflectivity":0.2,"aoMapChannel":"r","aoMapTiling":[1,1],"aoMapOffset":[0,0],"occludeSpecular":1,"diffuseMapChannel":"rgb","specularMapChannel":"rgb","specularMapTiling":[1,1],"specularMapOffset":[0,0],"specularAntialias":true,"metalnessMapChannel":"r","metalnessMapTiling":[1,1],"metalnessMapOffset":[0,0],"metalness":1,"glossMapChannel":"r","glossMapTiling":[1,1],"glossMapOffset":[0,0],"emissiveMapChannel":"rgb","emissiveIntensity":1,"heightMapChannel":"r","heightMapTiling":[1,1],"heightMapOffset":[0,0],"heightMapFactor":1,"opacityMapChannel":"r","opacityMapTiling":[1,1],"opacityMapOffset":[0,0],"refractionIndex":0.6666666666666666,"cubeMapProjectionBox":{"center":[0,0,0],"halfExtents":[0.5,0.5,0.5]},"lightMapChannel":"rgb","lightMapUv":1,"lightMapTiling":[1,1],"lightMapOffset":[0,0],"depthTest":true,"depthWrite":true,"cull":1,"blendType":3,"shadowSampleType":1,"useFog":true,"useLighting":true,"useSkybox":true,"mapping_format":"path"}
3 changes: 1 addition & 2 deletions src/scene/materials/lit-material-options-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
CUBEPROJ_NONE, LIGHTTYPE_DIRECTIONAL, LIGHTTYPE_OMNI, LIGHTTYPE_SPOT,
MASK_AFFECT_DYNAMIC, TONEMAP_NONE, SHADERDEF_INSTANCING, SHADERDEF_MORPH_NORMAL,
SHADERDEF_MORPH_POSITION, SHADERDEF_MORPH_TEXTURE_BASED, SHADERDEF_SCREENSPACE, SHADERDEF_SKIN,
SHADERDEF_NOSHADOW, SHADERDEF_TANGENTS, SPECULAR_BLINN, SPRITE_RENDERMODE_SIMPLE
SHADERDEF_NOSHADOW, SHADERDEF_TANGENTS, SPRITE_RENDERMODE_SIMPLE
} from "../constants.js";

class LitMaterialOptionsBuilder {
Expand Down Expand Up @@ -67,7 +67,6 @@ class LitMaterialOptionsBuilder {

litOptions.cubeMapProjection = CUBEPROJ_NONE;

litOptions.conserveEnergy = material.conserveEnergy && material.shadingModel === SPECULAR_BLINN;
litOptions.useSpecular = material.hasSpecular;
litOptions.useSpecularityFactor = material.hasSpecularityFactor;
litOptions.enableGGXSpecular = material.ggxSpecular;
Expand Down
2 changes: 0 additions & 2 deletions src/scene/materials/lit-material.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ class LitMaterial extends Material {

opacityShadowDither = DITHER_NONE;

conserveEnergy = true;

ggxSpecular = false;

fresnelModel = FRESNEL_SCHLICK;
Expand Down
1 change: 0 additions & 1 deletion src/scene/materials/standard-material-options-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,6 @@ class StandardMaterialOptionsBuilder {
options.litOptions.cubeMapProjection = stdMat.cubeMapProjection;

options.litOptions.occludeDirect = stdMat.occludeDirect;
options.litOptions.conserveEnergy = stdMat.conserveEnergy;
options.litOptions.useSpecular = useSpecular;
options.litOptions.useSpecularityFactor = (specularityFactorTint || !!stdMat.specularityFactorMap) && stdMat.useMetalnessSpecularColor;
options.litOptions.enableGGXSpecular = stdMat.enableGGXSpecular;
Expand Down
1 change: 0 additions & 1 deletion src/scene/materials/standard-material-parameters.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ const standardMaterialParameterTypes = {
..._textureParameter('metalness'),
useMetalnessSpecularColor: 'boolean',

conserveEnergy: 'boolean',
shininess: 'number',
gloss: 'number',
glossInvert: 'boolean',
Expand Down
7 changes: 1 addition & 6 deletions src/scene/materials/standard-material.js
Original file line number Diff line number Diff line change
Expand Up @@ -519,16 +519,12 @@ const _tempColor = new Color();
* @property {number} occludeSpecularIntensity Controls visibility of specular occlusion.
* @property {boolean} occludeDirect Tells if AO should darken directional lighting. Defaults to
* false.
* @property {boolean} conserveEnergy Defines how diffuse and specular components are combined when
* Fresnel is on. It is recommended that you leave this option enabled, although you may want to
* disable it in case when all reflection comes only from a few light sources, and you don't use an
* environment map, therefore having mostly black reflection.
* @property {number} shadingModel Defines the shading model.
* - {@link SPECULAR_BLINN}: Energy-conserving Blinn-Phong.
* @property {number} fresnelModel Defines the formula used for Fresnel effect.
* As a side-effect, enabling any Fresnel model changes the way diffuse and reflection components
* are combined. When Fresnel is off, legacy non energy-conserving combining is used. When it is
* on, combining behavior is defined by conserveEnergy parameter.
* on, combining behavior is energy-conserving.
*
* - {@link FRESNEL_NONE}: No Fresnel.
* - {@link FRESNEL_SCHLICK}: Schlick's approximation of Fresnel (recommended). Parameterized by
Expand Down Expand Up @@ -1219,7 +1215,6 @@ function _defineMaterialProps() {
_defineFlag('enableGGXSpecular', false);
_defineFlag('occludeDirect', false);
_defineFlag('normalizeNormalMap', true);
_defineFlag('conserveEnergy', true);
_defineFlag('opacityFadesSpecular', true);
_defineFlag('occludeSpecular', SPECOCC_AO);
_defineFlag('shadingModel', SPECULAR_BLINN);
Expand Down
1 change: 0 additions & 1 deletion src/scene/shader-lib/chunks/chunk-validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ const removedChunks = {
combineDiffuseSpecularNoReflPS: CHUNKAPI_1_56,
combineDiffuseSpecularNoReflSeparateAmbientPS: CHUNKAPI_1_56,
combineDiffuseSpecularOldPS: CHUNKAPI_1_56,
combineDiffuseSpecularNoConservePS: CHUNKAPI_1_55,
lightmapSingleVertPS: CHUNKAPI_1_55,
normalMapFastPS: CHUNKAPI_1_55,
specularAaNonePS: CHUNKAPI_1_55,
Expand Down
6 changes: 1 addition & 5 deletions src/scene/shader-lib/chunks/lit/frag/clusteredLight.js
Original file line number Diff line number Diff line change
Expand Up @@ -397,9 +397,7 @@ void evaluateLight(
vec3 areaDiffuse = (diffuseAttenuation * falloffAttenuation) * light.color * cookieAttenuation;

#if defined(LIT_SPECULAR)
#if defined(LIT_CONSERVE_ENERGY)
areaDiffuse = mix(areaDiffuse, vec3(0), dLTCSpecFres);
#endif
areaDiffuse = mix(areaDiffuse, vec3(0), dLTCSpecFres);
#endif

// area light diffuse - it does not mix diffuse lighting into specular attenuation
Expand Down Expand Up @@ -453,11 +451,9 @@ void evaluateLight(

#if defined(CLUSTER_AREALIGHTS)
#if defined(LIT_SPECULAR)
#if defined(LIT_CONSERVE_ENERGY)
punctualDiffuse = mix(punctualDiffuse, vec3(0), specularity);
#endif
#endif
#endif

dDiffuseLight += punctualDiffuse;
}
Expand Down
7 changes: 0 additions & 7 deletions src/scene/shader-lib/programs/lit-shader-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,6 @@ class LitShaderOptions {
*/
cubeMapProjection = 0;

/**
* The value of {@link StandardMaterial#conserveEnergy}.
*
* @type {boolean}
*/
conserveEnergy = false;

/**
* If any specular or reflections are needed at all.
*
Expand Down
11 changes: 3 additions & 8 deletions src/scene/shader-lib/programs/lit-shader.js
Original file line number Diff line number Diff line change
Expand Up @@ -593,11 +593,6 @@ class LitShader {
this.defines.push("LIT_SPECULAR_FRESNEL");
}

// enable conserve energy path in clustered chunk
if (options.conserveEnergy) {
this.defines.push("LIT_CONSERVE_ENERGY");
}

if (options.useSheen) {
this.defines.push("LIT_SHEEN");
}
Expand Down Expand Up @@ -1019,7 +1014,7 @@ class LitShader {

if (addAmbient) {
backend.append(" addAmbient(litArgs_worldNormal);");
if (options.conserveEnergy && options.useSpecular) {
if (options.useSpecular) {
backend.append(` dDiffuseLight = dDiffuseLight * (1.0 - litArgs_specularity);`);
}

Expand Down Expand Up @@ -1306,15 +1301,15 @@ class LitShader {
if (lightShape !== LIGHTSHAPE_PUNCTUAL) {

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

// punctual light
if (hasAreaLights && options.conserveEnergy && options.useSpecular) {
if (hasAreaLights && options.useSpecular) {
backend.append(" dDiffuseLight += (dAtten * light" + i + "_color" + (usesCookieNow ? " * dAtten3" : "") + ") * (1.0 - litArgs_specularity);");
} else {
backend.append(" dDiffuseLight += dAtten * light" + i + "_color" + (usesCookieNow ? " * dAtten3" : "") + ";");
Expand Down
2 changes: 0 additions & 2 deletions test/scene/materials/standard-material.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ describe('StandardMaterial', function () {
expect(material.clearCoatVertexColor).to.equal(false);
expect(material.clearCoatVertexColorChannel).to.equal('g');

expect(material.conserveEnergy).to.equal(true);

expect(material.cubeMap).to.be.null;
expect(material.cubeMapProjection).to.equal(CUBEPROJ_NONE);
expect(material.cubeMapProjectionBox).to.be.null;
Expand Down
1 change: 0 additions & 1 deletion test/test-assets/box/1/Box Material.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
0
],
"metalness": 1,
"conserveEnergy": true,
"glossMapChannel": "r",
"glossMapTiling": [
1,
Expand Down
Loading