Class LensFlareCommonSRP
Common code for all Data-Driven Lens Flare used
Inherited Members
Namespace: UnityEngine.Rendering
Assembly: Unity.RenderPipelines.Core.Runtime.dll
Syntax
public sealed class LensFlareCommonSRP
Fields
maxLensFlareWithOcclusion
Max lens-flares-with-occlusion supported
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 |
Methods
AddData(LensFlareComponentSRP)
Add a new lens flare component on the pool.
Declaration
public void AddData(LensFlareComponentSRP newData)
Parameters
Type | Name | Description |
---|---|---|
LensFlareComponentSRP | newData | The new data added |
ComputeOcclusion(Material, Camera, float, float, bool, float, float, bool, Vector3, Matrix4x4, CommandBuffer, bool, bool, Texture, Texture, int, int, int, int, int, int, int, int, int, int, int)
Effective Job of drawing the set of Lens Flare registered
Declaration
public static void ComputeOcclusion(Material lensFlareShader, Camera cam, 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 |
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 | Set if cloudLayerTexture is used |
Texture | cloudOpacityTexture | cloudOpacityTexture used for sky visibility fullscreen |
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()
Disposal function, must be called by the SRP to release all internal textures.
Declaration
public static void Dispose()
DoLensFlareDataDrivenCommon(Material, Camera, 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)
Effective Job of drawing the set of Lens Flare registered
Declaration
public static void DoLensFlareDataDrivenCommon(Material lensFlareShader, Camera cam, 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 |
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 | Set if cloudLayerTexture is used |
Texture | cloudOpacityTexture | cloudOpacityTexture used for sky visibility fullscreen |
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 |
GetFlareData0(Vector2, Vector2, Vector2, Vector2, float, float, float, Vector2, bool)
Compute internal parameters needed to render 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 | |
Vector2 | translationScale | |
Vector2 | rayOff0 | |
Vector2 | vLocalScreenRatio | |
float | angleDeg | |
float | position | |
float | angularOffset | |
Vector2 | positionOffset | |
bool | autoRotate |
Returns
Type | Description |
---|---|
Vector4 | Parameter used on the shader for _FlareData0 |
Initialize()
Initialization function which must be called by the SRP.
Declaration
public static void Initialize()
IsCloudLayerOpacityNeeded(Camera)
Check if at least one LensFlareComponentSRP request CloudLayer opacity
Declaration
public static bool IsCloudLayerOpacityNeeded(Camera cam)
Parameters
Type | Name | Description |
---|---|---|
Camera | cam | Camera |
Returns
Type | Description |
---|---|
bool | true if a cloudLayerOpacity is requested |
IsEmpty()
Check if we have at least one Lens Flare added on the pool
Declaration
public bool IsEmpty()
Returns
Type | Description |
---|---|
bool | true if no Lens Flare were added |
IsOcclusionRTCompatible()
Check if we can use an OcclusionRT
Declaration
public static bool IsOcclusionRTCompatible()
Returns
Type | Description |
---|---|
bool | return true if we can have the OcclusionRT |
RemoveData(LensFlareComponentSRP)
Remove a lens flare data which exist in the pool.
Declaration
public void RemoveData(LensFlareComponentSRP data)
Parameters
Type | Name | Description |
---|---|---|
LensFlareComponentSRP | data | The data which exist in the pool |
ShapeAttenuationAreaDiscLight(Vector3, Vector3)
Attenuation by Light Shape for Area Light with Disc Shape
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 |
ShapeAttenuationAreaRectangleLight(Vector3, Vector3)
Attenuation by Light Shape for Area Light with Rectangular Shape
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 |
ShapeAttenuationAreaTubeLight(Vector3, Vector3, float, Camera)
Attenuation by Light Shape for Area Light with Tube Shape
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 |
ShapeAttenuationDirLight(Vector3, Vector3)
Attenuation by Light Shape for 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 |
ShapeAttenuationPointLight()
Attenuation by Light Shape for Point Light
Declaration
public static float ShapeAttenuationPointLight()
Returns
Type | Description |
---|---|
float | Attenuation Factor |
ShapeAttenuationSpotBoxLight(Vector3, Vector3)
Attenuation by Light Shape for Spot Light with Box Shape
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 |
ShapeAttenuationSpotConeLight(Vector3, Vector3, float, float)
Attenuation by Light Shape for Spot Light with Cone Shape
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 |
ShapeAttenuationSpotPyramidLight(Vector3, Vector3)
Attenuation by Light Shape for Spot Light with Pyramid Shape
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 |