reckfellENGINE

VoxelGeneratorGraph

Graph-based voxel generator.

On this page
class VoxelGeneratorGraphReckfellSharpInherits VoxelGenerator

Graph-based voxel generator.

Generates voxel data from a graph of per-voxel operations. The graph must be created, compiled, and only then blocks can be generated. It can be used with SDF-based smooth terrain, and also blocky terrains. Warning: methods to modify the graph should only be called from the main thread.

Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.

Constructors1

VoxelGeneratorGraphConstructor
# VoxelGeneratorGraph
C#
public VoxelGeneratorGraph();

Properties8

DebugBlockClippingProperty
# DebugBlockClipping
C#
public bool DebugBlockClipping { get; set; }

When enabled, if the graph outputs SDF data, generated blocks that would otherwise be clipped will be inverted. This has the effect of them showing up as "walls artifacts", which is useful to visualize where the optimization occurs.

GraphDataProperty
# GraphData
C#
public Reckfell.Collections.Dictionary GraphData { get; set; }
SdfClipThresholdProperty
# SdfClipThreshold
C#
public float SdfClipThreshold { get; set; }

When generating SDF blocks for a terrain, if the range analysis of a block is beyond this threshold, its SDF data will be considered either fully air, or fully matter (using high constants, positive or negative). This optimizes memory because chunks entirely underground or in the air will have the same value on every voxel. It also saves processing time because SDF calculations (noise etc) are skipped. To turn off this optimization, set it to a high value. Downside: if you use operations to edit the terrain assuming coherent SDF, they might behave incorrectly at boundaries where the clipping starts to occur. This is notably the case of VoxelTool.GrowSphere.

SubdivisionSizeProperty
# SubdivisionSize
C#
public int SubdivisionSize { get; set; }

When generating SDF blocks for a terrain, and if block size is divisible by this value, range analysis will operate on such subdivision. This allows to optimize away more precise areas. However, it may not be set too small otherwise overhead will outweight the benefits.

TextureModeProperty
# TextureMode
C#
public VoxelGeneratorGraph.TextureModeEnum TextureMode { get; set; }

Sets which voxel format will be produced by texture outputs, if present.

UseOptimizedExecutionMapProperty
# UseOptimizedExecutionMap
C#
public bool UseOptimizedExecutionMap { get; set; }

If enabled, when generating blocks for a terrain, the generator will attempt to skip specific nodes if they are found to have no importance in specific areas.

UseSubdivisionProperty
# UseSubdivision
C#
public bool UseSubdivision { get; set; }

If enabled, VoxelGeneratorGraph.SubdivisionSize will be used.

UseXzCachingProperty
# UseXzCaching
C#
public bool UseXzCaching { get; set; }

If enabled, the generator will run only once branches of the graph that only depend on X and Z. This is effective when part of the graph generates a heightmap, as this part is not volumetric.

Methods24

BakeSphereBumpmapvoid
# BakeSphereBumpmap
C#
public void BakeSphereBumpmap(Image im, float refRadius, float sdfMin, float sdfMax);

Bakes a spherical bumpmap (or heightmap) using SDF output produced by the generator, if any. The bumpmap uses a panorama projection. ref_radius: radius of the sphere on which heights will be sampled. strength: strength of produced normals, may default to 1.0.

Parameters
NameTypeDefault
imImage—
refRadiusfloat—
sdfMinfloat—
sdfMaxfloat—
BakeSphereNormalmapvoid
# BakeSphereNormalmap
C#
public void BakeSphereNormalmap(Image im, float refRadius, float strength);

Bakes a spherical normalmap using SDF output produced by the generator, if any. The normalmap uses a panorama projection. It is assumed the generator produces a spherical shape (like a planet). Such normalmap can be used to add more detail to distant views of a terrain using this generator. ref_radius: radius of the sphere on which normals will be sampled. strength: strength of produced normals, may default to 1.0. Note: an alternative is to use distance normals feature with VoxelLodTerrain.

Parameters
NameTypeDefault
imImage—
refRadiusfloat—
strengthfloat—
Clearvoid
# Clear
C#
public void Clear();

Erases all nodes and connections from the graph.

CompileReckfell.Collections.Dictionary
# Compile
C#
public Reckfell.Collections.Dictionary Compile();

Compiles the graph so it can be used to generate blocks. If it succeeds, the returned result is a dictionary with the following layout:

Text
{
    "success": true
}

If it fails, the returned result may contain a message and the ID of a graph node that could be the cause:

Text
{
    "success": false,
    "node_id": int,
    "message": String
}

The node ID will be -1 if the error is not about a particular node.

Returns Reckfell.Collections.Dictionary
DebugAnalyzeRangeVector2
# DebugAnalyzeRange
C#
public Vector2 DebugAnalyzeRange(Vector3 minPos, Vector3 maxPos);
Parameters
NameTypeDefault
minPosVector3—
maxPosVector3—
Returns Vector2
DebugLoadWavesPresetvoid
# DebugLoadWavesPreset
C#
public void DebugLoadWavesPreset();
DebugMeasureMicrosecondsPerVoxelfloat
# DebugMeasureMicrosecondsPerVoxel
C#
public float DebugMeasureMicrosecondsPerVoxel(bool useSingularQueries);
Parameters
NameTypeDefault
useSingularQueriesbool—
Returns float
GenerateImageFromSdfvoid
# GenerateImageFromSdf
C#
public void GenerateImageFromSdf(Image im, Transform3D transform, Vector2 size);

Genereates SDF data within a plane centered on the given transform spanning its X and Y axes, and stores results in pixels of the image. Samples are centered on pixels. The image should preferably have a 32-bit float format, and must not be compressed.

Parameters
NameTypeDefault
imImage—
transformTransform3D—
sizeVector2—
GetMainFunctionVoxelGraphFunction
# GetMainFunction
C#
public VoxelGraphFunction GetMainFunction();

Gets the graph used for generation.

Returns VoxelGraphFunction
GetSdfClipThresholdfloat
# GetSdfClipThreshold
C#
public float GetSdfClipThreshold();
Returns float
GetSubdivisionSizeint
# GetSubdivisionSize
C#
public int GetSubdivisionSize();
Returns int
GetTextureModeVoxelGeneratorGraph.TextureModeEnum
# GetTextureMode
C#
public VoxelGeneratorGraph.TextureModeEnum GetTextureMode();
Returns VoxelGeneratorGraph.TextureModeEnum
IsDebugClippedBlocksbool
# IsDebugClippedBlocks
C#
public bool IsDebugClippedBlocks();
Returns bool
IsUsingOptimizedExecutionMapbool
# IsUsingOptimizedExecutionMap
C#
public bool IsUsingOptimizedExecutionMap();
Returns bool
IsUsingSubdivisionbool
# IsUsingSubdivision
C#
public bool IsUsingSubdivision();
Returns bool
IsUsingXzCachingbool
# IsUsingXzCaching
C#
public bool IsUsingXzCaching();
Returns bool
RaycastSdfApproxfloat
# RaycastSdfApprox
C#
public float RaycastSdfApprox(Vector3 rayOrigin, Vector3 rayEnd, float stride);

Generates values along a ray to find the first one where SDF &lt 0.0, and return distance along the ray. If no hit is found, returns -1.0. This is an approximation: the error margin of the returned value will be up to the given stride. The longer the distance, the more expensive it is. The lower the stride, the more expensive and accurate it is.

Parameters
NameTypeDefault
rayOriginVector3—
rayEndVector3—
stridefloat—
Returns float
SetDebugClippedBlocksvoid
# SetDebugClippedBlocks
C#
public void SetDebugClippedBlocks(bool enabled);
Parameters
NameTypeDefault
enabledbool—
SetSdfClipThresholdvoid
# SetSdfClipThreshold
C#
public void SetSdfClipThreshold(float threshold);
Parameters
NameTypeDefault
thresholdfloat—
SetSubdivisionSizevoid
# SetSubdivisionSize
C#
public void SetSubdivisionSize(int size);
Parameters
NameTypeDefault
sizeint—
SetTextureModevoid
# SetTextureMode
C#
public void SetTextureMode(VoxelGeneratorGraph.TextureModeEnum mode);
Parameters
NameTypeDefault
modeVoxelGeneratorGraph.TextureModeEnum—
SetUseOptimizedExecutionMapvoid
# SetUseOptimizedExecutionMap
C#
public void SetUseOptimizedExecutionMap(bool use);
Parameters
NameTypeDefault
usebool—
SetUseSubdivisionvoid
# SetUseSubdivision
C#
public void SetUseSubdivision(bool use);
Parameters
NameTypeDefault
usebool—
SetUseXzCachingvoid
# SetUseXzCaching
C#
public void SetUseXzCaching(bool enabled);
Parameters
NameTypeDefault
enabledbool—

Signals and events1

NodeNameChangedEvent
# NodeNameChanged
C#
public event VoxelGeneratorGraph.NodeNameChangedEventHandler NodeNameChanged;
Handler parameters
NameTypeDefault
nodeIdlong—

VoxelGeneratorGraph.TextureModeEnum

ValueDescription
Mixel4 = 0

Writes texture data into VoxelBuffer.ChannelId.ChannelIndices as 4 packed 4-bit indices and into VoxelBuffer.ChannelId.ChannelWeights as 4 packed 4-bit weights. See VoxelMesherTransvoxel and docs about smooth voxels to see how this data is used.

Single = 1

Writes texture data into VoxelBuffer.ChannelId.ChannelIndices as one 8-bit value per voxel. If you want to use this mode, make sure your voxels have the appropriate format (see VoxelFormat)

Reckfell Engine documentationBack to top ↑
QUICK LINKSGetting startedEntity hierarchyC# & .NET 10Scenes and prefabs
Reckfell guides and full API K
reckfellENGINE
RECKFELL ACCOUNT

Sign in

Sign in to your Reckfell account.

One account for the entire Reckfell platform.