Files
MoonlightVRC/Shader/Includes/LightStrength.hlsl
DeMuenu 8e740bd636 Add shadowcaster blur support to shaders
Introduces a _BlurPixels property and related parameters to BlendinShader and LitParticles shaders, enabling blurred shadowcaster sampling. Updates Shadowcaster.cginc to support blurred texture sampling using tex2Dgrad when blur is enabled. Also adjusts light intensity calculation in LightStrength.hlsl to remove NdotL multiplication for consistency with new shadow handling.
2025-10-01 14:48:44 +02:00

25 lines
1.1 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)); \
float threshold = (-1 + _Udon_LightDirections[LightCounter].w / 180); \
\
contrib = min(dot(normalize(i.worldPos - Lightposition), -normalize(_Udon_LightDirections[LightCounter].xyz)), 0); \
contrib= 1 - step(threshold, contrib); \
\
contrib = contrib * invSq; \
dIntensity += contrib; \
} \
float3 LightColor = _Udon_LightColors[LightCounter].xyz; \
#endif