mirror of
https://github.com/DeMuenu/MoonlightVRC.git
synced 2025-12-12 19:13:56 +00:00
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:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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; \
|
||||
|
||||
Reference in New Issue
Block a user