Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to render different objects to each eye? #146

Open
Xirion11 opened this issue Oct 23, 2020 · 16 comments
Open

Is it possible to render different objects to each eye? #146

Xirion11 opened this issue Oct 23, 2020 · 16 comments
Labels
feature request New feature or request

Comments

@Xirion11
Copy link

Xirion11 commented Oct 23, 2020

I want to be able to show different objects in each eye in Android/iOS.

In the now obsolete sdk it was possible to set a different target eye to each of two cameras and you could control which object were rendered with the culling mask property. With the new cardboard sdk whenever I try to get the same result I either end up:

  • only rendering the left eye in both eyes
  • only rendering the left eye while the right eye is completely black
  • not rendering anything

I believe this happens when I enable the checkbox "Virtual reality supported" under Player settings -> XR Settings (since this checkbox is needed to enable the target eye field in the cameras)

@dletozeun
Copy link

Hi,

Check: unity_StereoEyeIndex and example there: https://docs.unity3d.com/Manual/SinglePassStereoRendering.html

This allows you at least in the shader to treat each eye differently.

@jballoffet jballoffet added the question Further information is requested label Oct 29, 2020
@jballoffet
Copy link
Member

Cardboard SDK does not support rendering different objects to each eye and there are currently no plans to support it. However, it may be considered in a future update.

@jballoffet jballoffet added feature request New feature or request and removed question Further information is requested labels Nov 9, 2020
@yuhany1024
Copy link

I also want to render different contents to two eyes. I wonder which version SDK can achieve it? If I create two cameras targeted to different eyes. Do the cameras have the same position or should be separated by 6cm(eye distance)?

@Xirion11
Copy link
Author

I also want to render different contents to two eyes. I wonder which version SDK can achieve it? If I create two cameras targeted to different eyes. Do the cameras have the same position or should be separated by 6cm(eye distance)?

If you use the GVR SDK (now obsolete for iOS) you can do so, that's the one we are using. You just need to go to your cameras and define which eye they should render; you also need to define which layers to cull, basically the left camera should not see objects in the "right" layer and the right camera should not see objects in the "left" layer. The plugin will manage the cameras position and angle

@hi4c0ck
Copy link

hi4c0ck commented Dec 8, 2020

Also interested to get this feature as soon as possible. Seems like, we can't use Cardboard XR in common case, although, we cannot use GVR with actual iPhones. Any workarounds possible?

@Acimaz
Copy link

Acimaz commented Jan 11, 2021

I am interested as well and I'm searching for a quick solution for this. Downloaded the old gvr sdk but the documentation is not too great and I am a bit stuck atm.

@Acimaz
Copy link

Acimaz commented Jan 11, 2021

Hi,

Check: unity_StereoEyeIndex and example there: https://docs.unity3d.com/Manual/SinglePassStereoRendering.html

This allows you at least in the shader to treat each eye differently.

It took me a while but I finally found a solution that also works with shader graph using unity 2020.2. Here is a description and some screens of the custom node I used: https://forum.unity.com/threads/render-different-color-depending-on-stereo-eye-index.1037215/

@Ste-RH
Copy link

Ste-RH commented Jan 22, 2021

Does anyone know if there is a define we can use in a shader to know if 'unity_StereoEyeIndex' is valid for use?

In Unity I have been using 'UNITY_SINGLE_PASS_STEREO' and 'UNITY_STEREO_INSTANCING_ENABLED' to cover most bases, but the Cardboard XR Plugin does not fall into line with these.

@jballoffet
Copy link
Member

jballoffet commented Jan 25, 2021

Currently the Cardboard XR Plugin display provider has single pass rendering support disabled. Now that OpenGL ES 3 is supported by the SDK this flag should be able to change to true (see

rendering_caps->noSinglePassRenderingSupport = true;
and
bool noSinglePassRenderingSupport;
). Then, per
/// - Single pass stereo rendering (1 RenderPass x 2 RenderParams)
and
/// - If single-pass, two pose / projections per pass
, with a single rendering pass, two pose/projection matrices (RenderParams) could be used.

Patches here are welcome.

@rev111
Copy link

rev111 commented Apr 3, 2021

Currently the Cardboard XR Plugin display provider has single pass rendering support disabled. Now that OpenGL ES 3 is supported by the SDK this flag should be able to change to true (see

rendering_caps->noSinglePassRenderingSupport = true;

and

bool noSinglePassRenderingSupport;

). Then, per

/// - Single pass stereo rendering (1 RenderPass x 2 RenderParams)

and

/// - If single-pass, two pose / projections per pass

, with a single rendering pass, two pose/projection matrices (RenderParams) could be used.
Patches here are welcome.

This might be a stupid question, but how can I test this? I guess I would have to compile the Unity XR plugin, how? Also, would you expect this to work on the upcoming release that would work on Metal / iOS / Unity 2020?

Edit:
I think I understand what you are proposing and I see the source files where the changes should be made, but I have no idea how to put this into the XR package (if that is even the way this should be done).

@jballoffet
Copy link
Member

jballoffet commented Apr 29, 2021

@rev111, you will need to build the SDK with Android and/or Xcode and then overwrite the prebuilt binaries in the XR plugin package. You can find instructions to do so here and here. Hope this helps.

@rev111
Copy link

rev111 commented May 16, 2021

@rev111, you will need to build the SDK with Android and/or Xcode and then overwrite the prebuilt binaries in the XR plugin package. You can find instructions to do so here and here. Hope this helps.

Thank you very much. I was able to rebuild the SDK for iOS. But I am still confused about

Now that OpenGL ES 3 is supported by the SDK this flag should be able to change to true (see
rendering_caps->noSinglePassRenderingSupport = true;

So the SDK has only multipass enabled right now, is that correct?
Shouldn't that then be "false", as "false" would enable single pass rendering?

(Edit) I built the binary with rendering_caps->noSinglePassRenderingSupport = false;
I put a log entry above that change and it shows up in the XCode debugger.
So far I can't see any difference when experimenting with a shader graph. unity_StereoEyeIndex appears to always return 0.
Does anyone know how I could check if single pass rendering is enabled on the device? To confirm.

@jballoffet
Copy link
Member

jballoffet commented Jun 9, 2021

Shouldn't that then be "false", as "false" would enable single pass rendering?

Correct, setting it to false should enable single pass rendering.

Does anyone know how I could check if single pass rendering is enabled on the device?

IMO, the best way to debug this is by using the Frame Capture Debugging Tools in Xcode. You should be able to notice whether the rendering is being performed on a single pass or multiple passes.

Hope this helps.

@Pepn
Copy link

Pepn commented Mar 2, 2023

Anyone able to replicate this in Unity 2022.2 with URP? Does not seem to work

@cacard
Copy link

cacard commented Aug 5, 2023

rendering_caps->noSinglePassRenderingSupport = false;
The fps not change...
why?

@helifax
Copy link

helifax commented Apr 11, 2024

Is changing the above from true to false, actually enable single pass (multiview) rendering in cardboard SDK or there are other changes/missing code that is needed? (OpenGL ES 3.2 or Vulkan)?

Thank you, in advance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

No branches or pull requests