docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class ScreenSpaceLensFlare

    A volume component that holds settings for the Screen Space Lens Flare effect.

    Inheritance
    object
    Object
    ScriptableObject
    VolumeComponent
    ScreenSpaceLensFlare
    Implements
    IApplyRevertPropertyContextMenuItemProvider
    IPostProcessComponent
    Inherited Members
    VolumeComponent.active
    VolumeComponent.OnEnable()
    VolumeComponent.OnDisable()
    VolumeComponent.Override(VolumeComponent, float)
    VolumeComponent.SetAllOverridesTo(bool)
    VolumeComponent.GetHashCode()
    VolumeComponent.AnyPropertiesIsOverridden()
    VolumeComponent.OnDestroy()
    VolumeComponent.Release()
    VolumeComponent.TryGetRevertMethodForFieldName(SerializedProperty, out Action<SerializedProperty>)
    VolumeComponent.GetSourceTerm()
    VolumeComponent.TryGetApplyMethodForFieldName(SerializedProperty, out Action<SerializedProperty>)
    VolumeComponent.GetSourceName(Component)
    VolumeComponent.displayName
    VolumeComponent.parameters
    ScriptableObject.CreateInstance(string)
    ScriptableObject.CreateInstance(Type)
    ScriptableObject.CreateInstance<T>()
    Object.GetEntityId()
    Object.GetInstanceID()
    Object.Equals(object)
    Object.InstantiateAsync<T>(T)
    Object.InstantiateAsync<T>(T, Transform)
    Object.InstantiateAsync<T>(T, Vector3, Quaternion)
    Object.InstantiateAsync<T>(T, Transform, Vector3, Quaternion)
    Object.InstantiateAsync<T>(T, int)
    Object.InstantiateAsync<T>(T, int, Transform)
    Object.InstantiateAsync<T>(T, int, Vector3, Quaternion)
    Object.InstantiateAsync<T>(T, int, ReadOnlySpan<Vector3>, ReadOnlySpan<Quaternion>)
    Object.InstantiateAsync<T>(T, int, Transform, Vector3, Quaternion)
    Object.InstantiateAsync<T>(T, int, Transform, Vector3, Quaternion, CancellationToken)
    Object.InstantiateAsync<T>(T, int, Transform, ReadOnlySpan<Vector3>, ReadOnlySpan<Quaternion>)
    Object.InstantiateAsync<T>(T, int, Transform, ReadOnlySpan<Vector3>, ReadOnlySpan<Quaternion>, CancellationToken)
    Object.InstantiateAsync<T>(T, InstantiateParameters, CancellationToken)
    Object.InstantiateAsync<T>(T, int, InstantiateParameters, CancellationToken)
    Object.InstantiateAsync<T>(T, Vector3, Quaternion, InstantiateParameters, CancellationToken)
    Object.InstantiateAsync<T>(T, int, Vector3, Quaternion, InstantiateParameters, CancellationToken)
    Object.InstantiateAsync<T>(T, int, ReadOnlySpan<Vector3>, ReadOnlySpan<Quaternion>, InstantiateParameters, CancellationToken)
    Object.Instantiate(Object, Vector3, Quaternion)
    Object.Instantiate(Object, Vector3, Quaternion, Transform)
    Object.Instantiate(Object)
    Object.Instantiate(Object, Scene)
    Object.Instantiate<T>(T, InstantiateParameters)
    Object.Instantiate<T>(T, Vector3, Quaternion, InstantiateParameters)
    Object.Instantiate(Object, Transform)
    Object.Instantiate(Object, Transform, bool)
    Object.Instantiate<T>(T)
    Object.Instantiate<T>(T, Vector3, Quaternion)
    Object.Instantiate<T>(T, Vector3, Quaternion, Transform)
    Object.Instantiate<T>(T, Transform)
    Object.Instantiate<T>(T, Transform, bool)
    Object.Destroy(Object, float)
    Object.Destroy(Object)
    Object.DestroyImmediate(Object, bool)
    Object.DestroyImmediate(Object)
    Object.FindObjectsByType(Type, FindObjectsSortMode)
    Object.FindObjectsByType(Type, FindObjectsInactive, FindObjectsSortMode)
    Object.DontDestroyOnLoad(Object)
    Object.FindObjectsByType<T>(FindObjectsSortMode)
    Object.FindObjectsByType<T>(FindObjectsInactive, FindObjectsSortMode)
    Object.FindFirstObjectByType<T>()
    Object.FindAnyObjectByType<T>()
    Object.FindFirstObjectByType<T>(FindObjectsInactive)
    Object.FindAnyObjectByType<T>(FindObjectsInactive)
    Object.FindFirstObjectByType(Type)
    Object.FindAnyObjectByType(Type)
    Object.FindFirstObjectByType(Type, FindObjectsInactive)
    Object.FindAnyObjectByType(Type, FindObjectsInactive)
    Object.ToString()
    Object.name
    Object.hideFlags
    object.Equals(object, object)
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    Namespace: UnityEngine.Rendering.Universal
    Assembly: Unity.RenderPipelines.Universal.Runtime.dll
    Syntax
    [Serializable]
    [VolumeComponentMenu("Post-processing/Screen Space Lens Flare")]
    [SupportedOnRenderPipeline(typeof(UniversalRenderPipelineAsset))]
    public class ScreenSpaceLensFlare : VolumeComponent, IApplyRevertPropertyContextMenuItemProvider, IPostProcessComponent
    Remarks

    You can add VolumeComponent to a VolumeProfile in the Editor to apply a Screen Space Lens Flare post-processing effect.

    Examples

    This sample code shows how settings can be retrieved and modified in runtime:

    using System;
    using UnityEngine;
    using UnityEngine.Rendering;
    using UnityEngine.Rendering.Universal;
    

    public class ModifyVolumeComponent : MonoBehaviour { [SerializeField] VolumeProfile volumeProfile; [SerializeField] VolumeSettings volumeSettings;

    private bool m_HasRetrievedVolumeComponent;
    private ScreenSpaceLensFlare m_VolumeComponent;
    
    [Serializable]
    private struct VolumeSettings
    {
        public bool active;
        public MinFloatParameter intensity;
        public ColorParameter tintColor;
        public ClampedIntParameter bloomMip;
        public MinFloatParameter firstFlareIntensity;
        public MinFloatParameter secondaryFlareIntensity;
        public MinFloatParameter warpedFlareIntensity;
        public Vector2Parameter warpedFlareScale;
        public ClampedIntParameter samples;
        public ClampedFloatParameter sampleDimmer;
        public ClampedFloatParameter vignetteEffect;
        public ClampedFloatParameter startingPosition;
        public ClampedFloatParameter scale;
        public MinFloatParameter streaksIntensity;
        public ClampedFloatParameter streaksLength;
        public FloatParameter streaksOrientation;
        public ClampedFloatParameter streaksThreshold;
        public ScreenSpaceLensFlareResolutionParameter resolution;
        public ClampedFloatParameter chromaticAbberationIntensity;
    
    
        public void SetVolumeComponentSettings(ref ScreenSpaceLensFlare volumeComponent)
        {
            volumeComponent.active = active;
            volumeComponent.firstFlareIntensity = firstFlareIntensity;
            volumeComponent.secondaryFlareIntensity = secondaryFlareIntensity;
            volumeComponent.warpedFlareIntensity = warpedFlareIntensity;
            volumeComponent.warpedFlareScale = warpedFlareScale;
            volumeComponent.samples = samples;
            volumeComponent.sampleDimmer = sampleDimmer;
            volumeComponent.vignetteEffect = vignetteEffect;
            volumeComponent.startingPosition = startingPosition;
            volumeComponent.scale = scale;
            volumeComponent.streaksIntensity = streaksIntensity;
            volumeComponent.streaksLength = streaksLength;
            volumeComponent.streaksOrientation = streaksOrientation;
            volumeComponent.streaksThreshold = streaksThreshold;
            volumeComponent.resolution = resolution;
            volumeComponent.chromaticAbberationIntensity = chromaticAbberationIntensity;
        }
    
        public void GetVolumeComponentSettings(ref ScreenSpaceLensFlare volumeComponent)
        {
            active = volumeComponent.active;
            firstFlareIntensity = volumeComponent.firstFlareIntensity;
            secondaryFlareIntensity = volumeComponent.secondaryFlareIntensity;
            warpedFlareIntensity = volumeComponent.warpedFlareIntensity;
            warpedFlareScale = volumeComponent.warpedFlareScale;
            samples = volumeComponent.samples;
            sampleDimmer = volumeComponent.sampleDimmer;
            vignetteEffect = volumeComponent.vignetteEffect;
            startingPosition = volumeComponent.startingPosition;
            scale = volumeComponent.scale;
            streaksIntensity = volumeComponent.streaksIntensity;
            streaksLength = volumeComponent.streaksLength;
            streaksOrientation = volumeComponent.streaksOrientation;
            streaksThreshold = volumeComponent.streaksThreshold;
            resolution = volumeComponent.resolution;
            chromaticAbberationIntensity = volumeComponent.chromaticAbberationIntensity;
        }
    }
    
    private void Start()
    {
        m_HasRetrievedVolumeComponent = GetVolumeComponent(in volumeProfile, ref m_VolumeComponent);
        if (m_HasRetrievedVolumeComponent)
            volumeSettings.GetVolumeComponentSettings(ref m_VolumeComponent);
    }
    
    private void Update()
    {
        if (!m_HasRetrievedVolumeComponent)
            return;
    
        volumeSettings.SetVolumeComponentSettings(ref m_VolumeComponent);
    }
    
    private static bool GetVolumeComponent(in VolumeProfile volumeProfile, ref ScreenSpaceLensFlare volumeComponent)
    {
        if (volumeComponent != null)
            return true;
    
        if (volumeProfile == null)
        {
            Debug.LogError("ModifyVolumeComponent.GetVolumeComponent():\nvolumeProfile has not been assigned.");
            return false;
        }
    
        volumeProfile.TryGet(out ScreenSpaceLensFlare component);
        if (component == null)
        {
            Debug.LogError($"ModifyVolumeComponent.GetVolumeComponent():\nMissing component in the \"{volumeProfile.name}\" VolumeProfile ");
            return false;
        }
    
        volumeComponent = component;
        return true;
    }
    

    }

    Constructors

    ScreenSpaceLensFlare()

    Default constructor for the lens flare volume component.

    Declaration
    public ScreenSpaceLensFlare()
    See Also
    VolumeProfile
    VolumeComponent
    IPostProcessComponent
    VolumeParameter<T>
    MinFloatParameter
    ColorParameter
    ClampedIntParameter
    Vector2Parameter
    ClampedFloatParameter
    FloatParameter
    ScreenSpaceLensFlareResolutionParameter

    Fields

    bloomMip

    Controls the bloom Mip used as a source for the Lens Flare effect. A high value will result in a blurrier result for all flares.

    Declaration
    [AdditionalProperty]
    public ClampedIntParameter bloomMip
    Field Value
    Type Description
    ClampedIntParameter
    See Also
    VolumeProfile
    VolumeComponent
    IPostProcessComponent
    VolumeParameter<T>
    MinFloatParameter
    ColorParameter
    ClampedIntParameter
    Vector2Parameter
    ClampedFloatParameter
    FloatParameter
    ScreenSpaceLensFlareResolutionParameter

    chromaticAbberationIntensity

    Controls the strength of the Chromatic Aberration effect. The higher the value, the more light is dispersed on the sides of the screen

    Declaration
    [Header("Chromatic Abberation")]
    public ClampedFloatParameter chromaticAbberationIntensity
    Field Value
    Type Description
    ClampedFloatParameter
    See Also
    VolumeProfile
    VolumeComponent
    IPostProcessComponent
    VolumeParameter<T>
    MinFloatParameter
    ColorParameter
    ClampedIntParameter
    Vector2Parameter
    ClampedFloatParameter
    FloatParameter
    ScreenSpaceLensFlareResolutionParameter

    firstFlareIntensity

    Controls the intensity of the Regular Flare sample. Those flares are sampled using scaled screen coordinates.

    Declaration
    [Header("Flares")]
    public MinFloatParameter firstFlareIntensity
    Field Value
    Type Description
    MinFloatParameter
    See Also
    VolumeProfile
    VolumeComponent
    IPostProcessComponent
    VolumeParameter<T>
    MinFloatParameter
    ColorParameter
    ClampedIntParameter
    Vector2Parameter
    ClampedFloatParameter
    FloatParameter
    ScreenSpaceLensFlareResolutionParameter

    intensity

    Sets the global intensity of the Screen Space Lens Flare effect. When set to 0, the pass is skipped.

    Declaration
    public MinFloatParameter intensity
    Field Value
    Type Description
    MinFloatParameter
    See Also
    VolumeProfile
    VolumeComponent
    IPostProcessComponent
    VolumeParameter<T>
    MinFloatParameter
    ColorParameter
    ClampedIntParameter
    Vector2Parameter
    ClampedFloatParameter
    FloatParameter
    ScreenSpaceLensFlareResolutionParameter

    resolution

    Specifies the resolution at which the streak effect is evaluated.

    Declaration
    [SerializeField]
    [AdditionalProperty]
    public ScreenSpaceLensFlareResolutionParameter resolution
    Field Value
    Type Description
    ScreenSpaceLensFlareResolutionParameter
    See Also
    VolumeProfile
    VolumeComponent
    IPostProcessComponent
    VolumeParameter<T>
    MinFloatParameter
    ColorParameter
    ClampedIntParameter
    Vector2Parameter
    ClampedFloatParameter
    FloatParameter
    ScreenSpaceLensFlareResolutionParameter

    sampleDimmer

    Controls the value by which each additional sample is multiplied. A value of 1 keep the same intensities for all samples. A value of 0.7 multiplies the first sample by 1 (0.7 power 0), the second sample by 0.7 (0.7 power 1) and the third sample by 0.49 (0.7 power 2).

    Declaration
    [AdditionalProperty]
    public ClampedFloatParameter sampleDimmer
    Field Value
    Type Description
    ClampedFloatParameter
    See Also
    VolumeProfile
    VolumeComponent
    IPostProcessComponent
    VolumeParameter<T>
    MinFloatParameter
    ColorParameter
    ClampedIntParameter
    Vector2Parameter
    ClampedFloatParameter
    FloatParameter
    ScreenSpaceLensFlareResolutionParameter

    samples

    Controls the number of times the flare effect is repeated for each flare type (first, second, warped). This parameter has a strong impact on performance.

    Declaration
    public ClampedIntParameter samples
    Field Value
    Type Description
    ClampedIntParameter
    See Also
    VolumeProfile
    VolumeComponent
    IPostProcessComponent
    VolumeParameter<T>
    MinFloatParameter
    ColorParameter
    ClampedIntParameter
    Vector2Parameter
    ClampedFloatParameter
    FloatParameter
    ScreenSpaceLensFlareResolutionParameter

    scale

    Controls the scale at which the flare effect is sampled.

    Declaration
    public ClampedFloatParameter scale
    Field Value
    Type Description
    ClampedFloatParameter
    See Also
    VolumeProfile
    VolumeComponent
    IPostProcessComponent
    VolumeParameter<T>
    MinFloatParameter
    ColorParameter
    ClampedIntParameter
    Vector2Parameter
    ClampedFloatParameter
    FloatParameter
    ScreenSpaceLensFlareResolutionParameter

    secondaryFlareIntensity

    Controls the intensity of the Reversed Flare sample. Those flares are sampled using scaled and flipped screen coordinates.

    Declaration
    public MinFloatParameter secondaryFlareIntensity
    Field Value
    Type Description
    MinFloatParameter
    See Also
    VolumeProfile
    VolumeComponent
    IPostProcessComponent
    VolumeParameter<T>
    MinFloatParameter
    ColorParameter
    ClampedIntParameter
    Vector2Parameter
    ClampedFloatParameter
    FloatParameter
    ScreenSpaceLensFlareResolutionParameter

    startingPosition

    Controls the starting position of the flares in screen space relative to their source.

    Declaration
    public ClampedFloatParameter startingPosition
    Field Value
    Type Description
    ClampedFloatParameter
    See Also
    VolumeProfile
    VolumeComponent
    IPostProcessComponent
    VolumeParameter<T>
    MinFloatParameter
    ColorParameter
    ClampedIntParameter
    Vector2Parameter
    ClampedFloatParameter
    FloatParameter
    ScreenSpaceLensFlareResolutionParameter

    streaksIntensity

    Controls the intensity of streaks effect. This effect has an impact on performance when above zero. When this intensity is zero, this effect is not evaluated to save costs.

    Declaration
    [Header("Streaks")]
    public MinFloatParameter streaksIntensity
    Field Value
    Type Description
    MinFloatParameter
    See Also
    VolumeProfile
    VolumeComponent
    IPostProcessComponent
    VolumeParameter<T>
    MinFloatParameter
    ColorParameter
    ClampedIntParameter
    Vector2Parameter
    ClampedFloatParameter
    FloatParameter
    ScreenSpaceLensFlareResolutionParameter

    streaksLength

    Controls the length of streaks effect. A value of one creates streaks about the width of the screen.

    Declaration
    public ClampedFloatParameter streaksLength
    Field Value
    Type Description
    ClampedFloatParameter
    See Also
    VolumeProfile
    VolumeComponent
    IPostProcessComponent
    VolumeParameter<T>
    MinFloatParameter
    ColorParameter
    ClampedIntParameter
    Vector2Parameter
    ClampedFloatParameter
    FloatParameter
    ScreenSpaceLensFlareResolutionParameter

    streaksOrientation

    Controls the orientation of streaks effect in degrees. A value of 0 produces horizontal streaks.

    Declaration
    public FloatParameter streaksOrientation
    Field Value
    Type Description
    FloatParameter
    See Also
    VolumeProfile
    VolumeComponent
    IPostProcessComponent
    VolumeParameter<T>
    MinFloatParameter
    ColorParameter
    ClampedIntParameter
    Vector2Parameter
    ClampedFloatParameter
    FloatParameter
    ScreenSpaceLensFlareResolutionParameter

    streaksThreshold

    Controls the threshold of horizontal streak effect. A high value makes the effect more localised on the high intensity areas of the screen.

    Declaration
    public ClampedFloatParameter streaksThreshold
    Field Value
    Type Description
    ClampedFloatParameter
    See Also
    VolumeProfile
    VolumeComponent
    IPostProcessComponent
    VolumeParameter<T>
    MinFloatParameter
    ColorParameter
    ClampedIntParameter
    Vector2Parameter
    ClampedFloatParameter
    FloatParameter
    ScreenSpaceLensFlareResolutionParameter

    tintColor

    Sets the color used to tint all the flares.

    Declaration
    public ColorParameter tintColor
    Field Value
    Type Description
    ColorParameter
    See Also
    VolumeProfile
    VolumeComponent
    IPostProcessComponent
    VolumeParameter<T>
    MinFloatParameter
    ColorParameter
    ClampedIntParameter
    Vector2Parameter
    ClampedFloatParameter
    FloatParameter
    ScreenSpaceLensFlareResolutionParameter

    vignetteEffect

    Controls the intensity of the vignette effect to occlude the Lens Flare effect at the center of the screen.

    Declaration
    public ClampedFloatParameter vignetteEffect
    Field Value
    Type Description
    ClampedFloatParameter
    See Also
    VolumeProfile
    VolumeComponent
    IPostProcessComponent
    VolumeParameter<T>
    MinFloatParameter
    ColorParameter
    ClampedIntParameter
    Vector2Parameter
    ClampedFloatParameter
    FloatParameter
    ScreenSpaceLensFlareResolutionParameter

    warpedFlareIntensity

    Controls the intensity of the Warped Flare sample. Those flares are sampled using polar screen coordinates.

    Declaration
    public MinFloatParameter warpedFlareIntensity
    Field Value
    Type Description
    MinFloatParameter
    See Also
    VolumeProfile
    VolumeComponent
    IPostProcessComponent
    VolumeParameter<T>
    MinFloatParameter
    ColorParameter
    ClampedIntParameter
    Vector2Parameter
    ClampedFloatParameter
    FloatParameter
    ScreenSpaceLensFlareResolutionParameter

    warpedFlareScale

    Sets the scale of the warped flare. A value of 1,1 will keep this flare circular.

    Declaration
    [AdditionalProperty]
    public Vector2Parameter warpedFlareScale
    Field Value
    Type Description
    Vector2Parameter
    See Also
    VolumeProfile
    VolumeComponent
    IPostProcessComponent
    VolumeParameter<T>
    MinFloatParameter
    ColorParameter
    ClampedIntParameter
    Vector2Parameter
    ClampedFloatParameter
    FloatParameter
    ScreenSpaceLensFlareResolutionParameter

    Methods

    IsActive()

    Tells if the post process needs to be rendered or not.

    Declaration
    public bool IsActive()
    Returns
    Type Description
    bool

    true if the effect should be rendered, false otherwise.

    See Also
    VolumeProfile
    VolumeComponent
    IPostProcessComponent
    VolumeParameter<T>
    MinFloatParameter
    ColorParameter
    ClampedIntParameter
    Vector2Parameter
    ClampedFloatParameter
    FloatParameter
    ScreenSpaceLensFlareResolutionParameter

    IsStreaksActive()

    Returns true is streakIntensity is above zero.

    Declaration
    public bool IsStreaksActive()
    Returns
    Type Description
    bool
    See Also
    VolumeProfile
    VolumeComponent
    IPostProcessComponent
    VolumeParameter<T>
    MinFloatParameter
    ColorParameter
    ClampedIntParameter
    Vector2Parameter
    ClampedFloatParameter
    FloatParameter
    ScreenSpaceLensFlareResolutionParameter

    Implements

    IApplyRevertPropertyContextMenuItemProvider
    IPostProcessComponent

    See Also

    VolumeProfile
    VolumeComponent
    IPostProcessComponent
    VolumeParameter<T>
    MinFloatParameter
    ColorParameter
    ClampedIntParameter
    Vector2Parameter
    ClampedFloatParameter
    FloatParameter
    ScreenSpaceLensFlareResolutionParameter
    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)