mobfishgmbh / Cardboard-VR-Unity-SDK

Apache License 2.0
56 stars 11 forks source link

Wrong perspective and frame drops while in VR mode #69

Open CedoSnr opened 4 years ago

CedoSnr commented 4 years ago

Hi,

First, I wanted to say thanks for making this plugin. From what I've seen of it so far, it looks really good - in a lot of ways much better than the official Google one.

However, I have a couple of issues:

Issue 1: Perspective is way off in VR mode compared to Magic Window Mode. Below are screenshots of my application (from the same point) in both modes:

https://imgur.com/0OW6T2C https://imgur.com/Jcaa1DO

As you can see, the skybox appears much higher, and the "ocean" doesn't appear to go as far. On a related note, my ocean shader graph uses scene depth/camera nodes to add "foam" to the edge of the water, as seen in the MagicWindow version. This does not function in the VR version (but does in the official Google VR plugin).

Issue 2: Significantly lowered framerate compared to the official Google VR plugin

Below is a screenshot of the same environment as above running with the official plugin:

https://imgur.com/CqNK84G

The frame rate is much higher than when using this one. There are no major changes between the two other than switching the two VR plugins.

Thanks again for all your hard work.

cai-mobfish commented 4 years ago

Thank you for the kind words, and sorry for the late response. It's been very very busy lately.

Regards to the performance, there is another ticket who mentioned this, I already answered there, and marked as "Help Wanted".

https://github.com/mobfishgmbh/Cardboard-VR-Unity-SDK/issues/70

As for the Perspective issue, this is a very odd one. You mentioned that you use shader graph with camera nodes? maybe that's the cause because multiple cameras are used with this SDK and maybe the shader graph has trouble locating the camera it should use. But I'm not sure since I'm not expert on shader things.

Are you able to create a clean project with this issue so that I can investigate it?

CedoSnr commented 4 years ago

Thanks for your reply.

Apologies also for the slow reply - this is only a side project for me and I don't get to spend as much time on it as I'd like.

I thought your reasoning sounded good, so I tried swapping out the shader graph material for a standard material using only an opaque colour and a normal map.

I still get the same problems of perspective with this, so I don't think it can be only to do with the camera node function (although this clearly also does not work as evidenced by the lack of foam edging).

If I get time I will try to build a clean project for you (URP can be a bit tricky to get set up for some reason).

Edit: I've just realised this isn't a problem of perspective but actually of too-aggressive culling by the VR camera. The back portions of my water plane are being culled, leaving a blank space for the skybox to be viewed in. Terrains in the distance are also culled in a similar manner. This is easily fixed by editing this section in the CardboardLensDistortion script (increase the 100f variables to be bigger - in my case 400f worked):

CardboardLensDistortion_getProjectionMatrix(_lensDistortion, CardboardEye.kLeft, 0.1f, 100f, projectionMatrixLeft); CardboardLensDistortion_getProjectionMatrix(_lensDistortion, CardboardEye.kRight, 0.1f, 100f, projectionMatrixRight);

But this obviously doesn't do anything for the camera node function of the shader graph, so I still think you're probably right about that (the shader graph doesn't know which camera to work off perhaps).