Skip to content

Commit

Permalink
Merge pull request #12771 from yvele/perf-material-helper-tree-shaking
Browse files Browse the repository at this point in the history
perf: Improve `MaterialHelper` tree-shaking with `LightConstants`
  • Loading branch information
sebavan authored Jul 20, 2022
2 parents 48493df + a87ef11 commit 343ebd3
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions packages/dev/core/src/Materials/materialHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import { EngineStore } from "../Engines/engineStore";
import type { AbstractMesh } from "../Meshes/abstractMesh";
import type { Mesh } from "../Meshes/mesh";
import { VertexBuffer } from "../Buffers/buffer";
import { Light } from "../Lights/light";
import type { Light } from "../Lights/light";
import { LightConstants } from "../Lights/lightConstants";
import { Constants } from "../Engines/constants";
import type { PrePassConfiguration } from "../Materials/prePassConfiguration";

Expand Down Expand Up @@ -478,13 +479,13 @@ export class MaterialHelper {
defines["LIGHT_FALLOFF_STANDARD" + lightIndex] = false;

switch (light.falloffType) {
case Light.FALLOFF_GLTF:
case LightConstants.FALLOFF_GLTF:
defines["LIGHT_FALLOFF_GLTF" + lightIndex] = true;
break;
case Light.FALLOFF_PHYSICAL:
case LightConstants.FALLOFF_PHYSICAL:
defines["LIGHT_FALLOFF_PHYSICAL" + lightIndex] = true;
break;
case Light.FALLOFF_STANDARD:
case LightConstants.FALLOFF_STANDARD:
defines["LIGHT_FALLOFF_STANDARD" + lightIndex] = true;
break;
}
Expand Down Expand Up @@ -524,10 +525,10 @@ export class MaterialHelper {
}
}

if (light.lightmapMode != Light.LIGHTMAP_DEFAULT) {
if (light.lightmapMode != LightConstants.LIGHTMAP_DEFAULT) {
state.lightmapMode = true;
defines["LIGHTMAPEXCLUDED" + lightIndex] = true;
defines["LIGHTMAPNOSPECULAR" + lightIndex] = light.lightmapMode == Light.LIGHTMAP_SHADOWSONLY;
defines["LIGHTMAPNOSPECULAR" + lightIndex] = light.lightmapMode == LightConstants.LIGHTMAP_SHADOWSONLY;
} else {
defines["LIGHTMAPEXCLUDED" + lightIndex] = false;
defines["LIGHTMAPNOSPECULAR" + lightIndex] = false;
Expand Down

0 comments on commit 343ebd3

Please sign in to comment.