.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_gallery/other/edl_mesh.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr__gallery_other_edl_mesh.py: Stanford Bunny mesh with Eye-Dome Lighting (EDL) ================================================ This example loads the Stanford Bunny mesh via Open3D, converts it to pygfx, renders with a basic material, and applies EDL as a post-process. .. GENERATED FROM PYTHON SOURCE LINES 8-56 .. code-block:: Python from importlib.util import find_spec from rendercanvas.auto import RenderCanvas, loop import pygfx as gfx from pygfx.renderers.wgpu.engine.edl import EDLPass if not find_spec("open3d"): raise ImportError( "The `open3d` library is required for this example: pip install open3d" ) import open3d as o3d def load_open3d_bunny_mesh() -> o3d.geometry.TriangleMesh: mesh_path = o3d.data.BunnyMesh().path mesh = o3d.io.read_triangle_mesh(mesh_path) if not mesh.has_vertices() or not mesh.has_triangles(): raise RuntimeError("Failed to load Bunny mesh via Open3D data") return mesh canvas = RenderCanvas(update_mode="continuous") renderer = gfx.renderers.WgpuRenderer(canvas) scene = gfx.Scene() scene.add(gfx.Background.from_color("#111")) o3d_mesh = load_open3d_bunny_mesh() geometry = gfx.geometries.geometry_from_open3d(o3d_mesh) material = gfx.MeshBasicMaterial(color="#e6e6e6") mesh = gfx.Mesh(geometry, material) scene.add(mesh) camera = gfx.PerspectiveCamera(50, 1) camera.show_object(mesh, view_dir=(1, -1, 0.6)) controller = gfx.OrbitController(camera, register_events=renderer) scene.add(gfx.AmbientLight(0.2), camera.add(gfx.DirectionalLight(1.0))) renderer.effect_passes = [EDLPass(strength=10.0, radius=1.5, depth_edge_threshold=0.0)] if __name__ == "__main__": canvas.request_draw(lambda: renderer.render(scene, camera)) loop.run() .. _sphx_glr_download__gallery_other_edl_mesh.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: edl_mesh.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: edl_mesh.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: edl_mesh.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_ .. only:: html Interactive example ------------------- Try this example in your browser using Pyodide. Might not work with all examples and all devices. Check the output and your browser's console for details. .. raw:: html