From a462235caadd46d3e3c1531cf59415dc6ac0f0d7 Mon Sep 17 00:00:00 2001 From: Martin Valigursky <59932779+mvaligursky@users.noreply.github.com> Date: Mon, 9 Dec 2024 09:10:40 +0000 Subject: [PATCH] [Fix] Correctly handle VSM not being supported by cluseted lighting (#7184) Co-authored-by: Martin Valigursky --- src/scene/shader-lib/programs/lit-shader.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/scene/shader-lib/programs/lit-shader.js b/src/scene/shader-lib/programs/lit-shader.js index 4b6643cbbf0..20500cb070a 100644 --- a/src/scene/shader-lib/programs/lit-shader.js +++ b/src/scene/shader-lib/programs/lit-shader.js @@ -430,9 +430,6 @@ class LitShader { const lightType = this.shaderPassInfo.lightType; let shadowType = this.shaderPassInfo.shadowType; - const shadowInfo = shadowTypeInfo.get(shadowType); - Debug.assert(shadowInfo); - const isVsm = shadowInfo?.vsm ?? false; // If not a directional light and using clustered, fall back to using PCF3x3 if shadow type isn't supported if (lightType !== LIGHTTYPE_DIRECTIONAL && options.clusteredLightingEnabled) { @@ -441,6 +438,10 @@ class LitShader { } } + const shadowInfo = shadowTypeInfo.get(shadowType); + Debug.assert(shadowInfo); + const isVsm = shadowInfo?.vsm ?? false; + let code = this._fsGetBeginCode(); if (shadowType === SHADOW_VSM_32F) {