godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
88.96k stars 20.18k forks source link

Godot ignores Viewports with size 0 even though their size is determined by OpenVR #31400

Open Faeranne opened 5 years ago

Faeranne commented 5 years ago

Godot version: 3.1.1

OS/device including version: Ubuntu 19.10 Nvidia GTX 1080 Nvidia Driver: 430.34 Headset: HTC Vive SteamVR Version: 1.7.4

Issue description: Attempting to use arvr with a secondary viewport results in a blank screen on the headset

Steps to reproduce: Add godot-openvr addon Add camera to scene Add viewport to scene Add VR components (inc arvarcamera) to viewport Disable HDR on viewport, enable arvr Add following script to root of scene:

    var vr = ARVRServer.find_interface("OpenVR")
    if vr and vr.initialize():
        OS.vsync_enabled = false
        Engine.target_fps = 90

Start scene

Expected Result: Main window should render the fixed camera VR headset should render the ARVRcamerea

Actual Results: Main window renders fixed camera VR headset is blank

Minimal reproduction project: https://github.com/mrmakeit/VR-Viewport-Test

Additional Notes: The version of the openvr addon does not seem to matter. I have used both the latest and one downloaded for 3.0.6 with exactly the same results

Everything works as expected with 3.0.6.

I've opened an issue in godot-openvr as well, but since the bug shows up only in 3.1.1, regardless of addon version, I thought I'd open a issue here as well. Issue for godot-openvr: godotvr/godot_openvr#61

BastiaanOlij commented 5 years ago

The openvr plugin for 3.0 won't work with 3.1, you must use the one specifically build for 3.1, there will be a message in the console if the wrong plugin is used.

I'll have a closer look tonight since I use this setup in my main weapons tutorial without issue. That said, I do use a custom build that has a workaround for the HDR issue.

Faeranne commented 5 years ago

Interesting, I'm not actually seeing an error for using the 3.0 version in 3.1. Using it with the main viewport seems to work flawlessly. Could it be related?

BastiaanOlij commented 5 years ago

Hmm, that is strange, it should give the message and it shouldn't work at all when mismatched. Maybe they cherry picked the change into 3.0 at some point.

I would be using 3.1 for any VR related things anyway as there are various optimizations in there. My weekend went totally different than planned so I haven't had time to have a look yet, just catching up on emails atm.

Using a viewport and it not rendering usually is one of the following issues: 1) HDR not turned off on the viewport (but you mention you did this) 2) Update mode of the viewport not set to always (it defaults to visible which only works for viewport that are rendered to screen using a viewport container) 3) The viewport not set as a local resource.

Faeranne commented 5 years ago

For the test project linked, the update mode was not turned to always, however, changing that has had no effect. I've updated the project to reflect this. I'm not 100% sure how to confirm that the viewport is a local resource.

I do want to continue using 3.1, and have moved our current projects to the 3.1 branch, but this bug prevents any testing being done.

BastiaanOlij commented 5 years ago

@mrmakeit all right, many apologies for only having found the time to try out your example until tonight. The moment I opened it and looked at the setting it hit me. This is a damn stupid old problem that I've just learned to live with.

Godot tries to be smart around resource usage and will ignore a viewport with size 0,0. With OpenVR we get the viewport size from the headset but we won't actually run this code until the viewport gets processed, that however never happens. Your classic catch 22.

The workaround is dead simple, give the viewport a size, even just setting it to a default of 10x10 will do the trick.

Faeranne commented 5 years ago

Yep, that fixed it. Also, as a note to self, this bug did exist in 3.0, and I had already worked around it in the old project. I just forgot that we had a different bug with VR initialization not correctly running every launch.

Faeranne commented 5 years ago

I realized I closed this even though it is still an open bug. Should the title be adjusted, or a new issue reflecting the actual bug be opened?

KoBeWi commented 4 years ago

Can anyone still reproduce this bug in Godot 3.2.3 rc6 or any later release?

akien-mga commented 3 years ago

I haven't tested but given recent comments on https://github.com/GodotVR/godot_openvr/issues/85 this seems to still be a UX issue for VR.