Skip to content
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

Question: Are texture samples specified to be taken at a corner or center? #426

Open
trbabb opened this issue Sep 19, 2024 · 1 comment
Open

Comments

@trbabb
Copy link

trbabb commented Sep 19, 2024

When calling, e.g., textureSampleGrad(tex, sampler, st, dst_dx, dst_dy), is the effective sampled area of the texture a patch with "origin" at st, e.g. st + J * xy, with xy in [0,1]^2 and J the Jacobian to sample? Or is st the center of the sampled patch, with st in [-0.5, 0.5]`? Or something else?

What does the spec say? I couldn't find anything explicit, but I might not be searching for the right keywords.

@almarklein
Copy link
Collaborator

Maybe this helps: https://docs.pygfx.org/stable/_gallery/validation/validate_image1.html (the texture coords of a plane geometry are [0..1]).

When you sample from a texture, the st represents the "center" of the sample. E.g. with linear interpolation you'd get the exact pixel value when st is exactly on top of a pixel, but if it's in between two pixels, you get the mean.

Does this make sense? Or are you asking for a specific detail for the Grad-variant of texture sampling? I'm not 100% sure I understand the question.

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

No branches or pull requests

2 participants