OSVR / OSVR-Unity

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

UI Canvas judder related to manual render path #147

Closed chase-cobb closed 8 years ago

chase-cobb commented 8 years ago

Using a UI Canvas in world space and attached to a Tracked camera results in very notable judder (or an effect that looks like judder). It seems to be a side-effect of the manual render path. A sample unity binary has been included that shows the effect and can toggle between the current manual camera render and the normal camera render pipelines.

Even when the normal rendering pipeline is used, there are jumps in the UI text. It looks like this could be related to time warp. Thoughts?

Sample binary https://drive.google.com/file/d/0B5TmckqIm686VXNscnUyWkZJWjg/view?usp=sharing

Sample project https://drive.google.com/file/d/0B5TmckqIm686S21aUUJ4Z2NkekU/view?usp=sharing

This project has only one change to the OSVR Unity SDK. It is a change to VRSurface.Render(). This change is not a proposed fix but is meant to demonstrate the issue.


            //Render the camera
            public void Render()
            {
                Camera.targetTexture = RenderToTexture;

                if (!Camera.enabled)
                {
                    Camera.Render();
                }
            }
DuFF14 commented 8 years ago

Haven't dug into this yet, but are you seeing the same issue with the worldspace gui in https://github.com/OSVR/Unity-VR-Samples ? Attaching a UI to a tracked camera is bad practice in VR; it's recommended to build the UI into the environment like in the Unity VR Sample. We do want to be able to overlay information HUD-style, but the approach should be similar to SteamVR's compositor, where RenderManager will have a separate layer for UI (I think this on the roadmap, but not being worked on until some other pieces fall into place).

chase-cobb commented 8 years ago

Attaching UI elements to a tracked camera can be bad practice, but this is not true 100% of the time. This bug needs to be fixed because the current rendering pipeline delivers unexpected results.

DuFF14 commented 8 years ago

Interesting, I was expecting the artifacts would be due to timewarping. A compositor is needed so that the layer with the 3d scene is timewarped but the UI layer is not timewarped. However, turning off timewarp doesn't affect this. It looks more like the gui is drawn twice (https://github.com/OSVR/Unity-VR-Samples/issues/6). It even shows up in the preview window, not just the headset.

Chasing this a littler further, it appears this is also an issue in SteamVR (http://steamcommunity.com/app/358720/discussions/0/451848855027493382/), and looks like it's due to a bug in Unity, introduced in Unity 5.2.3. From Unity 5.2.3 changelog:

(710195) - Fixed issue where UI would not get rendered for disabled cameras when manually calling .Render().

I tried the VRSamples project in Unity 5.2.2 and can confirm, the GUI is not double-drawn. Re-opening the project in later versions of Unity has the double GUI issue. Apparently this has not been fixed as of the Unity 5.4 beta.

DuFF14 commented 8 years ago

This is fixed in Unity 5.3.5. I've updated Unity-VR-Samples and no longer see the double gui reticle that I see in unity 5.3.4. I tested @chase-cobb's OSVR Judder project and no longer see double rendered gui on the manual rendering path -- now there is no apparent difference between manual and auto rendering in that example.

sroettgermann commented 7 years ago

@DuFF14 can you tell me how to disable TimeWarp in unity. I read a lot about that, buth found no explanation regarding this. Maybe it will help me with another problem I'm experiencing right now.

DuFF14 commented 7 years ago

@sroettgermann Timewarp is enabled/disabled in the "renderManagerConfig" section of an OSVR server configuration file, along with a bunch of other rendering settings that are useful in tweaking performance and testing: https://github.com/sensics/OSVR-RenderManager/blob/master/doc/renderManagerConfig.md#timewarp

https://github.com/OSVR/OSVR-Core/blob/master/apps/sample-configs/osvr_server_config.renderManager.HDKv2.0.direct.json#L38

sroettgermann commented 7 years ago

Thank you @DuFF14. I will go through the links and do some testing.

Are there also any render settings regarding TimeWarp which can be set in Unity directly?