Search Unity

Resolved VR Singlepass Instanced blit not working

Discussion in 'VR' started by Kajta, Aug 17, 2021.

  1. Kajta

    Kajta

    Joined:
    Feb 13, 2016
    Posts:
    11
    I have been trying to wrap my head around getting any kind of screen space effect running in our project, this is a VR only project, using the Universal Render Pipeline and the ScriptableRender Feature

    URP version: 10.4.0
    Unity version: 2020.3.5f.1

    I am not sure what the problem seems to be, but when I try to use CommandBuffer.Blit to apply any effect to the current camera texture, the result is a grey screen for the left eye, and the right eye rendering gets stuck, this seems to happen whenever I try to apply any texture to the camera color texture. But only after drawing Opaque's, if I do it before, the result simply gets overridden, but rendering still works.
    Here is the result whenever I attempt to blit to the camera:

    BlitResult.PNG The Shader used for the Blit is a simple Stereoscopic debug shader that renders the left eye green, and the right eye red, taken from the Unity webpage about Singlepass Instanced rendering: https://docs.unity3d.com/Manual/SinglePassInstancing.html

    I have tried newer Unity versions and URP versions, but none seem to fix the issue, also it does not occur in multi-pass rendering.

    @ThomasZeng Sorry for tagging you directly in the post, but after searching through some older forum posts I saw your comment about Blit not working correctly in Singlepass Instanced VR, but I could not find any other official information on this issue.
     
  2. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    5,055
    This is a common problem with VR and I'm not sure if it's a bug (if you force both eyes the perspectives don't match).
    I have a VR fractal project on GitHub where we fixed the issue. I'm not sure how exactly since I'm not the shader dev, but you can find the code in assets/graphics/raymarching

    https://github.com/smitdylan2001/FractalsVR
     
  3. Kajta

    Kajta

    Joined:
    Feb 13, 2016
    Posts:
    11
    Thanks for taking the time to reply, I took a look at the project, but unfortunately it's done with the OnRenderImage function.

    This function is not usable in URP, and has been replaced by ScriptableRenderFeatures, which is where I encounter the issue.
     
  4. Sheynes

    Sheynes

    Joined:
    Mar 27, 2017
    Posts:
    66
  5. Kajta

    Kajta

    Joined:
    Feb 13, 2016
    Posts:
    11
    @Sheynes Thank you very much, this worked!

    I did take a look and tried it with cmd.DrawMesh before because that's what Unity also does for PostProcessing, but I guess I made a mistake earlier.
     
    Sheynes likes this.