Inherits: VoxelGenerator

Base class for custom generators defined with a script.


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.


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.

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 Sep 12, 2023