-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert final HDR output to RGBA8 #19724
Conversation
Wow, just tested it out after coming home. Works like a charm! Finally OpenVR works as it should with this option turned on :) |
Can you clarify, 16 bits per pixel or per channel? 16 bits per pixel is a very low color depth. |
@aaronfranke , Godots HDR rendering is done at 16bits per color channel, so 64bits per pixel, my bad for writing that down wrong :) OpenVR requires an 8bits per color channel, so 32bits per pixel buffer. I don't know why this restriction is there as normally OpenGL would handle this side of things so I'm guessing they did some sort of optimization in their lens shaders that don't play nice with the higher precision color buffers. As at the stage of output the precision is no longer as important doing a conversion right at the end as we're applying tone mapping anyway seems like a good way of doing things. |
Latest check-in is a small fix that prevented the preview output to screen when the main viewport was used. |
I was able to test it and it didn't break anything. The fix stopped the colour banding issues in my Sponza test map. |
@akien-mga this should probably be discussed soon in a PR meeting to make a final decision on it so it can either be cancelled or merged instead of lingering around. Last time I talked to @reduz about this his main concern, and I agree to a degree, is that this is a solution for one very specific use case that does not add anything for anyone else and in a way it's thus engine bloat. The flip side of this argument is that there are only two alternatives:
|
From today's meeting:
|
Thanks @vnen for the update :) |
Just rebased this. |
Based on the lack of answer on ValveSoftware/openvr#438, but also the fact that Valve devs hardly ever comment on any openvr issue nor ever merged any PR, I guess we can give up on getting any change made to OpenVR itself. So we'll have to hack it around ourselves if we want to support their tech... |
5e96719
to
3a3330c
Compare
@akien-mga I've rebased this in case we do decide to merge it. |
3a3330c
to
9951aef
Compare
Just another rebase, was testing out something :) |
Discussed again with @reduz, and he's still not really in favour of merging this.
So I'll keep this PR open for VR people to cherry-pick themselves if needed, but just stating in clear that it likely won't be merged. |
@akien-mga , @reduz is right, it can be done on the driver side and has been done: I'm not keen on merging that either because: |
Just read the openHMD driver also suffers this issue: Could really use some help in properly implementing doing any further GL stuff on the GDNative side that doesn't involve crashing when multitasking is turned on. Could be as simple as a strategically placed mutex or doing more initialisation in the plugin |
If this code goes away in 3.1, and it's optional I think that's a good reason for adding it to 3.1 so OpenHMD and OpenVR developers can at least get going. I've marked this for 3.1 for that reason. I don't want to make that decision by myself though so @akien-mga? :) |
Note that @BastiaanOlij has implemented a workaround so it's strictly not necessary. There may be performance gains, but not required to get the feature working. GodotVR/godot_openvr#30 |
@hpvb the issue with OpenHMD is around the multitasking issue. It's caused by Godot initializing all OpenGL related stuff as part of the render thread but the plugins creating a few shaders and such in the main thread. OpenGL does not like that very much. I've solved that one now for both OpenVR and Oculus in a pretty ugly way by postponing the initialisation in the plugin until the first frame is rendered, still need to figure out a similar solution for OpenHMD. So that part of it all will go away. This RGBA16F buffer not being supported by OpenVR however remains a crappy thing. Like @fire mentioned, I have a 'fix' but its far more wasteful then what we're doing in this PR. |
What is the chance of OpenVR adding support for RGBA16F? Wouldn't that be better? |
@aaronfranke yes it would be, I wager there is about a 1% chance of them doing so. There has been no response whatsoever on the issue that was raised. |
I'm closing this PR. Just pretty much finished #27527 which covers a broad spectrum of requirements for VR SDKs and having the SDK supply the texture into which we render. This should allow us to solve the HDR issue has well. |
Note I haven't tested this in VR yet to see if it indeed has the desired effect. Hope to do this tonight.
This PR adds a new setting to the viewport that if enabled adds an extra RGBA8 buffer to our viewport which will hold the final result of our rendering. We need this mainly because OpenVR does not accept 16 bits per pixel framebuffers when rendering in VR. There may however be other uses for this.
As 3D rendering still happens in HDR buffers and it is only the final tonemapping stage that now outputs into the 8bits per pixel buffer there is no performance penalty in this approach, only a memory penalty.
2D rendering will happen directly into the RGBA8 buffer when this is enabled in most scenarios.
The setting is ignored if 3D is turned off on the viewport or if HDR is turned off on the viewport.
This should solve the banding issues we've experienced on OpenVR when turning off HDR.