-
Notifications
You must be signed in to change notification settings - Fork 105
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
Comments
Maybe this helps: https://docs.pygfx.org/stable/_gallery/validation/validate_image1.html (the texture coords of a plane geometry are When you sample from a texture, the Does this make sense? Or are you asking for a specific detail for the |
It's A but y flipped. See the version at the bottom of the readme here https://github.com/gfx-rs/wgpu?tab=readme-ov-file#coordinate-systems |
@Vipitis I'm worried you might be answering a question I'm not asking, since in this diagram the blue and yellow vectors are user specified and can point in any direction. Just to restate here, I am not asking about the coordinate system of the entire texture (that's easy enough to find), I'm asking about the coordinate system and origin of a differential patch of texture when taking a single texture sample using So to double check, is that what you are answering? |
I think the answer you're looking for is C, though I may be misunderstanding your notation. The sample "box" is centered at st, and has the size of the dpdx and dpdy vectors. How this translates to exact samples can get a little mind bendy and in the case of antisotropic filtering is actually implementation defined |
Is the center + size behavior guaranteed by the spec, or part of the "implementation defined" behavior? |
I don't fully understand the question. I guess this is also because I've never used Perhaps you can code an example that will actually show what happens. You can then also try it on different hardware to see if its consistent. |
ah, now I get the question. I recently saw this video which makes use of this sampling method. So it seems answer C is correct, it's normalized to [-1..1] |
Wow, that video explains a lot. It's also really well done 🤩 Thanks for sharing! |
When calling, e.g.,
textureSampleGrad(tex, sampler, st, dst_dx, dst_dy)
, is the effective sampled area of the texture a patch with "origin" atst
, e.g.st + J * xy
, withxy
in[0,1]^2
and J the Jacobian to sample? Or isst
the center of the sampled patch, withst
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.
The text was updated successfully, but these errors were encountered: