f3d icon indicating copy to clipboard operation
f3d copied to clipboard

Add Temporal Anti-Aliasing

Open YuvaCpp opened this issue 5 months ago • 16 comments

Is your feature request related to a problem? Please describe. F3D supports two anti-aliasing method: FXAA and SSAA Both are quite useful for performance and quality, repectively. Supporting Temporal Anti-Aliasing would be great to combine performance and quality, at the cost of accumulating several frames over time to get the final image.

Describe the solution you'd like

  • Add a new render.effect.antialiasing.mode value taa
  • Add a new CLI value for --anti-aliasing-mode
  • Add testing and doc

Technical insights From reading on it, jittering would be added to the vertex shader and the jitter would be resolved in the fragment shader. Jittering would be added to vtkF3DPolyDataMapper, resolving to a class with an interface similar to vtkSSAAPass, called vtkF3DTAAResolvePass.

The implementation will be done in two phases:

  • [x] Implementation for static scenes only, the history buffer is cleared when camera moves
  • [ ] Implementation of a valocity buffer in order to reproject the history and get TAA for animated scenes

YuvaCpp avatar Jul 06 '25 21:07 YuvaCpp

Good article: https://sugulee.wordpress.com/2021/06/21/temporal-anti-aliasingtaa-tutorial/

I think we can focus on static scenes at the moment and clear the history buffer if the camera moves.
It will produce ghosting for animated scenes but it's ok for a first version, we'll introduce a velocity buffer later.

So, the jitter values can be hardcoded and sent to the GPU through a uniform vec2 value. You're right, I think we need a vtkF3DTAAResolvePass which will render the scene with its delegate, and use a full screen quad shader to resolve it into the final frame.
Note that you will need to set the uiOnly boolean in vtkF3DRenderPass::Render to false when TAA is enabled.

Meakk avatar Jul 07 '25 06:07 Meakk

https://github.com/f3d-app/f3d/issues/2237 looks like a duplicate?

AoGao-Kedoka avatar Jul 07 '25 15:07 AoGao-Kedoka

Good point. @Meakk wanna merge them ?

mwestphal avatar Jul 07 '25 15:07 mwestphal

Closing the previous one as this one has more info

Meakk avatar Jul 07 '25 16:07 Meakk

I would like to look into this.

AoGao-Kedoka avatar Jul 25 '25 23:07 AoGao-Kedoka

I would like to look into this.

Commonly TAA jitters the clip space by modifying camera projection matrices, which is the same compared to jitter the vertex, but in most case easier to implement (especially screen-space UIs are not effected). Please let me know which approach is easier to implement for existing codebase.

Of course!

mwestphal avatar Jul 26 '25 05:07 mwestphal

@AoGao-Kedoka any progress so far?

Meakk avatar Aug 14 '25 04:08 Meakk

@Meakk Hi, just started. Had https://github.com/f3d-app/f3d/pull/2352 previously and didn't managed to work on it parallel.

AoGao-Kedoka avatar Aug 14 '25 07:08 AoGao-Kedoka

Need help moving forward @AoGao-Kedoka ?

mwestphal avatar Sep 21 '25 06:09 mwestphal

Hi @mwestphal , I made some progress last time, but I’ve been really busy with other things recently. I’ve already planned to pick it up again next week.

AoGao-Kedoka avatar Sep 21 '25 07:09 AoGao-Kedoka

I think this issue can either be closed or be updated for velocity buffer? @Meakk

AoGao-Kedoka avatar Oct 18 '25 19:10 AoGao-Kedoka

I will update the issue to mention a velocity buffer must be implemented for animations.

Meakk avatar Oct 18 '25 20:10 Meakk

TAA implemented by @AoGao-Kedoka for static meshes here: https://github.com/f3d-app/f3d/pull/2501

Meakk avatar Oct 18 '25 20:10 Meakk

@AoGao-Kedoka Unassigning for now, do not hesitate to comment here if you start working on the velocity buffer :)

mwestphal avatar Nov 01 '25 09:11 mwestphal

@mwestphal I currently have quite limited availability, but I've slowly started looking into it. I guess you can assign me for now and if someone is interested and have more time, feel free to unassign me.

AoGao-Kedoka avatar Nov 22 '25 20:11 AoGao-Kedoka

Ok!

mwestphal avatar Nov 23 '25 07:11 mwestphal