OSVR / OSVR-Unity

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

Better Linux and OSX Support #215

Open demonixis opened 7 years ago

demonixis commented 7 years ago

Hi,

For now the Linux and OSX support is pretty bad but it can improved with two things

  1. Using the distortion correction shader provided in this project
  2. By moving the window in the HDK screen position

I've implemented the OSVR SDK in my game engine and of course, RenderManager is not yet supported. BUT I was able to get distortion correction by porting your post process. Please use it when RenderManager is not available.

For the second point, we can open a new window on the location of the HMD using this API.

I can help to do that, what do you think about? Adding this will bring a better support of OSVR on Linux and it's required.

Edit: You can find a working version of the post process here.

image

russell-taylor commented 7 years ago

Cool, thanks! Is there a barrier other than the time it would take to porting the RenderManager Unity plug-in to Linux or OSX?

demonixis commented 7 years ago

Well the port of the current plugin to Linux and OSX requires OpenGL support and it doesn't work for now. I don't know why, maybe a difficulty on the Unity side.

However, the rendermanager branch on the Managed-OSVR looks promising. According to @JeroMiya It's not yet finished and only supports OpenGL. To work, it requires a pointer to the OpenGL or DirectX texture and Unity allows us to get that from C#. So I think that a native plugin is not required if this branch can be finished/stabilized. Having Managed-OSVR complete will allows other C# engine to enjoy OSVR.

In very short term, I think we can implement two feature to the current Unity SDK

  1. Distortion correction, it's easy, I have published the effect we need (see my previous screenshot) and you can use that code to get the K1 parameters.
  2. Detect where is the OSVR HMD display (screen 2, 3 ?) and open a new window into that screen. Unity can handle multi monitors, so we just have to push the dual camera view on that screen and keep a preview (the left eye by example) on the main screen.

Edit: I have updated my fork and added the distortion correction if RenderManager is not available. I have to test it first.

DuFF14 commented 7 years ago

OpenGL support is working on Windows in extended mode. Direct mode won't work on OSX or Linux anyway, right? For OSX and Linux support, the platform-specific context sharing code needs to be ported. Specifically, this call to wglShareLists is only available on Windows: https://github.com/OSVR/OSVR-Unity-Rendering/blob/oglSupport/OsvrRenderingPlugin.cpp#L283

This splits to another branch for OSX support, and I just pushed my most recent commits which haven't been tested. https://github.com/OSVR/OSVR-Unity-Rendering/compare/oglSupportOSX

@demonixis I will take a look at the PR

demonixis commented 7 years ago

Hi,

Yes the plugin works well on Windows (Direct mode is good and as you said, OpenGL works in extended mode), you've made a nice work on it. But as I said, i've implemented the OSVR SDK into my own engine so I learnt a lot about OSVR recently. I believe if we use a complete binding of OSVR (Core + RenderManager) we can bring some RM features to Linux and Mac too in extended mode. That's what gamers on those OSs want. My pull request that adds Distortion correction is clearly not perfect, it's a temporary fix for a majority of uers on Linux and Mac which use an OSVR HDK.

I don't know but some methods fails to call from native code, you can see that in my last PR too. I've also opened an issus on the Managed-OSVR repository https://github.com/OSVR/Managed-OSVR/issues/41 and talked a bit about that with @JeroMiya .

Some parts of MonoGame-OSVR could be merged into Managed-OSVR (json descriptor parsing by example), because with a finished binding of RenderManager, we can avoid the native plugin and have a better support for other OSs.

Why do I have opened this issue? Because I'm a game developer for my own and for a company and in both cases, we use OSVR. It's impossible to sell a game or an application on Linux and Mac because it doesn't work as expected. And what do we want on those OSs?

All these features are supported on Linux and Mac with any GPU. So yes it's just a binding to finish.