Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Reusing a rendered background image for both eyes

Discussion in 'AR/VR (XR) Discussion' started by arharvey, Sep 28, 2015.

  1. arharvey

    arharvey

    Joined:
    Jul 8, 2015
    Posts:
    4
    Hi there, I'm just getting into VR development with Unity 5.2. I originally posted this question on the Oculus Unity Integration forum but got no response...

    In the game I'm writing my world's background (i.e; the far distance) is procedural and rendered using a native C++ plugin. Since the background is far way it should appear the same for both eyes. It's rather wasteful doing the same expensive render twice so I'd like to render once and reuse the image for each eye.

    Does anyone have any ideas or links that may prove useful?

    From my Googling it seems I should create a camera and link it to a render texture. Question is, how do I ensure Unity renders this camera before the left and right eyes?

    Many thanks!
     
  2. shakhruz

    shakhruz

    Joined:
    Feb 17, 2011
    Posts:
    43
    That is actually a good practice for optimizing your VR game - to render background to a texture and put it as a plane behind your 3D scene. Since it will be rendered with a separate non stereoscopic camera, it will not be doing it twice.

    So you can make a plane, put it behind your 3D scene and make it move with your camera by making it a child of the camera so wherever you look the plane with pre-rendered background-texture will be before your eyes. On that plane you will put the texture that will be rendered by a separate non stereoscopic camera.

    Hope that helps.
     
  3. arharvey

    arharvey

    Joined:
    Jul 8, 2015
    Posts:
    4
    Thanks! Yes, I tried it out yesterday and it seems to work well.

    One question: Is there any reliable way to get the resolution of the eye texture so that I can correctly size my own background texture and make it match?

    I am developing for Gear VR, which I believe defaults to 1024x1024. However I'm pretty sure this can be adjusted, so it would be a dangerous assumption to make.

    Best regards.