VoxelLodTerrain
Voxel volume using variable level of detail.
Voxel volume using variable level of detail.
Renders large terrain using variable level of details. This is preferably used with smooth meshing such as VoxelMesherTransvoxel. Blocky meshers can be used, but currently don't have as much support for LOD.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Constructors1
VoxelLodTerrainConstructor
public VoxelLodTerrain();Properties40
CacheGeneratedBlocksProperty
public bool CacheGeneratedBlocks { get; set; }If enabled, streaming the terrain will keep generated voxel data in memory around viewers, even if it wasn't edited. This can speedup voxel queries on non-edited areas and allows VoxelStream.SaveGeneratorOutput to work, but increases memory usage significantly.
This option is not supported when VoxelLodTerrain.FullLoadModeEnabled is enabled.
CollisionLayerProperty
public int CollisionLayer { get; set; }Collision layer used by generated colliders. Check Reckfell documentation for more information.
CollisionLodCountProperty
public int CollisionLodCount { get; set; }How many LOD levels are set to generate colliders, starting from LOD 0. Setting this property to 0 means all LODs have collision.
CollisionMarginProperty
public float CollisionMargin { get; set; }Collision margin used by generated colliders. Note that it may depend on which physics engine is used under the hood, as some don't use margins.
CollisionMaskProperty
public int CollisionMask { get; set; }Collision mask used by generated colliders. Check Reckfell documentation for more information.
CollisionUpdateDelayProperty
public int CollisionUpdateDelay { get; set; }How long to wait before updating colliders after an edit, in milliseconds. Collider generation is expensive, so the intent is to smooth it out.
DebugDrawActiveMeshBlocksProperty
public bool DebugDrawActiveMeshBlocks { get; set; }DebugDrawActiveVisualAndCollisionBlocksProperty
public bool DebugDrawActiveVisualAndCollisionBlocks { get; set; }DebugDrawEditBoxesProperty
public bool DebugDrawEditBoxes { get; set; }DebugDrawEditedBlocksProperty
public bool DebugDrawEditedBlocks { get; set; }DebugDrawEnabledProperty
public bool DebugDrawEnabled { get; set; }DebugDrawLoadedVisualAndCollisionBlocksProperty
public bool DebugDrawLoadedVisualAndCollisionBlocks { get; set; }DebugDrawMeshUpdatesProperty
public bool DebugDrawMeshUpdates { get; set; }DebugDrawModifierBoundsProperty
public bool DebugDrawModifierBounds { get; set; }DebugDrawOctreeBoundsProperty
public bool DebugDrawOctreeBounds { get; set; }DebugDrawOctreeNodesProperty
public bool DebugDrawOctreeNodes { get; set; }DebugDrawShadowOccludersProperty
public bool DebugDrawShadowOccluders { get; set; }DebugDrawViewerClipboxesProperty
public bool DebugDrawViewerClipboxes { get; set; }DebugDrawVolumeBoundsProperty
public bool DebugDrawVolumeBounds { get; set; }DebugDrawVoxelMetadataProperty
public bool DebugDrawVoxelMetadata { get; set; }FullLoadModeEnabledProperty
public bool FullLoadModeEnabled { get; set; }If enabled, data streaming will be turned off, and all voxel data will be loaded from the stream into memory.
This removes several constraints, such as being able to edit anywhere and allowing distant normalmaps to include edited regions. This comes at the expense of more memory usage. However, only edited regions use memory, so in practice it can be good enough.
GenerateCollisionsProperty
public bool GenerateCollisions { get; set; }If enabled, chunked colliders will be generated from meshes.
LodCountProperty
public int LodCount { get; set; }How many LOD levels to use. This should be tuned alongside VoxelLodTerrain.LodDistance: if you want to see very far, you need more LOD levels. This allows blocks to become larger the further away they are, to keep their numbers to an acceptable amount. In contrast, too few LOD levels means regions far away will have to use too many small blocks, which can affect performance.
LodDistanceProperty
public float LodDistance { get; set; }How far LOD 0 extends from the viewer. Each parent LOD will extend twice as far as their children LOD levels. When VoxelLodTerrain.FullLoadModeEnabled is disabled, this also defines how far edits are allowed.
For further control of LODs beyond 0, see VoxelLodTerrain.SecondaryLodDistance.
LodFadeDurationProperty
public float LodFadeDuration { get; set; }When set greater than 0, enables LOD fading. When mesh blocks get split/merged as level of detail changes, they will fade to make the transition less noticeable (or at least more pleasant). This feature requires to use a specific shader, check the online documentation or examples for more information.
MaterialProperty
public Material Material { get; set; }Material used for the surface of the volume. The main usage of this node is with smooth voxels, which means if you want more than one "material" on the ground, you need to use splatmapping techniques with a shader. In addition, many features require shaders to work properly. Check the online documentation or examples for more information.
Note: if you use a ShaderMaterial, it will be instanced on every chunk in order to support per-chunk/LOD features, so dynamic changes done to parameters will not apply. You can use global uniforms to workaround this limitation.
MeshBlockSizeProperty
public uint MeshBlockSize { get; set; }Sets how many voxels across meshes of the terrain span.
Voxel chunks are stored in cubic chunks of 16x16x16 voxels, and by default meshes of the terrain match that size. But you can set this to 32 so meshes will span 2x2x2 voxel chunks. This is a performance tradeoff. Higher mesh size may speed up rendering, at the cost of slower mesh updates.
Values other than 16 and 32 are not supported.
Note: this setting also affects VoxelInstancer chunks.
NormalmapBeginLodIndexProperty
public int NormalmapBeginLodIndex { get; set; }From which LOD index normalmaps will be generated. There won't be normalmaps below this index.
NormalmapEnabledProperty
public bool NormalmapEnabled { get; set; }Enables generation of distant normalmaps. This is a feature used with smooth terrain only (SDF). It is an expensive feature but allows to bring a lot more detail to distant ground. This feature requires to use a specific shader, check the online documentation or examples for more information.
NormalmapMaxDeviationDegreesProperty
public int NormalmapMaxDeviationDegrees { get; set; }NormalmapOctahedralEncodingEnabledProperty
public bool NormalmapOctahedralEncodingEnabled { get; set; }Enables octahedral compression of normalmaps, which reduces memory usage caused by distant normalmaps by about 33%, with some impact on visual quality. Your shader may be modified accordingly to decode them.
NormalmapTileResolutionMaxProperty
public int NormalmapTileResolutionMax { get; set; }Maximum resolution of tiles in distant normalmaps.
NormalmapTileResolutionMinProperty
public int NormalmapTileResolutionMin { get; set; }Minimum resolution of tiles in distant normalmaps.
This is the resolution at which normalmaps will begin with, at the LOD level defined in VoxelLodTerrain.NormalmapBeginLodIndex. Resolutions will double at each LOD level, until they reach VoxelLodTerrain.NormalmapTileResolutionMax.
NormalmapUseGpuProperty
public bool NormalmapUseGpu { get; set; }Enables GPU detail normalmaps generation, which can speed it up. This is only valid for generators that support it. Vulkan is required.
SecondaryLodDistanceProperty
public float SecondaryLodDistance { get; set; }Controls the size of each LOD above LOD 0, in voxels relative to those LODs (voxels of LOD N are twice as big than LOD N-1). Higher values allow to see further away before detail are decimated, but is more expensive.
Note that it will not necessarily be respected accurately, and will rather be used as a target minimum distance.
This is only used when VoxelLodTerrain.StreamingSystem is set to VoxelLodTerrain.StreamingSystemEnum.Clipbox. In other cases, VoxelLodTerrain.LodDistance is used.
To control LOD 0, see VoxelLodTerrain.LodDistance.
StreamingSystemProperty
public VoxelLodTerrain.StreamingSystemEnum StreamingSystem { get; set; }Selects the underlying algorithm used to determine when to load and unload chunks around viewers as they move around.
ThreadedUpdateEnabledProperty
public bool ThreadedUpdateEnabled { get; set; }When enabled, this node will run a large part of its update cycle in a separate thread. Otherwise, it will run on the main thread.
UseGpuGenerationProperty
public bool UseGpuGeneration { get; set; }Enables GPU block generation, which can speed it up. This is only valid for generators that support it. Vulkan is required.
ViewDistanceProperty
public int ViewDistance { get; set; }Maximum distance viewers can have. If a viewer has a larger distance, it will be clamped. Note that this is only a hint and not an exact boundary. Terrain may load within that distance, but can continue beyond it, rounding up to block size of the biggest LOD. If your terrain size is finite (like an island or planet) and you want to keep it in view, you may want to set this value to a very large number. This is mainly useful for infinite terrains where a cap is desired.
VoxelBoundsProperty
public Aabb VoxelBounds { get; set; }Bounds within which volume data can exist (loaded or not), in voxels. By default, it is pseudo-infinite. If you make a planet, island or some sort of arena, you may want to choose a finite size. Note, because this volume uses chunks with LOD, these bounds will snap to the closest chunk boundary.
Methods79
DebugDumpAsSceneint
public int DebugDumpAsScene(string path, bool includeInstancer);Saves the current state of the terrain as a Reckfell scene file. Can be used to inspect meshes and instances in more detail in the editor.
| Name | Type | Default |
|---|---|---|
path | string | — |
includeInstancer | bool | — |
intDebugGetDataBlockCountint
public int DebugGetDataBlockCount();Get how many voxel data chunks are currently loaded
intDebugGetDataBlockInfoReckfell.Collections.Dictionary
public Reckfell.Collections.Dictionary DebugGetDataBlockInfo(Vector3 blockPos, int lod);Gets some debug information about a specific voxel data chunk.
{
"loading_state": int,
}| Name | Type | Default |
|---|---|---|
blockPos | Vector3 | — |
lod | int | — |
Reckfell.Collections.DictionaryDebugGetDrawFlagbool
public bool DebugGetDrawFlag(VoxelLodTerrain.DebugDrawFlag flagIndex);Gets whether a specific debug drawing flag is enabled. This method always returns false in exported games.
| Name | Type | Default |
|---|---|---|
flagIndex | VoxelLodTerrain.DebugDrawFlag | — |
boolDebugGetDrawShadowOccludersbool
public bool DebugGetDrawShadowOccluders();boolDebugGetMeshBlockCountint
public int DebugGetMeshBlockCount();Gets how many meshes the terrain currently has.
intDebugGetMeshBlockInfoReckfell.Collections.Dictionary
public Reckfell.Collections.Dictionary DebugGetMeshBlockInfo(Vector3 blockPos, int lod);Gets some debug information about a specific mesh.
{
"transition_mask": int,
"recomputed_transition_mask": int,
"loaded": bool,
"meshed": bool,
"mesh_state": int,
"visible": bool,
"visual_active": bool,
"collision_active": bool
}| Name | Type | Default |
|---|---|---|
blockPos | Vector3 | — |
lod | int | — |
Reckfell.Collections.DictionaryDebugGetOctreesDetailedReckfell.Collections.Array
public Reckfell.Collections.Array DebugGetOctreesDetailed();Gets debug information about the grid of octrees used to stream the terrain at multiple levels of detail.
The returned array contains alternating Vector3I and Reckfell.Collections.Array values, where each pair corresponds to one octree at a specific position:
[
Vector3i,
Array,
Vector3i,
Array,
...
]The array after positions contains info about one octree:
[
int (node state),
null or Array (children info)
]When children info is not null, it contains 8 arrays structured the same way, and may be recursively traversed to obtain the state of every node of the octree.
Reckfell.Collections.ArrayDebugIsDrawEnabledbool
public bool DebugIsDrawEnabled();boolDebugPrintSdfTopDownReckfell.Collections.Array
public Reckfell.Collections.Array DebugPrintSdfTopDown(Vector3I center, Vector3I extents);Captures a top-down representation of the signed distance field (SDF) at multiple LOD levels within a specific area. The returned array contains an image for each LOD.
| Name | Type | Default |
|---|---|---|
center | Vector3I | — |
extents | Vector3I | — |
Reckfell.Collections.ArrayDebugRaycastMeshBlockReckfell.Collections.Array
public Reckfell.Collections.Array DebugRaycastMeshBlock(Vector3 origin, Vector3 dir);Gets the non-empty mesh chunk positions from a rough world-space ray, up to a distance of 256 units. All LODs are checked. The returned array contains:
[
{
"position": Vector3i,
"lod": int
},
...
]| Name | Type | Default |
|---|---|---|
origin | Vector3 | — |
dir | Vector3 | — |
Reckfell.Collections.ArrayDebugSetDrawEnabledvoid
public void DebugSetDrawEnabled(bool enabled);| Name | Type | Default |
|---|---|---|
enabled | bool | — |
DebugSetDrawFlagvoid
public void DebugSetDrawFlag(VoxelLodTerrain.DebugDrawFlag flagIndex, bool enabled);Sets a specific debug drawing flag. Note that debug drawing must also be enabled for it to be visible. This method does nothing in exported games.
| Name | Type | Default |
|---|---|---|
flagIndex | VoxelLodTerrain.DebugDrawFlag | — |
enabled | bool | — |
DebugSetDrawShadowOccludersvoid
public void DebugSetDrawShadowOccluders(bool enabled);| Name | Type | Default |
|---|---|---|
enabled | bool | — |
GetCacheGeneratedBlocksbool
public bool GetCacheGeneratedBlocks();boolGetCollisionLayerint
public int GetCollisionLayer();intGetCollisionLodCountint
public int GetCollisionLodCount();intGetCollisionMarginfloat
public float GetCollisionMargin();floatGetCollisionMaskint
public int GetCollisionMask();intGetCollisionUpdateDelayint
public int GetCollisionUpdateDelay();intGetDataBlockRegionExtentint
public int GetDataBlockRegionExtent();intGetDataBlockSizeuint
public uint GetDataBlockSize();Gets the size of one cunic data block in voxels.
uintGetGenerateCollisionsbool
public bool GetGenerateCollisions();boolGetGeneratorUseGpubool
public bool GetGeneratorUseGpu();boolGetLodCountint
public int GetLodCount();intGetLodDistancefloat
public float GetLodDistance();floatGetLodFadeDurationfloat
public float GetLodFadeDuration();floatGetMaterialMaterial
public Material GetMaterial();MaterialGetMeshBlockSizeuint
public uint GetMeshBlockSize();uintGetNormalmapBeginLodIndexint
public int GetNormalmapBeginLodIndex();intGetNormalmapGeneratorOverrideVoxelGenerator
public VoxelGenerator GetNormalmapGeneratorOverride();VoxelGeneratorGetNormalmapGeneratorOverrideBeginLodIndexint
public int GetNormalmapGeneratorOverrideBeginLodIndex();intGetNormalmapMaxDeviationDegreesint
public int GetNormalmapMaxDeviationDegrees();intGetNormalmapTileResolutionMaxint
public int GetNormalmapTileResolutionMax();intGetNormalmapTileResolutionMinint
public int GetNormalmapTileResolutionMin();intGetNormalmapUseGpubool
public bool GetNormalmapUseGpu();boolGetOctahedralNormalEncodingbool
public bool GetOctahedralNormalEncoding();boolGetProcessCallbackVoxelLodTerrain.ProcessCallback
public VoxelLodTerrain.ProcessCallback GetProcessCallback();Gets which callback is used to run the main thread update of this node.
VoxelLodTerrain.ProcessCallbackGetSecondaryLodDistancefloat
public float GetSecondaryLodDistance();floatGetStatisticsReckfell.Collections.Dictionary
public Reckfell.Collections.Dictionary GetStatistics();Gets debug information about how much time is spent processing the terrain. The returned dictionary has the following structure:
{
"time_detect_required_blocks": int,
"time_request_blocks_to_load": int,
"time_process_load_responses": int,
"time_request_blocks_to_update": int,
"time_process_update_responses": int,
"remaining_main_thread_blocks": int,
"dropped_block_loads": int,
"dropped_block_meshs": int,
"updated_blocks": int,
"blocked_lods": int
}Times are in microseconds.
Reckfell.Collections.DictionaryGetStreamingSystemVoxelLodTerrain.StreamingSystemEnum
public VoxelLodTerrain.StreamingSystemEnum GetStreamingSystem();VoxelLodTerrain.StreamingSystemEnumGetViewDistanceint
public int GetViewDistance();intGetVoxelBoundsAabb
public Aabb GetVoxelBounds();AabbIsAreaMeshedbool
public bool IsAreaMeshed(Aabb areaInVoxels, int lodIndex);Returns true if the area has been processed by meshing. It does not mean the area actually contains a mesh. Returns false if the area has not been processed by meshing (therefore it is unknown whethere there should be a mesh here or not). When streaming terrain, this can be used to determine if an area has fully "loaded", in case the game relies meshes or mesh colliders.
| Name | Type | Default |
|---|---|---|
areaInVoxels | Aabb | — |
lodIndex | int | — |
boolIsFullLoadModeEnabledbool
public bool IsFullLoadModeEnabled();boolIsNormalmapEnabledbool
public bool IsNormalmapEnabled();boolIsThreadedUpdateEnabledbool
public bool IsThreadedUpdateEnabled();boolSaveModifiedBlocksVoxelSaveCompletionTracker
public VoxelSaveCompletionTracker SaveModifiedBlocks();Requests saving of all modified voxels. Saving is asynchronous and will complete some time in the future. If the game quits, the engine will ensure saving tasks get completed before the application shuts down. Use the returned tracker object to know when saving has completed. However, saves occurring after calling this method won't be tracked by this object. Note that blocks getting unloaded as the viewer moves around can also trigger saving tasks, independently from this function.
VoxelSaveCompletionTrackerSetCacheGeneratedBlocksvoid
public void SetCacheGeneratedBlocks(bool enabled);| Name | Type | Default |
|---|---|---|
enabled | bool | — |
SetCollisionLayervoid
public void SetCollisionLayer(int layer);| Name | Type | Default |
|---|---|---|
layer | int | — |
SetCollisionLodCountvoid
public void SetCollisionLodCount(int count);| Name | Type | Default |
|---|---|---|
count | int | — |
SetCollisionMarginvoid
public void SetCollisionMargin(float margin);| Name | Type | Default |
|---|---|---|
margin | float | — |
SetCollisionMaskvoid
public void SetCollisionMask(int mask);| Name | Type | Default |
|---|---|---|
mask | int | — |
SetCollisionUpdateDelayvoid
public void SetCollisionUpdateDelay(int delayMsec);| Name | Type | Default |
|---|---|---|
delayMsec | int | — |
SetFullLoadModeEnabledvoid
public void SetFullLoadModeEnabled(bool _UnnamedArg0);| Name | Type | Default |
|---|---|---|
_UnnamedArg0 | bool | — |
SetGenerateCollisionsvoid
public void SetGenerateCollisions(bool enabled);| Name | Type | Default |
|---|---|---|
enabled | bool | — |
SetGeneratorUseGpuvoid
public void SetGeneratorUseGpu(bool enabled);| Name | Type | Default |
|---|---|---|
enabled | bool | — |
SetLodCountvoid
public void SetLodCount(int lodCount);| Name | Type | Default |
|---|---|---|
lodCount | int | — |
SetLodDistancevoid
public void SetLodDistance(float lodDistance);| Name | Type | Default |
|---|---|---|
lodDistance | float | — |
SetLodFadeDurationvoid
public void SetLodFadeDuration(float seconds);| Name | Type | Default |
|---|---|---|
seconds | float | — |
SetMaterialvoid
public void SetMaterial(Material material);| Name | Type | Default |
|---|---|---|
material | Material | — |
SetMeshBlockSizevoid
public void SetMeshBlockSize(uint _UnnamedArg0);| Name | Type | Default |
|---|---|---|
_UnnamedArg0 | uint | — |
SetNormalmapBeginLodIndexvoid
public void SetNormalmapBeginLodIndex(int lodIndex);| Name | Type | Default |
|---|---|---|
lodIndex | int | — |
SetNormalmapEnabledvoid
public void SetNormalmapEnabled(bool enabled);| Name | Type | Default |
|---|---|---|
enabled | bool | — |
SetNormalmapGeneratorOverridevoid
public void SetNormalmapGeneratorOverride(VoxelGenerator generatorOverride);| Name | Type | Default |
|---|---|---|
generatorOverride | VoxelGenerator | — |
SetNormalmapGeneratorOverrideBeginLodIndexvoid
public void SetNormalmapGeneratorOverrideBeginLodIndex(int lodIndex);| Name | Type | Default |
|---|---|---|
lodIndex | int | — |
SetNormalmapMaxDeviationDegreesvoid
public void SetNormalmapMaxDeviationDegrees(int angle);| Name | Type | Default |
|---|---|---|
angle | int | — |
SetNormalmapTileResolutionMaxvoid
public void SetNormalmapTileResolutionMax(int resolution);| Name | Type | Default |
|---|---|---|
resolution | int | — |
SetNormalmapTileResolutionMinvoid
public void SetNormalmapTileResolutionMin(int resolution);| Name | Type | Default |
|---|---|---|
resolution | int | — |
SetNormalmapUseGpuvoid
public void SetNormalmapUseGpu(bool enabled);| Name | Type | Default |
|---|---|---|
enabled | bool | — |
SetOctahedralNormalEncodingvoid
public void SetOctahedralNormalEncoding(bool enabled);| Name | Type | Default |
|---|---|---|
enabled | bool | — |
SetProcessCallbackvoid
public void SetProcessCallback(VoxelLodTerrain.ProcessCallback mode);Sets which process callback is used to run the main thread update of this node. By default, it uses _process.
| Name | Type | Default |
|---|---|---|
mode | VoxelLodTerrain.ProcessCallback | — |
SetSecondaryLodDistancevoid
public void SetSecondaryLodDistance(float lodDistance);| Name | Type | Default |
|---|---|---|
lodDistance | float | — |
SetStreamingSystemvoid
public void SetStreamingSystem(VoxelLodTerrain.StreamingSystemEnum system);| Name | Type | Default |
|---|---|---|
system | VoxelLodTerrain.StreamingSystemEnum | — |
SetThreadedUpdateEnabledvoid
public void SetThreadedUpdateEnabled(bool enabled);| Name | Type | Default |
|---|---|---|
enabled | bool | — |
SetViewDistancevoid
public void SetViewDistance(int distanceInVoxels);| Name | Type | Default |
|---|---|---|
distanceInVoxels | int | — |
SetVoxelBoundsvoid
public void SetVoxelBounds(Aabb _UnnamedArg0);| Name | Type | Default |
|---|---|---|
_UnnamedArg0 | Aabb | — |
VoxelToDataBlockPositionVector3I
public Vector3I VoxelToDataBlockPosition(Vector3 voxelPosition, int lodIndex);Converts a voxel position into a data block position for a specific LOD index.
| Name | Type | Default |
|---|---|---|
voxelPosition | Vector3 | — |
lodIndex | int | — |
Vector3IVoxelToMeshBlockPositionVector3I
public Vector3I VoxelToMeshBlockPosition(Vector3 voxelPosition, int lodIndex);Converts a voxel position into a mesh block position for a specific LOD index.
| Name | Type | Default |
|---|---|---|
voxelPosition | Vector3 | — |
lodIndex | int | — |
Vector3IVoxelLodTerrain.DebugDrawFlag
VoxelLodTerrain.ProcessCallback
| Value | Description |
|---|---|
Disabled = 2 | The node will not update. Use with caution! |
Idle = 0 | The node will use |
Physics = 1 | The node will use |
VoxelLodTerrain.StreamingSystemEnum
| Value | Description |
|---|---|
Clipbox = 1 | Loads chunks around the viewer in concentric boxes. Supports multiple viewers and collision-only viewers. This is a better system for multiplayer streaming.
Due to simplifications, chunk locations at each LOD might be less optimal than |
LegacyOctree = 0 | Loads chunks around the viewer in a spherical pattern.
Does not support multiple viewers. Does not support collision-only viewers. Does not support "no viewers" (will assume origin instead). Does not support per-viewer view distance, only |