VoxelInstanceGenerator
Decides where to spawn instances on top of a voxel surface.
Decides where to spawn instances on top of a voxel surface.
Generates the necessary information to spawn instances on top of a voxel surface. This may be used by a VoxelInstancer.
Note: to generate voxels, see VoxelGenerator.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Constructors1
VoxelInstanceGeneratorConstructor
public VoxelInstanceGenerator();Properties31
DensityProperty
public float Density { get; set; }Controls how many instances are generated. Might give different results depending on the type of emission chosen.
EmitModeProperty
public VoxelInstanceGenerator.EmitModeEnum EmitMode { get; set; }In which way instances are primarily emitted.
JitterProperty
public float Jitter { get; set; }Controls randomness of spawning position when VoxelInstanceGenerator.EmitMode is set to VoxelInstanceGenerator.EmitModeEnum.OnePerTriangle.
MaxHeightProperty
public float MaxHeight { get; set; }Instances will not be created above this height.
This also depends on the chosen VoxelInstancer.UpMode.
MaxHeightFalloffProperty
public float MaxHeightFalloff { get; set; }Distance over which density will fade, when below VoxelInstanceGenerator.MaxHeight.
MaxScaleProperty
public float MaxScale { get; set; }Minimum scale instances will be randomized with.
MaxSlopeDegreesProperty
public float MaxSlopeDegrees { get; set; }Instances will not spawn if the ground has a slope higher than this angle.
This also depends on the chosen VoxelInstancer.UpMode.
MaxSlopeFalloffDegreesProperty
public float MaxSlopeFalloffDegrees { get; set; }Angular distance over which density will fade, when below VoxelInstanceGenerator.MaxSlopeDegrees.
MinHeightProperty
public float MinHeight { get; set; }Instances will not be created below this height. This also depends on the chosen VoxelInstancer.UpMode.
MinHeightFalloffProperty
public float MinHeightFalloff { get; set; }Distance over which density will fade, when above VoxelInstanceGenerator.MinHeight.
MinScaleProperty
public float MinScale { get; set; }Maximum scale instances will be randomized with.
MinSlopeDegreesProperty
public float MinSlopeDegrees { get; set; }Instances will not spawn if the ground has a slope lower than this angle.
This also depends on the chosen VoxelInstancer.UpMode.
MinSlopeFalloffDegreesProperty
public float MinSlopeFalloffDegrees { get; set; }Angular distance over which density will fade, when above VoxelInstanceGenerator.MinSlopeDegrees.
NoiseProperty
public Noise Noise { get; set; }Noise used to filter out spawned instances, so that they may spawn in patterns described by the noise.
NoiseDimensionProperty
public VoxelInstanceGenerator.Dimension NoiseDimension { get; set; }Which dimension should be used when evaluating VoxelInstanceGenerator.Noise and VoxelInstanceGenerator.NoiseGraph.
NoiseFalloffProperty
public float NoiseFalloff { get; set; }Noise range over which density will fade. For example if falloff is 0.3, then density will fade when noise values are between 0 and 0.3.
NoiseGraphProperty
public VoxelGraphFunction NoiseGraph { get; set; }Graph function used to filter out spawned instances, similar to VoxelInstanceGenerator.Noise, but allows more custom noise computations.
The graph must have 2 inputs (X and Z) if VoxelInstanceGenerator.NoiseDimension is 2D, and 3 inputs (X, Y and Z) if 3D. There must be one SDF output.
NoiseOnScaleProperty
public float NoiseOnScale { get; set; }How much VoxelInstanceGenerator.Noise also affects the scale of instances.
NoiseThresholdProperty
public float NoiseThreshold { get; set; }Expands or shrink noise filtering. Higher values expand the areas where instances will spawn, lower values shrinks them.
OffsetAlongNormalProperty
public float OffsetAlongNormal { get; set; }Offsets spawned instances along the normal of the ground.
The normal depends on VoxelInstancer.UpMode and is also affected by VoxelInstanceGenerator.VerticalAlignment.
RandomRotationProperty
public bool RandomRotation { get; set; }When enbabled, instances will be given a random rotation. If not, they will use a consistent rotation depending on the ground slope.
RandomVerticalFlipProperty
public bool RandomVerticalFlip { get; set; }When enabled, instances will randomly be flipped upside down. This can be useful with small rocks to create illusion of more variety.
ScaleDistributionProperty
public VoxelInstanceGenerator.Distribution ScaleDistribution { get; set; }Sets how random scales are distributed.
SnapToGeneratorSdfEnabledProperty
public bool SnapToGeneratorSdfEnabled { get; set; }Enables snapping to generator SDF. The generator's SDF values will be queried to move instances along their normal to be closerr to ground. Can help reduce the occurrence of "floating" or "buried" instances when moving close to them. This requires the terrain's generator to support series generation. Side-effects: instances might become floating or buried when seen from far away; spawning might become less even.
SnapToGeneratorSdfSampleCountProperty
public int SnapToGeneratorSdfSampleCount { get; set; }How many samples per instance will be taken from the generator in order to approach the snapping position. More samples increases precision, but is more expensive.
SnapToGeneratorSdfSearchDistanceProperty
public float SnapToGeneratorSdfSearchDistance { get; set; }Distance up and down across which snapping will search for ground location.
TriangleAreaThresholdProperty
public float TriangleAreaThreshold { get; set; }If set greater than zero, triangles of the ground with an area lower than this threshold will be ignored. Some meshing algorithms can often produce thin or small triangles that can affect distribution quality of spawned instances. If this happens, use this property to filter them out. Note: this property is relative to LOD0. The generator will scale it when spawning instances on meshes of different LOD index.
VerticalAlignmentProperty
public float VerticalAlignment { get; set; }Sets how much instances will align with the ground.
If 0, they will completely align with the ground.
If 1, they will completely align with whichever direction is considered "up".
This depends on VoxelInstancer.UpMode.
VoxelTextureFilterArrayProperty
public int[] VoxelTextureFilterArray { get; set; }Specifies which voxel texture indices on top of which instances may spawn.
This only works when VoxelInstanceGenerator.VoxelTextureFilterEnabled is enabled, and VoxelMesherTransvoxel is used with VoxelMesherTransvoxel.TexturingMode set to VoxelMesherTransvoxel.TexturingModeEnum.Mixel4S4 or VoxelMesherTransvoxel.TexturingModeEnum.SingleS4. Indices are currently limited between 0 and 31 included.
VoxelTextureFilterEnabledProperty
public bool VoxelTextureFilterEnabled { get; set; }When true, enables filtering of instances based on voxel texture indices. See VoxelInstanceGenerator.VoxelTextureFilterArray.
VoxelTextureFilterThresholdProperty
public float VoxelTextureFilterThreshold { get; set; }When VoxelInstanceGenerator.VoxelTextureFilterEnabled is active, controls how much of filtered texture has to be present for instances to spawn. The value must be betweem 0 and 1.
Methods65
GetDensityfloat
public float GetDensity();floatGetEmitModeVoxelInstanceGenerator.EmitModeEnum
public VoxelInstanceGenerator.EmitModeEnum GetEmitMode();VoxelInstanceGenerator.EmitModeEnumGetJitterfloat
public float GetJitter();floatGetMaxHeightfloat
public float GetMaxHeight();floatGetMaxHeightFallofffloat
public float GetMaxHeightFalloff();floatGetMaxScalefloat
public float GetMaxScale();floatGetMaxSlopeDegreesfloat
public float GetMaxSlopeDegrees();floatGetMaxSlopeFalloffDegreesfloat
public float GetMaxSlopeFalloffDegrees();floatGetMinHeightfloat
public float GetMinHeight();floatGetMinHeightFallofffloat
public float GetMinHeightFalloff();floatGetMinScalefloat
public float GetMinScale();floatGetMinSlopeDegreesfloat
public float GetMinSlopeDegrees();floatGetMinSlopeFalloffDegreesfloat
public float GetMinSlopeFalloffDegrees();floatGetNoiseNoise
public Noise GetNoise();NoiseGetNoiseDimensionVoxelInstanceGenerator.Dimension
public VoxelInstanceGenerator.Dimension GetNoiseDimension();VoxelInstanceGenerator.DimensionGetNoiseFallofffloat
public float GetNoiseFalloff();floatGetNoiseGraphVoxelGraphFunction
public VoxelGraphFunction GetNoiseGraph();VoxelGraphFunctionGetNoiseOnScalefloat
public float GetNoiseOnScale();floatGetNoiseThresholdfloat
public float GetNoiseThreshold();floatGetOffsetAlongNormalfloat
public float GetOffsetAlongNormal();floatGetRandomRotationbool
public bool GetRandomRotation();boolGetRandomVerticalFlipbool
public bool GetRandomVerticalFlip();boolGetScaleDistributionVoxelInstanceGenerator.Distribution
public VoxelInstanceGenerator.Distribution GetScaleDistribution();VoxelInstanceGenerator.DistributionGetSnapToGeneratorSdfEnabledbool
public bool GetSnapToGeneratorSdfEnabled();boolGetSnapToGeneratorSdfSampleCountint
public int GetSnapToGeneratorSdfSampleCount();intGetSnapToGeneratorSdfSearchDistancefloat
public float GetSnapToGeneratorSdfSearchDistance();floatGetTriangleAreaThresholdfloat
public float GetTriangleAreaThreshold();floatGetVerticalAlignmentfloat
public float GetVerticalAlignment();floatGetVoxelTextureFilterArrayint[]
public int[] GetVoxelTextureFilterArray();int[]GetVoxelTextureFilterMaskuint
public uint GetVoxelTextureFilterMask();uintGetVoxelTextureFilterThresholdfloat
public float GetVoxelTextureFilterThreshold();floatIsVoxelTextureFilterEnabledbool
public bool IsVoxelTextureFilterEnabled();boolSetDensityvoid
public void SetDensity(float density);| Name | Type | Default |
|---|---|---|
density | float | — |
SetEmitModevoid
public void SetEmitMode(VoxelInstanceGenerator.EmitModeEnum density);| Name | Type | Default |
|---|---|---|
density | VoxelInstanceGenerator.EmitModeEnum | — |
SetJittervoid
public void SetJitter(float jitter);| Name | Type | Default |
|---|---|---|
jitter | float | — |
SetMaxHeightvoid
public void SetMaxHeight(float height);| Name | Type | Default |
|---|---|---|
height | float | — |
SetMaxHeightFalloffvoid
public void SetMaxHeightFalloff(float distance);| Name | Type | Default |
|---|---|---|
distance | float | — |
SetMaxScalevoid
public void SetMaxScale(float maxScale);| Name | Type | Default |
|---|---|---|
maxScale | float | — |
SetMaxSlopeDegreesvoid
public void SetMaxSlopeDegrees(float degrees);| Name | Type | Default |
|---|---|---|
degrees | float | — |
SetMaxSlopeFalloffDegreesvoid
public void SetMaxSlopeFalloffDegrees(float degrees);| Name | Type | Default |
|---|---|---|
degrees | float | — |
SetMinHeightvoid
public void SetMinHeight(float height);| Name | Type | Default |
|---|---|---|
height | float | — |
SetMinHeightFalloffvoid
public void SetMinHeightFalloff(float distance);| Name | Type | Default |
|---|---|---|
distance | float | — |
SetMinScalevoid
public void SetMinScale(float minScale);| Name | Type | Default |
|---|---|---|
minScale | float | — |
SetMinSlopeDegreesvoid
public void SetMinSlopeDegrees(float degrees);| Name | Type | Default |
|---|---|---|
degrees | float | — |
SetMinSlopeFalloffDegreesvoid
public void SetMinSlopeFalloffDegrees(float degrees);| Name | Type | Default |
|---|---|---|
degrees | float | — |
SetNoisevoid
public void SetNoise(Noise noise);| Name | Type | Default |
|---|---|---|
noise | Noise | — |
SetNoiseDimensionvoid
public void SetNoiseDimension(VoxelInstanceGenerator.Dimension dim);| Name | Type | Default |
|---|---|---|
dim | VoxelInstanceGenerator.Dimension | — |
SetNoiseFalloffvoid
public void SetNoiseFalloff(float falloff);| Name | Type | Default |
|---|---|---|
falloff | float | — |
SetNoiseGraphvoid
public void SetNoiseGraph(VoxelGraphFunction graph);| Name | Type | Default |
|---|---|---|
graph | VoxelGraphFunction | — |
SetNoiseOnScalevoid
public void SetNoiseOnScale(float amount);| Name | Type | Default |
|---|---|---|
amount | float | — |
SetNoiseThresholdvoid
public void SetNoiseThreshold(float threshold);| Name | Type | Default |
|---|---|---|
threshold | float | — |
SetOffsetAlongNormalvoid
public void SetOffsetAlongNormal(float offset);| Name | Type | Default |
|---|---|---|
offset | float | — |
SetRandomRotationvoid
public void SetRandomRotation(bool enabled);| Name | Type | Default |
|---|---|---|
enabled | bool | — |
SetRandomVerticalFlipvoid
public void SetRandomVerticalFlip(bool enabled);| Name | Type | Default |
|---|---|---|
enabled | bool | — |
SetScaleDistributionvoid
public void SetScaleDistribution(VoxelInstanceGenerator.Distribution distribution);| Name | Type | Default |
|---|---|---|
distribution | VoxelInstanceGenerator.Distribution | — |
SetSnapToGeneratorSdfEnabledvoid
public void SetSnapToGeneratorSdfEnabled(bool enabled);| Name | Type | Default |
|---|---|---|
enabled | bool | — |
SetSnapToGeneratorSdfSampleCountvoid
public void SetSnapToGeneratorSdfSampleCount(int enabled);| Name | Type | Default |
|---|---|---|
enabled | int | — |
SetSnapToGeneratorSdfSearchDistancevoid
public void SetSnapToGeneratorSdfSearchDistance(float d);| Name | Type | Default |
|---|---|---|
d | float | — |
SetTriangleAreaThresholdvoid
public void SetTriangleAreaThreshold(float threshold);| Name | Type | Default |
|---|---|---|
threshold | float | — |
SetVerticalAlignmentvoid
public void SetVerticalAlignment(float amount);| Name | Type | Default |
|---|---|---|
amount | float | — |
SetVoxelTextureFilterArray2 overloads
public void SetVoxelTextureFilterArray(int[] textureIndices);| Name | Type | Default |
|---|---|---|
textureIndices | int[] | — |
public void SetVoxelTextureFilterArray(ReadOnlySpan<int> textureIndices);| Name | Type | Default |
|---|---|---|
textureIndices | ReadOnlySpan<int> | — |
SetVoxelTextureFilterEnabledvoid
public void SetVoxelTextureFilterEnabled(bool enabled);| Name | Type | Default |
|---|---|---|
enabled | bool | — |
SetVoxelTextureFilterMaskvoid
public void SetVoxelTextureFilterMask(uint mask);| Name | Type | Default |
|---|---|---|
mask | uint | — |
SetVoxelTextureFilterThresholdvoid
public void SetVoxelTextureFilterThreshold(float threshold);| Name | Type | Default |
|---|---|---|
threshold | float | — |
VoxelInstanceGenerator.Dimension
| Value | Description |
|---|---|
Count = 2 | |
Dimension2D = 0 | |
Dimension3D = 1 |
VoxelInstanceGenerator.Distribution
| Value | Description |
|---|---|
Count = 4 | |
Cubic = 2 | Distribution with even more small items, and even fewer big ones. |
Linear = 0 | Uniform distribution. |
Quadratic = 1 | Distribution with more small items, and fewer big ones. |
Quintic = 3 |
VoxelInstanceGenerator.EmitModeEnum
| Value | Description |
|---|---|
FromFaces = 2 | Uses faces of the mesh to spawn instances. This is the slowest option, but should produce no noticeable patterns. |
FromFacesFast = 1 | Uses faces of the mesh to spawn instances. It is a balanced option with some shortcuts taken, without causing too noticeable patterns. |
FromVertices = 0 | Use vertices of the mesh to spawn instances. This is the fasted option, but can produce noticeable patterns. |
ModeCount = 4 | |
OnePerTriangle = 3 | Uses faces of the mesh to spawn instances (where faces are triangles). Only one instance is spawned per triangle. By default, it spawns in the middle of triangles. Randomness can be added to this position with |