mirror of
https://github.com/DeMuenu/MoonlightVRC.git
synced 2025-12-12 19:13:56 +00:00
Updated how light range and spot angle are calculated and packed for both editor and runtime scripts, distinguishing between sphere and non-sphere lights. Adjusted shader logic to use new packing for spot light contribution, improving consistency between CPU and GPU representations.
24 lines
1.0 KiB
HLSL
24 lines
1.0 KiB
HLSL
#ifndef LightTypeCalculations
|
|
#define LightTypeCalculations(_Udon_LightColors ,LightCounter, i, NdotL, dIntensity, radius, Lightposition) \
|
|
float invSqMul = max(1e-4, _InverseSqareMultiplier); \
|
|
\
|
|
if(_Udon_LightType[LightCounter] == 0) \
|
|
{ \
|
|
contrib = _Udon_LightColors[LightCounter].a / max(1e-4, max(0, max(1, distanceFromLight - radius) * invSqMul) * max(0, max(1, distanceFromLight - radius) * invSqMul)); \
|
|
\
|
|
dIntensity += contrib; \
|
|
} \
|
|
else if (_Udon_LightType[LightCounter] == 1) \
|
|
{ \
|
|
float invSq = _Udon_LightColors[LightCounter].a / max(1e-4, (distanceFromLight * invSqMul) * (distanceFromLight * invSqMul)); \
|
|
\
|
|
contrib = dot(normalize(i.worldPos - Lightposition), normalize(_Udon_LightDirections[LightCounter].xyz)); \
|
|
contrib = smoothstep(radius,_Udon_LightDirections[LightCounter].w, contrib); \
|
|
\
|
|
contrib = contrib * invSq; \
|
|
dIntensity += contrib; \
|
|
} \
|
|
float3 LightColor = _Udon_LightColors[LightCounter].xyz; \
|
|
|
|
|
|
#endif |