I want to use the vtkUnstructuredGrid to show some FEA models,but I meet with some problems.
- if I turn on the UseFAxxOn(),the grid may look like this picture.
- 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
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](https://discourse.vtk.org/uploads/default/original/2X/0/05a40c6e5fe769f0f5f1b6fe19aaf2403c34e1af.png)
It still have another problem ,if the grid is too dense,the line look discontinuous.
![image](https://discourse.vtk.org/uploads/default/original/2X/2/25170c0518ab47d5167269a4849e9ac60d041385.png)
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.
I try this,but not improve