Open Calinou opened 3 years ago
The reason CSGs aren't supported is because their mesh has no index array. Even if you convert a CSG to a MeshInstance3D by setting the MeshInstance3D's mesh to the CSG's mesh, occluders still won't be baked. It is possible to generate an index array by using SurfaceTool.index() though.
Describe the project you are working on
The Godot editor :slightly_smiling_face:
Describe the problem or limitation you are having in your project
The new occlusion culling feature in
master
has an occluder generation feature, but it doesn't take CSG nodes into account. cc @JFonSWith the following scene tree, only MeshInstance3D will have an occluder generated for it:
If you don't have any MeshInstances inside the OccluderInstance3D node but only CSG nodes, the generation will fail with a "No meshes to bake." message.
Screenshots
#### Normal view ![image](https://user-images.githubusercontent.com/180032/123103584-73241880-d436-11eb-8ec0-aac91a55ad78.png) #### Occlusion culling buffer debug view ![image](https://user-images.githubusercontent.com/180032/123103629-7e774400-d436-11eb-89a5-7f8d9e8b9a46.png)Describe the feature / enhancement and how it helps to overcome the problem or limitation
Take CSG nodes into account for occluder generation in the editor plugin that handles this.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
The CSG nodes could be converted to meshes for the purpose of occluder generation, but this should be done non-destructively so that you can keep editing your CSG nodes later on.
We may want to see whether we should extend this to other kinds of meshes such as MultiMeshInstances. While MultiMeshInstancees can only be culled as a group, we could allow generating occluders from their geometry.
If this enhancement will not be used often, can it be worked around with a few lines of script?
This may be doable with a script, but it makes sense to have this as a built-in feature given CSG is all about quick iteration times. While rendering performance is not critical when prototyping, many people use CSG in production, especially in simple games that have a low-poly aesthetic.
Is there a reason why this should be core and not an add-on in the asset library?
See above.