1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
|
"""
.. _edl:
Eye Dome Lighting
~~~~~~~~~~~~~~~~~
Eye-Dome Lighting (EDL) is a non-photorealistic, image-based shading technique
designed to improve depth perception in scientific visualization images.
To learn more, please see `this blog post`_.
.. _this blog post: https://blog.kitware.com/eye-dome-lighting-a-non-photorealistic-shading-technique/
"""
# %%
# sphinx_gallery_thumbnail_number = 1
from __future__ import annotations
import pyvista as pv
from pyvista import examples
# sphinx_gallery_start_ignore
# lighting does not seem to work in interactive mode
PYVISTA_GALLERY_FORCE_STATIC_IN_DOCUMENT = True
# sphinx_gallery_end_ignore
# %%
# Statue
# +++++++++++
#
# Eye-Dome Lighting can dramatically improve depth perception when plotting
# incredibly sophisticated meshes like the creative commons Queen Nefertiti
# statue:
nefertiti = examples.download_nefertiti()
nefertiti.plot(eye_dome_lighting=True, cpos=[-1, -1, 0.2], color=True)
# %%
# Here we will compare a EDL shading side by side with normal shading
p = pv.Plotter(shape=(1, 2), border=False)
# With eye-dome lighting
p.subplot(0, 0)
p.add_mesh(nefertiti, color=True)
p.enable_eye_dome_lighting()
p.add_text("Eye-Dome Lighting", font_size=24)
p.camera_position = [-1, -1, 0.2]
# No eye-dome lighting
p.subplot(0, 1)
p.add_mesh(nefertiti, color=True)
p.add_text("No Eye-Dome Lighting", font_size=24)
p.camera_position = [-1, -1, 0.2]
p.show()
# %%
# Point Cloud
# +++++++++++
#
# When plotting a simple point cloud, it can be difficult to perceive depth.
# Take this Lidar point cloud for example:
point_cloud = examples.download_lidar()
# %%
# And now plot this point cloud as-is:
# Plot a typical point cloud with no EDL
p = pv.Plotter()
p.add_mesh(point_cloud, color='lightblue', point_size=5)
p.show()
# %%
# We can improve the depth mapping by enabling eye dome lighting on the
# renderer with :func:`pyvista.Renderer.enable_eye_dome_lighting`.
# Plot with EDL
p = pv.Plotter()
p.add_mesh(point_cloud, color='lightblue', point_size=5)
p.enable_eye_dome_lighting()
p.show()
# %%
# The eye dome lighting mode can also handle plotting scalar arrays:
# Plot with EDL and scalar data
p = pv.Plotter()
p.add_mesh(point_cloud, scalars="Elevation", point_size=5)
p.enable_eye_dome_lighting()
p.show()
|