@@ -55,7 +55,7 @@ inline void ApplyLighting(in Surface surface, in Lighting lighting, inout half4
5555}
5656
5757//#define CASCADE_DITHERING
58- inline void light_directional (in ShaderEntity light, in Surface surface, inout Lighting lighting, in half shadow_mask = 1 )
58+ inline void light_directional (in ShaderEntity light, in uint entity_index, in Surface surface, inout Lighting lighting, in half shadow_mask = 1 )
5959{
6060 if (shadow_mask <= 0.001 )
6161 return ; // shadow mask zero
@@ -186,7 +186,7 @@ inline half attenuation_pointlight(in half dist2, in half range, in half range2)
186186 dist_per_range *= dist_per_range; // pow4
187187 return saturate (1 - dist_per_range) / max (0.0001 , dist2);
188188}
189- inline void light_point (in ShaderEntity light, in Surface surface, inout Lighting lighting, in half shadow_mask = 1 )
189+ inline void light_point (in ShaderEntity light, in uint entity_index, in Surface surface, inout Lighting lighting, in half shadow_mask = 1 )
190190{
191191 if (shadow_mask <= 0.001 )
192192 return ; // shadow mask zero
@@ -303,7 +303,7 @@ inline half attenuation_spotlight(in half dist2, in half range, in half range2,
303303 attenuation *= angularAttenuation;
304304 return attenuation;
305305}
306- inline void light_spot (in ShaderEntity light, in Surface surface, inout Lighting lighting, in half shadow_mask = 1 )
306+ inline void light_spot (in ShaderEntity light, in uint entity_index, in Surface surface, inout Lighting lighting, in half shadow_mask = 1 )
307307{
308308 if (shadow_mask <= 0.001 )
309309 return ; // shadow mask zero
@@ -343,7 +343,7 @@ inline void light_spot(in ShaderEntity light, in Surface surface, inout Lighting
343343 if ((GetFrame ().options & OPTION_BIT_RAYTRACED_SHADOWS) == 0 || GetCamera ().texture_rtshadow_index < 0 || (GetCamera ().options & SHADERCAMERA_OPTION_USE_SHADOW_MASK) == 0 )
344344#endif // SHADOW_MASK_ENABLED
345345 {
346- float4 shadow_pos = mul (load_entitymatrix (light. GetMatrixIndex () + 0 ), float4 (surface.P, 1 ));
346+ float4 shadow_pos = mul (load_entitymatrix (entity_index ), float4 (surface.P, 1 ));
347347 shadow_pos.xyz /= shadow_pos.w;
348348 float2 shadow_uv = clipspace_to_uv (shadow_pos.xy);
349349 [branch]
@@ -361,7 +361,7 @@ inline void light_spot(in ShaderEntity light, in Surface surface, inout Lighting
361361 [branch]
362362 if (maskTex > 0 )
363363 {
364- float4 shadow_pos = mul (load_entitymatrix (light. GetMatrixIndex () + 0 ), float4 (surface.P, 1 ));
364+ float4 shadow_pos = mul (load_entitymatrix (entity_index ), float4 (surface.P, 1 ));
365365 shadow_pos.xyz /= shadow_pos.w;
366366 float2 shadow_uv = clipspace_to_uv (shadow_pos.xy);
367367 half4 mask = bindless_textures_half4[descriptor_index (maskTex)].SampleLevel (sampler_linear_clamp, shadow_uv, 0 );
@@ -394,7 +394,7 @@ inline void light_spot(in ShaderEntity light, in Surface surface, inout Lighting
394394#endif // LIGHTING_SCATTER
395395}
396396
397- inline void light_rect (in ShaderEntity light, in Surface surface, inout Lighting lighting, in half shadow_mask = 1 )
397+ inline void light_rect (in ShaderEntity light, in uint entity_index, in Surface surface, inout Lighting lighting, in half shadow_mask = 1 )
398398{
399399#ifndef DISABLE_AREA_LIGHTS
400400 if (shadow_mask <= 0.001 )
@@ -477,7 +477,7 @@ inline void light_rect(in ShaderEntity light, in Surface surface, inout Lighting
477477 if ((GetFrame ().options & OPTION_BIT_RAYTRACED_SHADOWS) == 0 || GetCamera ().texture_rtshadow_index < 0 || (GetCamera ().options & SHADERCAMERA_OPTION_USE_SHADOW_MASK) == 0 )
478478#endif // SHADOW_MASK_ENABLED
479479 {
480- float4 shadow_pos = mul (load_entitymatrix (light. GetMatrixIndex () + 0 ), float4 (surface.P, 1 ));
480+ float4 shadow_pos = mul (load_entitymatrix (entity_index ), float4 (surface.P, 1 ));
481481 shadow_pos.xyz /= shadow_pos.w;
482482 float2 shadow_uv = clipspace_to_uv (shadow_pos.xy);
483483 [branch]
@@ -513,7 +513,7 @@ inline void light_rect(in ShaderEntity light, in Surface surface, inout Lighting
513513 uint mipcount;
514514 tex.GetDimensions (0 , dim.x, dim.y, mipcount);
515515
516- float4 shadow_pos = mul (load_entitymatrix (light. GetMatrixIndex () + 0 ), float4 (surface.P, 1 ));
516+ float4 shadow_pos = mul (load_entitymatrix (entity_index ), float4 (surface.P, 1 ));
517517 shadow_pos.xyz /= shadow_pos.w;
518518 float2 diffuse_uv = clipspace_to_uv (shadow_pos.xy);
519519 half4 diffuse_mask = tex.SampleLevel (sampler_linear_clamp, diffuse_uv, mipcount - 2 );
0 commit comments