mobfishgmbh / Cardboard-VR-Unity-SDK

Apache License 2.0
56 stars 11 forks source link

Bad Display Quality in VR Mode #57

Closed RajatPatel5 closed 4 years ago

RajatPatel5 commented 4 years ago

I have downloaded the project and used it. It works quite well and the camera transition between the VR and non-VR mode is smooth. But the main issue is with VR Mode in which the quality of the video is so poor. When I first used the plugin I needed to increase the far clip plane of the camera so I did in the lens distortion script and got the result. However, I am not able to find such things that can improve the quality in VR Mode.

Can you guys check this and help me out ?

cai-mobfish commented 4 years ago

@RajatPatel5

Can you provide more information about what exactly does "Bad Quality" "Video" means?

RajatPatel5 commented 4 years ago

Hello @cai-mobfish I am sharing with you the two different images for VR and non-vr mode. Here you can see how the image is pixelated when it is in VR mode. non-vr Mode vr mode

Please look into the images and suggest some steps for improving.

Thanks

cai-mobfish commented 4 years ago

That is strange. I can't reproduce it.

RajatPatel5 commented 4 years ago

image

Can this be the reason for the issue I am facing? and can you suggest me the way to change the far clip plane in VR mode?

cai-mobfish commented 4 years ago

First of all:

There are 3 cameras, one for left eye, one for right eye, and another for Screen (CamPost). I don't know why you need to change the far clip, but if you really need to change it, do it after where CardboardLensDistortion_getProjectionMatrix this method is called, if you want to override the far clip provided from cardboard profile. And you should not change "CamPost" camera because it's not meant to render anything other than final eye texture (render texture).

Then about the script:

You got the idea wrong when changing it. This method in your screenshot is a "Replacement Method", which will work in Unity Editor but not on device. The other DLLImport method will be called on real device. And I wrote this method for Editor Mockup. So when you change it, it will show difference in Editor but not in real device.

About the pixelated result:

I still failed to reproduce the issue, even when the far clip is changed in Editor. Can you upload a test project here so I can check on it? I have these theories:

Then I have one question: why do you need to change far clip? As far as I'm concerned, 1000 for far clip is far more than enough, especially for mobile devices.

RajatPatel5 commented 4 years ago

@cai-mobfish We have tried this plugin in different places. I first tried the same project which is in this repo and the quality is very smooth. I have created an empty project and there as well it looks smooth. But when using this in my existing plugin we are having quality issues. Just want to know if such issues can be due to heavy or large environment rendering? It is possible that due to any heavy process going on which can cause the quality issue?

Moreover, regarding the far clip plane as we have many different large environments that we needed to render. We have also some kind of space environments in which far clip plane should be kept higher so that the distant objects can be seen. 1000 is much less for our project. And I couldn't find any way to change the far clip plane for a device. Can you please provide steps to change the far clip plane for VR mode?

cdytoby commented 4 years ago

@RajatPatel5

About camera far clip, you can change it in script CardboardMainCamera.cs. In method RefreshCamera_Eye, you can change the camera far clip after eyeCam.projectionMatrix is changed.

About the rendering issue, I still can't reproduce the issue. I tested it with further far clip, and it doesn't produce blurry texture and mesh.

Can you try enable mipmap for these texture, and check if the blurry issue for these icons are improved?

(Sorry about the username, I forgot to switch to the company's github user to comment this. Feel free to at any of us to reply. Both are me.)

robibkuiper commented 4 years ago

I'm having exactly the same issue. Could have anything to do with CardboardMainCamera being initialized during a portrait resolution so it takes half of the screen width during portrait resolution?

I tested this on Android on a "clean" project by starting the project in portrait mode. When switching to VR mode i change the oriention to landscape and call CardboardManager.RefreshParameters() shortly after. This gives me the same result as @RajatPatel5 has in his screenshots.

RajatPatel5 commented 4 years ago

@cai-mobfish I tried the way you said to change the far clip plane. Here is the sample I tried

if (!projectionMat.Equals(Matrix4x4.zero))
                eyeCam.projectionMatrix = projectionMat;
 eyeCam.farClipPlane = 10000;

But I am not getting the expected result when testing in ios. Did you change something else? Can you please provide your CardboardMainCamera script for reference.

Also, for the quality issue I already said that on a new project I am getting proper quality but when I use it in my project it does not give proper result. I am still stuck on the same issue. Please provide some suggestions that I should try. I don't know on which texture should I change the mipmaps.

cdytoby commented 4 years ago

@RajatPatel5 Sorry for the late response, and sorry that I posted a solution without a test.

Regards to the far clip plane, it seems that after projection matrix is set, change camera property will not modify anything. I don't have a solution yet because I failed to find a way to get the "perspective" parameters from a exist matrix. The correct solution should be, mofidy the projectionMat in method RefreshCamera_Eye, before assign it to eyeCam.

Regards to the quality issue, I just tested it and I think @robibkuiper is right, if you set the device orientation (in program instead of in unity setting) after camera awake called, you might get this issue. Can you try to set the "Default Orientation" in Unity to "Landscape Left" and test again?

robibkuiper commented 4 years ago

The quality is like expected when i flip the screen.width en screen.height in CardboardMainCamera.SetupEyeRenderTextureDescription(). I also flipped them in CardboardLensDistortion.CreateLensDistortion() to make sure the carboard view also matches the correct resolution.

I guess a simple if statement checking Screen.orientation should be an east fix to make it more flexible.

cdytoby commented 4 years ago

@RajatPatel5 @robibkuiper I made a quick fix and here is the unitypackage.

Change is based on 0.8.1 and not yet merged, can you test if the screen quality issue still persists?

mobfishCardboard-issue-057.zip

Detail change is in the branch issue-rot_change_quality. There should be a better fix, like allow "Protrait" orientation, change render texture resolution when rotating the device, etc. But sadly I don't have much time on new features and these "fixes" are low priority for us.

For the same reason I can't provide a fix for far clip issue. You can research it by the direction I provided in previous comments. If you found solution, you can create extra ticket for this and create merge request.

cdytoby commented 4 years ago

I released Version 1.0 and I'm closing this ticket.

If issue still persists, you can reopen this ticket, or create a new one.