Rescaled mountains

This commit is contained in:
Joshua Barretto 2019-06-09 19:46:30 +01:00
parent 581c4d0e3b
commit f62725135a
4 changed files with 17 additions and 15 deletions

View File

@ -61,10 +61,10 @@ impl<'a> Sampler for BlockGen<'a> {
let warp = (self.world.sim() let warp = (self.world.sim()
.gen_ctx .gen_ctx
.warp_nz .warp_nz
.get((wposf.div(Vec3::new(120.0, 120.0, 150.0))).into_array()) .get((wposf.div(Vec3::new(120.0, 120.0, 140.0))).into_array())
as f32) as f32)
.mul((chaos - 0.1).max(0.0)) .mul((chaos - 0.1).max(0.0))
.mul(110.0); .mul(100.0);
let height = alt + warp; let height = alt + warp;

View File

@ -121,7 +121,7 @@ impl<'a> Sampler for ColumnGen<'a> {
- marble * 24.0) - marble * 24.0)
/ 12.0, / 12.0,
), ),
(alt - CONFIG.sea_level - 0.15 * CONFIG.mountain_scale) / 180.0, (alt - CONFIG.sea_level - 0.2 * CONFIG.mountain_scale) / 180.0,
), ),
// Beach // Beach
(alt - CONFIG.sea_level - 2.0) / 5.0, (alt - CONFIG.sea_level - 2.0) / 5.0,

View File

@ -5,5 +5,5 @@ pub struct Config {
pub const CONFIG: Config = Config { pub const CONFIG: Config = Config {
sea_level: 128.0, sea_level: 128.0,
mountain_scale: 900.0, mountain_scale: 1200.0,
}; };

View File

@ -8,7 +8,10 @@ use common::{
terrain::TerrainChunkSize, terrain::TerrainChunkSize,
vol::VolSize, vol::VolSize,
}; };
use crate::util::StructureGen2d; use crate::{
CONFIG,
util::StructureGen2d,
};
pub const WORLD_SIZE: Vec2<usize> = Vec2 { x: 1024, y: 1024 }; pub const WORLD_SIZE: Vec2<usize> = Vec2 { x: 1024, y: 1024 };
@ -137,9 +140,6 @@ impl WorldSim {
} }
} }
pub const SEA_LEVEL: f32 = 128.0;
pub const MOUNTAIN_HEIGHT: f32 = 900.0;
const Z_TOLERANCE: (f32, f32) = (128.0, 64.0); const Z_TOLERANCE: (f32, f32) = (128.0, 64.0);
pub struct SimChunk { pub struct SimChunk {
@ -167,10 +167,10 @@ impl SimChunk {
.add(0.3) .add(0.3)
.max(0.0); .max(0.0);
let chaos = (gen_ctx.chaos_nz.get((wposf.div(2_000.0)).into_array()) as f32) let chaos = (gen_ctx.chaos_nz.get((wposf.div(5_000.0)).into_array()) as f32)
.add(1.0) .add(1.0)
.mul(0.5) .mul(0.5)
.powf(1.5) .powf(1.6)
.add(0.1 * hill); .add(0.1 * hill);
let chaos = chaos + chaos.mul(16.0).sin().mul(0.02); let chaos = chaos + chaos.mul(16.0).sin().mul(0.02);
@ -181,9 +181,11 @@ impl SimChunk {
.add(alt_base.mul(128.0).sin().mul(0.005)) .add(alt_base.mul(128.0).sin().mul(0.005))
.mul(800.0); .mul(800.0);
let alt_main = gen_ctx.alt_nz.get((wposf.div(3_000.0)).into_array()) as f32; let alt_main = (gen_ctx.alt_nz.get((wposf.div(2_000.0)).into_array()) as f32)
.abs()
.powf(1.4);
let alt = SEA_LEVEL let alt = CONFIG.sea_level
+ alt_base + alt_base
+ (0.0 + (0.0
+ alt_main + alt_main
@ -194,7 +196,7 @@ impl SimChunk {
.add(1.0) .add(1.0)
.mul(0.5) .mul(0.5)
.mul(chaos) .mul(chaos)
.mul(MOUNTAIN_HEIGHT); .mul(CONFIG.mountain_scale);
Self { Self {
chaos, chaos,
@ -210,7 +212,7 @@ impl SimChunk {
.mul(0.5) .mul(0.5)
.mul(1.0 - chaos * 0.85) .mul(1.0 - chaos * 0.85)
.add(0.1) .add(0.1)
.mul(if alt > SEA_LEVEL + 2.0 { 1.0 } else { 0.0 }), .mul(if alt > CONFIG.sea_level + 2.0 { 1.0 } else { 0.0 }),
} }
} }
@ -223,6 +225,6 @@ impl SimChunk {
} }
pub fn get_max_z(&self) -> f32 { pub fn get_max_z(&self) -> f32 {
(self.alt + Z_TOLERANCE.1).max(SEA_LEVEL + 1.0) (self.alt + Z_TOLERANCE.1).max(CONFIG.sea_level + 1.0)
} }
} }