Class PaniniProjection
A volume component that holds settings for the Panini Projection effect.
Inherited Members
Namespace: UnityEngine .Rendering.Universal
Assembly: Unity.RenderPipelines.Universal.Runtime.dll
Syntax
[Serializable]
[VolumeComponentMenu("Post-processing/Panini Projection")]
[SupportedOnRenderPipeline(typeof(UniversalRenderPipelineAsset))]
public sealed class PaniniProjection : VolumeComponent, IApplyRevertPropertyContextMenuItemProvider, IPostProcessComponent
Remarks
You can add Unity
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 PaniniProjection m_VolumeComponent;
[Serializable]
private struct VolumeSettings
{
public bool active;
public ClampedFloatParameter distance;
public ClampedFloatParameter cropToFit;
public void SetVolumeComponentSettings(ref PaniniProjection volumeComponent)
{
volumeComponent.active = active;
volumeComponent.distance = distance;
volumeComponent.cropToFit = cropToFit;
}
public void GetVolumeComponentSettings(ref PaniniProjection volumeComponent)
{
active = volumeComponent.active;
distance = volumeComponent.distance;
cropToFit = volumeComponent.cropToFit;
}
}
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 PaniniProjection volumeComponent)
{
if (volumeComponent != null)
return true;
if (volumeProfile == null)
{
Debug.LogError("ModifyVolumeComponent.GetVolumeComponent():\nvolumeProfile has not been assigned.");
return false;
}
volumeProfile.TryGet(out PaniniProjection component);
if (component == null)
{
Debug.LogError($"ModifyVolumeComponent.GetVolumeComponent():\nMissing component in the \"{volumeProfile.name}\" VolumeProfile ");
return false;
}
volumeComponent = component;
return true;
}
}
Fields
cropToFit
Controls how much cropping HDRP applies to the screen with the panini projection effect. A value of 1 crops the distortion to the edge of the screen.
Declaration
[Tooltip("Panini projection crop to fit.")]
public ClampedFloatParameter cropToFit
Field Value
Type | Description |
---|---|
Clamped |
See Also
distance
Controls the panini projection distance. This controls the strength of the distorion.
Declaration
[Tooltip("Panini projection distance.")]
public ClampedFloatParameter distance
Field Value
Type | Description |
---|---|
Clamped |
See Also
Methods
IsActive()
Tells if the post process needs to be rendered or not.
Declaration
public bool IsActive()
Returns
Type | Description |
---|---|
bool |
|