Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workaround for PCVR depth submission #685

Merged
merged 1 commit into from
Apr 19, 2024
Merged
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
23 changes: 17 additions & 6 deletions Assets/Scripts/Rendering/RenderWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
#pragma warning disable 649, 414
#endif

// TODO:Mikesky - For some reason, offscreen rendering to m_hdrTarget is losing depth on XR.
// Unity's docs say this should be fine, so it may be a Unity bug.
// Investigate if this is fixed in newer Unity versions
// The temp fix is to no longer cull primary camera, and only display the offscreen render during
// a recording session, which is very rare and not likely to be using depth.

namespace TiltBrush
{

Expand Down Expand Up @@ -200,9 +206,12 @@ void OnPreCull()
// Store the clear and culling mask to restore after rendering.
m_cameraClearFlags = srcCam.clearFlags;
m_cameraCullingMask = srcCam.cullingMask;
srcCam.cullingMask = 0;
srcCam.clearFlags = CameraClearFlags.Nothing;
srcCam.allowHDR = GetTargetFormat() != RenderTextureFormat.ARGB32;

// TODO:Mikesky - See top of file.
// srcCam.cullingMask = 0;
// srcCam.clearFlags = CameraClearFlags.Nothing;

#endif

if (ReadBackTextures != null && m_readbackTextureFrame != Time.frameCount)
Expand Down Expand Up @@ -456,7 +465,8 @@ public void OnRenderImage(RenderTexture source, RenderTexture destination)
}
else
{
Graphics.Blit(m_hdrTarget, destination);
// TODO:Mikesky - See top of file.
Graphics.Blit(source, destination);
// Generate the outline mask for later use in the post fx chain
if (m_StencilToMaskMaterial)
{
Expand All @@ -469,9 +479,10 @@ public void OnRenderImage(RenderTexture source, RenderTexture destination)
// Only need the selection mask if the selection effect is enabled
if (App.Instance.SelectionEffect.RenderHighlight())
{
Graphics.Blit(m_hdrTarget, destination);
Graphics.Blit(destination, m_hdrTarget, m_StencilToMaskMaterial);
Graphics.Blit(m_hdrTarget, m_MaskTarget);
// TODO:Mikesky - See top of file.
Graphics.Blit(source, destination);
Graphics.Blit(destination, source, m_StencilToMaskMaterial);
Graphics.Blit(source, m_MaskTarget);
}
}
}
Expand Down
Loading