level_of_detail.rst 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. .. _doc_level_of_detail:
  2. Level of Detail (LOD)
  3. =====================
  4. Level of detail (LOD) is one of the most important ways to optimize rendering
  5. (and performance in general) in a 3D project, along with occlusion culling.
  6. The LOD node
  7. ------------
  8. The ``LOD`` node provides a simple way of automatically switching between visual
  9. representations as the node gets closer or further from the
  10. :ref:`Camera <class_Camera>`, in order to increase performance.
  11. You might:
  12. - substitute lower poly count meshes
  13. - swap several separate meshes for a single approximate mesh
  14. - swap from a mesh to a billboard
  15. - turn off particle effects, animations, sounds, scripts according to distance
  16. - entirely remove visuals in the distance
  17. The ``LOD`` node should be added as a parent to whatever you wish to use to show
  18. the object, e.g. a :ref:`MeshInstance <class_MeshInstance>`. You can place
  19. several :ref:`Spatial <class_Spatial>` derived nodes as children.
  20. .. image:: img/lod_node_scene.webp
  21. The ``LOD`` node will automatically hide and show Spatial children depending on
  22. the distance from the ``Camera``.
  23. .. tip::
  24. You can react to ``NOTIFICATION_VISIBILITY_CHANGED`` in scripts to detect
  25. when a node has been shown or hidden.
  26. Children are shown in order with the first children shown when closest to the
  27. ``Camera``, and the latter children shown when further away.
  28. You can determine the distance at which these swaps occur by setting the
  29. **lod_range** property of ``Spatial``.
  30. .. note::
  31. Children of the ``LOD`` node can in turn have any number of children, of
  32. any type. These grandchildren will inherit their visibility as the ``LOD``
  33. node operates.
  34. One of the most common cases is to swap between high-poly and low-poly models.
  35. .. figure:: img/lod_wireframe.webp
  36. :align: center
  37. :alt: From most detailed (left) to least detailed (right), wireframe view
  38. From most detailed (left) to least detailed (right), wireframe view
  39. .. note::
  40. Godot 3.x does not currently generate decimated meshes for you.
  41. You are advised to generate several versions of a mesh in your
  42. modeling program (e.g. using the Decimate modifier in Blender).