smooth falloff, but not correct angles

Replaced usage of GetCosHalfAngle() with spotAngleDeg for spot light calculations in both editor and runtime scripts. Updated shader logic to use smoothstep for light contribution falloff, improving spot light edge smoothness.
This commit is contained in:
DeMuenu
2025-10-03 23:27:27 +02:00
parent b26c189b89
commit bb31145e4d
3 changed files with 4 additions and 4 deletions

View File

@@ -38,7 +38,7 @@ public partial class LightUpdater
float intensity = (data != null) ? data.intensity * t.localScale.x : 1f;
// w = cosHalfAngle (0 for omni)
float cosHalf = (data != null) ? data.GetCosHalfAngle() : 0f;
float cosHalf = (data != null) ? data.spotAngleDeg : 0f;
// 0=Omni, 1=Spot, 2=Directional (your custom enum)
int typeId = (data != null) ? data.GetTypeId() : 0;

View File

@@ -221,7 +221,7 @@ public partial class LightUpdater : UdonSharpBehaviour
Vector3 fwd = rot * Vector3.down;
float cosHalf = (data != null) ? data.GetCosHalfAngle() : 0f;
float Lightangle = (data != null) ? data.spotAngleDeg : 0f;
Vector4 posTemp = new Vector4(pos.x, pos.y, pos.z, range);
if (_positions[currentCount] != posTemp)
@@ -235,7 +235,7 @@ public partial class LightUpdater : UdonSharpBehaviour
_lightColors[currentCount] = colorTemp;
_lightColors_isDirty = true;
}
Vector4 dirTemp = new Vector4(fwd.x, fwd.y, fwd.z, cosHalf);
Vector4 dirTemp = new Vector4(fwd.x, fwd.y, fwd.z, Lightangle);
if (_directions[currentCount] != dirTemp)
{
_directions[currentCount] = dirTemp;

View File

@@ -14,7 +14,7 @@
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= 1 - smoothstep(threshold, threshold + radius / 180, contrib); \
\
contrib = contrib * invSq; \
dIntensity += contrib; \