Search Unity

GrabPass is totally broken in 5.6.1 with Single-Pass Stereo Rendering??

Discussion in 'AR/VR (XR) Discussion' started by sunyifeng, Jun 14, 2017.

  1. sunyifeng

    sunyifeng

    Joined:
    Nov 4, 2014
    Posts:
    28
    In Single-Pass Stereo Rendering, the GrabPass is totally unusable. It just diaplay in the left eye and the right eye is always dark. I have tested the unity's Shader: FX/Glass/Stained BumpDistort, the problem is the same. Are there any solution to solve the problem? We are getting stuck in this problem.
     
  2. emptyxu

    emptyxu

    Joined:
    Jun 15, 2017
    Posts:
    12
    my game runs into cpu boundary...im trying sinple pass, but everything broken!

    im an AI developer and im really new to unity and shader programming, i think there must be some smarter way to solve this problem!!
    here's my method

    first you need two camera, one for the scene, one for distort,
    distort camera depth should larger than scene camera, and set clear flags to none,
    i think this can help to reuse the depth buffer from scene camera for proper ztest

    obviously we need modify cullmask of each camera, make sure distort gos only render in distort camera

    i delete grabpass. instead, i set _grabTexture property by this

    Code (CSharp):
    1.  
    2. private RenderTexture m_tex;
    3. private void OnPreRender()
    4.     {
    5.         urDistortMat.SetTexture("_grabTexture", m_tex); //"_grabTexture" should be hash
    6.     }
    7.  
    8.  
    9.     private void OnRenderImage(RenderTexture source, RenderTexture destination)
    10.     {
    11.         Graphics.Blit(source, destination);
    12.         m_tex = source;
    13.     }
    14.  
    if you are using unity standard asset effect glassdistort
    Add
    Code (CSharp):
    1. #pragma multi_compile _ UNITY_SINGLE_PASS_STEREO
    2.  
    and delete #if UNITY_SINGLE_PASS_STEREO snippet in frag

    then everything work ok now, hope this can help
     
    Last edited: Jun 18, 2017
  3. rr_7827

    rr_7827

    Joined:
    Feb 23, 2017
    Posts:
    4