Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug HDRP / VR 2022.3.6f1 Issue with 2nd camera (only on Build)

Discussion in 'High Definition Render Pipeline' started by baggyg, Nov 6, 2023.

  1. baggyg

    baggyg

    Joined:
    Nov 21, 2013
    Posts:
    27
    Having an issue with a game that was recently upgraded from 2021.3.17 to 2022.3.6f1.

    I have a second camera which is dynamically given a targetTexture of a dynamically created RenderTexture. It is activated for 0.3 seconds and then switched off again.


    Code (CSharp):
    1. RenderTexture picture = new RenderTexture(gameGlobalSettingsData.width, gameGlobalSettingsData.height, gameGlobalSettingsData.depth);
    2.             cameraScreenShoot.targetTexture = picture;
    3.             cameraScreenShoot.enabled = true;
    4.             yield return new WaitForSeconds(0.03f);
    5.             cameraScreenShoot.enabled = false;
    6.             yield return new WaitForEndOfFrame();
    7.             gameGlobalSettingsData.polaroidPhotoTarget.SetTexture("_BaseColorMap", picture);
    8.             gameGlobalSettingsData.polaroidPhotoTarget.SetColor("_Color", gameGlobalSettingsData.startColor);
    9.             pictureToSave = new Texture2D(picture.width, picture.height, gameGlobalSettingsData.textureFormat, true, true);
    This worked perfectly fine in 2021.3 (In-Editor & Builds) and also works fine in 2022.3.6f1 in-editor. However when I make a build, it ceases to work. Instead I seem to get a portion of the MainCamera rendered instead to the texture.

    Obviously very hard to diagnose when it doesn't occur at all in the editor version. Anything in a HDRP VR build which would be stopping this working? Something like forcing multiple cameras off completely?

    I can't tell if its actually sampling the wrong camera or just moving the second camera to match the headtracking (I've tried turning off XR Rendering and setting XRDevice.DisableAutoXRCameraTracking(Camera, true) on that camera, but no change).
     
    Last edited: Nov 8, 2023