Rendu
A lightweight rendering engine for experimentations
Loading...
Searching...
No Matches
PerlinNoise.hpp
1#pragma once
2
3#include "resources/Texture.hpp"
4#include "Common.hpp"
5#include <array>
11
12public:
17
26 void generate(Image & image, uint channel, float scale, float z, const glm::vec3 & offset = glm::vec3(0.0f));
27
28
38 void generatePeriodic(Image & image, uint channel, float scale, float z, const glm::vec3 & offset = glm::vec3(0.0f));
39
50 void generateLayers(Image & image, uint channel, int octaves, float gain, float lacunarity, float scale, const glm::vec3 & offset = glm::vec3(0.0f));
51
53 void reseed();
54
55private:
56
57 static const int kHashTableSize = 256;
58
64 float dotGrad(const glm::ivec3 & ip, const glm::vec3 & dp);
65
71 float perlin(const glm::vec3 & p, const glm::ivec3 & w = glm::ivec3(kHashTableSize-1));
72
73 std::array<int, 2*kHashTableSize> _hashes;
75};
Represents an image composed of pixels with values in [0,1]. Provide image loading/saving utilities,...
Definition: Image.hpp:8
Generate 3D perlin noise and multi-layered noise.
Definition: PerlinNoise.hpp:10
PerlinNoise()
Definition: PerlinNoise.cpp:5
Image _directions
random unit sphere directions.
Definition: PerlinNoise.hpp:74
float perlin(const glm::vec3 &p, const glm::ivec3 &w=glm::ivec3(kHashTableSize-1))
Definition: PerlinNoise.cpp:75
void generateLayers(Image &image, uint channel, int octaves, float gain, float lacunarity, float scale, const glm::vec3 &offset=glm::vec3(0.0f))
Definition: PerlinNoise.cpp:32
std::array< int, 2 *kHashTableSize > _hashes
Permutation table.
Definition: PerlinNoise.hpp:73
void generate(Image &image, uint channel, float scale, float z, const glm::vec3 &offset=glm::vec3(0.0f))
Definition: PerlinNoise.cpp:9
float dotGrad(const glm::ivec3 &ip, const glm::vec3 &dp)
Definition: PerlinNoise.cpp:69
static const int kHashTableSize
Number of hashes used for the generation, limit the periodicity.
Definition: PerlinNoise.hpp:57
void generatePeriodic(Image &image, uint channel, float scale, float z, const glm::vec3 &offset=glm::vec3(0.0f))
Definition: PerlinNoise.cpp:19
void reseed()
Definition: PerlinNoise.cpp:47