Infinity Engine v0.6.20
C++ API Documentation
Loading...
Searching...
No Matches
Infinity::Types::Procedural::Noise Class Reference

Configurable procedural noise generator powered by FastNoise2. More...

#include <Noise.hpp>

Inheritance diagram for Infinity::Types::Procedural::Noise:
[legend]
Collaboration diagram for Infinity::Types::Procedural::Noise:
[legend]

Public Member Functions

 Noise ()
 Default constructor.
 
 Noise (const std::string &base64Encoded)
 Constructs a noise generator from a base64-encoded node graph.
 
 Noise (const Noise &other)
 Copy constructor.
 
 ~Noise ()
 Destructor.
 
std::unique_ptr< Core::Baseclone () const override
 
Noiseoperator= (const Noise &other)
 Copy assignment operator.
 
const Infinity::Types::TypeIDtypeId () const override
 Gets the TypeID for Noise.
 
void generate2D (float *out, int xSize, int ySize, int seed) const
 Generates 2D noise into a pre-allocated float array.
 
void generate3D (float *out, int xSize, int ySize, int zSize, int seed) const
 Generates 3D noise into a pre-allocated float array.
 
FastNoise::SmartNode & generator ()
 Gets a reference to the underlying FastNoise2 generator.
 
const FastNoise::SmartNode & generator () const
 Gets a const reference to the underlying FastNoise2 generator.
 
void setFromBase64Encoded (const std::string &encoded)
 Loads a noise configuration from base64-encoded string.
 
std::string base64Encoded () const
 Serializes the noise configuration to base64-encoded string.
 
- Public Member Functions inherited from Infinity::Types::Core::Data
 Data ()
 
 Data (const Data &other)
 
 Data (Data &&other)
 
Dataoperator= (const Data &other)
 
Dataoperator= (Data &&other)
 
virtual ~Data ()
 Virtual destructor.
 
bool hasProperty (const std::string &key) const
 
template<typename T >
void setProperty (const std::string &key, T &&value)
 Sets a typed property value.
 
template<typename T >
void setProperty (const std::string &key, const T &value)
 Sets a typed property value.
 
void setProperty (const std::string &key, PropertyValue &&value)
 Sets a typed property value.
 
const PropertyValuegetProperty (const std::string &key) const
 Gets a property value without type checking.
 
template<typename T >
const T & getProperty (const std::string &key) const
 Gets a typed property value.
 
void removeProperty (const std::string &key)
 
- Public Member Functions inherited from Infinity::Types::Core::Base
virtual ~Base ()
 Virtual destructor.
 
virtual std::istream & legibleDataRead (std::istream &in) override
 Deserializes the object from a single-line text representation.
 
virtual std::ostream & legibleDataWrite (std::ostream &out) const override
 Serializes the object to a single-line text representation.
 

Public Attributes

Math::Vector3 position
 Offset position for noise sampling.
 
float frequency = 0.02f
 Base frequency for noise generation.
 
- Public Attributes inherited from Infinity::Types::Core::Data
std::unordered_map< std::string, PropertyValueproperties
 Property storage for arbitrary metadata.
 

Detailed Description

Configurable procedural noise generator powered by FastNoise2.

Noise provides an interface to FastNoise2's node-based noise generation system, encapsulating a complete noise graph that can generate coherent pseudo-random values in 2D and 3D space. The noise configuration is created using the embedded FastNoiseTool interface in the Infinity Creator and stored as base64-encoded strings.

FastNoise2 supports a wide variety of noise algorithms and operations:

  • Basic noise types: Perlin, Simplex, OpenSimplex2, Cellular (Worley), Value, etc.
  • Fractal operations: FBM (Fractal Brownian Motion), Ridged, PingPong
  • Domain warping for organic distortion effects
  • Mathematical operations: Add, Multiply, Min, Max, Fade, etc.
  • Modifiers: Curve, Terrace, Remap ranges

Noise configurations are created visually in the Infinity Creator and exported as base64-encoded node graphs, enabling:

  • Visual noise design without code
  • Preset creation and reuse
  • Real-time preview while editing
  • Version control of noise configurations
  • Easy sharing of noise setups

Common use cases in procedural generation:

  • Terrain heightmap generation
  • Biome distribution and blending
  • Texture synthesis and detail maps
  • Density fields for volumetric generation
  • Cave and cavern systems
  • Cloud and atmospheric effects
  • Procedural material variation
  • Grass and foliage distribution masks
Note
Noise graphs are configured in the Infinity Creator's FastNoiseTool interface.
The position and frequency fields provide convenient defaults for generation.
Noise is deterministic - same seed and coordinates always produce the same values.
Generated values typically range from -1 to 1 but can vary based on node configuration.

Example usage:

// Create noise from Infinity Creator export
// (The base64 string is copied from the Creator's noise editor)
std::string terrainConfig = "base64_encoded_fastnoise_graph...";
Noise terrain(terrainConfig);
terrain.frequency = 0.01f; // Large-scale features
terrain.position = Vector3{0.0f, 0.0f, 0.0f};
// Generate 2D heightmap
Array2D<float> heightmap(512, 512);
terrain.generate2D(heightmap.data(), 512, 512, worldSeed);
// Generate 3D density field for caves
std::string caveConfig = "base64_encoded_cave_noise...";
Noise caves(caveConfig);
caves.frequency = 0.05f;
Array3D<float> density(64, 64, 64);
caves.generate3D(density.data(), 64, 64, 64, worldSeed);
// Use with ProceduralSystem
system->setIn("terrain_noise", std::move(terrain));
// Create layered biome noise from Creator presets
Noise temperature("temperature_noise_config...");
Noise humidity("humidity_noise_config...");
Noise elevation("elevation_noise_config...");
// Sample all three for biome determination
for (int x = 0; x < width; ++x) {
for (int z = 0; z < depth; ++z) {
float temp = sampleNoise2D(temperature, x, z);
float humid = sampleNoise2D(humidity, x, z);
float elev = sampleNoise2D(elevation, x, z);
Biome biome = selectBiome(temp, humid, elev);
}
}
Configurable procedural noise generator powered by FastNoise2.
Definition Noise.hpp:97

Constructor & Destructor Documentation

◆ Noise() [1/3]

Infinity::Types::Procedural::Noise::Noise ( )

Default constructor.

Creates an empty noise generator. You must configure the generator by calling setFromBase64Encoded() with a configuration exported from the Infinity Creator.

◆ Noise() [2/3]

Infinity::Types::Procedural::Noise::Noise ( const std::string &  base64Encoded)

Constructs a noise generator from a base64-encoded node graph.

Deserializes a FastNoise2 node graph from base64 encoding exported from the Infinity Creator's FastNoiseTool interface.

Parameters
base64EncodedBase64-encoded FastNoise2 node graph string.
// String exported from Infinity Creator
std::string config = "base64_encoded_config...";
Noise noise(config);

◆ Noise() [3/3]

Infinity::Types::Procedural::Noise::Noise ( const Noise other)

Copy constructor.

Creates a deep copy of the noise generator, including the complete node graph configuration.

Parameters
otherNoise generator to copy from.

◆ ~Noise()

Infinity::Types::Procedural::Noise::~Noise ( )

Destructor.

Member Function Documentation

◆ base64Encoded()

std::string Infinity::Types::Procedural::Noise::base64Encoded ( ) const

Serializes the noise configuration to base64-encoded string.

Exports the complete FastNoise2 node graph as a base64-encoded string. This can be saved and later loaded back into the Infinity Creator or used to recreate the same noise configuration.

Returns
Base64-encoded FastNoise2 node graph string.
Noise noise("config...");
std::string config = noise.base64Encoded();
// Save config for later use or version control

◆ clone()

std::unique_ptr< Core::Base > Infinity::Types::Procedural::Noise::clone ( ) const
overridevirtual

Reimplemented from Infinity::Types::Core::Data.

◆ generate2D()

void Infinity::Types::Procedural::Noise::generate2D ( float *  out,
int  xSize,
int  ySize,
int  seed 
) const

Generates 2D noise into a pre-allocated float array.

Fills the output array with noise values sampled across a 2D grid. Uses the stored position offset and frequency for sampling.

Parameters
outOutput array of size xSize * ySize (row-major order).
xSizeWidth of the output grid.
ySizeHeight of the output grid.
seedRandom seed for deterministic generation.
Note
Output values typically range from -1 to 1 depending on noise configuration.
The array is indexed as: out[y * xSize + x]
Noise terrain("base64_encoded_config...");
Array2D<float> heightmap(512, 512);
terrain.generate2D(heightmap.data(), 512, 512, 12345);

◆ generate3D()

void Infinity::Types::Procedural::Noise::generate3D ( float *  out,
int  xSize,
int  ySize,
int  zSize,
int  seed 
) const

Generates 3D noise into a pre-allocated float array.

Fills the output array with noise values sampled across a 3D grid. Uses the stored position offset and frequency for sampling.

Parameters
outOutput array of size xSize * ySize * zSize.
xSizeWidth of the output grid (X dimension).
ySizeHeight of the output grid (Y dimension).
zSizeDepth of the output grid (Z dimension).
seedRandom seed for deterministic generation.
Note
Output values typically range from -1 to 1 depending on noise configuration.
The array is indexed as: out[(z * ySize + y) * xSize + x]
Noise density("base64_encoded_config...");
Array3D<float> volume(64, 64, 64);
density.generate3D(volume.data(), 64, 64, 64, 54321);

◆ generator() [1/2]

FastNoise::SmartNode & Infinity::Types::Procedural::Noise::generator ( )

Gets a reference to the underlying FastNoise2 generator.

Provides access to the FastNoise2 SmartNode for advanced usage with FastNoise2's API. This allows direct use of FastNoise2's comprehensive generation methods beyond the convenience functions provided by this class.

Returns
Reference to the FastNoise2 smart node.
Note
The noise graph structure cannot be modified through this interface.
Most users will not need to use this - the generate2D/3D methods cover typical use cases.
To change the noise configuration, use setFromBase64Encoded() with a new export from the Infinity Creator.
Noise noise("base64_config...");
const auto& gen = noise.generator();
// Use FastNoise2's API directly for custom generation patterns
std::vector<float> output(1024);
gen->GenUniformGrid2D(output.data(), 0, 0, 32, 32, 0.02f, 12345);

◆ generator() [2/2]

const FastNoise::SmartNode & Infinity::Types::Procedural::Noise::generator ( ) const

Gets a const reference to the underlying FastNoise2 generator.

Returns
Const reference to the FastNoise2 smart node.

◆ operator=()

Noise & Infinity::Types::Procedural::Noise::operator= ( const Noise other)

Copy assignment operator.

Parameters
otherNoise generator to copy from.
Returns
Reference to this noise generator.

◆ setFromBase64Encoded()

void Infinity::Types::Procedural::Noise::setFromBase64Encoded ( const std::string &  encoded)

Loads a noise configuration from base64-encoded string.

Deserializes and sets the noise generator from a base64-encoded FastNoise2 node graph exported from the Infinity Creator. This is the primary method for configuring the noise generator.

Parameters
encodedBase64-encoded FastNoise2 node graph string.
Noise noise;
std::string preset = "base64_from_infinity_creator...";
noise.setFromBase64Encoded(preset);
void setFromBase64Encoded(const std::string &encoded)
Loads a noise configuration from base64-encoded string.

◆ typeId()

const Infinity::Types::TypeID & Infinity::Types::Procedural::Noise::typeId ( ) const
overridevirtual

Gets the TypeID for Noise.

Returns
TypeID identifying this Noise type.

Reimplemented from Infinity::Types::Core::Data.

Member Data Documentation

◆ frequency

float Infinity::Types::Procedural::Noise::frequency = 0.02f

Base frequency for noise generation.

Controls the scale of noise features - lower values create larger, broader features; higher values create smaller, more detailed features. This is a multiplier applied to input coordinates.

Typical values:

  • 0.001 - 0.01: Large-scale terrain features (mountains, valleys)
  • 0.01 - 0.05: Medium-scale features (hills, biome transitions)
  • 0.05 - 0.2: Small-scale details (rocks, texture variation)

Default: 0.02f

Note
This is applied before FastNoise2 node processing.

◆ position

Math::Vector3 Infinity::Types::Procedural::Noise::position

Offset position for noise sampling.

3D offset applied to sampling coordinates, allowing the same noise configuration to generate different regions. Useful for:

  • Tiling noise patterns with offsets
  • Sampling different regions of the same noise
  • Animation by varying position over time

Default: (0, 0, 0) - no offset