Better warping

This commit is contained in:
Joshua Barretto 2019-08-24 00:49:14 +01:00
parent b0293ecce4
commit aaade23eef
2 changed files with 12 additions and 10 deletions

View File

@ -171,9 +171,9 @@ impl<'a> BlockGen<'a> {
(true, alt, CONFIG.sea_level /*water_level*/)
} else {
// Apply warping
let warp = (world.sim().gen_ctx.warp_nz.get(wposf.div(16.0)) as f32)
let warp = (world.sim().gen_ctx.warp_nz.get(wposf.div(24.0)) as f32)
.mul((chaos - 0.1).max(0.0))
.mul(15.0);
.mul(30.0);
let height = if (wposf.z as f32) < alt + warp - 10.0 {
// Shortcut cliffs

View File

@ -23,14 +23,16 @@ impl Sampler<'static> for FastNoise {
type Sample = f32;
fn get(&self, pos: Self::Index) -> Self::Sample {
let v000 = self.noise_at(pos.map(|e| e.floor() as i32) + Vec3::new(0, 0, 0));
let v100 = self.noise_at(pos.map(|e| e.floor() as i32) + Vec3::new(1, 0, 0));
let v010 = self.noise_at(pos.map(|e| e.floor() as i32) + Vec3::new(0, 1, 0));
let v110 = self.noise_at(pos.map(|e| e.floor() as i32) + Vec3::new(1, 1, 0));
let v001 = self.noise_at(pos.map(|e| e.floor() as i32) + Vec3::new(0, 0, 1));
let v101 = self.noise_at(pos.map(|e| e.floor() as i32) + Vec3::new(1, 0, 1));
let v011 = self.noise_at(pos.map(|e| e.floor() as i32) + Vec3::new(0, 1, 1));
let v111 = self.noise_at(pos.map(|e| e.floor() as i32) + Vec3::new(1, 1, 1));
let near_pos = pos.map(|e| e.floor() as i32);
let v000 = self.noise_at(near_pos + Vec3::new(0, 0, 0));
let v100 = self.noise_at(near_pos + Vec3::new(1, 0, 0));
let v010 = self.noise_at(near_pos + Vec3::new(0, 1, 0));
let v110 = self.noise_at(near_pos + Vec3::new(1, 1, 0));
let v001 = self.noise_at(near_pos + Vec3::new(0, 0, 1));
let v101 = self.noise_at(near_pos + Vec3::new(1, 0, 1));
let v011 = self.noise_at(near_pos + Vec3::new(0, 1, 1));
let v111 = self.noise_at(near_pos + Vec3::new(1, 1, 1));
let factor = pos.map(|e| 0.5 - (e.fract() as f32 * f32::consts::PI).cos() * 0.5);