Class LensFlareCommonSRP
Common code for all Data-Driven Lens Flare used
Namespace: UnityEngine.Rendering
Syntax
public sealed class LensFlareCommonSRP
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 |
DoLensFlareDataDrivenCommon(Material, LensFlareCommonSRP, Camera, Single, Single, Boolean, Single, Single, Boolean, Matrix4x4, CommandBuffer, RenderTargetIdentifier, Func<Light, Camera, Vector3, Single>, Int32, Int32, Int32, Int32, Int32, Int32, Int32, Boolean)
Effective Job of drawing the set of Lens Flare registered
Declaration
public static void DoLensFlareDataDrivenCommon(Material lensFlareShader, LensFlareCommonSRP lensFlares, Camera cam, float actualWidth, float actualHeight, bool usePanini, float paniniDistance, float paniniCropToFit, bool isCameraRelative, Matrix4x4 viewProjMatrix, CommandBuffer cmd, RenderTargetIdentifier colorBuffer, Func<Light, Camera, Vector3, float> GetLensFlareLightAttenuation, 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) |
LensFlareCommonSRP | lensFlares | Set of Lens Flare |
Camera | cam | Camera |
Single | actualWidth | Width actually used for rendering after dynamic resolution and XR is applied. |
Single | actualHeight | Height actually used for rendering after dynamic resolution and XR is applied. |
Boolean | usePanini | Set if use Panani Projection |
Single | paniniDistance | Distance used for Panini projection |
Single | paniniCropToFit | CropToFit parameter used for Panini projection |
Boolean | isCameraRelative | |
Matrix4x4 | viewProjMatrix | View Projection Matrix of the current camera |
CommandBuffer | cmd | Command Buffer |
RenderTargetIdentifier | colorBuffer | Source Render Target which contains the Color Buffer |
Func<Light, Camera, Vector3, Single> | GetLensFlareLightAttenuation | Delegate to which return return the Attenuation of the light based on their shape which uses the functions ShapeAttenuation...(...), must reimplemented per SRP |
Int32 | _FlareTex | ShaderID for the FlareTex |
Int32 | _FlareColorValue | ShaderID for the FlareColor |
Int32 | _FlareData0 | ShaderID for the FlareData0 |
Int32 | _FlareData1 | ShaderID for the FlareData1 |
Int32 | _FlareData2 | ShaderID for the FlareData2 |
Int32 | _FlareData3 | ShaderID for the FlareData3 |
Int32 | _FlareData4 | ShaderID for the FlareData4 |
Boolean | debugView | Debug View which setup black background to see only Lens Flare |
GetData()
Return the pool of Lens Flare added
Declaration
public List<LensFlareComponentSRP> GetData()
Returns
Type | Description |
---|---|
List<LensFlareComponentSRP> | The Lens Flare Pool |
GetFlareData0(Vector2, Vector2, Vector2, Vector2, Single, Single, Single, Vector2, Boolean)
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 | |
Single | angleDeg | |
Single | position | |
Single | angularOffset | |
Vector2 | positionOffset | |
Boolean | autoRotate |
Returns
Type | Description |
---|---|
Vector4 | Parameter used on the shader for _FlareData0 |
IsEmpty()
Check if we have at least one Lens Flare added on the pool
Declaration
public bool IsEmpty()
Returns
Type | Description |
---|---|
Boolean | true if no Lens Flare were added |
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 |
---|---|
Single | 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 |
---|---|
Single | Attenuation Factor |
ShapeAttenuationAreaTubeLight(Vector3, Vector3, Single, 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 |
Single | lightWidth | Width (half extent) of the tube light |
Camera | cam | Camera rendering the Tube Light |
Returns
Type | Description |
---|---|
Single | 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 |
---|---|
Single | Attenuation Factor |
ShapeAttenuationPointLight()
Attenuation by Light Shape for Point Light
Declaration
public static float ShapeAttenuationPointLight()
Returns
Type | Description |
---|---|
Single | 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 |
---|---|
Single | Attenuation Factor |
ShapeAttenuationSpotConeLight(Vector3, Vector3, Single, Single)
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 |
Single | spotAngle | The angle of the light's spotlight cone in degrees. |
Single | innerSpotPercent01 | Get the inner spot radius between 0 and 1. |
Returns
Type | Description |
---|---|
Single | 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 |
---|---|
Single | Attenuation Factor |