Skip to content

Commit a1a6891

Browse files
deltakoshDavid Catuhe
andauthored
Fix light reset when reducing maxSimultaneousLights value (#17068)
Co-authored-by: David Catuhe <[email protected]>
1 parent 80a53d1 commit a1a6891

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

packages/dev/core/src/Materials/materialHelper.functions.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,9 @@ export function PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, define
569569
defines["SHADOWS"] = state.shadowEnabled;
570570

571571
// Resetting all other lights if any
572-
for (let index = lightIndex; index < maxSimultaneousLights; index++) {
572+
const maxLightCount = Math.max(maxSimultaneousLights, defines["MAXLIGHTCOUNT"] || 0);
573+
574+
for (let index = lightIndex; index < maxLightCount; index++) {
573575
if (defines["LIGHT" + index] !== undefined) {
574576
defines["LIGHT" + index] = false;
575577
defines["HEMILIGHT" + index] = false;
@@ -596,6 +598,8 @@ export function PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, define
596598
}
597599
}
598600

601+
defines["MAXLIGHTCOUNT"] = maxSimultaneousLights;
602+
599603
const caps = scene.getEngine().getCaps();
600604

601605
if (defines["SHADOWFLOAT"] === undefined) {

0 commit comments

Comments
 (0)