Actor.set_point_sprite_shape

Actor.set_point_sprite_shape#

Actor.set_point_sprite_shape(
shape: PointSpriteShape | str,
) None[source]#

Set a custom point sprite shape via fragment shader.

Added in version 0.48.

Replaces the default square point rendering with a custom shape defined by a GLSL fragment shader. This uses the discard instruction to clip fragments outside the desired shape boundary.

The chosen shape is persisted on the actor and is only injected into the fragment shader while the actor’s style is 'points'. When the style is 'surface' or 'wireframe' the shader replacement is transparently removed, because the underlying GLSL relies on gl_PointCoord which is undefined for non-point primitives and would otherwise corrupt the rendering. Switching prop.style back to 'points' later will re-install the shader automatically.

Parameters:
shapePointSpriteShape | str

The sprite shape to use. Accepts a PointSpriteShape enum value or a string. Must be one of:

  • 'circle' - Circular disc

  • 'triangle' - Upward-pointing triangle

  • 'hexagon' - Regular hexagon

  • 'diamond' - Diamond (rotated square)

  • 'asterisk' - Five-pointed asterisk

  • 'star' - Five-pointed star

Raises:
ValueError

If shape is not one of the supported shapes.

Notes

Point sprite shapes only produce visible results when render_points_as_spheres=False and style='points'. When render_points_as_spheres=True, VTK uses a different rendering path that bypasses the fragment shader.

Examples

Render points as circles instead of squares.

>>> import numpy as np
>>> import pyvista as pv
>>> cloud = pv.PolyData(np.random.default_rng(0).random((100, 3)))
>>> pl = pv.Plotter()
>>> actor = pl.add_mesh(
...     cloud,
...     style='points',
...     render_points_as_spheres=False,
...     point_size=20,
... )
>>> actor.set_point_sprite_shape('circle')