-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
[Merged by Bors] - Add FXAA postprocessing #6393
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work!
I think the blit / intermediate tonemapping stuff can / should be removed in favor of running this after tonemapping (and thus, after effects like bloom). This cuts down on the complexity / work being done. This is how Unity and Wicked Engine do it, and is also how I generally see FXAA being used in the wild (it is often applied in userspace after all engine rendering has finished).
I think we can also simplify the FXAA pipeline generation stuff using specialization.
This should also be ported to #6415, which I made in direct response to this PR's intermediate texture creation. See the description for details.
I've addressed all of these things on my local branch. I'll push the changes after #6415 is merged.
let source = post_process.source; | ||
let destination = post_process.destination; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason for this or is it just to have shorter variable names?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I understand, yes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup just that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of general questions and I'm not familiar with the math, so I can't comment on that part but overall this looks great.
Something a bit odd: the difference between HDR vs LDR is now greater than it was before, with the old to_ldr & blit passes (97251f4). When set to ultra, may of the colored squares now still show aliasing only when using HDR. (View at original size or larger to see aliasing) Before without hdr (97251f4) Before with hdr (97251f4) After without hdr (2bd5fd8) After with hdr (2bd5fd8) |
Hmm nice catch. I can repro on my machine. The old non-hdr pipeline looks like this:
FXAA's inputs are "reinhard tonemapped Rgba8UnormSrgb" The old hdr pipeline looked like this:
FXAA's inputs are "reversible-tonemapped Rgba16Float" The new hdr pipeline looks like this:
FXAA's inputs are "reinhard tonemapped Rgba16Float" Worth poking around a bit. |
Lowering EDGE_THRESH_ULTRA to 0.043 does bring "new hdr" more in-line with the old results. But it does feel like we should be able to use the same threshold values between hdr and ldr pipelines, given that they should be the "same reinhard-mapped ldr colorspace" at this point in the pipeline. |
Notably, the "new hdr" image does have lower lumaRange values in the cube areas that have more aliasing, so that makes sense. |
Ok after much investigation, we've come to the following conclusions:
|
There was also a bug in how we applied tonemapping in the main pass (we skipped it in some cases). I have fixed it in the commit above. |
bors r+ |
# Objective - Add post processing passes for FXAA (Fast Approximate Anti-Aliasing) - Add example comparing MSAA and FXAA ## Solution When the FXAA plugin is added, passes for FXAA are inserted between the main pass and the tonemapping pass. Supports using either HDR or LDR output from the main pass. --- ## Changelog - Add a new FXAANode that runs after the main pass when the FXAA plugin is added. Co-authored-by: Carter Anderson <[email protected]>
# Objective - Add post processing passes for FXAA (Fast Approximate Anti-Aliasing) - Add example comparing MSAA and FXAA ## Solution When the FXAA plugin is added, passes for FXAA are inserted between the main pass and the tonemapping pass. Supports using either HDR or LDR output from the main pass. --- ## Changelog - Add a new FXAANode that runs after the main pass when the FXAA plugin is added. Co-authored-by: Carter Anderson <[email protected]>
Objective
Solution
When the FXAA plugin is added, passes for FXAA are inserted between the main pass and the tonemapping pass. Supports using either HDR or LDR output from the main pass.
Changelog