Note
Go to the end to download the full example code.
Lighting Properties#
Control aspects of the rendered mesh’s lighting such as Ambient, Diffuse,
and Specular. These options only work if the lighting argument to
add_mesh is True (it’s True by default).
You can turn off all lighting for the given mesh by passing lighting=False
to add_mesh.
from __future__ import annotations
import pyvista as pv
from pyvista import examples
mesh = examples.download_st_helens().warp_by_scalar()
cpos = pv.CameraPosition(
position=(575848.0, 5128459.0, 22289.0),
focal_point=(562835.0, 5114981.5, 2294.5),
viewup=(-0.5, -0.5, 0.7),
)
First, lets take a look at the mesh with default lighting conditions

What about with no lighting

Demonstration of the specular property
pl = pv.Plotter(shape=(1, 2), window_size=[1500, 500])
pl.subplot(0, 0)
pl.add_mesh(mesh, show_scalar_bar=False)
pl.add_text('No Specular')
pl.subplot(0, 1)
s = 1.0
pl.add_mesh(mesh, specular=s, show_scalar_bar=False)
pl.add_text(f'Specular of {s}')
pl.link_views()
pl.view_isometric()
pl.show(cpos=cpos)

Just specular

Specular power

Demonstration of all three in use

For detailed control over lighting conditions in general see the Lighting examples.
Total running time of the script: (0 minutes 8.093 seconds)