Search Unity

Resolved Oculus Quest - Custom Render Pipeline does not clear the center of the eyes

Discussion in 'VR' started by PelvisParsley, May 16, 2022.

  1. PelvisParsley

    PelvisParsley

    Joined:
    Aug 9, 2016
    Posts:
    89
    I'm moving a project to a custom render pipeline, but have been perplexed by this issue. Here is the Render function for the pipeline:

    Code (CSharp):
    1. public void Render(ScriptableRenderContext renderContext, Camera camera)
    2.     {
    3. #if UNITY_EDITOR
    4.         if (camera.cameraType == CameraType.SceneView)
    5.         {
    6.             ScriptableRenderContext.EmitWorldGeometryForSceneView(camera);
    7.         }
    8. #endif // UNITY_EDITOR
    9.  
    10.         renderContext.SetupCameraProperties(camera, camera.stereoEnabled);
    11.  
    12.         if (camera.TryGetCullingParameters(true, out ScriptableCullingParameters cullingParameters) == false)
    13.         {
    14.             return;
    15.         }
    16.      
    17.         CullResults = renderContext.Cull(ref cullingParameters);
    18.  
    19.         CommandBuffer.SetRenderTarget(BuiltinRenderTextureType.CameraTarget, BuiltinRenderTextureType.Depth);
    20.  
    21.         if (camera.stereoEnabled)
    22.         {
    23.             CommandBuffer.SetSinglePassStereo(SinglePassStereoMode.Multiview);
    24.             CommandBuffer.EnableShaderKeyword("STEREO_MULTIVIEW_ON");
    25.             renderContext.StartMultiEye(camera);
    26.         }
    27.         else
    28.         {
    29.             CommandBuffer.SetSinglePassStereo(SinglePassStereoMode.None);
    30.         }
    31.  
    32.         var flags = camera.clearFlags;
    33.  
    34.         CommandBuffer.ClearRenderTarget(flags <= CameraClearFlags.Depth, flags == CameraClearFlags.Color, Color.black, 1.0f);
    35.         renderContext.ExecuteCommandBuffer(CommandBuffer);
    36.         CommandBuffer.Clear();
    37.  
    38.         SortingSettings sortingSettings = new SortingSettings(camera);
    39.         sortingSettings.criteria = SortingCriteria.None;
    40.  
    41.         DrawingSettings drawSettings = new DrawingSettings(new ShaderTagId("SRPDefaultUnlit"), sortingSettings);
    42.         drawSettings.enableDynamicBatching = false;
    43.         drawSettings.enableInstancing = true;
    44.         drawSettings.sortingSettings = sortingSettings;
    45.         drawSettings.perObjectData = 0;
    46.         FilteringSettings filterSettings = new FilteringSettings(RenderQueueRange.all);
    47.         renderContext.DrawRenderers(CullResults, ref drawSettings, ref filterSettings);
    48.         if (camera.stereoEnabled)
    49.         {
    50.             renderContext.StopMultiEye(camera);
    51.         }
    52.  
    53. #if UNITY_EDITOR
    54.         if (UnityEditor.Handles.ShouldRenderGizmos())
    55.         {
    56.             renderContext.DrawGizmos(camera, GizmoSubset.PreImageEffects);
    57.             renderContext.DrawGizmos(camera, GizmoSubset.PostImageEffects);
    58.         }
    59. #endif // UNITY_EDITOR
    60.  
    61.         if (camera.stereoEnabled)
    62.         {
    63.             renderContext.StereoEndRender(camera);
    64.         }
    65.         renderContext.Submit();
    66.     }
    When I run this through Oculus Link, It clears correctly (although the scene only renders in one eye). But when I run the build, The center of screen does not clear. If there are objects in the area they will render correctly, its just that the area does not clear. If I set the ClearRenderTarget color buffer to true, it clears the entire screen and nothing is drawn, although this might be the intended result.

    Anyone know why the center area is not clearing? Below is an image depicting the area:
    https://imgur.com/ktMPehr
     
    Sir_Awesomness likes this.