class_occluderinstance3d.rst 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/OccluderInstance3D.xml.
  6. .. _class_OccluderInstance3D:
  7. OccluderInstance3D
  8. ==================
  9. **Inherits:** :ref:`VisualInstance3D<class_VisualInstance3D>` **<** :ref:`Node3D<class_Node3D>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  10. Provides occlusion culling for 3D nodes, which improves performance in closed areas.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. Occlusion culling can improve rendering performance in closed/semi-open areas by hiding geometry that is occluded by other objects.
  15. The occlusion culling system is mostly static. **OccluderInstance3D**\ s can be moved or hidden at run-time, but doing so will trigger a background recomputation that can take several frames. It is recommended to only move **OccluderInstance3D**\ s sporadically (e.g. for procedural generation purposes), rather than doing so every frame.
  16. The occlusion culling system works by rendering the occluders on the CPU in parallel using `Embree <https://www.embree.org/>`__, drawing the result to a low-resolution buffer then using this to cull 3D nodes individually. In the 3D editor, you can preview the occlusion culling buffer by choosing **Perspective > Display Advanced... > Occlusion Culling Buffer** in the top-left corner of the 3D viewport. The occlusion culling buffer quality can be adjusted in the Project Settings.
  17. \ **Baking:** Select an **OccluderInstance3D** node, then use the **Bake Occluders** button at the top of the 3D editor. Only opaque materials will be taken into account; transparent materials (alpha-blended or alpha-tested) will be ignored by the occluder generation.
  18. \ **Note:** Occlusion culling is only effective if :ref:`ProjectSettings.rendering/occlusion_culling/use_occlusion_culling<class_ProjectSettings_property_rendering/occlusion_culling/use_occlusion_culling>` is ``true``. Enabling occlusion culling has a cost on the CPU. Only enable occlusion culling if you actually plan to use it. Large open scenes with few or no objects blocking the view will generally not benefit much from occlusion culling. Large open scenes generally benefit more from mesh LOD and visibility ranges (:ref:`GeometryInstance3D.visibility_range_begin<class_GeometryInstance3D_property_visibility_range_begin>` and :ref:`GeometryInstance3D.visibility_range_end<class_GeometryInstance3D_property_visibility_range_end>`) compared to occlusion culling.
  19. \ **Note:** Due to memory constraints, occlusion culling is not supported by default in Web export templates. It can be enabled by compiling custom Web export templates with ``module_raycast_enabled=yes``.
  20. .. rst-class:: classref-introduction-group
  21. Tutorials
  22. ---------
  23. - :doc:`Occlusion culling <../tutorials/3d/occlusion_culling>`
  24. .. rst-class:: classref-reftable-group
  25. Properties
  26. ----------
  27. .. table::
  28. :widths: auto
  29. +-------------------------------------+-----------------------------------------------------------------------------------------------------+----------------+
  30. | :ref:`int<class_int>` | :ref:`bake_mask<class_OccluderInstance3D_property_bake_mask>` | ``4294967295`` |
  31. +-------------------------------------+-----------------------------------------------------------------------------------------------------+----------------+
  32. | :ref:`float<class_float>` | :ref:`bake_simplification_distance<class_OccluderInstance3D_property_bake_simplification_distance>` | ``0.1`` |
  33. +-------------------------------------+-----------------------------------------------------------------------------------------------------+----------------+
  34. | :ref:`Occluder3D<class_Occluder3D>` | :ref:`occluder<class_OccluderInstance3D_property_occluder>` | |
  35. +-------------------------------------+-----------------------------------------------------------------------------------------------------+----------------+
  36. .. rst-class:: classref-reftable-group
  37. Methods
  38. -------
  39. .. table::
  40. :widths: auto
  41. +-------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | :ref:`bool<class_bool>` | :ref:`get_bake_mask_value<class_OccluderInstance3D_method_get_bake_mask_value>`\ (\ layer_number\: :ref:`int<class_int>`\ ) |const| |
  43. +-------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | |void| | :ref:`set_bake_mask_value<class_OccluderInstance3D_method_set_bake_mask_value>`\ (\ layer_number\: :ref:`int<class_int>`, value\: :ref:`bool<class_bool>`\ ) |
  45. +-------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. .. rst-class:: classref-section-separator
  47. ----
  48. .. rst-class:: classref-descriptions-group
  49. Property Descriptions
  50. ---------------------
  51. .. _class_OccluderInstance3D_property_bake_mask:
  52. .. rst-class:: classref-property
  53. :ref:`int<class_int>` **bake_mask** = ``4294967295`` :ref:`🔗<class_OccluderInstance3D_property_bake_mask>`
  54. .. rst-class:: classref-property-setget
  55. - |void| **set_bake_mask**\ (\ value\: :ref:`int<class_int>`\ )
  56. - :ref:`int<class_int>` **get_bake_mask**\ (\ )
  57. The visual layers to account for when baking for occluders. Only :ref:`MeshInstance3D<class_MeshInstance3D>`\ s whose :ref:`VisualInstance3D.layers<class_VisualInstance3D_property_layers>` match with this :ref:`bake_mask<class_OccluderInstance3D_property_bake_mask>` will be included in the generated occluder mesh. By default, all objects with *opaque* materials are taken into account for the occluder baking.
  58. To improve performance and avoid artifacts, it is recommended to exclude dynamic objects, small objects and fixtures from the baking process by moving them to a separate visual layer and excluding this layer in :ref:`bake_mask<class_OccluderInstance3D_property_bake_mask>`.
  59. .. rst-class:: classref-item-separator
  60. ----
  61. .. _class_OccluderInstance3D_property_bake_simplification_distance:
  62. .. rst-class:: classref-property
  63. :ref:`float<class_float>` **bake_simplification_distance** = ``0.1`` :ref:`🔗<class_OccluderInstance3D_property_bake_simplification_distance>`
  64. .. rst-class:: classref-property-setget
  65. - |void| **set_bake_simplification_distance**\ (\ value\: :ref:`float<class_float>`\ )
  66. - :ref:`float<class_float>` **get_bake_simplification_distance**\ (\ )
  67. The simplification distance to use for simplifying the generated occluder polygon (in 3D units). Higher values result in a less detailed occluder mesh, which improves performance but reduces culling accuracy.
  68. The occluder geometry is rendered on the CPU, so it is important to keep its geometry as simple as possible. Since the buffer is rendered at a low resolution, less detailed occluder meshes generally still work well. The default value is fairly aggressive, so you may have to decrease it if you run into false negatives (objects being occluded even though they are visible by the camera). A value of ``0.01`` will act conservatively, and will keep geometry *perceptually* unaffected in the occlusion culling buffer. Depending on the scene, a value of ``0.01`` may still simplify the mesh noticeably compared to disabling simplification entirely.
  69. Setting this to ``0.0`` disables simplification entirely, but vertices in the exact same position will still be merged. The mesh will also be re-indexed to reduce both the number of vertices and indices.
  70. \ **Note:** This uses the `meshoptimizer <https://meshoptimizer.org/>`__ library under the hood, similar to LOD generation.
  71. .. rst-class:: classref-item-separator
  72. ----
  73. .. _class_OccluderInstance3D_property_occluder:
  74. .. rst-class:: classref-property
  75. :ref:`Occluder3D<class_Occluder3D>` **occluder** :ref:`🔗<class_OccluderInstance3D_property_occluder>`
  76. .. rst-class:: classref-property-setget
  77. - |void| **set_occluder**\ (\ value\: :ref:`Occluder3D<class_Occluder3D>`\ )
  78. - :ref:`Occluder3D<class_Occluder3D>` **get_occluder**\ (\ )
  79. The occluder resource for this **OccluderInstance3D**. You can generate an occluder resource by selecting an **OccluderInstance3D** node then using the **Bake Occluders** button at the top of the editor.
  80. You can also draw your own 2D occluder polygon by adding a new :ref:`PolygonOccluder3D<class_PolygonOccluder3D>` resource to the :ref:`occluder<class_OccluderInstance3D_property_occluder>` property in the Inspector.
  81. Alternatively, you can select a primitive occluder to use: :ref:`QuadOccluder3D<class_QuadOccluder3D>`, :ref:`BoxOccluder3D<class_BoxOccluder3D>` or :ref:`SphereOccluder3D<class_SphereOccluder3D>`.
  82. .. rst-class:: classref-section-separator
  83. ----
  84. .. rst-class:: classref-descriptions-group
  85. Method Descriptions
  86. -------------------
  87. .. _class_OccluderInstance3D_method_get_bake_mask_value:
  88. .. rst-class:: classref-method
  89. :ref:`bool<class_bool>` **get_bake_mask_value**\ (\ layer_number\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_OccluderInstance3D_method_get_bake_mask_value>`
  90. Returns whether or not the specified layer of the :ref:`bake_mask<class_OccluderInstance3D_property_bake_mask>` is enabled, given a ``layer_number`` between 1 and 32.
  91. .. rst-class:: classref-item-separator
  92. ----
  93. .. _class_OccluderInstance3D_method_set_bake_mask_value:
  94. .. rst-class:: classref-method
  95. |void| **set_bake_mask_value**\ (\ layer_number\: :ref:`int<class_int>`, value\: :ref:`bool<class_bool>`\ ) :ref:`🔗<class_OccluderInstance3D_method_set_bake_mask_value>`
  96. Based on ``value``, enables or disables the specified layer in the :ref:`bake_mask<class_OccluderInstance3D_property_bake_mask>`, given a ``layer_number`` between 1 and 32.
  97. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  98. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  99. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  100. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  101. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  102. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  103. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
  104. .. |void| replace:: :abbr:`void (No return value.)`