-
-
Notifications
You must be signed in to change notification settings - Fork 112
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
Improved picking #494
Improved picking #494
Conversation
if depth < 1.0 { | ||
Some(position + direction * depth * max_depth) | ||
Some(IntersectionResult { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The IDs here are limited by the maximum safe integer a f32 can hold (approximately 24 bits). However, use cases where the IDs ever get that high are probably extremely rare, so it probably isn't worth the additional complexity that fixing that issue would incur (what's currently done in #479). Maybe this limitation should be added to the documentation somewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I was thinking 24 bit integer would be enough (16,777,215 instances is probably rare 🙂), but if we also have to output primitive ids, it's probably better to support the whole u32/i32 range. I fixed that in 439261b
pub geometry_id: u32, | ||
/// The index of the intersected instance in the list of instances or 0 if the intersection did not hit an instanced geometry | ||
pub instance_id: u32, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recently noticed other 3D rendering libraries that provide this functionality also include the face index in their return result, which would take up the last alpha color slot. I believe this can be obtained from gl_PrimitiveID
in the IntersectionMaterial
fragment shader. This isn't needed for my use case, but could be beneficial in this hypothetical use case: a button panel, where all the buttons are part of the same model; it is known which triangles make up the buttons, so the face index is used to identify which button was clicked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good point! No reason not to add that to the intersection result as well. Fixed in e390c6a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turns out gl_PrimitiveID
is not supported on web, so I'm removing it again.
Alternative to #478 and #479. Closes #467