Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

VR Trying to port some effects from Cinematic Image Effects to single pass stereo

Discussion in '5.4 Beta' started by Cyrien5100, Jul 21, 2016.

  1. Cyrien5100

    Cyrien5100

    Joined:
    Oct 17, 2012
    Posts:
    145
    Hi,
    I'm trying to port some effects from Cinematic Image Effects. I've successfully ported Tonemapping Color Grading, but i'm struggling with Ambient Occlusion. I've correctly modified uv coordinates, using UnityStereoScreenSpaceUVAdjust and UnityStereoTransformScreenSpaceTex. I have ambient occlusion kind of working, but there is a some artifacts, which are eye dependant. So one eye is different from the other, resulting in eye strain. Here is some pictures illustrating the problem :

    What it looks without single pass stereo :


    With single pass stereo (the pillar should not be grey) :


    The same view, with the camera turned a little bit (the pillar's left face is now white) :


    Theses artifacts are view dependant, and different for each eye. I included the shader in attached files.

    I think the problem comes froms this part :
    Code (CSharp):
    1.         // Parameters used in coordinate conversion
    2.         float3x3 proj = (float3x3)unity_CameraProjection;
    3.         float2 p11_22 = float2(unity_CameraProjection._11, unity_CameraProjection._22);
    4.         float2 p13_31 = float2(unity_CameraProjection._13, unity_CameraProjection._23);
    5.  
    6.         // View space normal and depth
    7.         float3 norm_o;
    8.         float depth_o = SampleDepthNormal(uv, norm_o);
    9.  
    10.     #if _SOURCE_DEPTHNORMALS
    11.         // Offset the depth value to avoid precision error.
    12.         // (depth in the DepthNormals mode has only 16-bit precision)
    13.         depth_o -= _ProjectionParams.z / 65536;
    14.     #endif
    15.  
    16.         // Reconstruct the view-space position.
    17.         float3 vpos_o = ReconstructViewPos(uv, depth_o, p11_22, p13_31);
    The view space calculated is wrong, leading to these artifacts. What cause this can be the projection matrix used (is it the same for both eyes ?), or an incorrect uv, due to sampling a 2-in-1 texture.
    In the first case, a different matrix for each eye would be needed (i don't know how), and in the second case, we would have to correct uv coordinates (but how, it should be corrected). So how can i resolve this ?

    Thanks for your help.
     

    Attached Files:

  2. Alex-Lian

    Alex-Lian

    Guest

    Not a beta issue, because the team is aware of the lack of single pass support but it's just not their priority yet.

    If you're asking for community help, sure. The team wants to address this of course, but step 1 is to get things running out of beta and they're on their own schedule.
     
  3. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    Hi, after 5.4 ships and single pass stereo is stable we'll do a pass on upgrading the effects to work properly here.
     
  4. Cyrien5100

    Cyrien5100

    Joined:
    Oct 17, 2012
    Posts:
    145
    Alright, thanks. Most of them do not require much work (just replacing uv coordinates by corrected ones), but for some like ao, it is a bit difficult.
     
  5. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    just to add, any you do port feel free to make a pull request to the repository. we will take it :)