Skip to content

Commit 5a00c54

Browse files
SergioRZMassonRolandCsibrei
authored andcommitted
Fixes Area Lights for NME (BabylonJS#16577)
The samplers required by Area Lights are placed in files that might not always be included when using NME. I'm moving them to always be paired with the appropriate area Lights functions to make sure we always have the samplers available. Fixes issue reported from forum: https://forum.babylonjs.com/t/triplanar-node-material-area-lights-issue/58296
1 parent 972cad1 commit 5a00c54

File tree

4 files changed

+8
-12
lines changed

4 files changed

+8
-12
lines changed

packages/dev/core/src/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions.fx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ preLightingInfo computeHemisphericPreLightingInfo(vec4 lightData, vec3 V, vec3 N
9696
#if defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)
9797
#include<ltcHelperFunctions>
9898

99+
uniform sampler2D areaLightsLTC1Sampler;
100+
uniform sampler2D areaLightsLTC2Sampler;
101+
99102
preLightingInfo computeAreaPreLightingInfo(sampler2D ltc1, sampler2D ltc2, vec3 viewDirectionW, vec3 vNormal, vec3 vPosition, vec4 lightData, vec3 halfWidth, vec3 halfHeight, float roughness )
100103
{
101104
preLightingInfo result;

packages/dev/core/src/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.fx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,6 @@
8585
uniform sampler2D environmentBrdfSampler;
8686
#endif
8787

88-
#if defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)
89-
uniform sampler2D areaLightsLTC1Sampler;
90-
uniform sampler2D areaLightsLTC2Sampler;
91-
#endif
92-
9388
// SUBSURFACE
9489
#ifdef SUBSURFACE
9590
#ifdef SS_REFRACTION

packages/dev/core/src/ShadersWGSL/ShadersInclude/pbrDirectLightingSetupFunctions.fx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ fn computeHemisphericPreLightingInfo(lightData: vec4f, V: vec3f, N: vec3f) -> pr
9494
#if defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)
9595
#include<ltcHelperFunctions>
9696

97+
var areaLightsLTC1SamplerSampler: sampler;
98+
var areaLightsLTC1Sampler: texture_2d<f32>;
99+
var areaLightsLTC2SamplerSampler: sampler;
100+
var areaLightsLTC2Sampler: texture_2d<f32>;
101+
97102
fn computeAreaPreLightingInfo(ltc1: texture_2d<f32>, ltc1Sampler:sampler, ltc2:texture_2d<f32>, ltc2Sampler:sampler, viewDirectionW: vec3f, vNormal:vec3f, vPosition:vec3f, lightCenter:vec3f, halfWidth:vec3f, halfHeight:vec3f, roughness:f32) -> preLightingInfo {
98103
var result: preLightingInfo;
99104
var data: areaLightData = computeAreaLightSpecularDiffuseFresnel(ltc1, ltc1Sampler, ltc2, ltc2Sampler, viewDirectionW, vNormal, vPosition, lightCenter, halfWidth, halfHeight, roughness);

packages/dev/core/src/ShadersWGSL/ShadersInclude/pbrFragmentSamplersDeclaration.fx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,6 @@
9191
var environmentBrdfSampler: texture_2d<f32>;
9292
#endif
9393

94-
#if defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)
95-
var areaLightsLTC1SamplerSampler: sampler;
96-
var areaLightsLTC1Sampler: texture_2d<f32>;
97-
var areaLightsLTC2SamplerSampler: sampler;
98-
var areaLightsLTC2Sampler: texture_2d<f32>;
99-
#endif
100-
10194

10295
// SUBSURFACE
10396
#ifdef SUBSURFACE

0 commit comments

Comments
 (0)