VisibilityRange
VisibilityRange
- start_margin : core::ops::Range
- end_margin : core::ops::Range
- use_aabb : bool
Description
Specifies the range of distances that this entity must be from the camera in order to be rendered.
This is also known as hierarchical level of detail or HLOD.
Use this component when you want to render a high-polygon mesh when the camera is close and a lower-polygon mesh when the camera is far away. This is a common technique for improving performance, because fine details are hard to see in a mesh at a distance. To avoid an artifact known as popping between levels, each level has a margin, within which the object transitions gradually from invisible to visible using a dithering effect.
You can also use this feature to replace multiple meshes with a single mesh when the camera is distant. This is the reason for the term "hierarchical level of detail". Reducing the number of meshes can be useful for reducing drawcall count. Note that you must place the [
VisibilityRange
] component on each entity you want to be part of a LOD group, as [VisibilityRange
] isn't automatically propagated down to children.A typical use of this feature might look like this:
Entity start_margin
end_margin
Root N/A N/A ├─ High-poly mesh [0, 0) [20, 25) ├─ Low-poly mesh [20, 25) [70, 75) └─ Billboard imposter [70, 75) [150, 160) With this setup, the user will see a high-poly mesh when the camera is closer than 20 units. As the camera zooms out, between 20 units to 25 units, the high-poly mesh will gradually fade to a low-poly mesh. When the camera is 70 to 75 units away, the low-poly mesh will fade to a single textured quad. And between 150 and 160 units, the object fades away entirely. Note that the
end_margin
of a higher LOD is always identical to thestart_margin
of the next lower LOD; this is important for the crossfade effect to function properly.