# SSAA and FXAA not working

**URL:** <https://discourse.vtk.org/t/ssaa-and-fxaa-not-working/411>\
**Category:** Development\
**Created:** [March 5, 2019, 9:01pm UTC](https://discourse.vtk.org/t/ssaa-and-fxaa-not-working/411 "2019-03-05T21:01:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![chuan](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/c/4da419/32.png) [@chuan](https://discourse.vtk.org/u/chuan)\
**Post date:** [March 5, 2019, 9:01pm UTC](https://discourse.vtk.org/t/ssaa-and-fxaa-not-working/411/1 "2019-03-05T21:01:45Z")

</div>

Hi experts,

I’m using vtk 8.1 and am having a little bit of a trouble getting  
anti-aliasing working.

When using the FXAA approach, the graphic remains the same regardless of the  
FXAA options I pass to the renderer.

vtkSmartPointer renderer =  
vtkSmartPointer::New();  
renderer-\>SetUseFXAA ( true );  
auto options = renderer-\>GetFXAAOptions();  
options-\>SetSubpixelBlendLimit ( 0.75 );  
options-\>SetHardContrastThreshold ( 0.045 );  
options-\>SetRelativeContrastThreshold ( 0.125 );  
options-\>SetEndpointSearchIterations ( 12 );  
options-\>SetSubpixelContrastThreshold ( 0.25 );  
options-\>SetUseHighQualityEndpoints ( true );

![fxaa](https://discourse.vtk.org/uploads/default/original/1X/79effe4ea80bbd9c18d7fa2a8a4d22ca056d525b.png)

When using the SSAA render pass approach I have depth buffer issue where the  
surfaces of a primitive cube get rendered in an incorrect order. I came  
across this depth peeling fix but it didn’t work for me unfortunately.

[http://vtk.1045678.n5.nabble.com/vtk-developers-QVTKOpenGLWidget-SSAA-pass-breaks-depth-peeling-td5746428.html](http://vtk.1045678.n5.nabble.com/vtk-developers-QVTKOpenGLWidget-SSAA-pass-breaks-depth-peeling-td5746428.html)

vtkSmartPointer renderer = vtkSmartPointer::New();  
renderer-\>SetBackground ( 0.615f, 0.639f, 0.666f );

vtkNew basicPasses;  
vtkNew ssaa;

vtkSmartPointer depthPeel = vtkSmartPointer ::New();  
vtkSmartPointer translucent = vtkSmartPointer ::New();  
depthPeel-\>SetMaximumNumberOfPeels ( 0 );  
depthPeel-\>SetTranslucentPass ( translucent );  
basicPasses-\>SetTranslucentPass ( depthPeel );

ssaa-\>SetDelegatePass ( basicPasses );  
renderer-\>SetPass ( ssaa );  
renderer-\>SetUseDepthPeeling ( true );  
renderer-\>SetMaximumNumberOfPeels ( 0 );

![ssaa](https://discourse.vtk.org/uploads/default/original/1X/0e4a7c6d659d0457ec3fb092431bf0c43d1f4027.png)

I’m not sure what I’m missing and I would greatly appreciate if anyone can  
help me spot it.

Thanks,  
Chuan

---

<div class="post-metadata">

**Author:** ![chuan](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/c/4da419/32.png) [@chuan](https://discourse.vtk.org/u/chuan)\
**Post date:** [March 8, 2019, 7:30pm UTC](https://discourse.vtk.org/t/ssaa-and-fxaa-not-working/411/2 "2019-03-08T19:30:12Z")

</div>

I ended up using MSAA if anyone is interested.

[http://vtk.1045678.n5.nabble.com/SSAA-and-FXAA-td5750070.html#a5750085](http://vtk.1045678.n5.nabble.com/SSAA-and-FXAA-td5750070.html#a5750085)

---

<div class="post-metadata">

**Author:** ![langer](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/l/3e96dc/32.png) [@langer](https://discourse.vtk.org/u/langer)\
**Post date:** [March 11, 2019, 5:23pm UTC](https://discourse.vtk.org/t/ssaa-and-fxaa-not-working/411/3 "2019-03-11T17:23:38Z")

</div>

Try uncommenting lines 158 and 159 of Rendering/OpenGL2/vtkSSAAPass.cxx in 8.1, or using 8.2.0.

– Steve

---

<div class="post-metadata">

**Author:** ![chuan](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/c/4da419/32.png) [@chuan](https://discourse.vtk.org/u/chuan)\
**Post date:** [March 11, 2019, 9:02pm UTC](https://discourse.vtk.org/t/ssaa-and-fxaa-not-working/411/4 "2019-03-11T21:02:31Z")

</div>

Hi Steve,

That fixed the depth buffer issue. However there were other rendering artifacts with render window’s polygon smoothing enabled. (visible gray lines over polygon surfaces).

Thanks,  
Chuan

---

<div class="post-metadata">

**Author:** ![Thomas\_Gerster](https://discourse.vtk.org/user_avatar/discourse.vtk.org/thomas_gerster/32/3447_2.png) [@Thomas\_Gerster](https://discourse.vtk.org/u/Thomas_Gerster)\
**Post date:** [May 24, 2021, 12:14pm UTC](https://discourse.vtk.org/t/ssaa-and-fxaa-not-working/411/5 "2021-05-24T12:14:23Z")

</div>

@chuan  
Hi chuan, I was wondering if you can send me the code for the grid and the axes on the picture above ?

kind regards
