mirror of
https://github.com/DeMuenu/MoonlightVRC.git
synced 2025-12-13 11:33:54 +00:00
Refactor light range and angle calculations
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.
This commit is contained in:
@@ -30,15 +30,24 @@ public partial class LightUpdater
|
||||
|
||||
LightdataStorage data = t.GetComponent<LightdataStorage>();
|
||||
|
||||
// w = cosHalfAngle (0 for omni)
|
||||
float cosHalf = (data != null) ? data.GetCosHalfAngle() : 0f;
|
||||
|
||||
Vector3 pos = t.position;
|
||||
float range = (data != null) ? data.range * t.localScale.x : t.localScale.x;
|
||||
float range = 0;
|
||||
if (data.lightType == LightType.Sphere)
|
||||
{
|
||||
range = (data != null) ? data.range * t.localScale.x : t.localScale.x;
|
||||
}
|
||||
else
|
||||
{
|
||||
range = (data != null) ? Mathf.Cos(Mathf.Deg2Rad * ((data.spotAngleDeg * 0.5f) + Mathf.Max(data.range, 0))): 0f;
|
||||
}
|
||||
|
||||
// rgb = color, a = intensity (packed to match runtime/shader)
|
||||
Vector4 col = (data != null) ? data.GetFinalColor() : new Vector4(1f, 1f, 1f, 1f);
|
||||
float intensity = (data != null) ? data.intensity * t.localScale.x : 1f;
|
||||
|
||||
// w = cosHalfAngle (0 for omni)
|
||||
float cosHalf = (data != null) ? data.spotAngleDeg : 0f;
|
||||
|
||||
// 0=Omni, 1=Spot, 2=Directional (your custom enum)
|
||||
int typeId = (data != null) ? data.GetTypeId() : 0;
|
||||
|
||||
Reference in New Issue
Block a user