1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-09-30 19:22:14 +00:00

Add flags and lacunarity as new noise parameters

Add 'absolute value' option to noise map functions
Extend persistence modulation to 3D noise
Extend 'eased' option to noise2d_perlin* functions
Some noise.cpp formatting fixups
This commit is contained in:
kwolekr 2014-12-07 21:57:12 -05:00
parent 638f3a8454
commit 2fd3d52020
16 changed files with 306 additions and 214 deletions

View file

@ -28,6 +28,9 @@
#include "debug.h"
#include "irr_v3d.h"
#include "util/string.h"
extern FlagDesc flagdesc_noiseparams[];
class PseudoRandom
{
@ -66,6 +69,14 @@ private:
int m_next;
};
#define NOISE_FLAG_DEFAULTS 0x01
#define NOISE_FLAG_EASED 0x02
#define NOISE_FLAG_ABSVALUE 0x04
//// TODO(hmmmm): implement these!
#define NOISE_FLAG_POINTBUFFER 0x08
#define NOISE_FLAG_SIMPLEX 0x10
struct NoiseParams {
float offset;
float scale;
@ -73,20 +84,32 @@ struct NoiseParams {
s32 seed;
u16 octaves;
float persist;
bool eased;
float lacunarity;
u32 flags;
NoiseParams() {}
NoiseParams() {
offset = 0.0f;
scale = 1.0f;
spread = v3f(250, 250, 250);
seed = 12345;
octaves = 3;
persist = 0.6f;
lacunarity = 2.0f;
flags = NOISE_FLAG_DEFAULTS;
}
NoiseParams(float offset_, float scale_, v3f spread_,
int seed_, int octaves_, float persist_, bool eased_=false)
NoiseParams(float offset_, float scale_, v3f spread_, s32 seed_,
u16 octaves_, float persist_, float lacunarity_,
u32 flags_=NOISE_FLAG_DEFAULTS)
{
offset = offset_;
scale = scale_;
spread = spread_;
seed = seed_;
octaves = octaves_;
persist = persist_;
eased = eased_;
offset = offset_;
scale = scale_;
spread = spread_;
seed = seed_;
octaves = octaves_;
persist = persist_;
lacunarity = lacunarity_;
flags = flags_;
}
};
@ -123,10 +146,12 @@ public:
void gradientMap3D(
float x, float y, float z,
float step_x, float step_y, float step_z,
int seed, bool eased=false);
float *perlinMap2D(float x, float y);
float *perlinMap2DModulated(float x, float y, float *persist_map);
float *perlinMap3D(float x, float y, float z, bool eased=false);
int seed);
float *perlinMap2D(float x, float y, float *persistence_map=NULL);
float *perlinMap3D(float x, float y, float z, float *persistence_map=NULL);
void updateResults(float g, float *gmap, float *persistence_map, size_t bufsize);
void transformNoiseMap();
};
@ -134,14 +159,14 @@ public:
float noise2d(int x, int y, int seed);
float noise3d(int x, int y, int z, int seed);
float noise2d_gradient(float x, float y, int seed);
float noise2d_gradient(float x, float y, int seed, bool eased=true);
float noise3d_gradient(float x, float y, float z, int seed, bool eased=false);
float noise2d_perlin(float x, float y, int seed,
int octaves, float persistence);
int octaves, float persistence, bool eased=true);
float noise2d_perlin_abs(float x, float y, int seed,
int octaves, float persistence);
int octaves, float persistence, bool eased=true);
float noise3d_perlin(float x, float y, float z, int seed,
int octaves, float persistence, bool eased=false);