Zooming in on the surface results in stripes

Zooming in on the surface results in stripes, see the picture, how to solve it

Hello,

Please, post the code showing the entire VTK pipeline.

regards,

PC

zoom in any shading surface, SetParallelProjection(1), it will show the stripes

That doesn’t happen to me. That’s why the code was asked. Lots of artifacts can happen due to misconfigured objects along the pipeline.

If you’re just visualizing a surface mesh, is it possible for you to share the data? Sometimes, the points or cell connectivity could be weird.

#include <vtkSmartPointer.h>
#include <vtkPolygon.h>
#include <vtkTriangle.h>
#include <vtkCellArray.h>
#include <vtkPolyData.h>
#include <vtkPolyDataMapper.h>
#include <vtkActor.h>
#include <vtkRenderWindow.h>
#include <vtkRenderer.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkProperty.h>
#include <vtkTextActor.h>
#include <vtkCamera.h>
#include <vtkInteractorStyleTrackballCamera.h>

#include

int main(int argc, char *argv)
{
vtkSmartPointer points = vtkSmartPointer::New();
points->InsertNextPoint(0.0, 0.0, 0.0);
points->InsertNextPoint(1.0, 0.0, 0.0);
points->InsertNextPoint(1.0, 1.0, 0.0);
points->InsertNextPoint(0.0, 1.0, 0.0);
points->InsertNextPoint(2.0, 0.0, 0.0);

vtkSmartPointer<vtkPolygon> polygon = vtkSmartPointer<vtkPolygon>::New();
polygon->GetPointIds()->SetNumberOfIds(4);
polygon->GetPointIds()->SetId(0, 0);
polygon->GetPointIds()->SetId(1, 1);
polygon->GetPointIds()->SetId(2, 2);
polygon->GetPointIds()->SetId(3, 3);

vtkSmartPointer<vtkTriangle> trianle = vtkSmartPointer<vtkTriangle>::New();
trianle->GetPointIds()->SetId(0, 1);
trianle->GetPointIds()->SetId(1, 2);
trianle->GetPointIds()->SetId(2, 4);

vtkSmartPointer<vtkCellArray> cells = vtkSmartPointer<vtkCellArray>::New();
cells->InsertNextCell(polygon);
cells->InsertNextCell(trianle);

vtkSmartPointer<vtkPolyData> polygonPolyData = vtkSmartPointer<vtkPolyData>::New();
polygonPolyData->SetPoints(points);
polygonPolyData->SetPolys(cells);

vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInputData(polygonPolyData);

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

vtkSmartPointer<vtkRenderer> renderer = vtkSmartPointer<vtkRenderer>::New();
renderer->AddActor(actor);
renderer->SetBackground(0.2, 0.8, 0.5);
renderer->GetActiveCamera()->SetParallelProjection(1);

vtkSmartPointer<vtkRenderWindow> renderWindow = vtkSmartPointer<vtkRenderWindow>::New();
renderWindow->AddRenderer(renderer);
renderWindow->SetSize(640, 480);
renderWindow->Render();
renderWindow->SetWindowName("PolyDataNew");


vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor = vtkSmartPointer<vtkRenderWindowInteractor>::New();
renderWindowInteractor->SetRenderWindow(renderWindow);

vtkSmartPointer<vtkInteractorStyleTrackballCamera> style = vtkSmartPointer<vtkInteractorStyleTrackballCamera>::New();
renderWindowInteractor->SetInteractorStyle(style);

renderWindow->Render();
renderWindowInteractor->Start();

return EXIT_SUCCESS;

}

zoom in,zoom in…, the stripes will be appear.

@Paulo_Carvalho @jaswantp

It looks like you are running into this issue: https://gitlab.kitware.com/vtk/vtk/-/issues/18423

If you provide or generate normals for your surface, then you shouldn’t see this artifact of unstable fragment derivatives.

1 Like

It is important to compute point normals, not just cell normals.
Without the point normals the behavior is bad and the renderer may crash on some systems.
I provided an example here

This lets you compare SetComputePointNormals(true) and SetComputePointNormals(false).
-Matthias