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

Verify sampling of framebuffers in post-processing stages #12208

Open
jjhembd opened this issue Sep 20, 2024 · 0 comments
Open

Verify sampling of framebuffers in post-processing stages #12208

jjhembd opened this issue Sep 20, 2024 · 0 comments

Comments

@jjhembd
Copy link
Contributor

jjhembd commented Sep 20, 2024

Many of our post-processing stages are sampling the rendered framebuffers with a texture coordinate which is off by half a pixel.

Our current post-processing shaders sample the rendered depth and color framebuffers via the v_textureCoordinates varying. This varying takes values in [0, 1] across the full-screen quad.

At each fragment, the value of v_textureCoordinates equal the coordinate of the pixel's boundary, rather than its center. This leads to the following errors:

  • Depth values do not correspond to the computed X and Y coordinates. The depth buffer (in WebGL2) only supports nearest sampling, meaning that the value sampled from the texture is the depth at the pixel center, whereas X and Y are at the pixel boundary.
  • Interpolation errors in v_textureCoordinates may lead to unpredictability: the pixel just across the boundary may be selected instead of the expected one.

A better option may be to use gl_FragCoord.xy rather than a varying. gl_FragCoord consistently describes the position of the center of the current fragment. See #12201 for an example of this approach, as well as the impact on the post-processing result.

Some things we need to verify:

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

No branches or pull requests

2 participants