Files
Convention-Unity-Demo/Assets/Plugins/Unity-URP-Volumetric-Light-0.5.8/Runtime/VolumetricAdditionalLight.cs
2025-09-25 19:04:05 +08:00

47 lines
1.6 KiB
C#

using UnityEngine;
using UnityEngine.Rendering.Universal;
/// <summary>
/// This is a component that can be added to additional lights to set the parameters that will
/// affect how this light is considered for the volumetric fog effect.
/// </summary>
[DisallowMultipleComponent]
[RequireComponent(typeof(Light), typeof(UniversalAdditionalLightData))]
public sealed class VolumetricAdditionalLight : MonoBehaviour
{
#region Private Attributes
[Tooltip("Higher positive values will make the fog affected by this light to appear brighter when directly looking to it, while lower negative values will make the fog to appear brighter when looking away from it. The closer the value is closer to 1 or -1, the less the brightness will spread. Most times, positive values higher than 0 and lower than 1 should be used.")]
[Range(-1.0f, 1.0f)]
[SerializeField] private float anisotropy = 0.25f;
[Tooltip("Higher values will make fog affected by this light to appear brighter.")]
[Range(0.0f, 16.0f)]
[SerializeField] private float scattering = 1.0f;
[Tooltip("Sets a falloff radius for this light. A higher value reduces noise towards the origin of the light.")]
[Range(0.0f, 1.0f)]
[SerializeField] private float radius = 0.2f;
#endregion
#region Properties
public float Anisotropy
{
get { return anisotropy; }
set { anisotropy = Mathf.Clamp(value, -1.0f, 1.0f); }
}
public float Scattering
{
get { return scattering; }
set { scattering = Mathf.Clamp(value, 0.0f, 16.0f); }
}
public float Radius
{
get { return radius; }
set { radius = Mathf.Clamp01(value); }
}
#endregion
}