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

Take FXAA samples from half-pixel coordinates to improve quality #66466

Merged
merged 1 commit into from
Sep 27, 2022

Conversation

clayjohn
Copy link
Member

Fixes: #64985

It looks like the code we use for FXAA is a simplified model based on: https://www.geeks3d.com/20110405/fxaa-fast-approximate-anti-aliasing-demo-glsl-opengl-test-radeon-geforce/3/

One optimization this code makes is to only sample the four corners instead of taking all 8 samples around the current pixel. To make that effective, we need to use linear sampling and offset the samples so they overlap all 8 pixel positions. This can be seen in the linked code, the sample positions are at half-pixel offsets. However, when we implemented the code we used full pixel offsets so we are only getting contributions from the four corner pixels which leads to a lot of missing data which create artifacts.

This change results in a smaller blur, so FXAA is less blurry, but also a reduction in artifacts so there are fewer random jaggies created by the FXAA. This results in both smoother edges and less blurring.

This change can be made in 3.x as well.

Before:

Screenshot from 2022-09-26 11-41-14
Screenshot from 2022-09-26 11-41-00

After:
Screenshot from 2022-09-26 11-41-22
Screenshot from 2022-09-26 11-40-55

@clayjohn clayjohn added this to the 4.0 milestone Sep 26, 2022
@clayjohn clayjohn requested a review from a team as a code owner September 26, 2022 18:54
@akien-mga akien-mga added the cherrypick:3.x Considered for cherry-picking into a future 3.x release label Sep 27, 2022
@akien-mga akien-mga merged commit b8870b9 into godotengine:master Sep 27, 2022
@akien-mga
Copy link
Member

Thanks!

@clayjohn clayjohn deleted the FXAA-fix branch November 15, 2022 18:33
@akien-mga
Copy link
Member

Cherry-picked for 3.6.

@akien-mga akien-mga removed the cherrypick:3.x Considered for cherry-picking into a future 3.x release label Nov 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FXAA exhibits artifacts not present in NVIDIA's reference implementation
3 participants