Skip to content

Object Picking not working on Firefox #53

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

Closed
wbpaley opened this issue Oct 28, 2018 · 6 comments
Closed

Object Picking not working on Firefox #53

wbpaley opened this issue Oct 28, 2018 · 6 comments
Assignees
Milestone

Comments

@wbpaley
Copy link

wbpaley commented Oct 28, 2018

At least on FF 62.0.3 (Objects do not change color when clicked.)
Updated to 63.0 (64-bit); same behavior.

Works fine on Chrome

@mosra mosra self-assigned this Oct 29, 2018
@mosra
Copy link
Owner

mosra commented Oct 29, 2018

Ahh, I see. An unfortunate limitation where Firefox doesn't allow a read format any other than GL_RGBA + GL_UNSIGNED_BYTE. I already worked around this for the Mouse Interaction example (that one behaves properly for you, right?), so I will just need to put the same workaround here.

Thanks a lot for the report! 👍

@wbpaley
Copy link
Author

wbpaley commented Oct 29, 2018 via email

@mosra mosra transferred this issue from mosra/magnum-website Feb 1, 2019
@mosra mosra added this to the 2019.0b milestone Feb 1, 2019
@mosra
Copy link
Owner

mosra commented Feb 1, 2019

Well, I thought the fix would be simple and so I delayed the fix until now. It turns out to be harder than I thought, hitting one weirdness after another. Investigation so far:

  • Applying the same hack as in Mouse Interaction (RGBA + UNSIGNED_BYTE) seemingly works, but the readback returns values from the color buffer, not from the object ID buffer, like if glReadBuffer() wouldn't work at all (the same works correctly in Chromium-based browsers).
  • The object ID buffer is R8UI, but Firefox complains when reading it as R8UI. IMPLEMENTATION_COLOR_READ_FORMAT + TYPE on Firefox returns RGBA_INTEGER + UNSIGNED_INT (reading from R8UI works correctly on Chromium-based browsers).
  • Reading as RGBA_INTEGER + UNSIGNED_INT always returns a value of 46460, no matter where I click; changing the object ID buffer format to RGBA32UI (to match) doesn't help (again, this all works correctly on Chromium-based browsers).

Because it's unlikely I will find a magic solution to this in time for this release, I'm postponing to later.

mosra referenced this issue in facebookresearch/habitat-sim Aug 6, 2019
@mosra
Copy link
Owner

mosra commented Aug 12, 2019

The PhongGLTest / FlatGLTest Magnum tests now integrate Object ID rendering as well and should be a much easier target to investigate Firefox issues.

@mosra
Copy link
Owner

mosra commented Jun 10, 2020

The example now uses a R32UI format for Object ID, so this could get revisited.

While investigating one vaguely related issue (trying to read depth for the mouse interaction example), I saw that the GLES3 specification (4.3.1, page 186) says that the only allowed glReadPixels format + type combinations are:

  • RGBA + UNSIGNED_BYTE for normalized colors
  • RGBA_INTEGER + INT for signed integer formats
  • and RGBA_INTEGER + UNSIGNED_INT for unsigned integer formats

Not sure how this interacts with the fact that the Object ID buffer is just a single channel (browsers usually complain that the read type has to match exactly).

@mosra
Copy link
Owner

mosra commented Oct 17, 2021

This is finally fixed as of 52a5fae. While working on an unrelated issue with GL::Mesh tests on Firefox I tried this example again and the above-mentioned issue is no longer present:

Reading as RGBA_INTEGER + UNSIGNED_INT always returns a value of 46460

And Firefox now also prints understandable warnings when using anything else than full RGBA and a 32-bit type for buffer reading. Not sure at which point during the last three years Firefox fixed this, but what matters is that it indeed got fixed! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

2 participants