Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ public class OculusMotionVectorPass : ScriptableRenderPass
FilteringSettings m_FilteringSettings;
ProfilingSampler m_ProfilingSampler;

RenderTargetIdentifier motionVectorColorIdentifier;
RenderTargetIdentifier motionVectorDepthIdentifier;
RTHandle motionVectorColorHandle;
RTHandle motionVectorDepthHandle;

public OculusMotionVectorPass(string profilerTag, bool opaque, RenderPassEvent evt, RenderQueueRange renderQueueRange, LayerMask layerMask, StencilState stencilState, int stencilReference)
{
Expand All @@ -32,16 +32,16 @@ internal OculusMotionVectorPass(URPProfileId profileId, bool opaque, RenderPassE
}

public void Setup(
RenderTargetIdentifier motionVecColorIdentifier,
RenderTargetIdentifier motionVecDepthIdentifier)
RTHandle motionVecColorIdentifier,
RTHandle motionVecDepthIdentifier)
{
this.motionVectorColorIdentifier = motionVecColorIdentifier;
this.motionVectorDepthIdentifier = motionVecDepthIdentifier;
this.motionVectorColorHandle = motionVecColorIdentifier;
this.motionVectorDepthHandle = motionVecDepthIdentifier;
}

public override void OnCameraSetup(CommandBuffer cmd, ref RenderingData renderingData)
{
ConfigureTarget(motionVectorColorIdentifier, motionVectorDepthIdentifier);
ConfigureTarget(motionVectorColorHandle, motionVectorDepthHandle);
ConfigureClear(ClearFlag.All, Color.black);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ public override int SupportedCameraStackingTypes()
RTHandle m_OpaqueColor;
RTHandle m_MotionVectorColor;
RTHandle m_MotionVectorDepth;
RTHandle m_XRMotionVectorTargetHandleAlias;

ForwardLights m_ForwardLights;
DeferredLights m_DeferredLights;
Expand Down Expand Up @@ -393,6 +394,7 @@ internal override void ReleaseRenderTargets()
m_OpaqueColor?.Release();
m_MotionVectorColor?.Release();
m_MotionVectorDepth?.Release();
m_XRMotionVectorTargetHandleAlias?.Release();
hasReleasedRTs = true;
}

Expand Down Expand Up @@ -960,12 +962,19 @@ public override void Setup(ScriptableRenderContext context, ref RenderingData re
#if !UNITY_EDITOR
if (cameraData.xr.motionVectorRenderTargetValid)
{
RenderTargetHandle motionVecHandle = new RenderTargetHandle(cameraData.xr.motionVectorRenderTarget);
var rtMotionId = motionVecHandle.Identifier();
rtMotionId = new RenderTargetIdentifier(rtMotionId, 0, CubemapFace.Unknown, -1);
RenderTargetIdentifier motionVecId = cameraData.xr.motionVectorRenderTarget;

if (m_XRMotionVectorTargetHandleAlias == null || m_XRMotionVectorTargetHandleAlias.nameID != motionVecId)
{
m_XRMotionVectorTargetHandleAlias?.Release();
m_XRMotionVectorTargetHandleAlias = RTHandles.Alloc(motionVecId);
}

// ID is the same since a RenderTexture encapsulates all the attachments, including both color+depth.
m_OculusMotionVecPass.Setup(rtMotionId, rtMotionId);
RTHandle mvColor = m_XRMotionVectorTargetHandleAlias;
RTHandle mvDepth = m_XRMotionVectorTargetHandleAlias;

m_OculusMotionVecPass.Setup(mvColor, mvDepth);
EnqueuePass(m_OculusMotionVecPass);
}
#endif
Expand Down