Document converting CSG nodes to MeshInstance3D and related lightmapping workflow (#10229)

* Document converting CSG nodes to MeshInstance3D and related lightmapping workflow

---------

Co-authored-by: Max Hilbrunner <mhilbrunner@users.noreply.github.com>
Co-authored-by: tetrapod <145553014+tetrapod00@users.noreply.github.com>
This commit is contained in:
Hugo Locurcio
2024-11-17 11:15:16 +01:00
committed by GitHub
parent dfb8a1890c
commit 338c19ca9d
3 changed files with 57 additions and 2 deletions

View File

@@ -296,8 +296,39 @@ in the **Scale** property will cause the texture to repeat more often.
the material onto, click the dropdown arrow next to its material
property then choose **Paste**.
.. _doc_csg_tools_converting_to_mesh_instance_3d:
Converting to MeshInstance3D
----------------------------
Since Godot 4.4, you can convert a CSG node and its children to a :ref:`class_MeshInstance3D` node.
This has several benefits:
- Bake lightmaps, since UV2 can be generated on a MeshInstance3D.
- Bake occlusion culling, since the occlusion culling bake process only takes MeshInstance3D into account.
- Faster loading times, since the CSG mesh no longer needs to be rebuilt when the scene loads.
- Better performance when updating the node's transform if using the mesh within another CSG node.
To convert a CSG node to a MeshInstance3D node, select it, then choose
**CSG > Bake Mesh Instance** in the toolbar. The MeshInstance3D node
will be created as a sibling. Note that the CSG node that was used for baking is **not** hidden
automatically, so remember to hide it to prevent its geometry from overlapping with the newly created
MeshInstance3D.
You can also create a trimesh collision shape using **CSG > Bake Collision Shape**.
The generated :ref:`class_CollisionShape3D` node must be a child of a :ref:`class_StaticBody3D`
or :ref:`class_AnimatableBody3D` node to be effective.
.. tip::
Remember to keep the original CSG node in the scene tree, so that you can
perform changes to the geometry later if needed. To make changes to the
geometry, remove the MeshInstance3D node and make the root CSG node visible
again.
Exporting as glTF
------------------------
-----------------
It can be useful to block out a level using CSG, then export it as a 3d model, to
import into 3D modeling software. You can do this by selecting **Scene > Export As... >

View File

@@ -202,6 +202,25 @@ lightmap texture, which varies depending on the mesh's size properties and the
**UV2 Padding** value. **Lightmap Size Hint** should not be manually changed, as
any modifications will be lost when the scene is reloaded.
Generating UV2 for CSG nodes
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Since Godot 4.4, you can
:ref:`convert a CSG node and its children to a MeshInstance3D <doc_csg_tools_converting_to_mesh_instance_3d>`.
This can be used to bake lightmaps on a CSG node by following these steps:
- Select the root CSG node and choose **CSG > Bake Mesh Instance** at the top of the 3D editor viewport.
- Hide the root CSG node that was just baked (it is not hidden automatically).
- Select the newly created MeshInstance3D node and choose **Mesh > Unwrap UV2 for Lightmap/AO**.
- Bake lightmaps.
.. tip::
Remember to keep the original CSG node in the scene tree, so that you can
perform changes to the geometry later if needed. To make changes to the
geometry, remove the MeshInstance3D node and make the root CSG node visible
again.
Checking UV2
^^^^^^^^^^^^

View File

@@ -79,7 +79,8 @@ How occlusion culling works in Godot
.. note::
*"occluder" refers to the shape blocking the view, while "occludee" refers to the object being hidden.*
"occluder" refers to the shape blocking the view, while "occludee" refers to
the object being hidden.
In Godot, occlusion culling works by rasterizing the scene's occluder geometry
to a low-resolution buffer on the CPU. This is done using
@@ -124,6 +125,10 @@ Automatically baking occluders (recommended)
those to be treated as occluders, you have to manually create occluder
shapes that (roughly) match their geometry.
Since Godot 4.4, CSG nodes can be taken into account in the baking process if they are
:ref:`converted to a MeshInstance3D <doc_csg_tools_converting_to_mesh_instance_3d>`
before baking occluders.
This restriction does not apply to *occludees*. Any node type that inherits
from GeometryInstance3D can be occluded.