{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "%matplotlib inline" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Eye Dome Lighting {#edl}\n\nEye-Dome Lighting (EDL) is a non-photorealistic, image-based shading\ntechnique designed to improve depth perception in scientific\nvisualization images. To learn more, please see [this blog\npost](https://blog.kitware.com/eye-dome-lighting-a-non-photorealistic-shading-technique/).\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import pyvista as pv\nfrom pyvista import examples" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Statue\n\nEye-Dome Lighting can dramatically improve depth perception when\nplotting incredibly sophisticated meshes like the creative commons Queen\nNefertiti statue:\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "nefertiti = examples.download_nefertiti()\nnefertiti.plot(eye_dome_lighting=True, cpos=[-1, -1, 0.2], color=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Here we will compare a EDL shading side by side with normal shading\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "p = pv.Plotter(shape=(1, 2), border=False)\n\n# With eye-dome lighting\np.subplot(0, 0)\np.add_mesh(nefertiti, color=True)\np.enable_eye_dome_lighting()\np.add_text(\"Eye-Dome Lighting\", font_size=24)\np.camera_position = [-1, -1, 0.2]\n\n# No eye-dome lighting\np.subplot(0, 1)\np.add_mesh(nefertiti, color=True)\np.add_text(\"No Eye-Dome Lighting\", font_size=24)\np.camera_position = [-1, -1, 0.2]\n\np.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Point Cloud\n\nWhen plotting a simple point cloud, it can be difficult to perceive\ndepth. Take this Lidar point cloud for example:\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "point_cloud = examples.download_lidar()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "And now plot this point cloud as-is:\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# Plot a typical point cloud with no EDL\np = pv.Plotter()\np.add_mesh(point_cloud, color='lightblue', point_size=5)\np.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can improve the depth mapping by enabling eye dome lighting on the\nrenderer with\n`pyvista.Renderer.enable_eye_dome_lighting`{.interpreted-text\nrole=\"func\"}.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# Plot with EDL\np = pv.Plotter()\np.add_mesh(point_cloud, color='lightblue', point_size=5)\np.enable_eye_dome_lighting()\np.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The eye dome lighting mode can also handle plotting scalar arrays:\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# Plot with EDL and scalar data\np = pv.Plotter()\np.add_mesh(point_cloud, scalars=\"Elevation\", point_size=5)\np.enable_eye_dome_lighting()\np.show()" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.2" } }, "nbformat": 4, "nbformat_minor": 0 }