# Examples from pyvista.Actor.add_shader_replacement
# ==================================================

# Add a custom fragment shader that discards pixels outside a circle.
import pyvista as pv
mesh = pv.Sphere()
pl = pv.Plotter()
actor = pl.add_mesh(mesh, style='points', point_size=20)
actor.add_shader_replacement(
    'fragment',
    '//VTK::Color::Impl',
    '//VTK::Color::Impl\n'
    'vec2 p = gl_PointCoord * 2.0 - 1.0;\n'
    'if (dot(p, p) > 1.0) discard;\n',
)

# ----------------------------------------------------------------------
# Generated by sphinx-examples-as-code https://github.com/pyvista/sphinx-examples-as-code

