CesiumGS / cesium-unity

Bringing the 3D geospatial ecosystem to Unity
https://cesium.com/platform/cesium-for-unity/
Apache License 2.0
334 stars 79 forks source link

Problems with left eye rendering on Quest 2/3 with Vulcan api #388

Open dudziakl opened 7 months ago

dudziakl commented 7 months ago

The image displayed in VR on the left eye contains artifacts.

image

The issue was discovered on Quest 3 with Vulcan set Graphic API. The stereo rendering mode of the Oculus Plugin was set to Multiview.

It can be easily reproduced with the Cesium Unity Samples project; however, the issue appears in any project that uses the Cesium Unity plugin.

  1. Download and unpack the Cesium Unity Samples project.
  2. Open it in Unity 2022.3.x switch the target platform to Android.
  3. Build an app with Oculus/Meta SDK for Meta Quest 2/3 and deploy it to the device.
  4. Artifacts will be visible on the left eye as soon as CesiumGeoreference script starts to work.

The issue can be fixed by changing in Project Settings >> Other Settings >> Graphic API to OpenGLES3 instead of Vulcan (remove the Vulcan from the list). image

IMPORTANT NOTE It is not an ideal solution because Vulcan is recommended Graphic API as it has better performance than OpenGLES3.

kring commented 7 months ago

Do you have any idea what might cause those artifacts? I don't have the hardware to try out your steps myself, but it's not obvious what Cesium for Unity could be doing wrong that would cause that. For the most part, 3D Tiles just become normal game objects with MeshFilter and MeshRenderer components.

dudziakl commented 7 months ago

I have no idea. I spent two days trying to solve it, and that is all that I found.

kring commented 7 months ago

I'm inclined to think it's a bug in Unity. We're not doing anything Vulkan specific, as far as I know, so I can't think of any good reason it would work in one renderer and not the other, short of a renderer bug.

As an experiment, maybe try specifying a Material on your tileset. Just choose a simple default one. That will likely break the model's textures, but it will still be interesting to see if it makes the artifacts go away.

s4t0 commented 6 months ago

Switching the graphics API to OpenGLES3 is not a fix because it causes error spam on the Quest 2 and 3. Assertion failed: OPENGL NATIVE PLUG-IN ERROR: GL_INVALID_OPERATION: Operation illegal in current state

It doesn't appear to be related to the shader because

it also only starts when the 3D Tileset starts creating/updating the tiles.

When testing on the quest 3 I found the visual issue only shows up when using multiview rendering mode. Using multipass rendering isn't a good solution because it's not as performant.

kring commented 6 months ago

We've had reports that Unity does not support single-pass instance rendering with shaders built using Shader Graph (which ours are). See here: https://community.cesium.com/t/does-cesium-for-unity-support-hololens/22759/12 If this is the problem you're seeing, there's probably little we can do it to fix it, and you're better off raising it with Unity. Moving away from Shader Graph would require us to develop custom shaders for each render pipeline, which would be a pretty significant burden. Perhaps that user from the forum would be willing to share their HLSL implementation to use as a starting point for a workaround?