Skip to content

Commit

Permalink
[Fix] Fix to light options processing causing clustered shaders compi…
Browse files Browse the repository at this point in the history
…lation when lights change (#4955)

Co-authored-by: Martin Valigursky <mvaligursky@snapchat.com>
  • Loading branch information
mvaligursky and Martin Valigursky committed Jan 9, 2023
1 parent 9db2ced commit 4199b6d
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/scene/shader-lib/programs/standard.js
Expand Up @@ -59,15 +59,20 @@ const standard = {
}

if (options.litOptions) {
for (const m in options.litOptions)
key += m + options.litOptions[m];
if (options.litOptions.lights) {
const isClustered = options.litOptions.clusteredLightingEnabled;
for (let i = 0; i < options.litOptions.lights.length; i++) {
const light = options.litOptions.lights[i];
if (!isClustered || light._type === LIGHTTYPE_DIRECTIONAL) {
key += light.key;

for (const m in options.litOptions) {

// handle lights in a custom way
if (m === 'lights') {
const isClustered = options.litOptions.clusteredLightingEnabled;
for (let i = 0; i < options.litOptions.lights.length; i++) {
const light = options.litOptions.lights[i];
if (!isClustered || light._type === LIGHTTYPE_DIRECTIONAL) {
key += light.key;
}
}
} else {
key += m + options.litOptions[m];
}
}
}
Expand Down

0 comments on commit 4199b6d

Please sign in to comment.