.. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_tutorials_04_shaders_viz_sdfactor.py: =================== Visualize SDF Actor =================== Here is a simple tutorial that shows how to visualize SDF primitives using FURY. SDFs or Signed-distance functions when passed the coordinates of a point in space, return the shortest distance between that point and some surface. This property of SDFs can be used to model 3D geometry at a faster rate compared to traditional polygons based modeling. In this example we use the raymarching algorithm to render the SDF primitives shapes using shaders .. code-block:: default import numpy as np from fury import window, actor Lets define variables for the SDF Actor .. code-block:: default dirs = np.random.rand(3, 3) colors = np.random.rand(3, 3) * 255 centers = np.array([[1, 0, 0], [0, 0, 0], [-1, 0, 0]]) scales = np.random.rand(3, 1) Create SDF Actor .. code-block:: default sdfactor = actor.sdf(centers=centers, directions=dirs, colors=colors, primitives=['sphere', 'torus', 'ellipsoid'], scales=scales) Create a scene .. code-block:: default scene = window.Scene() scene.background((1.0, 0.8, 0.8)) scene.add(sdfactor) Show Manager Since all the elements have been initialised ,we add them to the show manager. .. code-block:: default current_size = (1024, 720) showm = window.ShowManager(scene, size=current_size, title="Visualize SDF Actor") interactive = False if interactive: showm.start() window.record(scene, out_path='viz_sdfactor.png', size=current_size) .. image:: /auto_tutorials/04_shaders/images/sphx_glr_viz_sdfactor_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.217 seconds) .. _sphx_glr_download_auto_tutorials_04_shaders_viz_sdfactor.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download :download:`Download Python source code: viz_sdfactor.py ` .. container:: sphx-glr-download :download:`Download Jupyter notebook: viz_sdfactor.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_