Reusing a rendered background image for both eyes

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!

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.

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.