Actor.set_point_sprite_shape#
- Actor.set_point_sprite_shape(
- shape: PointSpriteShape | str,
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
discardinstruction 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
styleis'points'. When the style is'surface'or'wireframe'the shader replacement is transparently removed, because the underlying GLSL relies ongl_PointCoordwhich is undefined for non-point primitives and would otherwise corrupt the rendering. Switchingprop.styleback to'points'later will re-install the shader automatically.- Parameters:
- shape
PointSpriteShape|str The sprite shape to use. Accepts a
PointSpriteShapeenum 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
- shape
- Raises:
ValueErrorIf
shapeis not one of the supported shapes.
See also
Notes
Point sprite shapes only produce visible results when
render_points_as_spheres=Falseandstyle='points'. Whenrender_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')