OSVR / OSVR-Unity

Package for authoring OSVR experiences with Unity.
Apache License 2.0
98 stars 38 forks source link

Force the distortion correction if RenderManager is not available #216

Closed demonixis closed 7 years ago

demonixis commented 7 years ago

Hi,

This PR force the distortion correction effect if renderManager is not available. It's the case on plateform that doesn't support the UnityRenderingPlugin. It allows Linux and Mac user to have a better image, even if it's not perfect.

You'll note that I have to use a try/catch on the GetViewerEyeSurfaceRadialDistortion function because it fails. That's the case for many OSVR native functions.

demonixis commented 7 years ago

Both 1.3 and 1.4 with latest firmware

Le dim. 2 avr. 2017 à 21:48, Greg Aring notifications@github.com a écrit :

@DuFF14 commented on this pull request.

In OSVR-Unity/Assets/OSVRUnity/src/VREye.cs https://github.com/OSVR/OSVR-Unity/pull/216#discussion_r109318087:

                 {

//@todo figure out which type of distortion to use //right now, there is only one option, SurfaceRadialDistortion //get distortion parameters

  • OSVR.ClientKit.RadialDistortionParameters distortionParameters =
  • Viewer.DisplayController.DisplayConfig.GetViewerEyeSurfaceRadialDistortion(
  • Viewer.ViewerIndex, (byte)_eyeIndex, surfaceIndex);
  • OSVR.ClientKit.RadialDistortionParameters distortionParameters;
  • try
  • {
  • distortionParameters = Viewer.DisplayController.DisplayConfig.GetViewerEyeSurfaceRadialDistortion(Viewer.ViewerIndex, (byte)_eyeIndex, surfaceIndex);

which HDKs have you tested?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/OSVR/OSVR-Unity/pull/216#discussion_r109318087, or mute the thread https://github.com/notifications/unsubscribe-auth/AA-FJpymg9uUlVdISenSYJwRwXSnzWbtks5rr_ulgaJpZM4Mwdr_ .

DuFF14 commented 7 years ago

Added some comments. I'm guessing the image is not upside-down in the editor for you?

DuFF14 commented 7 years ago

@demonixis I tested that if the radial (k1) distortion parameters are in the config file, everything seems to work as expected.

GetViewerEyeSurfaceRadialDistortion fails if the k1_red,k1green,k1_blue settings are not in the config file:

"distortion": {
            "k1_red": 0.25,
            "k1_green": 0.25,
            "k1_blue": 0.25
        },

When present, DoesViewerEyeSurfaceWantDistortion returns true, and GetViewerEyeSurfaceRadialDistortion populates the RadialDistortionParameters object with values from the config.

You should be able to accomplish what this PR does just by changing the config file to use k1 distortion parameters. Can you try testing master branch with the attached config file? osvr_server_config.hdk13.k1distort.json.txt

demonixis commented 7 years ago

OK I understand, but it doesn't fix the problem with Linux and Mac users. The current config files don't have those values so it'll not work. I know that the best way is to use RenderManager, and believe me, I would like to always use it because it has a lot of features. But RM is not working in Unity on Linux and Mac, I proposed to finish the C# binding or hack the current Unity plugin but I understand that it's not possible for now. So I decided to close this PR.