-
Notifications
You must be signed in to change notification settings - Fork 618
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
Add sampling using [0,1] for GenericImageView
#1929
Conversation
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.
Looking at these changes, I think adding bilinear sampling to this crate is valuable but I worry that a generic sample method is going to add too much complexity. There's just so many different ways to sample an image with a (f32, f32)
. For instance, there's the question of whether (0,0) is the center of the top left pixel (like in this PR) or the corner of that pixel (like the usual convention in OpenGL/Vulkan/etc.) and that's on top of questions about wrapping mode and filtering method. And no single option is "right"
What would you think of adding just a bilinear_sample
method that always clamped to edge and used the same coordinates as get_pixel
(ie from 0
to size-1
with integer values being pixel centers). It shouldn't be too hard for users to implement wrapping or normalized coordinates based on that if they want
I think that's definitely a step forward. I think that clamping against the edge quietly is probably going to lead to unexpected behavior for users. Instead, we should probably return an |
Just wanted to bump this, while I am pushing back on some ideas you suggested, if you feel strongly about them I will change it. I would rather have sampling in some form than no sampling. |
Let's go with one method per supported sampling type. If users want to dynamically pick between sampling types, they can implement it themselves, but this way there's no extra branching if the sampling type is known in advance. Thinking about it, the methods probably belong in the |
Sounds good, it may take me a bit to implement but I'll add them in. |
d17d8fc
to
2945419
Compare
b4a651e
to
08afcc6
Compare
a3e8dc2
to
575819e
Compare
Cheers, was out of town but have fixed most of the comments |
843777d
to
2f4eb9e
Compare
Adds a way to sample images in [0,1], which is a common use case in graphics. Currently adds non-exhaustive enums based on OpenGL's that allow for simple sampling of nearby coordinates. Nearest sampling can produce artifacts depending on the sampling resolution of the UV whereas bilinear will smoothly interpolate.
2f4eb9e
to
9f27cbe
Compare
@fintelia You're gonna have to merge it, I don't have the ability to do so |
WIP
Not sure whether this should directly go on
GenericImageView
, and where the enums should go.Also need to add tests but put the general idea up for review.
Adds a way to sample images in [0,1], which is a common use case in graphics.
Currently adds non-exhaustive enums based on OpenGL's that allow for simple sampling of nearby coordinates.
Nearest sampling can produce artifacts depending on the sampling resolution of the UV whereas bilinear will smoothly interpolate.
Addresses #1905