VoxelGeneratorScript

Inherits: VoxelGenerator

Base class for custom generators defined with a script.

Description:

Important: this engine makes heavy use of threads. Generators will run in one of them, so make sure you don't access the scene tree or other unsafe APIs from within a generator.

Methods:

Return Signature
void _generate_block ( VoxelBuffer out_buffer, Vector3i origin_in_voxels, int lod ) virtual
int _get_used_channels_mask ( ) virtual const

Method Descriptions

out_buffer: Buffer in which to populate voxel data. It will never be null and will have the requested size. It is only valid for this function, do not store it anywhere after the end. Note: this buffer can have any non-empty size, but some assumptions can be made depending on which terrain node you're using. VoxelTerrain will always request blocks of size 16x16x16, but VoxelLodTerrain can request blocks of different sizes.

origin_in_voxels: Coordinates of the lower corner of the box to generate, relative to LOD0. The size of the box is known from out_buffer.

lod: Level of detail index to use for this block. It can be ignored if you don't use LOD. This may be used as a power of two, telling how big is one voxel. For example, if you use a loop to fill the buffer using noise, you should sample that noise at steps of 2^lod, starting from origin_in_voxels (in code you can use 1 << lod for fast computation, instead of pow(2, lod)). You may want to separate variables that iterate the coordinates in out_buffer and variables used to generate voxel values in space.

  • int _get_used_channels_mask( )

Use this to indicate which channels your generator will use. It returns a bitmask, so for example you may provide information like this: (1 << channel1) | (1 << channel2)

Generated on Mar 24, 2024