-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Proper handling of offset and scale in metadata picking #12237
base: main
Are you sure you want to change the base?
Conversation
Thank you for the pull request, @javagl! ✅ We can confirm we have a CLA on file for you. |
It's never as easy as it looks...
This is not possible. At the point where the actual value is obtained (namely, inside the shader), it is not longer possible to know where any There might be solutions to that, but all approaches that I can think of right now are ... complicated, to say the least. We certainly don't want to replicate the whole logic of value transforms (and things like |
The solution to the previous point turned out to be not toooo complicated. When the picking starts, it will obtain the This object always offers the
I started adding the corresponding tests. In that process I stumbled over an issue where the shader compilation bails out for normalized I'd also like to do more tests with property attributes (because these are currently not covered at all). Since the picking only relies on the metadata, and this does not even "know where it comes from" (attribute or texture), this might just work transparently. But now there is some code that explicitly has to handle both textures and attributes, so that should be covered by specs as well. |
So, I did try out some of this with property attributes. Or rather tried to try it. There are more issues with that, and see the handling of property attributes for metadata picking as a part of #12225 , likely to be spun out into a dedicated issue. (Handling of arbitrary types being moved through the frame buffer does raise quite a few questions). So I'll consider this as ready for review, given that it contains several spec test cases, and I tried it out with the data from #12232 (where this originally came up), and there, the current state seems to work as expected. I did have to re-run some CI steps a few times. We do have some flaky tests there... |
A small update: As mentioned above, pricking arbitrary property attributes is not supported until now. It is not entirely clear what the expected behavior should be when someone tries to pick property attributes. But in the previous state, it could happen that this caused an error to be thrown (specifically, when the property attribute type was one of the types that could not trivially be transported through the picking frame buffer, like a The last commit handles this: The function that determines the "picked metadata property" now only looks for property texture properties (and no longer for property attribute properties), and bails out early if no property texture property is found. A |
Description
Addresses #12236
The metadata picking did not take into account the
offset/scale
that may be defined in a class property or property texture property.The solution is to ensure that the
offset/scale
(and normalization) are properly handled when converting the metadata values into values that are supposed to be written into the metadata picking frame buffer. For example, a normalizedUINT8
property withoffset=1.0
andscale=2.0
will be converted into1.0 + 2.0 * ~0.5 = 2.0
by the standard metadata handling, But before writing this into the frame buffer, it has to be converted back into the [0, 1] range (reflecting the [0,255] range that can be stored in the frame buffer).After reading the value from the frame buffer, it has to be converted back into the proper metadata value. These operations strongly resemble the
MetadataComponentType.apply/unapplyValueTransform
, but have additional caveatsoffset/scale
that is defined by a 'class property' may actually be overridden by the 'property texture property'The last point may make it necessary to store the "effective"
offset/scale
inside thePickedMetadataInfo
. Right now, it only stores theMetadataClassProperty
. But when theoffset/scale
have been defined in thePropertyTextureProperty
or aPropertyAttributeProperty
(!), then theseoffset/scale
values have to be used for the conversions.Issue number and link
#12236
Testing plan
Details TBD - started creating specs
Author checklist
CONTRIBUTORS.md
CHANGES.md
with a short summary of my change