-
Notifications
You must be signed in to change notification settings - Fork 148
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
Feature request: more control about the pixel alignment (?) of draw_image()
#719
Comments
cc @dfrg. The relevant code is here: vello/vello_shaders/shader/fine.wgsl Lines 1165 to 1177 in f7e3cee
Your provided image suggests that the calculations are incorrect; the alpha bleed on the bottom right is really concerning. One thing to try would be subtracting I'm not sure what the expected behaviour for pixel position is. |
Thanks for investigating!
I too am not sure. I guess this matters less when the number of pixels is large, so this might not be very important. |
Thanks for this test case that perfectly identifies deficiencies in the current code. Both clamping the extents and sampling at pixel center seem reasonable to me. I’m not sure when I’ll have time to work on this but I’ve added it to my list. |
Needed a bit of a break from other things so I took a swing at this. Please test out #722 and see if this provides the expected rendering. |
Wow, thanks for the fix! I confirmed it gives the expected result perfectly (yutannihilation/vellogd-r#18). |
#722) Constrains image sampling to the actual atlas region for a given image and adds a half pixel adjustment to sample from the pixel center. Addresses #719 and maybe #656 Example 2x2 image with red, blue, cyan and magenta pixels: <img width="387" alt="vello_image_sampling" src="https://github.com/user-attachments/assets/6bc02607-e9fa-4c79-83c9-241e76a42fb0"> --------- Co-authored-by: Daniel McNab <[email protected]>
Thanks for fixing! |
(I'm not very familiar with graphics things, so excuse me if I'm missing some point)
Currently, drawing these 4 pixels by
draw_image()
gives the following result.I'm not familiar with graphics things, so I'm not sure what's the correct behavior, but, in my usage, I prefer
(cf. yutannihilation/vellogd-r#14 (comment) is the expected result)
Regarding the first request, I think this is what I should handle by adding extra pixels at the left edge and at the bottom edge and then cut.
For the second one, does it make sense to introduce some option to
Scene::draw_image()
? Probably, addingkurbo::Affine::translate((0.5, 0.5))
tobrush_transform
ofScene::fill()
.The text was updated successfully, but these errors were encountered: