
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "tutorial/03_figures/solutions/b_lighting_mesh.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

    .. note::
        :class: sphx-glr-download-link-note

        :ref:`Go to the end <sphx_glr_download_tutorial_03_figures_solutions_b_lighting_mesh.py>`
        to download the full example code. or to run this example in your browser via Binder

.. rst-class:: sphx-glr-example-title

.. _sphx_glr_tutorial_03_figures_solutions_b_lighting_mesh.py:


.. _ref_lighting_properties_example:

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``.

See the ``add_mesh`` docs for lighting options:
https://docs.pyvista.org/api/plotting/_autosummary/pyvista.Plotter.add_mesh.html

.. GENERATED FROM PYTHON SOURCE LINES 17-25

.. code-block:: Python


    import pyvista as pv
    from pyvista import examples

    mesh = examples.download_st_helens().warp_by_scalar()

    cpos = [(575848.0, 5128459.0, 22289.0), (562835.0, 5114981.5, 2294.5), (-0.5, -0.5, 0.7)]








.. GENERATED FROM PYTHON SOURCE LINES 27-28

First, lets take a look at the mesh with default lighting conditions

.. GENERATED FROM PYTHON SOURCE LINES 28-30

.. code-block:: Python

    mesh.plot(cpos=cpos, show_scalar_bar=False)








.. tab-set::



   .. tab-item:: Static Scene



            
     .. image-sg:: /tutorial/03_figures/solutions/images/sphx_glr_b_lighting_mesh_001.png
        :alt: b lighting mesh
        :srcset: /tutorial/03_figures/solutions/images/sphx_glr_b_lighting_mesh_001.png
        :class: sphx-glr-single-img
     


   .. tab-item:: Interactive Scene



       .. offlineviewer:: /home/runner/work/pyvista-tutorial/pyvista-tutorial/doc/source/tutorial/03_figures/solutions/images/sphx_glr_b_lighting_mesh_001.vtksz






.. GENERATED FROM PYTHON SOURCE LINES 31-32

What about with no lighting?

.. GENERATED FROM PYTHON SOURCE LINES 32-34

.. code-block:: Python

    mesh.plot(lighting=False, cpos=cpos, show_scalar_bar=False)








.. tab-set::



   .. tab-item:: Static Scene



            
     .. image-sg:: /tutorial/03_figures/solutions/images/sphx_glr_b_lighting_mesh_002.png
        :alt: b lighting mesh
        :srcset: /tutorial/03_figures/solutions/images/sphx_glr_b_lighting_mesh_002.png
        :class: sphx-glr-single-img
     


   .. tab-item:: Interactive Scene



       .. offlineviewer:: /home/runner/work/pyvista-tutorial/pyvista-tutorial/doc/source/tutorial/03_figures/solutions/images/sphx_glr_b_lighting_mesh_002.vtksz






.. GENERATED FROM PYTHON SOURCE LINES 35-38

Demonstration of the specular property

Feel free to adjust the specular value in the ``s`` variable.

.. GENERATED FROM PYTHON SOURCE LINES 38-53

.. code-block:: Python

    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)
    specular = 1.0
    pl.add_mesh(mesh, specular=specular, show_scalar_bar=False)
    pl.add_text(f"Specular of {specular}")

    pl.link_views()
    pl.view_isometric()
    pl.show(cpos=cpos)








.. tab-set::



   .. tab-item:: Static Scene



            
     .. image-sg:: /tutorial/03_figures/solutions/images/sphx_glr_b_lighting_mesh_003.png
        :alt: b lighting mesh
        :srcset: /tutorial/03_figures/solutions/images/sphx_glr_b_lighting_mesh_003.png
        :class: sphx-glr-single-img
     


   .. tab-item:: Interactive Scene



       .. offlineviewer:: /home/runner/work/pyvista-tutorial/pyvista-tutorial/doc/source/tutorial/03_figures/solutions/images/sphx_glr_b_lighting_mesh_003.vtksz






.. GENERATED FROM PYTHON SOURCE LINES 54-55

Specular power (feel free to adjust)

.. GENERATED FROM PYTHON SOURCE LINES 55-57

.. code-block:: Python

    mesh.plot(specular=0.5, specular_power=15, cpos=cpos, show_scalar_bar=False)








.. tab-set::



   .. tab-item:: Static Scene



            
     .. image-sg:: /tutorial/03_figures/solutions/images/sphx_glr_b_lighting_mesh_004.png
        :alt: b lighting mesh
        :srcset: /tutorial/03_figures/solutions/images/sphx_glr_b_lighting_mesh_004.png
        :class: sphx-glr-single-img
     


   .. tab-item:: Interactive Scene



       .. offlineviewer:: /home/runner/work/pyvista-tutorial/pyvista-tutorial/doc/source/tutorial/03_figures/solutions/images/sphx_glr_b_lighting_mesh_004.vtksz






.. GENERATED FROM PYTHON SOURCE LINES 58-60

Demonstration of all diffuse, specular, and ambient in use together
(feel free to adjust)

.. GENERATED FROM PYTHON SOURCE LINES 60-62

.. code-block:: Python

    mesh.plot(diffuse=0.5, specular=0.5, ambient=0.5, cpos=cpos, show_scalar_bar=False)








.. tab-set::



   .. tab-item:: Static Scene



            
     .. image-sg:: /tutorial/03_figures/solutions/images/sphx_glr_b_lighting_mesh_005.png
        :alt: b lighting mesh
        :srcset: /tutorial/03_figures/solutions/images/sphx_glr_b_lighting_mesh_005.png
        :class: sphx-glr-single-img
     


   .. tab-item:: Interactive Scene



       .. offlineviewer:: /home/runner/work/pyvista-tutorial/pyvista-tutorial/doc/source/tutorial/03_figures/solutions/images/sphx_glr_b_lighting_mesh_005.vtksz






.. GENERATED FROM PYTHON SOURCE LINES 63-65

For detailed control over lighting conditions in general see the
`lighting examples <https://docs.pyvista.org/examples/index.html#lighting>`_

.. GENERATED FROM PYTHON SOURCE LINES 67-74

.. raw:: html

    <center>
      <a target="_blank" href="https://colab.research.google.com/github/pyvista/pyvista-tutorial/blob/gh-pages/notebooks/tutorial/03_figures/solutions/b_lighting_mesh.ipynb">
        <img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/ width="150px">
      </a>
    </center>


.. rst-class:: sphx-glr-timing

   **Total running time of the script:** (0 minutes 9.555 seconds)


.. _sphx_glr_download_tutorial_03_figures_solutions_b_lighting_mesh.py:

.. only:: html

  .. container:: sphx-glr-footer sphx-glr-footer-example

    .. container:: binder-badge

      .. image:: images/binder_badge_logo.svg
        :target: https://mybinder.org/v2/gh/pyvista/pyvista-tutorial/gh-pages?urlpath=lab/tree/notebooks/tutorial/03_figures/solutions/b_lighting_mesh.ipynb
        :alt: Launch binder
        :width: 150 px

    .. container:: sphx-glr-download sphx-glr-download-jupyter

      :download:`Download Jupyter notebook: b_lighting_mesh.ipynb <b_lighting_mesh.ipynb>`

    .. container:: sphx-glr-download sphx-glr-download-python

      :download:`Download Python source code: b_lighting_mesh.py <b_lighting_mesh.py>`

    .. container:: sphx-glr-download sphx-glr-download-zip

      :download:`Download zipped: b_lighting_mesh.zip <b_lighting_mesh.zip>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_
