Edit: I have no idea why someone devote this question, it's obviously a common issue but no solution found yet on Android, or VR devices.
It's a Quest 2 Unity URP related issue. I am trying to save the main camera view as render texture "SavedRenderTexture" for later use. It's very easy to do it in standard render pipeline via OnRenderImage().
private void OnRenderImage(RenderTexture source, RenderTexture destination)
{
Graphics.Blit(source, SavedRenderTexture);
Graphics.Blit(source, destination);
}
I tried to achieve similar result in Unity Universal Render pipeline, below scripts are working fine in Editor Mode. But it always freezes my Quest 2 VR screen view.
private void RenderPipelineManager_beginCameraRendering(ScriptableRenderContext context, Camera camera)
{
//OnPreRender();
if (SavedRenderTexture == null)
{
sourceDescriptor = (UnityEngine.XR.XRSettings.enabled) ? UnityEngine.XR.XRSettings.eyeTextureDesc : new RenderTextureDescriptor(Screen.width, Screen.height, RenderTextureFormat.ARGB32);
SavedRenderTexture = new RenderTexture(sourceDescriptor);
}
MainCam.targetTexture = SavedRenderTexture;
}
private void RenderPipelineManager_endCameraRendering(ScriptableRenderContext context, Camera camera)
{
//OnPostRender();
MainCam.targetTexture = null;
Graphics.Blit(SavedRenderTexture, null as RenderTexture);
}
I guess that the freeze screen was due to this line, maybe hardware, gpu related issue too.
Graphics.Blit(SavedRenderTexture, null as RenderTexture);
In standard pipeline, we can output the source to destination by default.
However, Universal Render Pipeline is completely different structure. I couldn't find any alternative for Universal pipeline.
I would be very appreciated for any suggestion. thanks.