Search Unity

WMR stereo-effect fails when Graphics.CopyTexture is used in OnRenderImage

Discussion in 'VR' started by habolog, Jun 7, 2019.

  1. habolog

    habolog

    Joined:
    May 17, 2017
    Posts:
    8
    Hello!

    I've faced a bug that easily reproduced.
    There is a very simple scene: MainCamera, Canvas with sprite on it, simple MonoBehaviour script attached to MainCamera.
    That script implements OnRenderImage method.
    In that method I need to copy source RenderTexture to some intermediate Texture2D, do something with that texture and copy back to destination RenderTexture.

    Here is the code:
    Code (CSharp):
    1. private void OnRenderImage(RenderTexture source, RenderTexture destination)
    2.     {
    3.         if(TestTexture == null)
    4.         {
    5.             TestTexture = new Texture2D(source.width, source.height, TextureFormat.RGBAHalf, false);
    6.         }
    7.  
    8.         Graphics.CopyTexture(source, TestTexture);
    9.         Graphics.Blit(TestTexture, destination);
    10.        
    11.     }
    That code works fine in SteamVR but somehow spoils stereo-effect in WMR. It looks like textures for left and right eyes are being applied with incorrect shifts to render on displays.

    I've already reported the bug as (Case 1160871) but I hope there might by some workaround solution.
     
  2. Unity_Wesley

    Unity_Wesley

    Unity Technologies

    Joined:
    Sep 17, 2015
    Posts:
    558
    Hello,

    It looks like our QA tried to reproduce the bug and couldn't, can you respond to email if you feel like there some missing information?

    Do you have an image or screenshot of the issue?

    Thank you,
    Wesley