Cliff height variety

This commit is contained in:
Joshua Barretto 2021-02-15 17:35:54 +00:00
parent 7b807ed34c
commit 660b297dd0
4 changed files with 11 additions and 7 deletions

View File

@ -127,7 +127,7 @@ impl<'a> BlockGen<'a> {
let col = Lerp::lerp(
col.map(|e| e as f32),
col.map(|e| e as f32) * 0.7,
(wposf.z as f32 - basement).div(2.0).sin() * 0.5 + 0.5,
(wposf.z as f32 - basement * 0.3).div(2.0).sin() * 0.5 + 0.5,
).map(|e| e as u8);
Some(Block::new(BlockKind::Rock, col))
}

View File

@ -701,7 +701,7 @@ fn walk_in_dir(sim: &WorldSim, a: Vec2<i32>, dir: Vec2<i32>) -> Option<f32> {
/// Return true if a position is suitable for walking on
fn loc_suitable_for_walking(sim: &WorldSim, loc: Vec2<i32>) -> bool {
if let Some(chunk) = sim.get(loc) {
!chunk.river.is_ocean() && !chunk.river.is_lake()
!chunk.river.is_ocean() && !chunk.river.is_lake() && !chunk.near_cliffs()
} else {
false
}

View File

@ -268,13 +268,13 @@ impl<'a> Sampler<'a> for ColumnGen<'a> {
// Cliffs
let cliff_factor = (alt
+ self.sim.gen_ctx.hill_nz.get(wposf.div(64.0).into_array()) as f32 * 8.0
+ self.sim.gen_ctx.hill_nz.get(wposf.div(256.0).into_array()) as f32 * 64.0)
.rem_euclid(128.0)
+ self.sim.gen_ctx.hill_nz.get(wposf.div(350.0).into_array()) as f32 * 128.0)
.rem_euclid(200.0)
/ 64.0
- 1.0;
let cliff_scale = ((self.sim.gen_ctx.hill_nz.get(wposf.div(128.0).into_array()) * 2.0 + 1.0)
+ self.sim.gen_ctx.hill_nz.get(wposf.div(48.0).into_array()) * 0.1)
.clamped(0.0, 1.0) as f32;
let cliff_scale = ((self.sim.gen_ctx.hill_nz.get(wposf.div(128.0).into_array()) as f32 * 1.5 + 0.75)
+ self.sim.gen_ctx.hill_nz.get(wposf.div(48.0).into_array()) as f32 * 0.1)
.clamped(0.0, 1.0).powf(2.0);
let cliff_height =
sim.get_interpolated(wpos, |chunk| chunk.cliff_height)? * cliff_scale;
let cliff = if cliff_factor < 0.0 {

View File

@ -2392,4 +2392,8 @@ impl SimChunk {
BiomeKind::Grassland
}
}
pub fn near_cliffs(&self) -> bool {
self.cliff_height > 0.0
}
}