VOX
A little voxel engine
Loading...
Searching...
No Matches
Perlin.hpp
Go to the documentation of this file.
1#pragma once
2
3#define GLM_FORCE_RADIANS
4#include <glm/vec2.hpp>
5#include <glm/vec3.hpp>
6#include <glm/common.hpp>
7#include <glm/geometric.hpp>
8#include <glm/trigonometric.hpp>
9
10
22class Perlin
23{
24public:
25
32 Perlin(unsigned int seed);
33
46 Perlin(
47 unsigned int seed,
48 int octaves,
49 float frequency,
50 float persistence,
51 float lacunarity);
52
59 float noise(const float & x) const;
60
67 float noise(const glm::vec2 & v) const;
68
75 float noise(const glm::vec3 & v) const;
76private:
77 unsigned int _seed;
78 int _octaves = 1;
79 float _frequency = 1;
80 float _persistence = 0.5;
81 float _lacunarity = 2.0;
82
83
84 float insideNoise(const glm::vec3 & v, const unsigned int & seed) const;
85 float interpolate(
86 const float & v1,
87 const float & v2,
88 const float & v3,
89 const float & v4,
90 const float & v5,
91 const float & v6,
92 const float & v7,
93 const float & v8,
94 const glm::vec3 & t) const;
95
103 unsigned int hash(unsigned int x, const unsigned int & seed) const;
104
112 unsigned int hash(const glm::uvec3 & v, const unsigned int & seed) const;
113
114 uint_fast8_t testHash(const glm::uvec3 & v, const unsigned int & seed) const;
122 glm::vec3 getHashedGradient(const glm::uvec3 & v, const unsigned int & seed) const;
123
131 glm::vec2 getAngleGradient(const glm::uvec2 & v, const unsigned int & seed) const;
132};
Perlin noise generator.
Definition: Perlin.hpp:23
float noise(const float &x) const
generate 1D Perlin noise in the range [-1, 1]
Definition: Perlin.cpp:213