+ float samples[5][5][5];
+};
+
+struct Parameters {
+ glm::ivec3 a;
+ glm::ivec3 b;
+ glm::ivec3 d;
+};
+
+struct Detail {
+ float humidity;
+ float temperature;
+ float richness;
+ float randomness;
+};
+
+}
+
+struct Generator::ValueField {
+
+ Interpolation solidity;
+ Interpolation humidity;
+ Interpolation temperature;
+ Interpolation richness;
+ Interpolation randomness;
+
+ static Parameters GetParams(const glm::ivec3 &pos) noexcept {
+ Parameters p;
+ p.a = pos / 4;
+ p.b = p.a + 1;
+ p.d = pos % 4;
+ return p;
+ }
+
+ static float Interpolate(const Interpolation &i, const Parameters &p) noexcept {
+ constexpr float A[4] = { 1.0f, 0.75f, 0.5f, 0.25f };
+ constexpr float B[4] = { 0.0f, 0.25f, 0.5f, 0.75f };
+ const float l1[4] = {
+ i.samples[p.a.z][p.a.y][p.a.x] * A[p.d.x] + i.samples[p.a.z][p.a.y][p.b.x] * B[p.d.x],
+ i.samples[p.a.z][p.b.y][p.a.x] * A[p.d.x] + i.samples[p.a.z][p.b.y][p.b.x] * B[p.d.x],
+ i.samples[p.b.z][p.a.y][p.a.x] * A[p.d.x] + i.samples[p.b.z][p.a.y][p.b.x] * B[p.d.x],
+ i.samples[p.b.z][p.b.y][p.a.x] * A[p.d.x] + i.samples[p.b.z][p.b.y][p.b.x] * B[p.d.x],
+ };
+ const float l2[2] = {
+ l1[0] * A[p.d.y] + l1[1] * B[p.d.y],
+ l1[2] * A[p.d.y] + l1[3] * B[p.d.y],
+ };
+ return l2[0] * A[p.d.z] + l2[1] * B[p.d.z];
+ }
+
+};
+
+void Generator::operator ()(Chunk &chunk) const noexcept {
+ ExactLocation::Fine coords(chunk.Position() * ExactLocation::Extent());
+ coords += 0.5f;
+ ValueField field {
+ { solidity_noise, coords, config.solidity },
+ { humidity_noise, coords, config.humidity },
+ { temperature_noise, coords, config.temperature },
+ { richness_noise, coords, config.richness },
+ { random_noise, coords, config.randomness },
+ };
+ for (int z = 0; z < Chunk::side; ++z) {
+ for (int y = 0; y < Chunk::side; ++y) {
+ for (int x = 0; x < Chunk::side; ++x) {
+ chunk.SetBlock(RoughLocation::Fine(x, y, z), Generate(field, RoughLocation::Fine(x, y, z)));