Different shaped vertex points

Hi there,

I am working with a collection of point data, with vertices mapped accordingly. I currently have a set of points rendered with the square shaped points in the 3D space.

I am wondering what is the simplest way to render different shapes for different categories of points.

I’d like to have square, triangular and circular shaped points.

Is this possible?

The idea would be to modify the vtkGlyph3DMapper to support a “Source” id like in C++.

If you do not want to modify the code, you could actually create 3 Glyph3DMapper (one for square glyph, one for triangle glyph and one for circle glyph), and make them use 3 different scalar arrays that “scale” the glyphs to 0 when it is not of the correct type.

Alternatively, you could also split your pointset into 3 pointsets. and render each with a different glyph3dmapper.

I have done this with a custom shader.
// This makes the 2D dot circular rather than square.
// From a Kitware developer (https://gitlab.kitware.com/vtk/vtk/-/issues/17000)
// “gl point smooth is not uniformly supported by modern open gl implementations. With VTK’s openGL2 you can use this code to produce the round pixel effect.”
// The comments are from the original author.
vtkShader::Fragment, // in the fragment shader
“//VTK::Color::Impl”, // replace the color block
true, // before the standard replacements
“//VTK::Color::Impl\n” // we still want the default calc
" float dist = length(vec2(gl_PointCoord.x - 0.5, gl_PointCoord.y - 0.5));\nif (dist > 0.5) { discard; }\n", //but we add this
false // only do it once

It is necessary to have the following line at start up: