+void GenerateEarthlike(Planet &p) noexcept {
+ rand::SimplexNoise elevation_gen(0);
+
+ constexpr int ice = 0;
+ constexpr int grass = 3;
+ constexpr int water = 4;
+ constexpr int sand = 5;
+ constexpr int rock = 8;
+
+ constexpr double water_thresh = 0.0;
+ constexpr double beach_thresh = 0.1;
+ constexpr double mountain_thresh = 0.5;
+
+ const glm::dvec3 axis(glm::dvec4(0.0, 1.0, 0.0, 0.0) * glm::eulerAngleXY(p.SurfaceTilt().x, p.SurfaceTilt().y));
+ const double cap_thresh = std::cos(p.AxialTilt().x);
+
+ for (int surface = 0; surface <= 5; ++surface) {
+ for (int y = 0; y < p.SideLength(); ++y) {
+ for (int x = 0; x < p.SideLength(); ++x) {
+ glm::dvec3 to_tile = p.TileCenter(surface, x, y);
+ double near_axis = std::abs(glm::dot(glm::normalize(to_tile), axis));
+ if (near_axis > cap_thresh) {
+ p.TileAt(surface, x, y).type = ice;
+ continue;
+ }
+ float elevation = rand::OctaveNoise(
+ elevation_gen,
+ to_tile / p.Radius(),
+ 3, // octaves
+ 0.5, // persistence
+ 2 / p.Radius(), // frequency
+ 2, // amplitude
+ 2 // growth
+ );
+ if (elevation < water_thresh) {
+ p.TileAt(surface, x, y).type = water;
+ } else if (elevation < beach_thresh) {
+ p.TileAt(surface, x, y).type = sand;
+ } else if (elevation < mountain_thresh) {
+ p.TileAt(surface, x, y).type = grass;
+ } else {
+ p.TileAt(surface, x, y).type = rock;
+ }
+ }
+ }
+ }
+ p.BuildVAOs();
+}
+
+void GenerateTest(Planet &p) noexcept {