class LightshipOcclusionExtension
(Niantic.Lightship.AR.Occlusion.LightshipOcclusionExtension)
Overview
This component allows configuration of the additional functionality available in Lightship's implementation of XROcclusionSubsystem.
class LightshipOcclusionExtension: CompositeRenderer {
public:
// fields
bool IsRenderingActive => IsCommandBufferAdded ||(!IsUsingLegacyRenderPipeline&& IsAnyFeatureEnabled);
bool SupportsTargetFrameRate => IsUsingLightshipOcclusionSubsystem;
static const string ZBufferOcclusionShaderName = "Lightship/ZBufferOcclusion";
static const string OcclusionMeshShaderName = "Lightship/OcclusionMesh";
// properties
uint?? TargetFrameRate;
Matrix4x4? LatestIntrinsicsMatrix;
Matrix4x4? LatestExtrinsicsMatrix;
OptimalOcclusionDistanceMode OcclusionDistanceMode;
bool BypassOcclusionManagerUpdates;
bool OverrideOcclusionManagerSettings;
Texture2D? DepthTexture;
Matrix4x4??? DepthTransform;
Material CustomMaterial;
Material CustomBackgroundMaterial;
Material BackgroundMaterial;
bool UseCustomBackgroundMaterial;
Material FusedDepthMaterial;
OptimalOcclusionDistanceMode Mode;
// methods
bool TryGetDepth(int screenX, int screenY, out float depth);
void TrackOccludee(Renderer occludee);
protected:
// fields
override string RendererName => "LightshipOcclusionExtension Pass(LegacyRP)";
override bool ShouldAddCommandBuffer => IsUsingLegacyRenderPipeline&& IsAnyFeatureEnabled;
// properties
override string ShaderName;
// methods
override string[] OnRequestExternalPassDependencies(CameraEvent evt);
override bool OnAddRenderCommands(CommandBuffer cmd, Material mat);
override void Awake();
override void Update();
};
Detailed Documentation
This component allows configuration of the additional functionality available in Lightship's implementation of XROcclusionSubsystem.
Fields
RendererName
override string RendererName => "LightshipOcclusionExtension Pass(LegacyRP)"
The name of the occlusion extension command buffer.
ShouldAddCommandBuffer
override bool ShouldAddCommandBuffer => IsUsingLegacyRenderPipeline&& IsAnyFeatureEnabled
Determines whether the command buffer should be attached to the camera.
IsRenderingActive
bool IsRenderingActive => IsCommandBufferAdded ||(!IsUsingLegacyRenderPipeline&& IsAnyFeatureEnabled)
Whether the second pass of background rendering is active to satisfy custom occlusion features.
SupportsTargetFrameRate
bool SupportsTargetFrameRate => IsUsingLightshipOcclusionSubsystem
Determines whether the TargetFrameRate API is supported with the current configuration.
Properties
ShaderName
override string ShaderName
The name of the shader used by the rendering material.
TargetFrameRate
uint?? TargetFrameRate
The framerate that depth inference will aim to run at. Setting the value to 0 will result in using the recommended frame rate. Call SupportsTargetFrameRate to check if the target frame rate is supported.
LatestIntrinsicsMatrix
Matrix4x4? LatestIntrinsicsMatrix
Returns the intrinsics matrix for DepthTexture. Contains values for the camera's focal length and principal point. Converts between 2D image pixel coordinates and 3D world coordinates relative to the camera.
LatestExtrinsicsMatrix
Matrix4x4? LatestExtrinsicsMatrix
Returns the extrinsics matrix for DepthTexture.
OcclusionDistanceMode
OptimalOcclusionDistanceMode OcclusionDistanceMode
Get or set the current mode in use for determining the distance at which occlusions will have the best visual quality.
BypassOcclusionManagerUpdates
bool BypassOcclusionManagerUpdates
Whether to disable automatically updating the depth texture of the occlusion manager. This feature can be used to avoid redundant texture operations since depth is ultimately going to be overriden by the Lightship Occlusion Extension anyway. Not using this setting may result in undesired synchronization with the rendering thread that impacts performance.
OverrideOcclusionManagerSettings
bool OverrideOcclusionManagerSettings
Whether to override the occlusion manager's settings to set the most optimal configuration for the occlusion extension. Currently, the following overrides are applied: 1) On iPhone devices with Lidar sensor, the best and medium occlusion mode will cause a significant performance hit as well as a crash. We will override the occlusion mode to fastest to avoid this issue and enable smooth edges for the best results. 2) The occlusion preference mode is set to NoOcclusion when the occlusion extension is active.
DepthTexture
Texture2D? DepthTexture
Returns the raw depth texture used in rendering.
DepthTransform
Matrix4x4??? DepthTransform
Returns a transform for converting between normalized image coordinates and a coordinate space appropriate for rendering DepthTexture on the viewport.
CustomMaterial
Material CustomMaterial
Get or set the custom material used for processing the AR background depth buffer. If set to null, the default material will be used.
Methods
OnRequestExternalPassDependencies
override string[] OnRequestExternalPassDependencies(CameraEvent evt)
The occlusion extension command buffer needs to run after the AR Background command buffer.
TryGetDepth
bool TryGetDepth(int screenX, int screenY, out float depth)
Returns the metric eye depth at the specified pixel coordinates.
Parameters:
screenX
- The x position on the screen.
screenY
- The y position on the screen.
depth
- The resulting depth value.
Returns:
Whether retrieving the depth value was successful.
TrackOccludee
void TrackOccludee(Renderer occludee)
Sets the principal virtual object being occluded in the SpecifiedGameObject occlusion mode.
This method changes the optimal occlusion distance mode setting.
>