Showing results for 
Search instead for 
Did you mean: 

unity_StereoEyeIndex always set to 0 for Oculus Quest?

Not applicable

I'm trying to create a portal effect using render textures with no luck. I create two cameras to observe the other side of the portal, using the stereo settings from the main camera (separation and projection matrices), rendering to two separate render textures. Then, to render the portal itself, I want to select the appropriate texture based on the eye index.

But this test shows that the eye index is always 0 (renders red to both eyes):

fixed4 color = unity_StereoEyeIndex == 0 ? fixed4(1.0, 0.0, 0.0, 1) : fixed4(0.0, 0.0, 1.0, 1.0);

I've also noticed that UNITY_SINGLE_PASS_STEREO is not defined when building for Quest. I have set "Multiview" rendering in the XR plugin, which is supposed to enable Unity's single pass stereo infrastructure.

Any ideas?

Thank you!

Honored Guest

I'm also curious about this! Reading some of the compiled code it looks like unity_StereoEyeIndex is only defined with UNITY_SINGLE_PASS_STEREO, UNITY_STEREO_INSTANCING_ENABLED, UNITY_STEREO_MULTIVIEW_ENABLED. The issue for me was that I was using Multi Pass. Switching to single pass instanced in the editor and multiview for android solved the issue. I am kinda curious why unity_StereoEyeIndex doesn't work in Multi Pass though. You'd think they might come up with some kind of workaround for people using it in an artistic way?

I think this problem has been fixed. Currently, unity_StereoEyeIndex works well in Multi-Pass Mode.