How to show the vtkUnstructuredGrid grid?

I want to use the vtkUnstructuredGrid to show some FEA models,but I meet with some problems.

  1. if I turn on the UseFAxxOn(),the grid may look like this picture.
  2. when I set FAXXOff ,the grid may like this picture. if I dont rotate the model, the grid may show normaly,but if I rotate the model, the grid line look like this picture
    image

here is the core code:

void show(vtkSmartPointer source){

                //source is the grid data
                vtkSmartPointer<vtkMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();

                vtkSmartPointer<vtkDataSetSurfaceFilter> surfaceFilter = vtkSmartPointer<vtkDataSetSurfaceFilter>::New();
                surfaceFilter->SetInputData(source);
                surfaceFilter->Update();

                mapper->SetInputConnection(surfaceFilter->GetOutputPort());
                mapper->SetResolveCoincidentTopologyToPolygonOffset();
                mapper->Update();

                auto   actor = vtkSmartPointer<vtkActor>::New();
                actor->SetMapper(mapper);

                renderer->SetUseDepthPeeling(true);
                renderer->SetMaximumNumberOfPeels(500);
                renderer->SetOcclusionRatio(0.1);
                renderer->UseFXAAOff();
                //renderer->UseFXAAOn();
                renderer->AddActor(actor);

                renderWindow = renderer->GetRenderWindow();


                renderer->Render();
              
              }

Hello,

I suggest you to tune the FXAA options:

#include <vtkFXAAOptions.h>

        (...)
        _renderer->UseFXAAOn();

        // configure the FXAA antialiasing
        vtkSmartPointer<vtkFXAAOptions> fxaaOptions = _renderer->GetFXAAOptions();
        fxaaOptions->SetSubpixelBlendLimit( 1/2.0 );
        //fxaaOptions->SetSubpixelContrastThreshold(1/2.0);
        //fxaaOptions->SetRelativeContrastThreshold(0.125);
        //fxaaOptions->SetHardContrastThreshold(0.045);
        //fxaaOptions->SetSubpixelBlendLimit(0.75);
        //fxaaOptions->SetSubpixelContrastThreshold(0.25);
        //fxaaOptions->SetUseHighQualityEndpoints(true);
        //fxaaOptions->SetEndpointSearchIterations(12);

take care,

PC

You can also try the slower MSAA that results in better rendering according to some users.

If you’re using Qt:


    // MSAA aliasing (these must be called BEFORE creating a QVTKOpenGLWidget).
    vtkOpenGLRenderWindow::SetGlobalMaximumNumberOfMultiSamples ( 8 );
    QSurfaceFormat::setDefaultFormat ( QVTKOpenGLNativeWidget::defaultFormat() );

    (...)

    //_vtkwidet points to a QVTKOpenGLNativeWidget
    _vtkwidget->renderWindow()->SetMultiSamples( 4 );

thanks for your replay,I try to add this code before creating a QVTKOpenGLWidget;
I use this in Qt5 and the version of vtk is vtk9.2

// MSAA aliasing (these must be called BEFORE creating a QVTKOpenGLWidget).
    vtkOpenGLRenderWindow::SetGlobalMaximumNumberOfMultiSamples ( 8 );
    QSurfaceFormat::setDefaultFormat ( QVTKOpenGLNativeWidget::defaultFormat() );

when use the UseFXAAOn(),the intersection point of grid lines may have shadow,like in the picture.

  _renderer->UseFXAAOn();

        // configure the FXAA antialiasing
        vtkSmartPointer<vtkFXAAOptions> fxaaOptions = _renderer->GetFXAAOptions();
        fxaaOptions->SetSubpixelBlendLimit( 1/2.0 );
        //fxaaOptions->SetSubpixelContrastThreshold(1/2.0);
        //fxaaOptions->SetRelativeContrastThreshold(0.125);
        //fxaaOptions->SetHardContrastThreshold(0.045);
        //fxaaOptions->SetSubpixelBlendLimit(0.75);
        //fxaaOptions->SetSubpixelContrastThreshold(0.25);
        //fxaaOptions->SetUseHighQualityEndpoints(true);
        //fxaaOptions->SetEndpointSearchIterations(12);

image
It still have another problem ,if the grid is too dense,the line look discontinuous.
image

Have you tried the other FXAA settings?

Pelase, don’t enable FXAA and MSAA at the same time. If you choose MSAA, disable everything related to FXAA.