OccluderInstance3D
Provides occlusion culling for 3D nodes, which improves performance in closed areas.
OccluderInstance3D.swift:28class OccluderInstance3D
Occlusion culling can improve rendering performance in closed/semi-open areas by hiding geometry that is occluded by other objects.
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.
The occlusion culling system works by rendering the occluders on the CPU in parallel using Embree, 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 > Debug 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.
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.
Superclasses
class VisualInstance3D
Parent of all visual 3D nodes.
Citizens in SwiftGodot
Conformances
protocol CustomStringConvertible
A type with a customized textual representation.
protocol Equatable
A type that can be compared for value equality.
protocol Hashable
A type that can be hashed into a
Hasher
to produce an integer hash value.protocol Identifiable<ID>
A class of types whose instances hold the value of an entity with stable identity.
protocol VariantRepresentable
Types that conform to VariantRepresentable can be stored directly in
Variant
with no conversion. These include all of the Variant types from Godot (for exampleGString
,Rect
,Plane
), Godot objects (those that subclass SwiftGodot.Object) as well as the built-in Swift types UInt8, Int64 and Double.protocol VariantStorable
Types that conform to VariantStorable can be stored in a Variant and can be extracted back out of a Variant.
Type members
Instance members
var bakeMask: UInt32
The visual layers to account for when baking for occluders. Only
MeshInstance3D
s whoselayers
match with thisbakeMask
will be included in the generated occluder mesh. By default, all objects with opaque materials are taken into account for the occluder baking.var bakeSimplificationDistance: Double
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.
var occluder: Occluder3D?
The occluder resource for this
OccluderInstance3D
. You can generate an occluder resource by selecting anOccluderInstance3D
node then using the Bake Occluders button at the top of the editor.func getBakeMaskValue(layerNumber: Int32
) -> Bool Returns whether or not the specified layer of the
bakeMask
is enabled, given alayerNumber
between 1 and 32.func setBakeMaskValue(layerNumber: Int32, value: Bool
) Based on
value
, enables or disables the specified layer in thebakeMask
, given alayerNumber
between 1 and 32.