docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class LensFlareCommonSRP

    Provides methods for implementing lens flares in a render pipeline.

    Inheritance
    object
    LensFlareCommonSRP
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: UnityEngine.Rendering
    Assembly: Unity.RenderPipelines.Core.Runtime.dll
    Syntax
    public sealed class LensFlareCommonSRP
    Remarks

    The High Definition Render Pipeline (HDRP) and Universal Render Pipeline (URP) use this class for their lens flare implementation. The class supports both screen space lens flares and quad-based lens flares. You must call the methods of LensFlareCommonSRP at several places inside the Scriptable Render Pipeline (SRP). At minimum, you must call the Initialize() method. You can use any of these methods in a LensFlareComponentSRP Monobehaviour script. Dispose() DoLensFlareDataDrivenCommon(Material, Camera, Rect, XRPass, int, float, float, bool, float, float, bool, Vector3, Matrix4x4, UnsafeCommandBuffer, bool, bool, Texture, Texture, RenderTargetIdentifier, Func<Light, Camera, Vector3, float>, bool).

    Note that only one LensFlareCommonSRP can be alive at any point. To call members of this class, use the Instance property.

    Fields

    maxLensFlareWithOcclusion

    Defines how many lens flare with occlusion are supported in the view at any time.

    Declaration
    public static int maxLensFlareWithOcclusion
    Field Value
    Type Description
    int

    maxLensFlareWithOcclusionTemporalSample

    With TAA Occlusion jitter depth, thought frame on HDRP. So we do a "unanimity vote" for occlusion thought 'maxLensFlareWithOcclusionTemporalSample' frame Important to keep this value maximum of 8 If this value change that could implies an implementation modification on: com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/LensFlareMergeOcclusionDataDriven.compute

    Declaration
    public static int maxLensFlareWithOcclusionTemporalSample
    Field Value
    Type Description
    int

    mergeNeeded

    Set to 1 to enable temporal sample merge. Set to 0 to disable temporal sample merge (must support 16 bit textures, and the occlusion merge must be written in the last texel (vertical) of the lens flare texture.

    Declaration
    public static int mergeNeeded
    Field Value
    Type Description
    int

    occlusionRT

    occlusion texture either provided or created automatically by the SRP for lens flare. Texture width is the max number of lens flares that have occlusion (x axis the lens flare index). y axis is the number of samples (maxLensFlareWithOcclusionTemporalSample) plus the number of merge results. Merge results must be done by the SRP and stored in the [(lens flareIndex), (maxLensFlareWithOcclusionTemporalSample + 1)] coordinate. Note: It's not supported on OpenGL3 and OpenGLCore

    Declaration
    public static RTHandle occlusionRT
    Field Value
    Type Description
    RTHandle

    Properties

    Instance

    Current unique instance.

    Declaration
    public static LensFlareCommonSRP Instance { get; }
    Property Value
    Type Description
    LensFlareCommonSRP
    Remarks

    Use this property to call other members of this class and make sure that only one lens flare system is running at any time.

    Methods

    AddData(LensFlareComponentSRP)

    Adds a new lens flare component for rendering.

    Declaration
    public void AddData(LensFlareComponentSRP newData)
    Parameters
    Type Name Description
    LensFlareComponentSRP newData

    The new data added

    Remarks

    When LensFlareComponentSRP is used, this method is called automatically when the lens flare is enabled. You don't need to call this function unless you're manually removing lens flare data using RemoveData(LensFlareComponentSRP).

    ComputeOcclusion(Material, Camera, XRPass, int, float, float, bool, float, float, bool, Vector3, Matrix4x4, CommandBuffer, bool, bool, Texture, Texture)

    Computes the occlusion of lens flare using the depth buffer and additional occlusion textures if not null.

    Declaration
    public static void ComputeOcclusion(Material lensFlareShader, Camera cam, XRPass xr, int xrIndex, float actualWidth, float actualHeight, bool usePanini, float paniniDistance, float paniniCropToFit, bool isCameraRelative, Vector3 cameraPositionWS, Matrix4x4 viewProjMatrix, CommandBuffer cmd, bool taaEnabled, bool hasCloudLayer, Texture cloudOpacityTexture, Texture sunOcclusionTexture)
    Parameters
    Type Name Description
    Material lensFlareShader

    Lens flare material (HDRP or URP shader)

    Camera cam

    Camera

    XRPass xr

    XRPass data.

    int xrIndex

    XR multipass ID.

    float actualWidth

    Width actually used for rendering after dynamic resolution and XR is applied.

    float actualHeight

    Height actually used for rendering after dynamic resolution and XR is applied.

    bool usePanini

    Set if use Panani Projection

    float paniniDistance

    Distance used for Panini projection

    float paniniCropToFit

    CropToFit parameter used for Panini projection

    bool isCameraRelative

    Set if camera is relative

    Vector3 cameraPositionWS

    Camera World Space position

    Matrix4x4 viewProjMatrix

    View Projection Matrix of the current camera

    CommandBuffer cmd

    Command Buffer

    bool taaEnabled

    Set if TAA is enabled

    bool hasCloudLayer

    Unused

    Texture cloudOpacityTexture

    Unused

    Texture sunOcclusionTexture

    Sun Occlusion Texture from VolumetricCloud on HDRP or null

    ComputeOcclusion(Material, Camera, XRPass, int, float, float, bool, float, float, bool, Vector3, Matrix4x4, CommandBuffer, bool, bool, Texture, Texture, int, int, int, int, int, int, int, int, int, int, int)

    Renders the set of lens flare registered.

    Declaration
    [Obsolete("Use ComputeOcclusion without _FlareOcclusionTex.._FlareData4 parameters.")]
    public static void ComputeOcclusion(Material lensFlareShader, Camera cam, XRPass xr, int xrIndex, float actualWidth, float actualHeight, bool usePanini, float paniniDistance, float paniniCropToFit, bool isCameraRelative, Vector3 cameraPositionWS, Matrix4x4 viewProjMatrix, CommandBuffer cmd, bool taaEnabled, bool hasCloudLayer, Texture cloudOpacityTexture, Texture sunOcclusionTexture, int _FlareOcclusionTex, int _FlareCloudOpacity, int _FlareOcclusionIndex, int _FlareTex, int _FlareColorValue, int _FlareSunOcclusionTex, int _FlareData0, int _FlareData1, int _FlareData2, int _FlareData3, int _FlareData4)
    Parameters
    Type Name Description
    Material lensFlareShader

    lens flare material (HDRP or URP shader)

    Camera cam

    Camera

    XRPass xr

    XRPass data.

    int xrIndex

    XR multipass ID.

    float actualWidth

    Width actually used for rendering after dynamic resolution and XR is applied.

    float actualHeight

    Height actually used for rendering after dynamic resolution and XR is applied.

    bool usePanini

    Set if use Panani Projection

    float paniniDistance

    Distance used for Panini projection

    float paniniCropToFit

    CropToFit parameter used for Panini projection

    bool isCameraRelative

    Set if camera is relative

    Vector3 cameraPositionWS

    Camera World Space position

    Matrix4x4 viewProjMatrix

    View Projection Matrix of the current camera

    CommandBuffer cmd

    Command Buffer

    bool taaEnabled

    Set if TAA is enabled

    bool hasCloudLayer

    Unused

    Texture cloudOpacityTexture

    Unused

    Texture sunOcclusionTexture

    Sun Occlusion Texture from VolumetricCloud on HDRP or null

    int _FlareOcclusionTex

    ShaderID for the FlareOcclusionTex

    int _FlareCloudOpacity

    ShaderID for the FlareCloudOpacity

    int _FlareOcclusionIndex

    ShaderID for the FlareOcclusionIndex

    int _FlareTex

    ShaderID for the FlareTex

    int _FlareColorValue

    ShaderID for the FlareColor

    int _FlareSunOcclusionTex

    ShaderID for the _FlareSunOcclusionTex

    int _FlareData0

    ShaderID for the FlareData0

    int _FlareData1

    ShaderID for the FlareData1

    int _FlareData2

    ShaderID for the FlareData2

    int _FlareData3

    ShaderID for the FlareData3

    int _FlareData4

    ShaderID for the FlareData4

    ComputeOcclusion(Material, Camera, XRPass, int, float, float, bool, float, float, bool, Vector3, Matrix4x4, UnsafeCommandBuffer, bool, bool, Texture, Texture)

    Renders the set of lens flare registered.

    Declaration
    public static void ComputeOcclusion(Material lensFlareShader, Camera cam, XRPass xr, int xrIndex, float actualWidth, float actualHeight, bool usePanini, float paniniDistance, float paniniCropToFit, bool isCameraRelative, Vector3 cameraPositionWS, Matrix4x4 viewProjMatrix, UnsafeCommandBuffer cmd, bool taaEnabled, bool hasCloudLayer, Texture cloudOpacityTexture, Texture sunOcclusionTexture)
    Parameters
    Type Name Description
    Material lensFlareShader

    lens flare material (HDRP or URP shader)

    Camera cam

    Camera

    XRPass xr

    XRPass data.

    int xrIndex

    XR multipass ID.

    float actualWidth

    Width actually used for rendering after dynamic resolution and XR is applied.

    float actualHeight

    Height actually used for rendering after dynamic resolution and XR is applied.

    bool usePanini

    Set if use Panani Projection

    float paniniDistance

    Distance used for Panini projection

    float paniniCropToFit

    CropToFit parameter used for Panini projection

    bool isCameraRelative

    Set if camera is relative

    Vector3 cameraPositionWS

    Camera World Space position

    Matrix4x4 viewProjMatrix

    View Projection Matrix of the current camera

    UnsafeCommandBuffer cmd

    Command Buffer

    bool taaEnabled

    Set if TAA is enabled

    bool hasCloudLayer

    Unused

    Texture cloudOpacityTexture

    Unused

    Texture sunOcclusionTexture

    Sun Occlusion Texture from VolumetricCloud on HDRP or null

    ComputeOcclusion(Material, Camera, XRPass, int, float, float, bool, float, float, bool, Vector3, Matrix4x4, UnsafeCommandBuffer, bool, bool, Texture, Texture, int, int, int, int, int, int, int, int, int, int, int)

    Renders the set of lens flare registered.

    Declaration
    [Obsolete("Use ComputeOcclusion without _FlareOcclusionTex.._FlareData4 parameters.")]
    public static void ComputeOcclusion(Material lensFlareShader, Camera cam, XRPass xr, int xrIndex, float actualWidth, float actualHeight, bool usePanini, float paniniDistance, float paniniCropToFit, bool isCameraRelative, Vector3 cameraPositionWS, Matrix4x4 viewProjMatrix, UnsafeCommandBuffer cmd, bool taaEnabled, bool hasCloudLayer, Texture cloudOpacityTexture, Texture sunOcclusionTexture, int _FlareOcclusionTex, int _FlareCloudOpacity, int _FlareOcclusionIndex, int _FlareTex, int _FlareColorValue, int _FlareSunOcclusionTex, int _FlareData0, int _FlareData1, int _FlareData2, int _FlareData3, int _FlareData4)
    Parameters
    Type Name Description
    Material lensFlareShader

    lens flare material (HDRP or URP shader)

    Camera cam

    Camera

    XRPass xr

    XR Infos

    int xrIndex

    Index of the SinglePass XR

    float actualWidth

    Width actually used for rendering after dynamic resolution and XR is applied.

    float actualHeight

    Height actually used for rendering after dynamic resolution and XR is applied.

    bool usePanini

    Set if use Panani Projection

    float paniniDistance

    Distance used for Panini projection

    float paniniCropToFit

    CropToFit parameter used for Panini projection

    bool isCameraRelative

    Set if camera is relative

    Vector3 cameraPositionWS

    Camera World Space position

    Matrix4x4 viewProjMatrix

    View Projection Matrix of the current camera

    UnsafeCommandBuffer cmd

    Command Buffer

    bool taaEnabled

    Set if TAA is enabled

    bool hasCloudLayer

    Unused

    Texture cloudOpacityTexture

    Unused

    Texture sunOcclusionTexture

    Sun Occlusion Texture from VolumetricCloud on HDRP or null

    int _FlareOcclusionTex

    ShaderID for the FlareOcclusionTex

    int _FlareCloudOpacity

    ShaderID for the FlareCloudOpacity

    int _FlareOcclusionIndex

    ShaderID for the FlareOcclusionIndex

    int _FlareTex

    ShaderID for the FlareTex

    int _FlareColorValue

    ShaderID for the FlareColor

    int _FlareSunOcclusionTex

    ShaderID for the _FlareSunOcclusionTex

    int _FlareData0

    ShaderID for the FlareData0

    int _FlareData1

    ShaderID for the FlareData1

    int _FlareData2

    ShaderID for the FlareData2

    int _FlareData3

    ShaderID for the FlareData3

    int _FlareData4

    ShaderID for the FlareData4

    Dispose()

    Releases all internal textures.

    Declaration
    public static void Dispose()
    Remarks

    Usually, Dispose is called in the Dispose(bool) function.

    DoLensFlareDataDrivenCommon(Material, Camera, Rect, XRPass, int, float, float, bool, float, float, bool, Vector3, Matrix4x4, CommandBuffer, bool, bool, Texture, Texture, RenderTargetIdentifier, Func<Light, Camera, Vector3, float>, bool)

    Renders all visible lens flares.

    Declaration
    public static void DoLensFlareDataDrivenCommon(Material lensFlareShader, Camera cam, Rect viewport, XRPass xr, int xrIndex, float actualWidth, float actualHeight, bool usePanini, float paniniDistance, float paniniCropToFit, bool isCameraRelative, Vector3 cameraPositionWS, Matrix4x4 viewProjMatrix, CommandBuffer cmd, bool taaEnabled, bool hasCloudLayer, Texture cloudOpacityTexture, Texture sunOcclusionTexture, RenderTargetIdentifier colorBuffer, Func<Light, Camera, Vector3, float> GetLensFlareLightAttenuation, bool debugView)
    Parameters
    Type Name Description
    Material lensFlareShader

    Lens flare material (HDRP or URP shader)

    Camera cam

    Camera

    Rect viewport

    Viewport used for rendering and XR applied.

    XRPass xr

    XRPass data.

    int xrIndex

    XR multipass ID.

    float actualWidth

    Width actually used for rendering after dynamic resolution and XR is applied.

    float actualHeight

    Height actually used for rendering after dynamic resolution and XR is applied.

    bool usePanini

    Set if use Panani Projection

    float paniniDistance

    Distance used for Panini projection

    float paniniCropToFit

    CropToFit parameter used for Panini projection

    bool isCameraRelative

    Set if camera is relative

    Vector3 cameraPositionWS

    Camera World Space position

    Matrix4x4 viewProjMatrix

    View Projection Matrix of the current camera

    CommandBuffer cmd

    Command Buffer

    bool taaEnabled

    Set if TAA is enabled

    bool hasCloudLayer

    Unused

    Texture cloudOpacityTexture

    Unused

    Texture sunOcclusionTexture

    Sun Occlusion Texture from VolumetricCloud on HDRP or null

    RenderTargetIdentifier colorBuffer

    Source Render Target which contains the Color Buffer

    Func<Light, Camera, Vector3, float> GetLensFlareLightAttenuation

    Delegate to which return return the Attenuation of the light based on their shape which uses the functions ShapeAttenuation...(...), must reimplemented per SRP

    bool debugView

    Debug View which setup black background to see only lens flare

    Remarks

    Call this function during the post processing phase of the Render Pipeline.

    DoLensFlareDataDrivenCommon(Material, Camera, Rect, XRPass, int, float, float, bool, float, float, bool, Vector3, Matrix4x4, CommandBuffer, bool, bool, Texture, Texture, RenderTargetIdentifier, Func<Light, Camera, Vector3, float>, int, int, int, int, int, int, int, int, int, int, int, int, bool)

    Renders the set of lens flare registered.

    Declaration
    [Obsolete("Use DoLensFlareDataDrivenCommon without _FlareOcclusionRemapTex.._FlareData4 parameters.")]
    public static void DoLensFlareDataDrivenCommon(Material lensFlareShader, Camera cam, Rect viewport, XRPass xr, int xrIndex, float actualWidth, float actualHeight, bool usePanini, float paniniDistance, float paniniCropToFit, bool isCameraRelative, Vector3 cameraPositionWS, Matrix4x4 viewProjMatrix, CommandBuffer cmd, bool taaEnabled, bool hasCloudLayer, Texture cloudOpacityTexture, Texture sunOcclusionTexture, RenderTargetIdentifier colorBuffer, Func<Light, Camera, Vector3, float> GetLensFlareLightAttenuation, int _FlareOcclusionRemapTex, int _FlareOcclusionTex, int _FlareOcclusionIndex, int _FlareCloudOpacity, int _FlareSunOcclusionTex, int _FlareTex, int _FlareColorValue, int _FlareData0, int _FlareData1, int _FlareData2, int _FlareData3, int _FlareData4, bool debugView)
    Parameters
    Type Name Description
    Material lensFlareShader

    Lens flare material (HDRP or URP shader)

    Camera cam

    Camera

    Rect viewport

    Viewport used for rendering and XR applied.

    XRPass xr

    XRPass data.

    int xrIndex

    XR multipass ID.

    float actualWidth

    Width actually used for rendering after dynamic resolution and XR is applied.

    float actualHeight

    Height actually used for rendering after dynamic resolution and XR is applied.

    bool usePanini

    Set if use Panani Projection

    float paniniDistance

    Distance used for Panini projection

    float paniniCropToFit

    CropToFit parameter used for Panini projection

    bool isCameraRelative

    Set if camera is relative

    Vector3 cameraPositionWS

    Camera World Space position

    Matrix4x4 viewProjMatrix

    View Projection Matrix of the current camera

    CommandBuffer cmd

    Command Buffer

    bool taaEnabled

    Set if TAA is enabled

    bool hasCloudLayer

    Unused

    Texture cloudOpacityTexture

    Unused

    Texture sunOcclusionTexture

    Sun Occlusion Texture from VolumetricCloud on HDRP or null

    RenderTargetIdentifier colorBuffer

    Source Render Target which contains the Color Buffer

    Func<Light, Camera, Vector3, float> GetLensFlareLightAttenuation

    Delegate to which return return the Attenuation of the light based on their shape which uses the functions ShapeAttenuation...(...), must reimplemented per SRP

    int _FlareOcclusionRemapTex

    ShaderID for the OcclusionRemap

    int _FlareOcclusionTex

    ShaderID for the FlareOcclusionTex

    int _FlareOcclusionIndex

    ShaderID for the FlareOcclusionIndex

    int _FlareCloudOpacity

    ShaderID for the FlareCloudOpacity

    int _FlareSunOcclusionTex

    ShaderID for the _FlareSunOcclusionTex

    int _FlareTex

    ShaderID for the FlareTex

    int _FlareColorValue

    ShaderID for the FlareColor

    int _FlareData0

    ShaderID for the FlareData0

    int _FlareData1

    ShaderID for the FlareData1

    int _FlareData2

    ShaderID for the FlareData2

    int _FlareData3

    ShaderID for the FlareData3

    int _FlareData4

    ShaderID for the FlareData4

    bool debugView

    Debug View which setup black background to see only lens flare

    DoLensFlareDataDrivenCommon(Material, Camera, Rect, XRPass, int, float, float, bool, float, float, bool, Vector3, Matrix4x4, UnsafeCommandBuffer, bool, bool, Texture, Texture, RenderTargetIdentifier, Func<Light, Camera, Vector3, float>, bool)

    Renders all visible lens flares.

    Declaration
    public static void DoLensFlareDataDrivenCommon(Material lensFlareShader, Camera cam, Rect viewport, XRPass xr, int xrIndex, float actualWidth, float actualHeight, bool usePanini, float paniniDistance, float paniniCropToFit, bool isCameraRelative, Vector3 cameraPositionWS, Matrix4x4 viewProjMatrix, UnsafeCommandBuffer cmd, bool taaEnabled, bool hasCloudLayer, Texture cloudOpacityTexture, Texture sunOcclusionTexture, RenderTargetIdentifier colorBuffer, Func<Light, Camera, Vector3, float> GetLensFlareLightAttenuation, bool debugView)
    Parameters
    Type Name Description
    Material lensFlareShader

    Lens flare material (HDRP or URP shader)

    Camera cam

    Camera

    Rect viewport

    Viewport used for rendering and XR applied.

    XRPass xr

    XRPass data.

    int xrIndex

    XR multipass ID.

    float actualWidth

    Width actually used for rendering after dynamic resolution and XR is applied.

    float actualHeight

    Height actually used for rendering after dynamic resolution and XR is applied.

    bool usePanini

    Set if use Panani Projection

    float paniniDistance

    Distance used for Panini projection

    float paniniCropToFit

    CropToFit parameter used for Panini projection

    bool isCameraRelative

    Set if camera is relative

    Vector3 cameraPositionWS

    Camera World Space position

    Matrix4x4 viewProjMatrix

    View Projection Matrix of the current camera

    UnsafeCommandBuffer cmd

    Command Buffer

    bool taaEnabled

    Set if TAA is enabled

    bool hasCloudLayer

    Unused

    Texture cloudOpacityTexture

    Unused

    Texture sunOcclusionTexture

    Sun Occlusion Texture from VolumetricCloud on HDRP or null

    RenderTargetIdentifier colorBuffer

    Source Render Target which contains the Color Buffer

    Func<Light, Camera, Vector3, float> GetLensFlareLightAttenuation

    Delegate to which return return the Attenuation of the light based on their shape which uses the functions ShapeAttenuation...(...), must reimplemented per SRP

    bool debugView

    Debug View which setup black background to see only lens flare

    Remarks

    Call this function during the post processing phase of the Render Pipeline.

    DoLensFlareDataDrivenCommon(Material, Camera, Rect, XRPass, int, float, float, bool, float, float, bool, Vector3, Matrix4x4, UnsafeCommandBuffer, bool, bool, Texture, Texture, RenderTargetIdentifier, Func<Light, Camera, Vector3, float>, int, int, int, int, int, int, int, int, int, int, int, int, bool)

    Renders the set of lens flare registered.

    Declaration
    [Obsolete("Use DoLensFlareDataDrivenCommon without _FlareOcclusionRemapTex.._FlareData4 parameters.")]
    public static void DoLensFlareDataDrivenCommon(Material lensFlareShader, Camera cam, Rect viewport, XRPass xr, int xrIndex, float actualWidth, float actualHeight, bool usePanini, float paniniDistance, float paniniCropToFit, bool isCameraRelative, Vector3 cameraPositionWS, Matrix4x4 viewProjMatrix, UnsafeCommandBuffer cmd, bool taaEnabled, bool hasCloudLayer, Texture cloudOpacityTexture, Texture sunOcclusionTexture, RenderTargetIdentifier colorBuffer, Func<Light, Camera, Vector3, float> GetLensFlareLightAttenuation, int _FlareOcclusionRemapTex, int _FlareOcclusionTex, int _FlareOcclusionIndex, int _FlareCloudOpacity, int _FlareSunOcclusionTex, int _FlareTex, int _FlareColorValue, int _FlareData0, int _FlareData1, int _FlareData2, int _FlareData3, int _FlareData4, bool debugView)
    Parameters
    Type Name Description
    Material lensFlareShader

    Lens flare material (HDRP or URP shader)

    Camera cam

    Camera

    Rect viewport

    Viewport used for rendering and XR applied.

    XRPass xr

    XRPass data.

    int xrIndex

    XR multipass ID.

    float actualWidth

    Width actually used for rendering after dynamic resolution and XR is applied.

    float actualHeight

    Height actually used for rendering after dynamic resolution and XR is applied.

    bool usePanini

    Set if use Panani Projection

    float paniniDistance

    Distance used for Panini projection

    float paniniCropToFit

    CropToFit parameter used for Panini projection

    bool isCameraRelative

    Set if camera is relative

    Vector3 cameraPositionWS

    Camera World Space position

    Matrix4x4 viewProjMatrix

    View Projection Matrix of the current camera

    UnsafeCommandBuffer cmd

    Command Buffer

    bool taaEnabled

    Set if TAA is enabled

    bool hasCloudLayer

    Unused

    Texture cloudOpacityTexture

    Unused

    Texture sunOcclusionTexture

    Sun Occlusion Texture from VolumetricCloud on HDRP or null

    RenderTargetIdentifier colorBuffer

    Source Render Target which contains the Color Buffer

    Func<Light, Camera, Vector3, float> GetLensFlareLightAttenuation

    Delegate to which return return the Attenuation of the light based on their shape which uses the functions ShapeAttenuation...(...), must reimplemented per SRP

    int _FlareOcclusionRemapTex

    ShaderID for the OcclusionRemap

    int _FlareOcclusionTex

    ShaderID for the FlareOcclusionTex

    int _FlareOcclusionIndex

    ShaderID for the FlareOcclusionIndex

    int _FlareCloudOpacity

    ShaderID for the FlareCloudOpacity

    int _FlareSunOcclusionTex

    ShaderID for the _FlareSunOcclusionTex

    int _FlareTex

    ShaderID for the FlareTex

    int _FlareColorValue

    ShaderID for the FlareColor

    int _FlareData0

    ShaderID for the FlareData0

    int _FlareData1

    ShaderID for the FlareData1

    int _FlareData2

    ShaderID for the FlareData2

    int _FlareData3

    ShaderID for the FlareData3

    int _FlareData4

    ShaderID for the FlareData4

    bool debugView

    Debug View which setup black background to see only lens flare

    DoLensFlareScreenSpaceCommon(Material, Camera, float, float, Color, Texture, Texture, Texture, Texture, Texture, Vector4, Vector4, Vector4, Vector4, Vector4, CommandBuffer, RTHandle, bool)

    Renders the screen space lens flare effect.

    Declaration
    public static void DoLensFlareScreenSpaceCommon(Material lensFlareShader, Camera cam, float actualWidth, float actualHeight, Color tintColor, Texture originalBloomTexture, Texture bloomMipTexture, Texture spectralLut, Texture streakTextureTmp, Texture streakTextureTmp2, Vector4 parameters1, Vector4 parameters2, Vector4 parameters3, Vector4 parameters4, Vector4 parameters5, CommandBuffer cmd, RTHandle result, bool debugView)
    Parameters
    Type Name Description
    Material lensFlareShader

    Lens flare material (HDRP or URP shader)

    Camera cam

    Camera

    float actualWidth

    Width actually used for rendering after dynamic resolution and XR is applied.

    float actualHeight

    Height actually used for rendering after dynamic resolution and XR is applied.

    Color tintColor

    tintColor to multiply all the flare by

    Texture originalBloomTexture

    original Bloom texture used to write on at the end of compositing

    Texture bloomMipTexture

    Bloom mip texture used as data for the effect

    Texture spectralLut

    spectralLut used for chromatic aberration effect

    Texture streakTextureTmp

    Texture used for the multiple pass streaks effect

    Texture streakTextureTmp2

    Texture used for the multiple pass streaks effect

    Vector4 parameters1

    globalIntensity, regularIntensity, reverseIntensity, warpedIntensity

    Vector4 parameters2

    vignetteEffect, startingPosition, scale, freeSlot

    Vector4 parameters3

    samples, sampleDimmer, chromaticAbberationIntensity, chromaticAbberationSamples

    Vector4 parameters4

    streaksIntensity, streaksLength, streaksOrientation, streaksThreshold

    Vector4 parameters5

    downsampleStreak, warpedFlareScaleX, warpedFlareScaleY, freeSlot

    CommandBuffer cmd

    Command Buffer

    RTHandle result

    Result RT for the lens flare Screen Space

    bool debugView

    Information if we are in debug mode or not

    Remarks

    Call this function during the post processing of the render pipeline after the bloom.

    DoLensFlareScreenSpaceCommon(Material, Camera, float, float, Color, Texture, Texture, Texture, Texture, Texture, Vector4, Vector4, Vector4, Vector4, Vector4, CommandBuffer, RTHandle, int, int, int, int, int, int, int, int, int, int, int, bool)

    Renders the screen space lens flare effect.

    Declaration
    [Obsolete("Use DoLensFlareScreenSpaceCommon without _Shader IDs parameters.")]
    public static void DoLensFlareScreenSpaceCommon(Material lensFlareShader, Camera cam, float actualWidth, float actualHeight, Color tintColor, Texture originalBloomTexture, Texture bloomMipTexture, Texture spectralLut, Texture streakTextureTmp, Texture streakTextureTmp2, Vector4 parameters1, Vector4 parameters2, Vector4 parameters3, Vector4 parameters4, Vector4 parameters5, CommandBuffer cmd, RTHandle result, int _LensFlareScreenSpaceBloomMipTexture, int _LensFlareScreenSpaceResultTexture, int _LensFlareScreenSpaceSpectralLut, int _LensFlareScreenSpaceStreakTex, int _LensFlareScreenSpaceMipLevel, int _LensFlareScreenSpaceTintColor, int _LensFlareScreenSpaceParams1, int _LensFlareScreenSpaceParams2, int _LensFlareScreenSpaceParams3, int _LensFlareScreenSpaceParams4, int _LensFlareScreenSpaceParams5, bool debugView)
    Parameters
    Type Name Description
    Material lensFlareShader

    Lens flare material (HDRP or URP shader)

    Camera cam

    Camera

    float actualWidth

    Width actually used for rendering after dynamic resolution and XR is applied.

    float actualHeight

    Height actually used for rendering after dynamic resolution and XR is applied.

    Color tintColor

    tintColor to multiply all the flare by

    Texture originalBloomTexture

    original Bloom texture used to write on at the end of compositing

    Texture bloomMipTexture

    Bloom mip texture used as data for the effect

    Texture spectralLut

    spectralLut used for chromatic aberration effect

    Texture streakTextureTmp

    Texture used for the multiple pass streaks effect

    Texture streakTextureTmp2

    Texture used for the multiple pass streaks effect

    Vector4 parameters1

    globalIntensity, regularIntensity, reverseIntensity, warpedIntensity

    Vector4 parameters2

    vignetteEffect, startingPosition, scale, freeSlot

    Vector4 parameters3

    samples, sampleDimmer, chromaticAbberationIntensity, chromaticAbberationSamples

    Vector4 parameters4

    streaksIntensity, streaksLength, streaksOrientation, streaksThreshold

    Vector4 parameters5

    downsampleStreak, warpedFlareScaleX, warpedFlareScaleY, freeSlot

    CommandBuffer cmd

    Command Buffer

    RTHandle result

    Result RT for the lens flare Screen Space

    int _LensFlareScreenSpaceBloomMipTexture

    ShaderID for the original bloom texture

    int _LensFlareScreenSpaceResultTexture

    ShaderID for the LensFlareScreenSpaceResultTexture texture

    int _LensFlareScreenSpaceSpectralLut

    ShaderID for the LensFlareScreenSpaceSpectralLut texture

    int _LensFlareScreenSpaceStreakTex

    ShaderID for the LensFlareScreenSpaceStreakTex streak temp texture

    int _LensFlareScreenSpaceMipLevel

    ShaderID for the LensFlareScreenSpaceMipLevel parameter

    int _LensFlareScreenSpaceTintColor

    ShaderID for the LensFlareScreenSpaceTintColor color

    int _LensFlareScreenSpaceParams1

    ShaderID for the LensFlareScreenSpaceParams1

    int _LensFlareScreenSpaceParams2

    ShaderID for the LensFlareScreenSpaceParams2

    int _LensFlareScreenSpaceParams3

    ShaderID for the LensFlareScreenSpaceParams3

    int _LensFlareScreenSpaceParams4

    ShaderID for the LensFlareScreenSpaceParams4

    int _LensFlareScreenSpaceParams5

    ShaderID for the LensFlareScreenSpaceParams5

    bool debugView

    Information if we are in debug mode or not

    Remarks

    Call this function during the post processing of the render pipeline after the bloom.

    DoLensFlareScreenSpaceCommon(Material, Camera, float, float, Color, Texture, Texture, Texture, Texture, Texture, Vector4, Vector4, Vector4, Vector4, Vector4, UnsafeCommandBuffer, RTHandle, bool)

    Renders the screen space lens flare effect.

    Declaration
    public static void DoLensFlareScreenSpaceCommon(Material lensFlareShader, Camera cam, float actualWidth, float actualHeight, Color tintColor, Texture originalBloomTexture, Texture bloomMipTexture, Texture spectralLut, Texture streakTextureTmp, Texture streakTextureTmp2, Vector4 parameters1, Vector4 parameters2, Vector4 parameters3, Vector4 parameters4, Vector4 parameters5, UnsafeCommandBuffer cmd, RTHandle result, bool debugView)
    Parameters
    Type Name Description
    Material lensFlareShader

    Lens flare material (HDRP or URP shader)

    Camera cam

    Camera

    float actualWidth

    Width actually used for rendering after dynamic resolution and XR is applied.

    float actualHeight

    Height actually used for rendering after dynamic resolution and XR is applied.

    Color tintColor

    tintColor to multiply all the flare by

    Texture originalBloomTexture

    original Bloom texture used to write on at the end of compositing

    Texture bloomMipTexture

    Bloom mip texture used as data for the effect

    Texture spectralLut

    spectralLut used for chromatic aberration effect

    Texture streakTextureTmp

    Texture used for the multiple pass streaks effect

    Texture streakTextureTmp2

    Texture used for the multiple pass streaks effect

    Vector4 parameters1

    globalIntensity, regularIntensity, reverseIntensity, warpedIntensity

    Vector4 parameters2

    vignetteEffect, startingPosition, scale, freeSlot

    Vector4 parameters3

    samples, sampleDimmer, chromaticAbberationIntensity, chromaticAbberationSamples

    Vector4 parameters4

    streaksIntensity, streaksLength, streaksOrientation, streaksThreshold

    Vector4 parameters5

    downsampleStreak, warpedFlareScaleX, warpedFlareScaleY, freeSlot

    UnsafeCommandBuffer cmd

    UnsafeCommandBuffer

    RTHandle result

    Result RT for the lens flare Screen Space

    bool debugView

    Information if we are in debug mode or not

    Remarks

    Call this function during the post processing of the render pipeline after the bloom.

    GetFlareData0(Vector2, Vector2, Vector2, Vector2, float, float, float, Vector2, bool)

    Computes the internal parameters needed to render a single flare.

    Declaration
    public static Vector4 GetFlareData0(Vector2 screenPos, Vector2 translationScale, Vector2 rayOff0, Vector2 vLocalScreenRatio, float angleDeg, float position, float angularOffset, Vector2 positionOffset, bool autoRotate)
    Parameters
    Type Name Description
    Vector2 screenPos

    The screen position of the flare.

    Vector2 translationScale

    The scale of translation applied to the flare.

    Vector2 rayOff0

    The base offset for the flare ray.

    Vector2 vLocalScreenRatio

    The ratio of the flare's local screen size.

    float angleDeg

    The base angle of rotation for the flare.

    float position

    The position along the flare's radial line, relative to the source, where 1.0 represents the edge of the screen.

    float angularOffset

    Angular offset applied to the flare's position.

    Vector2 positionOffset

    The offset from the flare's calculated position.

    bool autoRotate

    Flag to enable automatic rotation based on flare's position.

    Returns
    Type Description
    Vector4

    A Vector4 object representing the shader parameters _FlareData0.

    Initialize()

    Initializes the lens flares. You must call this method.

    Declaration
    public static void Initialize()
    Remarks

    You usually call Initialize in the RenderPipeline constructor.

    IsCloudLayerOpacityNeeded(Camera)

    Checks if at least one LensFlareComponentSRP requests occlusion from environment effects.

    Declaration
    public static bool IsCloudLayerOpacityNeeded(Camera cam)
    Parameters
    Type Name Description
    Camera cam

    Camera

    Returns
    Type Description
    bool

    true if cloud occlusion is requested

    Remarks

    Environment occlusion can be enabled by setting environmentOcclusion to true.

    IsEmpty()

    Checks if at least one lens flare has been added to the pool.

    Declaration
    public bool IsEmpty()
    Returns
    Type Description
    bool

    true if no lens flare were added

    Remarks

    You can use this method to check if there are any lens flares to render before rendering the lens flares.

    Examples

    if (!LensFlareCommonSRP.Instance.IsEmpty()) { LensFlareCommonSRP.DoLensFlareDataDrivenCommon(...); }

    IsOcclusionRTCompatible()

    Check if we can create OcclusionRT texture to be used as render target

    Declaration
    public static bool IsOcclusionRTCompatible()
    Returns
    Type Description
    bool

    Returns true if a supported format is found

    ProcessLensFlareSRPElementsSingle(LensFlareDataElementSRP, CommandBuffer, Color, Light, float, float, Material, Vector2, bool, Vector2, Vector4, bool, int)

    Renders a single element of a LensFlareDataSRP, this function is used on scene/game view and on the inspector for the thumbnail.

    Declaration
    public static void ProcessLensFlareSRPElementsSingle(LensFlareDataElementSRP element, CommandBuffer cmd, Color globalColorModulation, Light light, float compIntensity, float scale, Material lensFlareShader, Vector2 screenPos, bool compAllowOffScreen, Vector2 vScreenRatio, Vector4 flareData1, bool preview, int depth)
    Parameters
    Type Name Description
    LensFlareDataElementSRP element

    Single LensFlare asset we need to process.

    CommandBuffer cmd

    Command Buffer.

    Color globalColorModulation

    Color Modulation from Component?

    Light light

    Light used for the modulation of this singe element.

    float compIntensity

    Intensity from Component.

    float scale

    Scale from component

    Material lensFlareShader

    Shader used on URP or HDRP.

    Vector2 screenPos

    Screen Position

    bool compAllowOffScreen

    Allow lens flare offscreen

    Vector2 vScreenRatio

    Screen Ratio

    Vector4 flareData1

    _FlareData1 used internally by the shader.

    bool preview

    true if we are on preview on the inspector

    int depth

    Depth counter for recursive call of 'ProcessLensFlareSRPElementsSingle'.

    Remarks

    Can be used to draw aa single lens flare for editor or preview purpose.

    RemoveData(LensFlareComponentSRP)

    Removes a lens flare data from rendering.

    Declaration
    public void RemoveData(LensFlareComponentSRP data)
    Parameters
    Type Name Description
    LensFlareComponentSRP data

    The data which exist in the pool

    Remarks

    When LensFlareComponentSRP is used, this method is called automatically when the lens flare is disabled.

    ShapeAttenuationAreaDiscLight(Vector3, Vector3)

    Obtains the attenuation for a disc light.

    Declaration
    public static float ShapeAttenuationAreaDiscLight(Vector3 forward, Vector3 wo)
    Parameters
    Type Name Description
    Vector3 forward

    Forward Vector of Directional Light

    Vector3 wo

    Vector pointing to the eye

    Returns
    Type Description
    float

    Attenuation Factor

    Remarks

    This method can be used to help compute the light attenuation to pass to DoLensFlareDataDrivenCommon(Material, Camera, Rect, XRPass, int, float, float, bool, float, float, bool, Vector3, Matrix4x4, UnsafeCommandBuffer, bool, bool, Texture, Texture, RenderTargetIdentifier, Func<Light, Camera, Vector3, float>, bool)

    Examples

    To handle more than one light type, write a dedicated function to compute the attenuation using these helpers

    static float GetLensFlareLightAttenuation(Light light, Camera cam, Vector3 wo)
    {
        switch (light.type)
        {
            case LightType.Directional:
                return LensFlareCommonSRP.ShapeAttenuationDirLight(light.transform.forward, cam.transform.forward);
            case LightType.Point:
                // Do nothing point are omnidirectional for the lens flare
                return LensFlareCommonSRP.ShapeAttenuationPointLight();
            case LightType.Spot:
                float innerSpotPercent01 = 1;
                return LensFlareCommonSRP.ShapeAttenuationSpotConeLight(light.transform.forward, wo, light.spotAngle, light.innerSpotAngle / 180.0f);
            case LightType.Pyramid:
                return LensFlareCommonSRP.ShapeAttenuationSpotPyramidLight(light.transform.forward, wo);
            case LightType.Box:
                return LensFlareCommonSRP.ShapeAttenuationSpotBoxLight(light.transform.forward, wo);
            case LightType.Rectangle:
                return LensFlareCommonSRP.ShapeAttenuationAreaRectangleLight(light.transform.forward, wo);
            case LightType.Tube:
                float shapeWidth = 1; // Get this data from an external source if our render pipeline supports tube lights.
                return LensFlareCommonSRP.ShapeAttenuationAreaTubeLight(light.transform.position, light.transform.right, shapeWidth, cam);
            case LightType.Disc:
                return LensFlareCommonSRP.ShapeAttenuationAreaDiscLight(light.transform.forward, wo);
            default: throw new Exception($"GetLensFlareLightAttenuation HDLightType Unknown {typeof(LightType)}: {light.type}");
        }
    }

    ShapeAttenuationAreaRectangleLight(Vector3, Vector3)

    Obtains the attenuation for a rectangle light.

    Declaration
    public static float ShapeAttenuationAreaRectangleLight(Vector3 forward, Vector3 wo)
    Parameters
    Type Name Description
    Vector3 forward

    Forward Vector of Directional Light

    Vector3 wo

    Vector pointing to the eye

    Returns
    Type Description
    float

    Attenuation Factor

    Remarks

    This method can be used to help compute the light attenuation to pass to DoLensFlareDataDrivenCommon(Material, Camera, Rect, XRPass, int, float, float, bool, float, float, bool, Vector3, Matrix4x4, UnsafeCommandBuffer, bool, bool, Texture, Texture, RenderTargetIdentifier, Func<Light, Camera, Vector3, float>, bool)

    Examples

    To handle more than one light type, write a dedicated function to compute the attenuation using these helpers

    static float GetLensFlareLightAttenuation(Light light, Camera cam, Vector3 wo)
    {
        switch (light.type)
        {
            case LightType.Directional:
                return LensFlareCommonSRP.ShapeAttenuationDirLight(light.transform.forward, cam.transform.forward);
            case LightType.Point:
                // Do nothing point are omnidirectional for the lens flare
                return LensFlareCommonSRP.ShapeAttenuationPointLight();
            case LightType.Spot:
                float innerSpotPercent01 = 1;
                return LensFlareCommonSRP.ShapeAttenuationSpotConeLight(light.transform.forward, wo, light.spotAngle, light.innerSpotAngle / 180.0f);
            case LightType.Pyramid:
                return LensFlareCommonSRP.ShapeAttenuationSpotPyramidLight(light.transform.forward, wo);
            case LightType.Box:
                return LensFlareCommonSRP.ShapeAttenuationSpotBoxLight(light.transform.forward, wo);
            case LightType.Rectangle:
                return LensFlareCommonSRP.ShapeAttenuationAreaRectangleLight(light.transform.forward, wo);
            case LightType.Tube:
                float shapeWidth = 1; // Get this data from an external source if our render pipeline supports tube lights.
                return LensFlareCommonSRP.ShapeAttenuationAreaTubeLight(light.transform.position, light.transform.right, shapeWidth, cam);
            case LightType.Disc:
                return LensFlareCommonSRP.ShapeAttenuationAreaDiscLight(light.transform.forward, wo);
            default: throw new Exception($"GetLensFlareLightAttenuation HDLightType Unknown {typeof(LightType)}: {light.type}");
        }
    }

    ShapeAttenuationAreaTubeLight(Vector3, Vector3, float, Camera)

    Obtains the attenuation for a tube light.

    Declaration
    public static float ShapeAttenuationAreaTubeLight(Vector3 lightPositionWS, Vector3 lightSide, float lightWidth, Camera cam)
    Parameters
    Type Name Description
    Vector3 lightPositionWS

    World Space position of the Light

    Vector3 lightSide

    Vector pointing to the side (right or left) or the light

    float lightWidth

    Width (half extent) of the tube light

    Camera cam

    Camera rendering the Tube Light

    Returns
    Type Description
    float

    Attenuation Factor

    Remarks

    This method can be used to help compute the light attenuation to pass to DoLensFlareDataDrivenCommon(Material, Camera, Rect, XRPass, int, float, float, bool, float, float, bool, Vector3, Matrix4x4, UnsafeCommandBuffer, bool, bool, Texture, Texture, RenderTargetIdentifier, Func<Light, Camera, Vector3, float>, bool)

    Examples

    To handle more than one light type, write a dedicated function to compute the attenuation using these helpers

    static float GetLensFlareLightAttenuation(Light light, Camera cam, Vector3 wo)
    {
        switch (light.type)
        {
            case LightType.Directional:
                return LensFlareCommonSRP.ShapeAttenuationDirLight(light.transform.forward, cam.transform.forward);
            case LightType.Point:
                // Do nothing point are omnidirectional for the lens flare
                return LensFlareCommonSRP.ShapeAttenuationPointLight();
            case LightType.Spot:
                float innerSpotPercent01 = 1;
                return LensFlareCommonSRP.ShapeAttenuationSpotConeLight(light.transform.forward, wo, light.spotAngle, light.innerSpotAngle / 180.0f);
            case LightType.Pyramid:
                return LensFlareCommonSRP.ShapeAttenuationSpotPyramidLight(light.transform.forward, wo);
            case LightType.Box:
                return LensFlareCommonSRP.ShapeAttenuationSpotBoxLight(light.transform.forward, wo);
            case LightType.Rectangle:
                return LensFlareCommonSRP.ShapeAttenuationAreaRectangleLight(light.transform.forward, wo);
            case LightType.Tube:
                float shapeWidth = 1; // Get this data from an external source if our render pipeline supports tube lights.
                return LensFlareCommonSRP.ShapeAttenuationAreaTubeLight(light.transform.position, light.transform.right, shapeWidth, cam);
            case LightType.Disc:
                return LensFlareCommonSRP.ShapeAttenuationAreaDiscLight(light.transform.forward, wo);
            default: throw new Exception($"GetLensFlareLightAttenuation HDLightType Unknown {typeof(LightType)}: {light.type}");
        }
    }

    ShapeAttenuationDirLight(Vector3, Vector3)

    Obtains the attenuation for a directional light.

    Declaration
    public static float ShapeAttenuationDirLight(Vector3 forward, Vector3 wo)
    Parameters
    Type Name Description
    Vector3 forward

    Forward Vector of Directional Light

    Vector3 wo

    Vector pointing to the eye

    Returns
    Type Description
    float

    Attenuation Factor

    Remarks

    This method can be used to help compute the light attenuation to pass to DoLensFlareDataDrivenCommon(Material, Camera, Rect, XRPass, int, float, float, bool, float, float, bool, Vector3, Matrix4x4, UnsafeCommandBuffer, bool, bool, Texture, Texture, RenderTargetIdentifier, Func<Light, Camera, Vector3, float>, bool)

    Examples

    To handle more than one light type, write a dedicated function to compute the attenuation using these helpers

    static float GetLensFlareLightAttenuation(Light light, Camera cam, Vector3 wo)
    {
        switch (light.type)
        {
            case LightType.Directional:
                return LensFlareCommonSRP.ShapeAttenuationDirLight(light.transform.forward, cam.transform.forward);
            case LightType.Point:
                // Do nothing point are omnidirectional for the lens flare
                return LensFlareCommonSRP.ShapeAttenuationPointLight();
            case LightType.Spot:
                float innerSpotPercent01 = 1;
                return LensFlareCommonSRP.ShapeAttenuationSpotConeLight(light.transform.forward, wo, light.spotAngle, light.innerSpotAngle / 180.0f);
            case LightType.Pyramid:
                return LensFlareCommonSRP.ShapeAttenuationSpotPyramidLight(light.transform.forward, wo);
            case LightType.Box:
                return LensFlareCommonSRP.ShapeAttenuationSpotBoxLight(light.transform.forward, wo);
            case LightType.Rectangle:
                return LensFlareCommonSRP.ShapeAttenuationAreaRectangleLight(light.transform.forward, wo);
            case LightType.Tube:
                float shapeWidth = 1; // Get this data from an external source if our render pipeline supports tube lights.
                return LensFlareCommonSRP.ShapeAttenuationAreaTubeLight(light.transform.position, light.transform.right, shapeWidth, cam);
            case LightType.Disc:
                return LensFlareCommonSRP.ShapeAttenuationAreaDiscLight(light.transform.forward, wo);
            default: throw new Exception($"GetLensFlareLightAttenuation HDLightType Unknown {typeof(LightType)}: {light.type}");
        }
    }

    ShapeAttenuationPointLight()

    Obtains the attenuation for a point light.

    Declaration
    public static float ShapeAttenuationPointLight()
    Returns
    Type Description
    float

    Attenuation Factor

    Remarks

    This method can be used to help compute the light attenuation to pass to DoLensFlareDataDrivenCommon(Material, Camera, Rect, XRPass, int, float, float, bool, float, float, bool, Vector3, Matrix4x4, UnsafeCommandBuffer, bool, bool, Texture, Texture, RenderTargetIdentifier, Func<Light, Camera, Vector3, float>, bool)

    Examples

    To handle more than one light type, write a dedicated function to compute the attenuation using these helpers

    static float GetLensFlareLightAttenuation(Light light, Camera cam, Vector3 wo)
    {
        switch (light.type)
        {
            case LightType.Directional:
                return LensFlareCommonSRP.ShapeAttenuationDirLight(light.transform.forward, cam.transform.forward);
            case LightType.Point:
                // Do nothing point are omnidirectional for the lens flare
                return LensFlareCommonSRP.ShapeAttenuationPointLight();
            case LightType.Spot:
                float innerSpotPercent01 = 1;
                return LensFlareCommonSRP.ShapeAttenuationSpotConeLight(light.transform.forward, wo, light.spotAngle, light.innerSpotAngle / 180.0f);
            case LightType.Pyramid:
                return LensFlareCommonSRP.ShapeAttenuationSpotPyramidLight(light.transform.forward, wo);
            case LightType.Box:
                return LensFlareCommonSRP.ShapeAttenuationSpotBoxLight(light.transform.forward, wo);
            case LightType.Rectangle:
                return LensFlareCommonSRP.ShapeAttenuationAreaRectangleLight(light.transform.forward, wo);
            case LightType.Tube:
                float shapeWidth = 1; // Get this data from an external source if our render pipeline supports tube lights.
                return LensFlareCommonSRP.ShapeAttenuationAreaTubeLight(light.transform.position, light.transform.right, shapeWidth, cam);
            case LightType.Disc:
                return LensFlareCommonSRP.ShapeAttenuationAreaDiscLight(light.transform.forward, wo);
            default: throw new Exception($"GetLensFlareLightAttenuation HDLightType Unknown {typeof(LightType)}: {light.type}");
        }
    }

    ShapeAttenuationSpotBoxLight(Vector3, Vector3)

    Obtains the attenuation for a box spot light.

    Declaration
    public static float ShapeAttenuationSpotBoxLight(Vector3 forward, Vector3 wo)
    Parameters
    Type Name Description
    Vector3 forward

    Forward Vector of Directional Light

    Vector3 wo

    Vector pointing to the eye

    Returns
    Type Description
    float

    Attenuation Factor

    Remarks

    This method can be used to help compute the light attenuation to pass to DoLensFlareDataDrivenCommon(Material, Camera, Rect, XRPass, int, float, float, bool, float, float, bool, Vector3, Matrix4x4, UnsafeCommandBuffer, bool, bool, Texture, Texture, RenderTargetIdentifier, Func<Light, Camera, Vector3, float>, bool)

    Examples

    To handle more than one light type, write a dedicated function to compute the attenuation using these helpers

    static float GetLensFlareLightAttenuation(Light light, Camera cam, Vector3 wo)
    {
        switch (light.type)
        {
            case LightType.Directional:
                return LensFlareCommonSRP.ShapeAttenuationDirLight(light.transform.forward, cam.transform.forward);
            case LightType.Point:
                // Do nothing point are omnidirectional for the lens flare
                return LensFlareCommonSRP.ShapeAttenuationPointLight();
            case LightType.Spot:
                float innerSpotPercent01 = 1;
                return LensFlareCommonSRP.ShapeAttenuationSpotConeLight(light.transform.forward, wo, light.spotAngle, light.innerSpotAngle / 180.0f);
            case LightType.Pyramid:
                return LensFlareCommonSRP.ShapeAttenuationSpotPyramidLight(light.transform.forward, wo);
            case LightType.Box:
                return LensFlareCommonSRP.ShapeAttenuationSpotBoxLight(light.transform.forward, wo);
            case LightType.Rectangle:
                return LensFlareCommonSRP.ShapeAttenuationAreaRectangleLight(light.transform.forward, wo);
            case LightType.Tube:
                float shapeWidth = 1; // Get this data from an external source if our render pipeline supports tube lights.
                return LensFlareCommonSRP.ShapeAttenuationAreaTubeLight(light.transform.position, light.transform.right, shapeWidth, cam);
            case LightType.Disc:
                return LensFlareCommonSRP.ShapeAttenuationAreaDiscLight(light.transform.forward, wo);
            default: throw new Exception($"GetLensFlareLightAttenuation HDLightType Unknown {typeof(LightType)}: {light.type}");
        }
    }

    ShapeAttenuationSpotConeLight(Vector3, Vector3, float, float)

    Obtains the attenuation for a cone spot light.

    Declaration
    public static float ShapeAttenuationSpotConeLight(Vector3 forward, Vector3 wo, float spotAngle, float innerSpotPercent01)
    Parameters
    Type Name Description
    Vector3 forward

    Forward Vector of Directional Light

    Vector3 wo

    Vector pointing to the eye

    float spotAngle

    The angle of the light's spotlight cone in degrees.

    float innerSpotPercent01

    Get the inner spot radius between 0 and 1.

    Returns
    Type Description
    float

    Attenuation Factor

    Remarks

    This method can be used to help compute the light attenuation to pass to DoLensFlareDataDrivenCommon(Material, Camera, Rect, XRPass, int, float, float, bool, float, float, bool, Vector3, Matrix4x4, UnsafeCommandBuffer, bool, bool, Texture, Texture, RenderTargetIdentifier, Func<Light, Camera, Vector3, float>, bool)

    Examples

    To handle more than one light type, write a dedicated function to compute the attenuation using these helpers

    static float GetLensFlareLightAttenuation(Light light, Camera cam, Vector3 wo)
    {
        switch (light.type)
        {
            case LightType.Directional:
                return LensFlareCommonSRP.ShapeAttenuationDirLight(light.transform.forward, cam.transform.forward);
            case LightType.Point:
                // Do nothing point are omnidirectional for the lens flare
                return LensFlareCommonSRP.ShapeAttenuationPointLight();
            case LightType.Spot:
                float innerSpotPercent01 = 1;
                return LensFlareCommonSRP.ShapeAttenuationSpotConeLight(light.transform.forward, wo, light.spotAngle, light.innerSpotAngle / 180.0f);
            case LightType.Pyramid:
                return LensFlareCommonSRP.ShapeAttenuationSpotPyramidLight(light.transform.forward, wo);
            case LightType.Box:
                return LensFlareCommonSRP.ShapeAttenuationSpotBoxLight(light.transform.forward, wo);
            case LightType.Rectangle:
                return LensFlareCommonSRP.ShapeAttenuationAreaRectangleLight(light.transform.forward, wo);
            case LightType.Tube:
                float shapeWidth = 1; // Get this data from an external source if our render pipeline supports tube lights.
                return LensFlareCommonSRP.ShapeAttenuationAreaTubeLight(light.transform.position, light.transform.right, shapeWidth, cam);
            case LightType.Disc:
                return LensFlareCommonSRP.ShapeAttenuationAreaDiscLight(light.transform.forward, wo);
            default: throw new Exception($"GetLensFlareLightAttenuation HDLightType Unknown {typeof(LightType)}: {light.type}");
        }
    }

    ShapeAttenuationSpotPyramidLight(Vector3, Vector3)

    Obtains the attenuation for a pyramid spot light.

    Declaration
    public static float ShapeAttenuationSpotPyramidLight(Vector3 forward, Vector3 wo)
    Parameters
    Type Name Description
    Vector3 forward

    Forward Vector of Directional Light

    Vector3 wo

    Vector pointing to the eye

    Returns
    Type Description
    float

    Attenuation Factor

    Remarks

    This method can be used to help compute the light attenuation to pass to DoLensFlareDataDrivenCommon(Material, Camera, Rect, XRPass, int, float, float, bool, float, float, bool, Vector3, Matrix4x4, UnsafeCommandBuffer, bool, bool, Texture, Texture, RenderTargetIdentifier, Func<Light, Camera, Vector3, float>, bool)

    Examples

    To handle more than one light type, write a dedicated function to compute the attenuation using these helpers

    static float GetLensFlareLightAttenuation(Light light, Camera cam, Vector3 wo)
    {
        switch (light.type)
        {
            case LightType.Directional:
                return LensFlareCommonSRP.ShapeAttenuationDirLight(light.transform.forward, cam.transform.forward);
            case LightType.Point:
                // Do nothing point are omnidirectional for the lens flare
                return LensFlareCommonSRP.ShapeAttenuationPointLight();
            case LightType.Spot:
                float innerSpotPercent01 = 1;
                return LensFlareCommonSRP.ShapeAttenuationSpotConeLight(light.transform.forward, wo, light.spotAngle, light.innerSpotAngle / 180.0f);
            case LightType.Pyramid:
                return LensFlareCommonSRP.ShapeAttenuationSpotPyramidLight(light.transform.forward, wo);
            case LightType.Box:
                return LensFlareCommonSRP.ShapeAttenuationSpotBoxLight(light.transform.forward, wo);
            case LightType.Rectangle:
                return LensFlareCommonSRP.ShapeAttenuationAreaRectangleLight(light.transform.forward, wo);
            case LightType.Tube:
                float shapeWidth = 1; // Get this data from an external source if our render pipeline supports tube lights.
                return LensFlareCommonSRP.ShapeAttenuationAreaTubeLight(light.transform.position, light.transform.right, shapeWidth, cam);
            case LightType.Disc:
                return LensFlareCommonSRP.ShapeAttenuationAreaDiscLight(light.transform.forward, wo);
            default: throw new Exception($"GetLensFlareLightAttenuation HDLightType Unknown {typeof(LightType)}: {light.type}");
        }
    }

    Extension Methods

    ReflectionUtils.GetField(object, string)
    ReflectionUtils.GetFields(object)
    ReflectionUtils.Invoke(object, string, params object[])
    ReflectionUtils.SetField(object, string, object)
    AnalyticsUtils.ToNestedColumnWithDefault<T>(T, T, bool)
    AnalyticsUtils.ToNestedColumn<T>(T, T)
    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)