From 61dda0ea8ccdf3145abcca57b75f7df40aa46e12 Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Thu, 6 Jun 2019 15:52:29 +0100 Subject: [PATCH 01/30] Separated sampler code from simulation code --- world/src/lib.rs | 12 +- world/src/sampler.rs | 567 +++++++++++++++++++++++++++++++++++++++++ world/src/sim.rs | 583 ++----------------------------------------- 3 files changed, 595 insertions(+), 567 deletions(-) create mode 100644 world/src/sampler.rs diff --git a/world/src/lib.rs b/world/src/lib.rs index f041fef15e..6976adee1f 100644 --- a/world/src/lib.rs +++ b/world/src/lib.rs @@ -1,6 +1,7 @@ #![feature(euclidean_division)] mod sim; +mod sampler; mod structure; use common::{ @@ -79,12 +80,11 @@ impl World { let wpos = lpos + Vec3::from(chunk_pos) * TerrainChunkSize::SIZE.map(|e| e as i32); - let sim::Sample3d { block } = - if let Some(sample) = world_sampler.sample_3d(wpos) { - sample - } else { - continue; - }; + let block = if let Some(sample) = world_sampler.sample_3d(wpos) { + sample.block + } else { + continue; + }; let _ = chunk.set(lpos, block); } diff --git a/world/src/sampler.rs b/world/src/sampler.rs new file mode 100644 index 0000000000..ca3ac037cf --- /dev/null +++ b/world/src/sampler.rs @@ -0,0 +1,567 @@ +use std::{ + ops::{Add, Div, Mul, Neg, Sub}, + sync::Arc, +}; +use vek::*; +use lazy_static::lazy_static; +use noise::NoiseFn; +use common::{ + assets, + terrain::{Block, Structure}, + vol::{ReadVol, VolSize, Vox}, +}; +use crate::{ + structure::StructureGen2d, + sim::{ + GenCtx, + WorldSim, + SEA_LEVEL, + MOUNTAIN_HEIGHT, + }, + Cache, +}; + +pub struct Sampler<'a> { + sim: &'a WorldSim, + sample2d_cache: Cache, Option>, +} + +impl<'a> Sampler<'a> { + pub(crate) fn new(sim: &'a WorldSim) -> Self { + Self { + sim, + sample2d_cache: Cache::with_capacity(1024), + } + } + + fn sample_2d_impl(sim: &WorldSim, wpos: Vec2) -> Option { + let wposf = wpos.map(|e| e as f64); + + let alt_base = sim.get_interpolated(wpos, |chunk| chunk.alt_base)?; + let chaos = sim.get_interpolated(wpos, |chunk| chunk.chaos)?; + let temp = sim.get_interpolated(wpos, |chunk| chunk.temp)?; + let rockiness = sim.get_interpolated(wpos, |chunk| chunk.rockiness)?; + let tree_density = sim.get_interpolated(wpos, |chunk| chunk.tree_density)?; + + let rock = (sim.gen_ctx.small_nz.get((wposf.div(100.0)).into_array()) as f32) + .mul(rockiness) + .sub(0.35) + .max(0.0) + .mul(6.0); + + let alt = sim.get_interpolated(wpos, |chunk| chunk.alt)? + + sim.gen_ctx.small_nz.get((wposf.div(256.0)).into_array()) as f32 + * chaos.max(0.2) + * 64.0; + + let wposf3d = Vec3::new(wposf.x, wposf.y, alt as f64); + + let marble = (sim.gen_ctx.hill_nz.get((wposf3d.div(48.0)).into_array()) as f32) + .add(1.0) + .mul(0.5); + + // Colours + let cold_grass = Rgb::new(0.0, 0.55, 0.15); + let warm_grass = Rgb::new(0.25, 0.8, 0.05); + let cold_stone = Rgb::new(0.55, 0.7, 0.75); + let warm_stone = Rgb::new(0.65, 0.65, 0.35); + let beach_sand = Rgb::new(0.93, 0.84, 0.33); + let desert_sand = Rgb::new(0.97, 0.84, 0.23); + let snow = Rgb::broadcast(1.0); + + let grass = Rgb::lerp(cold_grass, warm_grass, marble); + let grassland = grass; //Rgb::lerp(grass, warm_stone, rock.mul(5.0).min(0.8)); + let cliff = Rgb::lerp(cold_stone, warm_stone, marble); + + let ground = Rgb::lerp( + Rgb::lerp(snow, grassland, temp.add(0.4).mul(32.0).sub(0.4)), + desert_sand, + temp.sub(0.4).mul(32.0).add(0.4), + ); + + // Caves + let cave_at = |wposf: Vec2| { + (sim.gen_ctx.cave_0_nz.get( + Vec3::new(wposf.x, wposf.y, alt as f64 * 8.0) + .div(800.0) + .into_array(), + ) as f32) + .powf(2.0) + .neg() + .add(1.0) + .mul((1.15 - chaos).min(1.0)) + }; + let cave_xy = cave_at(wposf); + let cave_alt = alt - 32.0 + + (sim + .gen_ctx + .cave_1_nz + .get(Vec2::new(wposf.x, wposf.y).div(48.0).into_array()) as f32) + * 8.0 + + (sim + .gen_ctx + .cave_1_nz + .get(Vec2::new(wposf.x, wposf.y).div(300.0).into_array()) as f32) + .add(1.0) + .mul(0.5) + .powf(8.0) + .mul(256.0); + + Some(Sample2d { + alt, + chaos, + surface_color: Rgb::lerp( + beach_sand, + // Land + Rgb::lerp( + ground, + // Mountain + Rgb::lerp( + cliff, + snow, + (alt - SEA_LEVEL + - 0.3 * MOUNTAIN_HEIGHT + - alt_base + - temp * 96.0 + - marble * 24.0) + / 12.0, + ), + (alt - SEA_LEVEL - 0.15 * MOUNTAIN_HEIGHT) / 180.0, + ), + // Beach + (alt - SEA_LEVEL - 2.0) / 5.0, + ), + tree_density, + close_trees: sim.tree_gen.sample(wpos), + cave_xy, + cave_alt, + rock, + }) + } + + pub fn sample_2d(&mut self, wpos2d: Vec2) -> Option<&Sample2d> { + let sim = &self.sim; + self.sample2d_cache + .get(wpos2d, |wpos2d| Self::sample_2d_impl(sim, wpos2d)) + .as_ref() + } + + pub fn sample_3d(&mut self, wpos: Vec3) -> Option { + let wpos2d = Vec2::from(wpos); + let wposf = wpos.map(|e| e as f64); + + // Sample 2D terrain attributes + + let Sample2d { + alt, + chaos, + surface_color, + tree_density, + close_trees, + cave_xy, + cave_alt, + rock, + } = *self.sample_2d(wpos2d)?; + + // Apply warping + + let warp = (self + .sim + .gen_ctx + .warp_nz + .get((wposf.div(Vec3::new(120.0, 120.0, 150.0))).into_array()) + as f32) + .mul((chaos - 0.1).max(0.0)) + .mul(110.0); + + let height = alt + warp; + + // Sample blocks + + let air = Block::empty(); + let stone = Block::new(2, Rgb::new(200, 220, 255)); + let dirt = Block::new(1, Rgb::new(128, 90, 0)); + let sand = Block::new(1, Rgb::new(180, 150, 50)); + let water = Block::new(1, Rgb::new(100, 150, 255)); + let warm_stone = Block::new(1, Rgb::new(165, 165, 90)); + + let block = if (wposf.z as f32) < height - 4.0 { + // Underground + Some(stone) + } else if (wposf.z as f32) < height { + // Surface + Some(Block::new(1, surface_color.map(|e| (e * 255.0) as u8))) + } else if (wposf.z as f32) < SEA_LEVEL { + // Ocean + Some(water) + } else { + None + }; + + // Caves + let block = block.and_then(|block| { + // Underground + let cave = cave_xy.powf(2.0) + * (wposf.z as f32 - cave_alt) + .div(40.0) + .powf(4.0) + .neg() + .add(1.0) + > 0.9993; + + if cave { + None + } else { + Some(block) + } + }); + + // Rocks + let block = block.or_else(|| { + if (height + 2.5 - wposf.z as f32).div(7.5).abs().powf(2.0) < rock { + Some(warm_stone) + } else { + None + } + }); + + let block = match block { + Some(block) => block, + None => (&close_trees) + .iter() + .fold(air, |block, (tree_pos, tree_seed)| { + match self.sample_2d(*tree_pos) { + Some(tree_sample) + if tree_sample.tree_density + > 0.5 + (*tree_seed as f32 / 1000.0).fract() * 0.2 => + { + let tree_pos3d = + Vec3::new(tree_pos.x, tree_pos.y, tree_sample.alt as i32); + let rpos = wpos - tree_pos3d; + block.or(TREES[*tree_seed as usize % TREES.len()] + .get((rpos * 160) / 128) // Scaling + .map(|b| b.clone()) + .unwrap_or(Block::empty())) + } + _ => block, + } + }), + }; + + Some(Sample3d { block }) + } +} + +#[derive(Copy, Clone)] +pub struct Sample2d { + pub alt: f32, + pub chaos: f32, + pub surface_color: Rgb, + pub tree_density: f32, + pub close_trees: [(Vec2, u32); 9], + pub cave_xy: f32, + pub cave_alt: f32, + pub rock: f32, +} + +#[derive(Copy, Clone)] +pub struct Sample3d { + pub block: Block, +} + +lazy_static! { + static ref TREES: [Arc; 61] = [ + // green oaks + assets::load_map("world/tree/oak_green/1.vox", |s: Structure| s + .with_center(Vec3::new(15, 18, 14))) + .unwrap(), + assets::load_map("world/tree/oak_green/2.vox", |s: Structure| s + .with_center(Vec3::new(15, 18, 14))) + .unwrap(), + assets::load_map("world/tree/oak_green/3.vox", |s: Structure| s + .with_center(Vec3::new(16, 20, 14))) + .unwrap(), + assets::load_map("world/tree/oak_green/4.vox", |s: Structure| s + .with_center(Vec3::new(18, 21, 14))) + .unwrap(), + assets::load_map("world/tree/oak_green/5.vox", |s: Structure| s + .with_center(Vec3::new(18, 18, 14))) + .unwrap(), + assets::load_map("world/tree/oak_green/6.vox", |s: Structure| s + .with_center(Vec3::new(16, 21, 14))) + .unwrap(), + assets::load_map("world/tree/oak_green/7.vox", |s: Structure| s + .with_center(Vec3::new(20, 19, 14))) + .unwrap(), + assets::load_map("world/tree/oak_green/8.vox", |s: Structure| s + .with_center(Vec3::new(22, 20, 14))) + .unwrap(), + assets::load_map("world/tree/oak_green/9.vox", |s: Structure| s + .with_center(Vec3::new(26, 26, 14))) + .unwrap(), + // green pines + assets::load_map("world/tree/pine_green/1.vox", |s: Structure| s + .with_center(Vec3::new(15, 15, 14))) + .unwrap(), + assets::load_map("world/tree/pine_green/2.vox", |s: Structure| s + .with_center(Vec3::new(15, 15, 14))) + .unwrap(), + assets::load_map("world/tree/pine_green/3.vox", |s: Structure| s + .with_center(Vec3::new(17, 15, 12))) + .unwrap(), + assets::load_map("world/tree/pine_green/4.vox", |s: Structure| s + .with_center(Vec3::new(10, 8, 12))) + .unwrap(), + assets::load_map("world/tree/pine_green/5.vox", |s: Structure| s + .with_center(Vec3::new(12, 12, 12))) + .unwrap(), + assets::load_map("world/tree/pine_green/6.vox", |s: Structure| s + .with_center(Vec3::new(11, 10, 12))) + .unwrap(), + assets::load_map("world/tree/pine_green/7.vox", |s: Structure| s + .with_center(Vec3::new(16, 15, 12))) + .unwrap(), + assets::load_map("world/tree/pine_green/8.vox", |s: Structure| s + .with_center(Vec3::new(12, 10, 12))) + .unwrap(), + // green pines 2 + assets::load_map("world/tree/pine_green_2/1.vox", |s: Structure| s + .with_center(Vec3::new(15, 15, 14))) + .unwrap(), + assets::load_map("world/tree/pine_green_2/2.vox", |s: Structure| s + .with_center(Vec3::new(15, 15, 14))) + .unwrap(), + assets::load_map("world/tree/pine_green_2/3.vox", |s: Structure| s + .with_center(Vec3::new(17, 15, 12))) + .unwrap(), + assets::load_map("world/tree/pine_green_2/4.vox", |s: Structure| s + .with_center(Vec3::new(10, 8, 12))) + .unwrap(), + assets::load_map("world/tree/pine_green_2/5.vox", |s: Structure| s + .with_center(Vec3::new(12, 12, 12))) + .unwrap(), + assets::load_map("world/tree/pine_green_2/6.vox", |s: Structure| s + .with_center(Vec3::new(11, 10, 12))) + .unwrap(), + assets::load_map("world/tree/pine_green_2/7.vox", |s: Structure| s + .with_center(Vec3::new(16, 15, 12))) + .unwrap(), + assets::load_map("world/tree/pine_green_2/8.vox", |s: Structure| s + .with_center(Vec3::new(12, 10, 12))) + .unwrap(), + // blue pines + assets::load_map("world/tree/pine_blue/1.vox", |s: Structure| s + .with_center(Vec3::new(15, 15, 14))) + .unwrap(), + assets::load_map("world/tree/pine_blue/2.vox", |s: Structure| s + .with_center(Vec3::new(15, 15, 14))) + .unwrap(), + assets::load_map("world/tree/pine_blue/3.vox", |s: Structure| s + .with_center(Vec3::new(17, 15, 12))) + .unwrap(), + assets::load_map("world/tree/pine_blue/4.vox", |s: Structure| s + .with_center(Vec3::new(10, 8, 12))) + .unwrap(), + assets::load_map("world/tree/pine_blue/5.vox", |s: Structure| s + .with_center(Vec3::new(12, 12, 12))) + .unwrap(), + assets::load_map("world/tree/pine_blue/6.vox", |s: Structure| s + .with_center(Vec3::new(11, 10, 12))) + .unwrap(), + assets::load_map("world/tree/pine_blue/7.vox", |s: Structure| s + .with_center(Vec3::new(16, 15, 12))) + .unwrap(), + assets::load_map("world/tree/pine_blue/8.vox", |s: Structure| s + .with_center(Vec3::new(12, 10, 12))) + .unwrap(), + // temperate small + assets::load_map("world/tree/temperate_small/1.vox", |s: Structure| s + .with_center(Vec3::new(4, 4, 7))) + .unwrap(), + assets::load_map("world/tree/temperate_small/2.vox", |s: Structure| s + .with_center(Vec3::new(4, 4, 7))) + .unwrap(), + assets::load_map("world/tree/temperate_small/3.vox", |s: Structure| s + .with_center(Vec3::new(4, 4, 7))) + .unwrap(), + assets::load_map("world/tree/temperate_small/4.vox", |s: Structure| s + .with_center(Vec3::new(4, 4, 7))) + .unwrap(), + assets::load_map("world/tree/temperate_small/5.vox", |s: Structure| s + .with_center(Vec3::new(4, 4, 7))) + .unwrap(), + assets::load_map("world/tree/temperate_small/6.vox", |s: Structure| s + .with_center(Vec3::new(4, 4, 7))) + .unwrap(), + // birch + assets::load_map("world/tree/birch/1.vox", |s: Structure| s + .with_center(Vec3::new(12, 9, 5))) + .unwrap(), + assets::load_map("world/tree/birch/2.vox", |s: Structure| s + .with_center(Vec3::new(11, 10, 5))) + .unwrap(), + assets::load_map("world/tree/birch/3.vox", |s: Structure| s + .with_center(Vec3::new(9, 10, 5))) + .unwrap(), + assets::load_map("world/tree/birch/4.vox", |s: Structure| s + .with_center(Vec3::new(9, 10, 5))) + .unwrap(), + assets::load_map("world/tree/birch/5.vox", |s: Structure| s + .with_center(Vec3::new(9, 11, 5))) + .unwrap(), + assets::load_map("world/tree/birch/6.vox", |s: Structure| s + .with_center(Vec3::new(9, 9, 5))) + .unwrap(), + assets::load_map("world/tree/birch/7.vox", |s: Structure| s + .with_center(Vec3::new(10, 10, 5))) + .unwrap(), + assets::load_map("world/tree/birch/8.vox", |s: Structure| s + .with_center(Vec3::new(9, 9, 5))) + .unwrap(), + assets::load_map("world/tree/birch/9.vox", |s: Structure| s + .with_center(Vec3::new(9, 10, 5))) + .unwrap(), + assets::load_map("world/tree/birch/10.vox", |s: Structure| s + .with_center(Vec3::new(10, 9, 5))) + .unwrap(), + assets::load_map("world/tree/birch/11.vox", |s: Structure| s + .with_center(Vec3::new(9, 10, 5))) + .unwrap(), + assets::load_map("world/tree/birch/12.vox", |s: Structure| s + .with_center(Vec3::new(10, 9, 5))) + .unwrap(), + // poplar + assets::load_map("world/tree/poplar/1.vox", |s: Structure| s + .with_center(Vec3::new(6, 6, 10))) + .unwrap(), + assets::load_map("world/tree/poplar/2.vox", |s: Structure| s + .with_center(Vec3::new(6, 6, 10))) + .unwrap(), + assets::load_map("world/tree/poplar/3.vox", |s: Structure| s + .with_center(Vec3::new(6, 6, 10))) + .unwrap(), + assets::load_map("world/tree/poplar/4.vox", |s: Structure| s + .with_center(Vec3::new(6, 6, 10))) + .unwrap(), + assets::load_map("world/tree/poplar/5.vox", |s: Structure| s + .with_center(Vec3::new(6, 6, 10))) + .unwrap(), + assets::load_map("world/tree/poplar/6.vox", |s: Structure| s + .with_center(Vec3::new(6, 6, 10))) + .unwrap(), + assets::load_map("world/tree/poplar/7.vox", |s: Structure| s + .with_center(Vec3::new(6, 6, 10))) + .unwrap(), + assets::load_map("world/tree/poplar/8.vox", |s: Structure| s + .with_center(Vec3::new(6, 6, 10))) + .unwrap(), + assets::load_map("world/tree/poplar/9.vox", |s: Structure| s + .with_center(Vec3::new(6, 6, 10))) + .unwrap(), + assets::load_map("world/tree/poplar/10.vox", |s: Structure| s + .with_center(Vec3::new(7, 7, 10))) + .unwrap(), + // palm trees + /*assets::load_map("world/tree/desert_palm/1.vox", |s: Structure| s + .with_center(Vec3::new(12, 12, 10))) + .unwrap(), + assets::load_map("world/tree/desert_palm/2.vox", |s: Structure| s + .with_center(Vec3::new(12, 10, 10))) + .unwrap(), + assets::load_map("world/tree/desert_palm/3.vox", |s: Structure| s + .with_center(Vec3::new(12, 12, 10))) + .unwrap(), + assets::load_map("world/tree/desert_palm/4.vox", |s: Structure| s + .with_center(Vec3::new(10, 10, 10))) + .unwrap(), + assets::load_map("world/tree/desert_palm/5.vox", |s: Structure| s + .with_center(Vec3::new(10, 10, 10))) + .unwrap(), + assets::load_map("world/tree/desert_palm/6.vox", |s: Structure| s + .with_center(Vec3::new(10, 10, 10))) + .unwrap(), + assets::load_map("world/tree/desert_palm/7.vox", |s: Structure| s + .with_center(Vec3::new(10, 10, 10))) + .unwrap(), + assets::load_map("world/tree/desert_palm/8.vox", |s: Structure| s + .with_center(Vec3::new(10, 10, 10))) + .unwrap(), + assets::load_map("world/tree/desert_palm/9.vox", |s: Structure| s + .with_center(Vec3::new(10, 10, 10))) + .unwrap(), + assets::load_map("world/tree/desert_palm/10.vox", |s: Structure| s + .with_center(Vec3::new(10, 10, 10))) + .unwrap(), + // snow pines + assets::load_map("world/tree/snow_pine/1.vox", |s: Structure| s + .with_center(Vec3::new(15, 15, 14))) + .unwrap(), + assets::load_map("world/tree/snow_pine/2.vox", |s: Structure| s + .with_center(Vec3::new(15, 15, 14))) + .unwrap(), + assets::load_map("world/tree/snow_pine/3.vox", |s: Structure| s + .with_center(Vec3::new(17, 15, 12))) + .unwrap(), + assets::load_map("world/tree/snow_pine/4.vox", |s: Structure| s + .with_center(Vec3::new(10, 8, 12))) + .unwrap(), + assets::load_map("world/tree/snow_pine/5.vox", |s: Structure| s + .with_center(Vec3::new(12, 12, 12))) + .unwrap(), + assets::load_map("world/tree/snow_pine/6.vox", |s: Structure| s + .with_center(Vec3::new(11, 10, 12))) + .unwrap(), + assets::load_map("world/tree/snow_pine/7.vox", |s: Structure| s + .with_center(Vec3::new(16, 15, 12))) + .unwrap(), + assets::load_map("world/tree/snow_pine/8.vox", |s: Structure| s + .with_center(Vec3::new(12, 10, 12))) + .unwrap(), + // snow birches -> need roots! + assets::load_map("world/tree/snow_birch/1.vox", |s: Structure| s + .with_center(Vec3::new(12, 9, 4))) + .unwrap(), + assets::load_map("world/tree/snow_birch/2.vox", |s: Structure| s + .with_center(Vec3::new(11, 10, 4))) + .unwrap(), + assets::load_map("world/tree/snow_birch/3.vox", |s: Structure| s + .with_center(Vec3::new(9, 10, 4))) + .unwrap(), + assets::load_map("world/tree/snow_birch/4.vox", |s: Structure| s + .with_center(Vec3::new(9, 10, 4))) + .unwrap(), + assets::load_map("world/tree/snow_birch/5.vox", |s: Structure| s + .with_center(Vec3::new(9, 11, 4))) + .unwrap(), + assets::load_map("world/tree/snow_birch/6.vox", |s: Structure| s + .with_center(Vec3::new(9, 9, 4))) + .unwrap(), + assets::load_map("world/tree/snow_birch/7.vox", |s: Structure| s + .with_center(Vec3::new(10, 10, 4))) + .unwrap(), + assets::load_map("world/tree/snow_birch/8.vox", |s: Structure| s + .with_center(Vec3::new(9, 9, 4))) + .unwrap(), + assets::load_map("world/tree/snow_birch/9.vox", |s: Structure| s + .with_center(Vec3::new(9, 10, 4))) + .unwrap(), + assets::load_map("world/tree/snow_birch/10.vox", |s: Structure| s + .with_center(Vec3::new(10, 9, 4))) + .unwrap(), + assets::load_map("world/tree/snow_birch/11.vox", |s: Structure| s + .with_center(Vec3::new(9, 10, 4))) + .unwrap(), + assets::load_map("world/tree/snow_birch/12.vox", |s: Structure| s + .with_center(Vec3::new(10, 9, 4))) + .unwrap(), + // willows + assets::load_map("world/tree/willow/1.vox", |s: Structure| s + .with_center(Vec3::new(15, 14, 1))) + .unwrap(), + assets::load_map("world/tree/willow/2.vox", |s: Structure| s + .with_center(Vec3::new(11, 12, 1))) + .unwrap(), + */ + + ]; +} diff --git a/world/src/sim.rs b/world/src/sim.rs index 0a1f43a1df..830c486daa 100644 --- a/world/src/sim.rs +++ b/world/src/sim.rs @@ -1,6 +1,9 @@ -use crate::{structure::StructureGen2d, Cache}; +use crate::{ + structure::StructureGen2d, + Cache, + sampler::Sampler, +}; use common::{ - assets, terrain::{Block, Structure, TerrainChunkSize}, vol::{ReadVol, VolSize, Vox}, }; @@ -9,33 +12,32 @@ use noise::{BasicMulti, HybridMulti, MultiFractal, NoiseFn, RidgedMulti, Seedabl use std::{ f32, ops::{Add, Div, Mul, Neg, Sub}, - sync::Arc, }; use vek::*; pub const WORLD_SIZE: Vec2 = Vec2 { x: 1024, y: 1024 }; -struct GenCtx { - turb_x_nz: BasicMulti, - turb_y_nz: BasicMulti, - chaos_nz: RidgedMulti, - alt_nz: HybridMulti, - hill_nz: SuperSimplex, - temp_nz: SuperSimplex, - small_nz: BasicMulti, - rock_nz: HybridMulti, - warp_nz: BasicMulti, - tree_nz: BasicMulti, +pub(crate) struct GenCtx { + pub turb_x_nz: BasicMulti, + pub turb_y_nz: BasicMulti, + pub chaos_nz: RidgedMulti, + pub alt_nz: HybridMulti, + pub hill_nz: SuperSimplex, + pub temp_nz: SuperSimplex, + pub small_nz: BasicMulti, + pub rock_nz: HybridMulti, + pub warp_nz: BasicMulti, + pub tree_nz: BasicMulti, - cave_0_nz: SuperSimplex, - cave_1_nz: SuperSimplex, + pub cave_0_nz: SuperSimplex, + pub cave_1_nz: SuperSimplex, } pub struct WorldSim { pub seed: u32, - chunks: Vec, - gen_ctx: GenCtx, - tree_gen: StructureGen2d, + pub(crate) chunks: Vec, + pub(crate) gen_ctx: GenCtx, + pub(crate) tree_gen: StructureGen2d, } impl WorldSim { @@ -138,254 +140,10 @@ impl WorldSim { } pub fn sampler(&self) -> Sampler { - Sampler { - sim: self, - sample2d_cache: Cache::with_capacity(1024), - } + Sampler::new(self) } } -pub struct Sampler<'a> { - sim: &'a WorldSim, - sample2d_cache: Cache, Option>, -} - -impl<'a> Sampler<'a> { - fn sample_2d_impl(sim: &WorldSim, wpos: Vec2) -> Option { - let wposf = wpos.map(|e| e as f64); - - let alt_base = sim.get_interpolated(wpos, |chunk| chunk.alt_base)?; - let chaos = sim.get_interpolated(wpos, |chunk| chunk.chaos)?; - let temp = sim.get_interpolated(wpos, |chunk| chunk.temp)?; - let rockiness = sim.get_interpolated(wpos, |chunk| chunk.rockiness)?; - let tree_density = sim.get_interpolated(wpos, |chunk| chunk.tree_density)?; - - let rock = (sim.gen_ctx.small_nz.get((wposf.div(100.0)).into_array()) as f32) - .mul(rockiness) - .sub(0.35) - .max(0.0) - .mul(6.0); - - let alt = sim.get_interpolated(wpos, |chunk| chunk.alt)? - + sim.gen_ctx.small_nz.get((wposf.div(256.0)).into_array()) as f32 - * chaos.max(0.2) - * 64.0; - - let wposf3d = Vec3::new(wposf.x, wposf.y, alt as f64); - - let marble = (sim.gen_ctx.hill_nz.get((wposf3d.div(48.0)).into_array()) as f32) - .add(1.0) - .mul(0.5); - - // Colours - let cold_grass = Rgb::new(0.0, 0.55, 0.15); - let warm_grass = Rgb::new(0.25, 0.8, 0.05); - let cold_stone = Rgb::new(0.55, 0.7, 0.75); - let warm_stone = Rgb::new(0.65, 0.65, 0.35); - let beach_sand = Rgb::new(0.93, 0.84, 0.33); - let desert_sand = Rgb::new(0.97, 0.84, 0.23); - let snow = Rgb::broadcast(1.0); - - let grass = Rgb::lerp(cold_grass, warm_grass, marble); - let grassland = grass; //Rgb::lerp(grass, warm_stone, rock.mul(5.0).min(0.8)); - let cliff = Rgb::lerp(cold_stone, warm_stone, marble); - - let ground = Rgb::lerp( - Rgb::lerp(snow, grassland, temp.add(0.4).mul(32.0).sub(0.4)), - desert_sand, - temp.sub(0.4).mul(32.0).add(0.4), - ); - - // Caves - let cave_at = |wposf: Vec2| { - (sim.gen_ctx.cave_0_nz.get( - Vec3::new(wposf.x, wposf.y, alt as f64 * 8.0) - .div(800.0) - .into_array(), - ) as f32) - .powf(2.0) - .neg() - .add(1.0) - .mul((1.15 - chaos).min(1.0)) - }; - let cave_xy = cave_at(wposf); - let cave_alt = alt - 32.0 - + (sim - .gen_ctx - .cave_1_nz - .get(Vec2::new(wposf.x, wposf.y).div(48.0).into_array()) as f32) - * 8.0 - + (sim - .gen_ctx - .cave_1_nz - .get(Vec2::new(wposf.x, wposf.y).div(300.0).into_array()) as f32) - .add(1.0) - .mul(0.5) - .powf(8.0) - .mul(256.0); - - Some(Sample2d { - alt, - chaos, - surface_color: Rgb::lerp( - beach_sand, - // Land - Rgb::lerp( - ground, - // Mountain - Rgb::lerp( - cliff, - snow, - (alt - SEA_LEVEL - - 0.3 * MOUNTAIN_HEIGHT - - alt_base - - temp * 96.0 - - marble * 24.0) - / 12.0, - ), - (alt - SEA_LEVEL - 0.15 * MOUNTAIN_HEIGHT) / 180.0, - ), - // Beach - (alt - SEA_LEVEL - 2.0) / 5.0, - ), - tree_density, - close_trees: sim.tree_gen.sample(wpos), - cave_xy, - cave_alt, - rock, - }) - } - - pub fn sample_2d(&mut self, wpos2d: Vec2) -> Option<&Sample2d> { - let sim = &self.sim; - self.sample2d_cache - .get(wpos2d, |wpos2d| Self::sample_2d_impl(sim, wpos2d)) - .as_ref() - } - - pub fn sample_3d(&mut self, wpos: Vec3) -> Option { - let wpos2d = Vec2::from(wpos); - let wposf = wpos.map(|e| e as f64); - - // Sample 2D terrain attributes - - let Sample2d { - alt, - chaos, - surface_color, - tree_density, - close_trees, - cave_xy, - cave_alt, - rock, - } = *self.sample_2d(wpos2d)?; - - // Apply warping - - let warp = (self - .sim - .gen_ctx - .warp_nz - .get((wposf.div(Vec3::new(120.0, 120.0, 150.0))).into_array()) - as f32) - .mul((chaos - 0.1).max(0.0)) - .mul(110.0); - - let height = alt + warp; - - // Sample blocks - - let air = Block::empty(); - let stone = Block::new(2, Rgb::new(200, 220, 255)); - let dirt = Block::new(1, Rgb::new(128, 90, 0)); - let sand = Block::new(1, Rgb::new(180, 150, 50)); - let water = Block::new(1, Rgb::new(100, 150, 255)); - let warm_stone = Block::new(1, Rgb::new(165, 165, 90)); - - let block = if (wposf.z as f32) < height - 4.0 { - // Underground - Some(stone) - } else if (wposf.z as f32) < height { - // Surface - Some(Block::new(1, surface_color.map(|e| (e * 255.0) as u8))) - } else if (wposf.z as f32) < SEA_LEVEL { - // Ocean - Some(water) - } else { - None - }; - - // Caves - let block = block.and_then(|block| { - // Underground - let cave = cave_xy.powf(2.0) - * (wposf.z as f32 - cave_alt) - .div(40.0) - .powf(4.0) - .neg() - .add(1.0) - > 0.9993; - - if cave { - None - } else { - Some(block) - } - }); - - // Rocks - let block = block.or_else(|| { - if (height + 2.5 - wposf.z as f32).div(7.5).abs().powf(2.0) < rock { - Some(warm_stone) - } else { - None - } - }); - - let block = match block { - Some(block) => block, - None => (&close_trees) - .iter() - .fold(air, |block, (tree_pos, tree_seed)| { - match self.sample_2d(*tree_pos) { - Some(tree_sample) - if tree_sample.tree_density - > 0.5 + (*tree_seed as f32 / 1000.0).fract() * 0.2 => - { - let tree_pos3d = - Vec3::new(tree_pos.x, tree_pos.y, tree_sample.alt as i32); - let rpos = wpos - tree_pos3d; - block.or(TREES[*tree_seed as usize % TREES.len()] - .get((rpos * 160) / 128) // Scaling - .map(|b| b.clone()) - .unwrap_or(Block::empty())) - } - _ => block, - } - }), - }; - - Some(Sample3d { block }) - } -} - -#[derive(Copy, Clone)] -pub struct Sample2d { - pub alt: f32, - pub chaos: f32, - pub surface_color: Rgb, - pub tree_density: f32, - pub close_trees: [(Vec2, u32); 9], - pub cave_xy: f32, - pub cave_alt: f32, - pub rock: f32, -} - -#[derive(Copy, Clone)] -pub struct Sample3d { - pub block: Block, -} - pub const SEA_LEVEL: f32 = 128.0; pub const MOUNTAIN_HEIGHT: f32 = 900.0; @@ -475,300 +233,3 @@ impl SimChunk { (self.alt + Z_TOLERANCE.1).max(SEA_LEVEL + 1.0) } } - -lazy_static! { - static ref TREES: [Arc; 61] = [ - // green oaks - assets::load_map("world/tree/oak_green/1.vox", |s: Structure| s - .with_center(Vec3::new(15, 18, 14))) - .unwrap(), - assets::load_map("world/tree/oak_green/2.vox", |s: Structure| s - .with_center(Vec3::new(15, 18, 14))) - .unwrap(), - assets::load_map("world/tree/oak_green/3.vox", |s: Structure| s - .with_center(Vec3::new(16, 20, 14))) - .unwrap(), - assets::load_map("world/tree/oak_green/4.vox", |s: Structure| s - .with_center(Vec3::new(18, 21, 14))) - .unwrap(), - assets::load_map("world/tree/oak_green/5.vox", |s: Structure| s - .with_center(Vec3::new(18, 18, 14))) - .unwrap(), - assets::load_map("world/tree/oak_green/6.vox", |s: Structure| s - .with_center(Vec3::new(16, 21, 14))) - .unwrap(), - assets::load_map("world/tree/oak_green/7.vox", |s: Structure| s - .with_center(Vec3::new(20, 19, 14))) - .unwrap(), - assets::load_map("world/tree/oak_green/8.vox", |s: Structure| s - .with_center(Vec3::new(22, 20, 14))) - .unwrap(), - assets::load_map("world/tree/oak_green/9.vox", |s: Structure| s - .with_center(Vec3::new(26, 26, 14))) - .unwrap(), - // green pines - assets::load_map("world/tree/pine_green/1.vox", |s: Structure| s - .with_center(Vec3::new(15, 15, 14))) - .unwrap(), - assets::load_map("world/tree/pine_green/2.vox", |s: Structure| s - .with_center(Vec3::new(15, 15, 14))) - .unwrap(), - assets::load_map("world/tree/pine_green/3.vox", |s: Structure| s - .with_center(Vec3::new(17, 15, 12))) - .unwrap(), - assets::load_map("world/tree/pine_green/4.vox", |s: Structure| s - .with_center(Vec3::new(10, 8, 12))) - .unwrap(), - assets::load_map("world/tree/pine_green/5.vox", |s: Structure| s - .with_center(Vec3::new(12, 12, 12))) - .unwrap(), - assets::load_map("world/tree/pine_green/6.vox", |s: Structure| s - .with_center(Vec3::new(11, 10, 12))) - .unwrap(), - assets::load_map("world/tree/pine_green/7.vox", |s: Structure| s - .with_center(Vec3::new(16, 15, 12))) - .unwrap(), - assets::load_map("world/tree/pine_green/8.vox", |s: Structure| s - .with_center(Vec3::new(12, 10, 12))) - .unwrap(), - // green pines 2 - assets::load_map("world/tree/pine_green_2/1.vox", |s: Structure| s - .with_center(Vec3::new(15, 15, 14))) - .unwrap(), - assets::load_map("world/tree/pine_green_2/2.vox", |s: Structure| s - .with_center(Vec3::new(15, 15, 14))) - .unwrap(), - assets::load_map("world/tree/pine_green_2/3.vox", |s: Structure| s - .with_center(Vec3::new(17, 15, 12))) - .unwrap(), - assets::load_map("world/tree/pine_green_2/4.vox", |s: Structure| s - .with_center(Vec3::new(10, 8, 12))) - .unwrap(), - assets::load_map("world/tree/pine_green_2/5.vox", |s: Structure| s - .with_center(Vec3::new(12, 12, 12))) - .unwrap(), - assets::load_map("world/tree/pine_green_2/6.vox", |s: Structure| s - .with_center(Vec3::new(11, 10, 12))) - .unwrap(), - assets::load_map("world/tree/pine_green_2/7.vox", |s: Structure| s - .with_center(Vec3::new(16, 15, 12))) - .unwrap(), - assets::load_map("world/tree/pine_green_2/8.vox", |s: Structure| s - .with_center(Vec3::new(12, 10, 12))) - .unwrap(), - // blue pines - assets::load_map("world/tree/pine_blue/1.vox", |s: Structure| s - .with_center(Vec3::new(15, 15, 14))) - .unwrap(), - assets::load_map("world/tree/pine_blue/2.vox", |s: Structure| s - .with_center(Vec3::new(15, 15, 14))) - .unwrap(), - assets::load_map("world/tree/pine_blue/3.vox", |s: Structure| s - .with_center(Vec3::new(17, 15, 12))) - .unwrap(), - assets::load_map("world/tree/pine_blue/4.vox", |s: Structure| s - .with_center(Vec3::new(10, 8, 12))) - .unwrap(), - assets::load_map("world/tree/pine_blue/5.vox", |s: Structure| s - .with_center(Vec3::new(12, 12, 12))) - .unwrap(), - assets::load_map("world/tree/pine_blue/6.vox", |s: Structure| s - .with_center(Vec3::new(11, 10, 12))) - .unwrap(), - assets::load_map("world/tree/pine_blue/7.vox", |s: Structure| s - .with_center(Vec3::new(16, 15, 12))) - .unwrap(), - assets::load_map("world/tree/pine_blue/8.vox", |s: Structure| s - .with_center(Vec3::new(12, 10, 12))) - .unwrap(), - // temperate small - assets::load_map("world/tree/temperate_small/1.vox", |s: Structure| s - .with_center(Vec3::new(4, 4, 7))) - .unwrap(), - assets::load_map("world/tree/temperate_small/2.vox", |s: Structure| s - .with_center(Vec3::new(4, 4, 7))) - .unwrap(), - assets::load_map("world/tree/temperate_small/3.vox", |s: Structure| s - .with_center(Vec3::new(4, 4, 7))) - .unwrap(), - assets::load_map("world/tree/temperate_small/4.vox", |s: Structure| s - .with_center(Vec3::new(4, 4, 7))) - .unwrap(), - assets::load_map("world/tree/temperate_small/5.vox", |s: Structure| s - .with_center(Vec3::new(4, 4, 7))) - .unwrap(), - assets::load_map("world/tree/temperate_small/6.vox", |s: Structure| s - .with_center(Vec3::new(4, 4, 7))) - .unwrap(), - // birch - assets::load_map("world/tree/birch/1.vox", |s: Structure| s - .with_center(Vec3::new(12, 9, 5))) - .unwrap(), - assets::load_map("world/tree/birch/2.vox", |s: Structure| s - .with_center(Vec3::new(11, 10, 5))) - .unwrap(), - assets::load_map("world/tree/birch/3.vox", |s: Structure| s - .with_center(Vec3::new(9, 10, 5))) - .unwrap(), - assets::load_map("world/tree/birch/4.vox", |s: Structure| s - .with_center(Vec3::new(9, 10, 5))) - .unwrap(), - assets::load_map("world/tree/birch/5.vox", |s: Structure| s - .with_center(Vec3::new(9, 11, 5))) - .unwrap(), - assets::load_map("world/tree/birch/6.vox", |s: Structure| s - .with_center(Vec3::new(9, 9, 5))) - .unwrap(), - assets::load_map("world/tree/birch/7.vox", |s: Structure| s - .with_center(Vec3::new(10, 10, 5))) - .unwrap(), - assets::load_map("world/tree/birch/8.vox", |s: Structure| s - .with_center(Vec3::new(9, 9, 5))) - .unwrap(), - assets::load_map("world/tree/birch/9.vox", |s: Structure| s - .with_center(Vec3::new(9, 10, 5))) - .unwrap(), - assets::load_map("world/tree/birch/10.vox", |s: Structure| s - .with_center(Vec3::new(10, 9, 5))) - .unwrap(), - assets::load_map("world/tree/birch/11.vox", |s: Structure| s - .with_center(Vec3::new(9, 10, 5))) - .unwrap(), - assets::load_map("world/tree/birch/12.vox", |s: Structure| s - .with_center(Vec3::new(10, 9, 5))) - .unwrap(), - // poplar - assets::load_map("world/tree/poplar/1.vox", |s: Structure| s - .with_center(Vec3::new(6, 6, 10))) - .unwrap(), - assets::load_map("world/tree/poplar/2.vox", |s: Structure| s - .with_center(Vec3::new(6, 6, 10))) - .unwrap(), - assets::load_map("world/tree/poplar/3.vox", |s: Structure| s - .with_center(Vec3::new(6, 6, 10))) - .unwrap(), - assets::load_map("world/tree/poplar/4.vox", |s: Structure| s - .with_center(Vec3::new(6, 6, 10))) - .unwrap(), - assets::load_map("world/tree/poplar/5.vox", |s: Structure| s - .with_center(Vec3::new(6, 6, 10))) - .unwrap(), - assets::load_map("world/tree/poplar/6.vox", |s: Structure| s - .with_center(Vec3::new(6, 6, 10))) - .unwrap(), - assets::load_map("world/tree/poplar/7.vox", |s: Structure| s - .with_center(Vec3::new(6, 6, 10))) - .unwrap(), - assets::load_map("world/tree/poplar/8.vox", |s: Structure| s - .with_center(Vec3::new(6, 6, 10))) - .unwrap(), - assets::load_map("world/tree/poplar/9.vox", |s: Structure| s - .with_center(Vec3::new(6, 6, 10))) - .unwrap(), - assets::load_map("world/tree/poplar/10.vox", |s: Structure| s - .with_center(Vec3::new(7, 7, 10))) - .unwrap(), - // palm trees - /*assets::load_map("world/tree/desert_palm/1.vox", |s: Structure| s - .with_center(Vec3::new(12, 12, 10))) - .unwrap(), - assets::load_map("world/tree/desert_palm/2.vox", |s: Structure| s - .with_center(Vec3::new(12, 10, 10))) - .unwrap(), - assets::load_map("world/tree/desert_palm/3.vox", |s: Structure| s - .with_center(Vec3::new(12, 12, 10))) - .unwrap(), - assets::load_map("world/tree/desert_palm/4.vox", |s: Structure| s - .with_center(Vec3::new(10, 10, 10))) - .unwrap(), - assets::load_map("world/tree/desert_palm/5.vox", |s: Structure| s - .with_center(Vec3::new(10, 10, 10))) - .unwrap(), - assets::load_map("world/tree/desert_palm/6.vox", |s: Structure| s - .with_center(Vec3::new(10, 10, 10))) - .unwrap(), - assets::load_map("world/tree/desert_palm/7.vox", |s: Structure| s - .with_center(Vec3::new(10, 10, 10))) - .unwrap(), - assets::load_map("world/tree/desert_palm/8.vox", |s: Structure| s - .with_center(Vec3::new(10, 10, 10))) - .unwrap(), - assets::load_map("world/tree/desert_palm/9.vox", |s: Structure| s - .with_center(Vec3::new(10, 10, 10))) - .unwrap(), - assets::load_map("world/tree/desert_palm/10.vox", |s: Structure| s - .with_center(Vec3::new(10, 10, 10))) - .unwrap(), - // snow pines - assets::load_map("world/tree/snow_pine/1.vox", |s: Structure| s - .with_center(Vec3::new(15, 15, 14))) - .unwrap(), - assets::load_map("world/tree/snow_pine/2.vox", |s: Structure| s - .with_center(Vec3::new(15, 15, 14))) - .unwrap(), - assets::load_map("world/tree/snow_pine/3.vox", |s: Structure| s - .with_center(Vec3::new(17, 15, 12))) - .unwrap(), - assets::load_map("world/tree/snow_pine/4.vox", |s: Structure| s - .with_center(Vec3::new(10, 8, 12))) - .unwrap(), - assets::load_map("world/tree/snow_pine/5.vox", |s: Structure| s - .with_center(Vec3::new(12, 12, 12))) - .unwrap(), - assets::load_map("world/tree/snow_pine/6.vox", |s: Structure| s - .with_center(Vec3::new(11, 10, 12))) - .unwrap(), - assets::load_map("world/tree/snow_pine/7.vox", |s: Structure| s - .with_center(Vec3::new(16, 15, 12))) - .unwrap(), - assets::load_map("world/tree/snow_pine/8.vox", |s: Structure| s - .with_center(Vec3::new(12, 10, 12))) - .unwrap(), - // snow birches -> need roots! - assets::load_map("world/tree/snow_birch/1.vox", |s: Structure| s - .with_center(Vec3::new(12, 9, 4))) - .unwrap(), - assets::load_map("world/tree/snow_birch/2.vox", |s: Structure| s - .with_center(Vec3::new(11, 10, 4))) - .unwrap(), - assets::load_map("world/tree/snow_birch/3.vox", |s: Structure| s - .with_center(Vec3::new(9, 10, 4))) - .unwrap(), - assets::load_map("world/tree/snow_birch/4.vox", |s: Structure| s - .with_center(Vec3::new(9, 10, 4))) - .unwrap(), - assets::load_map("world/tree/snow_birch/5.vox", |s: Structure| s - .with_center(Vec3::new(9, 11, 4))) - .unwrap(), - assets::load_map("world/tree/snow_birch/6.vox", |s: Structure| s - .with_center(Vec3::new(9, 9, 4))) - .unwrap(), - assets::load_map("world/tree/snow_birch/7.vox", |s: Structure| s - .with_center(Vec3::new(10, 10, 4))) - .unwrap(), - assets::load_map("world/tree/snow_birch/8.vox", |s: Structure| s - .with_center(Vec3::new(9, 9, 4))) - .unwrap(), - assets::load_map("world/tree/snow_birch/9.vox", |s: Structure| s - .with_center(Vec3::new(9, 10, 4))) - .unwrap(), - assets::load_map("world/tree/snow_birch/10.vox", |s: Structure| s - .with_center(Vec3::new(10, 9, 4))) - .unwrap(), - assets::load_map("world/tree/snow_birch/11.vox", |s: Structure| s - .with_center(Vec3::new(9, 10, 4))) - .unwrap(), - assets::load_map("world/tree/snow_birch/12.vox", |s: Structure| s - .with_center(Vec3::new(10, 9, 4))) - .unwrap(), - // willows - assets::load_map("world/tree/willow/1.vox", |s: Structure| s - .with_center(Vec3::new(15, 14, 1))) - .unwrap(), - assets::load_map("world/tree/willow/2.vox", |s: Structure| s - .with_center(Vec3::new(11, 12, 1))) - .unwrap(), - */ - - ]; -} From a34aff3a8b1e1fe519994797e44292c223bfd4a8 Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Thu, 6 Jun 2019 21:56:16 +0100 Subject: [PATCH 02/30] Prevented rock smearing --- world/src/sampler.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/world/src/sampler.rs b/world/src/sampler.rs index ca3ac037cf..0c09743e0b 100644 --- a/world/src/sampler.rs +++ b/world/src/sampler.rs @@ -43,17 +43,17 @@ impl<'a> Sampler<'a> { let rockiness = sim.get_interpolated(wpos, |chunk| chunk.rockiness)?; let tree_density = sim.get_interpolated(wpos, |chunk| chunk.tree_density)?; - let rock = (sim.gen_ctx.small_nz.get((wposf.div(100.0)).into_array()) as f32) - .mul(rockiness) - .sub(0.35) - .max(0.0) - .mul(6.0); - let alt = sim.get_interpolated(wpos, |chunk| chunk.alt)? + sim.gen_ctx.small_nz.get((wposf.div(256.0)).into_array()) as f32 * chaos.max(0.2) * 64.0; + let rock = (sim.gen_ctx.small_nz.get(Vec3::new(wposf.x, wposf.y, alt as f64).div(100.0).into_array()) as f32) + .mul(rockiness) + .sub(0.35) + .max(0.0) + .mul(6.0); + let wposf3d = Vec3::new(wposf.x, wposf.y, alt as f64); let marble = (sim.gen_ctx.hill_nz.get((wposf3d.div(48.0)).into_array()) as f32) From cf193a97c45e3eb0860b6c154e7f06aa7137e1fd Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Thu, 6 Jun 2019 22:02:59 +0100 Subject: [PATCH 03/30] Set default case for block type opacity --- common/src/terrain/block.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/common/src/terrain/block.rs b/common/src/terrain/block.rs index 690d2997b3..ef3b5d2ffb 100644 --- a/common/src/terrain/block.rs +++ b/common/src/terrain/block.rs @@ -28,8 +28,7 @@ impl Block { match self.kind { 0 => None, 1 => Some(0.85), - 2 => Some(1.0), - _ => unimplemented!(), + _ => Some(1.0), } } } From 3285fc9b88225c1536db511bfabb911301ded483 Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Sat, 8 Jun 2019 11:10:31 +0100 Subject: [PATCH 04/30] Added sampler clearing --- world/src/lib.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/world/src/lib.rs b/world/src/lib.rs index 6976adee1f..d4302cef15 100644 --- a/world/src/lib.rs +++ b/world/src/lib.rs @@ -117,6 +117,11 @@ impl Cache { pub fn get V>(&mut self, k: K, f: F) -> &V { let counter = &mut self.counter; + + if self.map.len() > self.capacity { + self.map.clear(); + } + &self .map .entry(k) From c445e76afaeead64efe6a666eafcf07c1107a9b8 Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Sat, 8 Jun 2019 11:15:40 +0100 Subject: [PATCH 05/30] Fixed usize size issue for 32-bit platforms --- common/src/net/post2.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/src/net/post2.rs b/common/src/net/post2.rs index d864b66055..55cf64c3ee 100644 --- a/common/src/net/post2.rs +++ b/common/src/net/post2.rs @@ -267,9 +267,9 @@ impl PostBox { for _ in 0..100 { match incoming_buf.get(0..9) { Some(len_bytes) => { - let len = usize::from_le_bytes( + let len = u64::from_le_bytes( <[u8; 8]>::try_from(&len_bytes[0..8]).unwrap(), - ); // Can't fail + ) as usize; // Can't fail if len > MAX_MSG_SIZE { recv_tx.send(Err(Error::InvalidMessage)).unwrap(); From e4d5476d2861cd96cc11d9773e25a272df0c6c3a Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Sun, 9 Jun 2019 11:24:18 +0100 Subject: [PATCH 06/30] Major worldgen structural refactor --- world/src/block/mod.rs | 145 +++++++++++++ world/src/{sampler.rs => block/tree.rs} | 269 +----------------------- world/src/column/mod.rs | 148 +++++++++++++ world/src/config.rs | 9 + world/src/lib.rs | 78 ++----- world/src/{sim.rs => sim/mod.rs} | 35 ++- world/src/util/hash_cache.rs | 47 +++++ world/src/util/mod.rs | 10 + world/src/util/sampler.rs | 6 + world/src/{ => util}/structure.rs | 2 +- 10 files changed, 405 insertions(+), 344 deletions(-) create mode 100644 world/src/block/mod.rs rename world/src/{sampler.rs => block/tree.rs} (62%) create mode 100644 world/src/column/mod.rs create mode 100644 world/src/config.rs rename world/src/{sim.rs => sim/mod.rs} (92%) create mode 100644 world/src/util/hash_cache.rs create mode 100644 world/src/util/mod.rs create mode 100644 world/src/util/sampler.rs rename world/src/{ => util}/structure.rs (96%) diff --git a/world/src/block/mod.rs b/world/src/block/mod.rs new file mode 100644 index 0000000000..937fc4396e --- /dev/null +++ b/world/src/block/mod.rs @@ -0,0 +1,145 @@ +mod tree; + +use std::ops::{Add, Div, Mul, Neg, Sub}; +use noise::NoiseFn; +use vek::*; +use common::{ + terrain::Block, + vol::{Vox, ReadVol}, +}; +use crate::{ + util::{Sampler, HashCache}, + column::{ColumnGen, ColumnSample}, + CONFIG, + World, +}; +use self::tree::TREES; + +pub struct BlockGen<'a> { + world: &'a World, + column_cache: HashCache, Option>, + column_gen: ColumnGen<'a>, +} + +impl<'a> BlockGen<'a> { + pub fn new(world: &'a World, column_gen: ColumnGen<'a>) -> Self { + Self { + world, + column_cache: HashCache::with_capacity(1024), + column_gen, + } + } + + fn sample_column(&mut self, wpos: Vec2) -> Option { + let column_gen = &mut self.column_gen; + self.column_cache + .get(Vec2::from(wpos), |wpos| column_gen.get(wpos)) + .clone() + } +} + +impl<'a> Sampler for BlockGen<'a> { + type Index = Vec3; + type Sample = Option; + + fn get(&mut self, wpos: Vec3) -> Option { + let ColumnSample { + alt, + chaos, + surface_color, + tree_density, + close_trees, + cave_xy, + cave_alt, + rock, + } = self.sample_column(Vec2::from(wpos))?; + + let wposf = wpos.map(|e| e as f64); + + // Apply warping + + let warp = (self.world.sim() + .gen_ctx + .warp_nz + .get((wposf.div(Vec3::new(120.0, 120.0, 150.0))).into_array()) + as f32) + .mul((chaos - 0.1).max(0.0)) + .mul(110.0); + + let height = alt + warp; + + // Sample blocks + + let air = Block::empty(); + let stone = Block::new(2, Rgb::new(200, 220, 255)); + let dirt = Block::new(1, Rgb::new(128, 90, 0)); + let sand = Block::new(1, Rgb::new(180, 150, 50)); + let water = Block::new(1, Rgb::new(100, 150, 255)); + let warm_stone = Block::new(1, Rgb::new(165, 165, 90)); + + let block = if (wposf.z as f32) < height - 4.0 { + // Underground + Some(stone) + } else if (wposf.z as f32) < height { + // Surface + Some(Block::new(1, surface_color.map(|e| (e * 255.0) as u8))) + } else if (wposf.z as f32) < CONFIG.sea_level { + // Ocean + Some(water) + } else { + None + }; + + // Caves + let block = block.and_then(|block| { + // Underground + let cave = cave_xy.powf(2.0) + * (wposf.z as f32 - cave_alt) + .div(40.0) + .powf(4.0) + .neg() + .add(1.0) + > 0.9993; + + if cave { + None + } else { + Some(block) + } + }); + + // Rocks + let block = block.or_else(|| { + if (height + 2.5 - wposf.z as f32).div(7.5).abs().powf(2.0) < rock { + Some(warm_stone) + } else { + None + } + }); + + let block = match block { + Some(block) => block, + None => (&close_trees) + .iter() + .fold(air, |block, (tree_pos, tree_seed)| { + match self.sample_column(Vec2::from(*tree_pos)) { + Some(tree_sample) + if tree_sample.tree_density + > 0.5 + (*tree_seed as f32 / 1000.0).fract() * 0.2 => + { + let tree_pos3d = + Vec3::new(tree_pos.x, tree_pos.y, tree_sample.alt as i32); + let rpos = wpos - tree_pos3d; + block.or(TREES[*tree_seed as usize % TREES.len()] + .get((rpos * 160) / 128) // Scaling + .map(|b| b.clone()) + .unwrap_or(Block::empty())) + } + _ => block, + } + }), + }; + + Some(block) + } +} diff --git a/world/src/sampler.rs b/world/src/block/tree.rs similarity index 62% rename from world/src/sampler.rs rename to world/src/block/tree.rs index 0c09743e0b..7f98b7a895 100644 --- a/world/src/sampler.rs +++ b/world/src/block/tree.rs @@ -1,276 +1,13 @@ -use std::{ - ops::{Add, Div, Mul, Neg, Sub}, - sync::Arc, -}; +use std::sync::Arc; use vek::*; use lazy_static::lazy_static; -use noise::NoiseFn; use common::{ assets, - terrain::{Block, Structure}, - vol::{ReadVol, VolSize, Vox}, + terrain::Structure, }; -use crate::{ - structure::StructureGen2d, - sim::{ - GenCtx, - WorldSim, - SEA_LEVEL, - MOUNTAIN_HEIGHT, - }, - Cache, -}; - -pub struct Sampler<'a> { - sim: &'a WorldSim, - sample2d_cache: Cache, Option>, -} - -impl<'a> Sampler<'a> { - pub(crate) fn new(sim: &'a WorldSim) -> Self { - Self { - sim, - sample2d_cache: Cache::with_capacity(1024), - } - } - - fn sample_2d_impl(sim: &WorldSim, wpos: Vec2) -> Option { - let wposf = wpos.map(|e| e as f64); - - let alt_base = sim.get_interpolated(wpos, |chunk| chunk.alt_base)?; - let chaos = sim.get_interpolated(wpos, |chunk| chunk.chaos)?; - let temp = sim.get_interpolated(wpos, |chunk| chunk.temp)?; - let rockiness = sim.get_interpolated(wpos, |chunk| chunk.rockiness)?; - let tree_density = sim.get_interpolated(wpos, |chunk| chunk.tree_density)?; - - let alt = sim.get_interpolated(wpos, |chunk| chunk.alt)? - + sim.gen_ctx.small_nz.get((wposf.div(256.0)).into_array()) as f32 - * chaos.max(0.2) - * 64.0; - - let rock = (sim.gen_ctx.small_nz.get(Vec3::new(wposf.x, wposf.y, alt as f64).div(100.0).into_array()) as f32) - .mul(rockiness) - .sub(0.35) - .max(0.0) - .mul(6.0); - - let wposf3d = Vec3::new(wposf.x, wposf.y, alt as f64); - - let marble = (sim.gen_ctx.hill_nz.get((wposf3d.div(48.0)).into_array()) as f32) - .add(1.0) - .mul(0.5); - - // Colours - let cold_grass = Rgb::new(0.0, 0.55, 0.15); - let warm_grass = Rgb::new(0.25, 0.8, 0.05); - let cold_stone = Rgb::new(0.55, 0.7, 0.75); - let warm_stone = Rgb::new(0.65, 0.65, 0.35); - let beach_sand = Rgb::new(0.93, 0.84, 0.33); - let desert_sand = Rgb::new(0.97, 0.84, 0.23); - let snow = Rgb::broadcast(1.0); - - let grass = Rgb::lerp(cold_grass, warm_grass, marble); - let grassland = grass; //Rgb::lerp(grass, warm_stone, rock.mul(5.0).min(0.8)); - let cliff = Rgb::lerp(cold_stone, warm_stone, marble); - - let ground = Rgb::lerp( - Rgb::lerp(snow, grassland, temp.add(0.4).mul(32.0).sub(0.4)), - desert_sand, - temp.sub(0.4).mul(32.0).add(0.4), - ); - - // Caves - let cave_at = |wposf: Vec2| { - (sim.gen_ctx.cave_0_nz.get( - Vec3::new(wposf.x, wposf.y, alt as f64 * 8.0) - .div(800.0) - .into_array(), - ) as f32) - .powf(2.0) - .neg() - .add(1.0) - .mul((1.15 - chaos).min(1.0)) - }; - let cave_xy = cave_at(wposf); - let cave_alt = alt - 32.0 - + (sim - .gen_ctx - .cave_1_nz - .get(Vec2::new(wposf.x, wposf.y).div(48.0).into_array()) as f32) - * 8.0 - + (sim - .gen_ctx - .cave_1_nz - .get(Vec2::new(wposf.x, wposf.y).div(300.0).into_array()) as f32) - .add(1.0) - .mul(0.5) - .powf(8.0) - .mul(256.0); - - Some(Sample2d { - alt, - chaos, - surface_color: Rgb::lerp( - beach_sand, - // Land - Rgb::lerp( - ground, - // Mountain - Rgb::lerp( - cliff, - snow, - (alt - SEA_LEVEL - - 0.3 * MOUNTAIN_HEIGHT - - alt_base - - temp * 96.0 - - marble * 24.0) - / 12.0, - ), - (alt - SEA_LEVEL - 0.15 * MOUNTAIN_HEIGHT) / 180.0, - ), - // Beach - (alt - SEA_LEVEL - 2.0) / 5.0, - ), - tree_density, - close_trees: sim.tree_gen.sample(wpos), - cave_xy, - cave_alt, - rock, - }) - } - - pub fn sample_2d(&mut self, wpos2d: Vec2) -> Option<&Sample2d> { - let sim = &self.sim; - self.sample2d_cache - .get(wpos2d, |wpos2d| Self::sample_2d_impl(sim, wpos2d)) - .as_ref() - } - - pub fn sample_3d(&mut self, wpos: Vec3) -> Option { - let wpos2d = Vec2::from(wpos); - let wposf = wpos.map(|e| e as f64); - - // Sample 2D terrain attributes - - let Sample2d { - alt, - chaos, - surface_color, - tree_density, - close_trees, - cave_xy, - cave_alt, - rock, - } = *self.sample_2d(wpos2d)?; - - // Apply warping - - let warp = (self - .sim - .gen_ctx - .warp_nz - .get((wposf.div(Vec3::new(120.0, 120.0, 150.0))).into_array()) - as f32) - .mul((chaos - 0.1).max(0.0)) - .mul(110.0); - - let height = alt + warp; - - // Sample blocks - - let air = Block::empty(); - let stone = Block::new(2, Rgb::new(200, 220, 255)); - let dirt = Block::new(1, Rgb::new(128, 90, 0)); - let sand = Block::new(1, Rgb::new(180, 150, 50)); - let water = Block::new(1, Rgb::new(100, 150, 255)); - let warm_stone = Block::new(1, Rgb::new(165, 165, 90)); - - let block = if (wposf.z as f32) < height - 4.0 { - // Underground - Some(stone) - } else if (wposf.z as f32) < height { - // Surface - Some(Block::new(1, surface_color.map(|e| (e * 255.0) as u8))) - } else if (wposf.z as f32) < SEA_LEVEL { - // Ocean - Some(water) - } else { - None - }; - - // Caves - let block = block.and_then(|block| { - // Underground - let cave = cave_xy.powf(2.0) - * (wposf.z as f32 - cave_alt) - .div(40.0) - .powf(4.0) - .neg() - .add(1.0) - > 0.9993; - - if cave { - None - } else { - Some(block) - } - }); - - // Rocks - let block = block.or_else(|| { - if (height + 2.5 - wposf.z as f32).div(7.5).abs().powf(2.0) < rock { - Some(warm_stone) - } else { - None - } - }); - - let block = match block { - Some(block) => block, - None => (&close_trees) - .iter() - .fold(air, |block, (tree_pos, tree_seed)| { - match self.sample_2d(*tree_pos) { - Some(tree_sample) - if tree_sample.tree_density - > 0.5 + (*tree_seed as f32 / 1000.0).fract() * 0.2 => - { - let tree_pos3d = - Vec3::new(tree_pos.x, tree_pos.y, tree_sample.alt as i32); - let rpos = wpos - tree_pos3d; - block.or(TREES[*tree_seed as usize % TREES.len()] - .get((rpos * 160) / 128) // Scaling - .map(|b| b.clone()) - .unwrap_or(Block::empty())) - } - _ => block, - } - }), - }; - - Some(Sample3d { block }) - } -} - -#[derive(Copy, Clone)] -pub struct Sample2d { - pub alt: f32, - pub chaos: f32, - pub surface_color: Rgb, - pub tree_density: f32, - pub close_trees: [(Vec2, u32); 9], - pub cave_xy: f32, - pub cave_alt: f32, - pub rock: f32, -} - -#[derive(Copy, Clone)] -pub struct Sample3d { - pub block: Block, -} lazy_static! { - static ref TREES: [Arc; 61] = [ + pub static ref TREES: [Arc; 61] = [ // green oaks assets::load_map("world/tree/oak_green/1.vox", |s: Structure| s .with_center(Vec3::new(15, 18, 14))) diff --git a/world/src/column/mod.rs b/world/src/column/mod.rs new file mode 100644 index 0000000000..2d2201f327 --- /dev/null +++ b/world/src/column/mod.rs @@ -0,0 +1,148 @@ +use std::ops::{Add, Div, Mul, Neg, Sub}; +use vek::*; +use noise::NoiseFn; +use common::{ + terrain::Block, + vol::Vox, +}; +use crate::{ + CONFIG, + util::Sampler, + World, +}; + +pub struct ColumnGen<'a> { + world: &'a World, +} + +impl<'a> ColumnGen<'a> { + pub fn new(world: &'a World) -> Self { + Self { + world, + } + } +} + +impl<'a> Sampler for ColumnGen<'a> { + type Index = Vec2; + type Sample = Option; + + fn get(&mut self, wpos: Vec2) -> Option { + let wposf = wpos.map(|e| e as f64); + + let sim = self.world.sim(); + + let alt_base = sim.get_interpolated(wpos, |chunk| chunk.alt_base)?; + let chaos = sim.get_interpolated(wpos, |chunk| chunk.chaos)?; + let temp = sim.get_interpolated(wpos, |chunk| chunk.temp)?; + let rockiness = sim.get_interpolated(wpos, |chunk| chunk.rockiness)?; + let tree_density = sim.get_interpolated(wpos, |chunk| chunk.tree_density)?; + + let alt = sim.get_interpolated(wpos, |chunk| chunk.alt)? + + sim.gen_ctx.small_nz.get((wposf.div(256.0)).into_array()) as f32 + * chaos.max(0.2) + * 64.0; + + let rock = (sim.gen_ctx.small_nz.get(Vec3::new(wposf.x, wposf.y, alt as f64).div(100.0).into_array()) as f32) + .mul(rockiness) + .sub(0.35) + .max(0.0) + .mul(6.0); + + let wposf3d = Vec3::new(wposf.x, wposf.y, alt as f64); + + let marble = (sim.gen_ctx.hill_nz.get((wposf3d.div(48.0)).into_array()) as f32) + .add(1.0) + .mul(0.5); + + // Colours + let cold_grass = Rgb::new(0.0, 0.4, 0.1); + let warm_grass = Rgb::new(0.25, 0.8, 0.05); + let cold_stone = Rgb::new(0.55, 0.7, 0.75); + let warm_stone = Rgb::new(0.65, 0.65, 0.35); + let beach_sand = Rgb::new(0.93, 0.84, 0.33); + let desert_sand = Rgb::new(0.97, 0.84, 0.23); + let snow = Rgb::broadcast(1.0); + + let grass = Rgb::lerp(cold_grass, warm_grass, marble); + let grassland = grass; //Rgb::lerp(grass, warm_stone, rock.mul(5.0).min(0.8)); + let cliff = Rgb::lerp(cold_stone, warm_stone, marble); + + let ground = Rgb::lerp( + Rgb::lerp(snow, grassland, temp.add(0.4).mul(32.0).sub(0.4)), + desert_sand, + temp.sub(0.4).mul(32.0).add(0.4), + ); + + // Caves + let cave_at = |wposf: Vec2| { + (sim.gen_ctx.cave_0_nz.get( + Vec3::new(wposf.x, wposf.y, alt as f64 * 8.0) + .div(800.0) + .into_array(), + ) as f32) + .powf(2.0) + .neg() + .add(1.0) + .mul((1.15 - chaos).min(1.0)) + }; + let cave_xy = cave_at(wposf); + let cave_alt = alt - 32.0 + + (sim + .gen_ctx + .cave_1_nz + .get(Vec2::new(wposf.x, wposf.y).div(48.0).into_array()) as f32) + * 8.0 + + (sim + .gen_ctx + .cave_1_nz + .get(Vec2::new(wposf.x, wposf.y).div(300.0).into_array()) as f32) + .add(1.0) + .mul(0.5) + .powf(8.0) + .mul(256.0); + + Some(ColumnSample { + alt, + chaos, + surface_color: Rgb::lerp( + beach_sand, + // Land + Rgb::lerp( + ground, + // Mountain + Rgb::lerp( + cliff, + snow, + (alt - CONFIG.sea_level + - 0.3 * CONFIG.mountain_scale + - alt_base + - temp * 96.0 + - marble * 24.0) + / 12.0, + ), + (alt - CONFIG.sea_level - 0.15 * CONFIG.mountain_scale) / 180.0, + ), + // Beach + (alt - CONFIG.sea_level - 2.0) / 5.0, + ), + tree_density, + close_trees: sim.gen_ctx.tree_gen.get(wpos), + cave_xy, + cave_alt, + rock, + }) + } +} + +#[derive(Clone)] +pub struct ColumnSample { + pub alt: f32, + pub chaos: f32, + pub surface_color: Rgb, + pub tree_density: f32, + pub close_trees: [(Vec2, u32); 9], + pub cave_xy: f32, + pub cave_alt: f32, + pub rock: f32, +} diff --git a/world/src/config.rs b/world/src/config.rs new file mode 100644 index 0000000000..3dd6f6e09e --- /dev/null +++ b/world/src/config.rs @@ -0,0 +1,9 @@ +pub struct Config { + pub sea_level: f32, + pub mountain_scale: f32, +} + +pub const CONFIG: Config = Config { + sea_level: 128.0, + mountain_scale: 900.0, +}; diff --git a/world/src/lib.rs b/world/src/lib.rs index d4302cef15..15289dfafa 100644 --- a/world/src/lib.rs +++ b/world/src/lib.rs @@ -1,17 +1,25 @@ -#![feature(euclidean_division)] +#![feature(euclidean_division, bind_by_move_pattern_guards)] +mod config; +mod util; +mod block; +mod column; mod sim; -mod sampler; -mod structure; + +// Reexports +pub use crate::config::CONFIG; use common::{ terrain::{Block, TerrainChunk, TerrainChunkMeta, TerrainChunkSize}, vol::{VolSize, Vox, WriteVol}, }; -use fxhash::FxHashMap; -use noise::{BasicMulti, MultiFractal, Seedable}; -use std::{hash::Hash, time::Duration}; +use std::time::Duration; use vek::*; +use crate::{ + util::{Sampler, HashCache}, + column::ColumnGen, + block::BlockGen, +}; #[derive(Debug)] pub enum Error { @@ -37,15 +45,15 @@ impl World { // TODO } - pub fn generate_chunk(&self, chunk_pos: Vec2) -> TerrainChunk { - // TODO: This is all test code, remove/improve this later. + pub fn sample(&self) -> impl Sampler, Sample=Option> + '_ { + BlockGen::new(self, ColumnGen::new(self)) + } + pub fn generate_chunk(&self, chunk_pos: Vec2) -> TerrainChunk { let air = Block::empty(); let stone = Block::new(1, Rgb::new(200, 220, 255)); let water = Block::new(5, Rgb::new(100, 150, 255)); - let warp_nz = BasicMulti::new().set_octaves(3).set_seed(self.sim.seed + 0); - let chunk_size2d = Vec2::from(TerrainChunkSize::SIZE); let base_z = match self.sim.get_interpolated( chunk_pos.map2(chunk_size2d, |e, sz: u32| e * sz as i32 + sz as i32 / 2), @@ -57,7 +65,7 @@ impl World { let mut chunk = TerrainChunk::new(base_z - 8, stone, air, TerrainChunkMeta::void()); - let mut world_sampler = self.sim.sampler(); + let mut sampler = self.sample(); for x in 0..TerrainChunkSize::SIZE.x as i32 { for y in 0..TerrainChunkSize::SIZE.y as i32 { @@ -80,13 +88,9 @@ impl World { let wpos = lpos + Vec3::from(chunk_pos) * TerrainChunkSize::SIZE.map(|e| e as i32); - let block = if let Some(sample) = world_sampler.sample_3d(wpos) { - sample.block - } else { - continue; - }; - - let _ = chunk.set(lpos, block); + if let Some(block) = sampler.get(wpos) { + let _ = chunk.set(lpos, block); + } } } } @@ -94,41 +98,3 @@ impl World { chunk } } - -struct Cache { - capacity: usize, - map: FxHashMap, - counter: usize, -} - -impl Cache { - pub fn with_capacity(capacity: usize) -> Self { - Self { - capacity, - map: FxHashMap::default(), - counter: 0, - } - } - - pub fn maintain(&mut self) { - let (capacity, counter) = (self.capacity, self.counter); - self.map.retain(|_, (c, _)| *c + capacity > counter); - } - - pub fn get V>(&mut self, k: K, f: F) -> &V { - let counter = &mut self.counter; - - if self.map.len() > self.capacity { - self.map.clear(); - } - - &self - .map - .entry(k) - .or_insert_with(|| { - *counter += 1; - (*counter, f(k)) - }) - .1 - } -} diff --git a/world/src/sim.rs b/world/src/sim/mod.rs similarity index 92% rename from world/src/sim.rs rename to world/src/sim/mod.rs index 830c486daa..e062e5d293 100644 --- a/world/src/sim.rs +++ b/world/src/sim/mod.rs @@ -1,19 +1,14 @@ -use crate::{ - structure::StructureGen2d, - Cache, - sampler::Sampler, +use std::ops::{Add, Div, Mul, Neg, Sub}; +use vek::*; +use noise::{ + BasicMulti, RidgedMulti, SuperSimplex, HybridMulti, + MultiFractal, NoiseFn, Seedable, }; use common::{ - terrain::{Block, Structure, TerrainChunkSize}, - vol::{ReadVol, VolSize, Vox}, + terrain::TerrainChunkSize, + vol::VolSize, }; -use lazy_static::lazy_static; -use noise::{BasicMulti, HybridMulti, MultiFractal, NoiseFn, RidgedMulti, Seedable, SuperSimplex}; -use std::{ - f32, - ops::{Add, Div, Mul, Neg, Sub}, -}; -use vek::*; +use crate::util::StructureGen2d; pub const WORLD_SIZE: Vec2 = Vec2 { x: 1024, y: 1024 }; @@ -31,13 +26,14 @@ pub(crate) struct GenCtx { pub cave_0_nz: SuperSimplex, pub cave_1_nz: SuperSimplex, + + pub tree_gen: StructureGen2d, } pub struct WorldSim { pub seed: u32, pub(crate) chunks: Vec, pub(crate) gen_ctx: GenCtx, - pub(crate) tree_gen: StructureGen2d, } impl WorldSim { @@ -61,6 +57,8 @@ impl WorldSim { .set_seed(seed + 9), cave_0_nz: SuperSimplex::new().set_seed(seed + 10), cave_1_nz: SuperSimplex::new().set_seed(seed + 11), + + tree_gen: StructureGen2d::new(seed, 24, 16), }; let mut chunks = Vec::new(); @@ -74,7 +72,6 @@ impl WorldSim { seed, chunks, gen_ctx, - tree_gen: StructureGen2d::new(seed, 24, 16), } } @@ -138,16 +135,12 @@ impl WorldSim { Some(cubic(x[0], x[1], x[2], x[3], pos.x.fract() as f32)) } - - pub fn sampler(&self) -> Sampler { - Sampler::new(self) - } } pub const SEA_LEVEL: f32 = 128.0; pub const MOUNTAIN_HEIGHT: f32 = 900.0; -const Z_TOLERANCE: (f32, f32) = (64.0, 64.0); +const Z_TOLERANCE: (f32, f32) = (128.0, 64.0); pub struct SimChunk { pub chaos: f32, @@ -226,7 +219,7 @@ impl SimChunk { } pub fn get_min_z(&self) -> f32 { - self.alt - Z_TOLERANCE.0 * (self.chaos + 0.5) + self.alt - Z_TOLERANCE.0 * (self.chaos + 0.3) } pub fn get_max_z(&self) -> f32 { diff --git a/world/src/util/hash_cache.rs b/world/src/util/hash_cache.rs new file mode 100644 index 0000000000..ffdd3eebfd --- /dev/null +++ b/world/src/util/hash_cache.rs @@ -0,0 +1,47 @@ +use std::hash::Hash; +use fxhash::FxHashMap; + +pub struct HashCache { + capacity: usize, + map: FxHashMap, + counter: usize, +} + +impl Default for HashCache { + fn default() -> Self { + Self::with_capacity(1024) + } +} + +impl HashCache { + pub fn with_capacity(capacity: usize) -> Self { + Self { + capacity, + map: FxHashMap::default(), + counter: 0, + } + } + + pub fn maintain(&mut self) { + const CACHE_BLOAT_RATE: usize = 2; + + if self.map.len() > self.capacity * CACHE_BLOAT_RATE { + let (capacity, counter) = (self.capacity, self.counter); + self.map.retain(|_, (c, _)| *c + capacity > counter); + } + } + + pub fn get V>(&mut self, key: K, f: F) -> &V { + self.maintain(); + + let counter = &mut self.counter; + &self + .map + .entry(key.clone()) + .or_insert_with(|| { + *counter += 1; + (*counter, f(key)) + }) + .1 + } +} diff --git a/world/src/util/mod.rs b/world/src/util/mod.rs new file mode 100644 index 0000000000..c5f27e4ace --- /dev/null +++ b/world/src/util/mod.rs @@ -0,0 +1,10 @@ +pub mod sampler; +pub mod hash_cache; +pub mod structure; + +// Reexports +pub use self::{ + sampler::Sampler, + hash_cache::HashCache, + structure::StructureGen2d, +}; diff --git a/world/src/util/sampler.rs b/world/src/util/sampler.rs new file mode 100644 index 0000000000..20d6c74080 --- /dev/null +++ b/world/src/util/sampler.rs @@ -0,0 +1,6 @@ +pub trait Sampler: Sized { + type Index; + type Sample; + + fn get(&mut self, index: Self::Index) -> Self::Sample; +} diff --git a/world/src/structure.rs b/world/src/util/structure.rs similarity index 96% rename from world/src/structure.rs rename to world/src/util/structure.rs index 4e51c0f206..920e689f95 100644 --- a/world/src/structure.rs +++ b/world/src/util/structure.rs @@ -32,7 +32,7 @@ impl StructureGen2d { next } - pub fn sample(&self, sample_pos: Vec2) -> [(Vec2, u32); 9] { + pub fn get(&self, sample_pos: Vec2) -> [(Vec2, u32); 9] { let mut samples = [(Vec2::zero(), 0); 9]; let sample_closest = sample_pos.map(|e| e - e.rem_euclid(self.freq as i32)); From 581c4d0e3bbf088ac8b6a616d8aa32a016154f9e Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Sun, 9 Jun 2019 18:05:10 +0100 Subject: [PATCH 07/30] Fixed frustum culling efficiency bug --- voxygen/src/scene/terrain.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/voxygen/src/scene/terrain.rs b/voxygen/src/scene/terrain.rs index 98b9c458f2..f9beaeec07 100644 --- a/voxygen/src/scene/terrain.rs +++ b/voxygen/src/scene/terrain.rs @@ -247,7 +247,7 @@ impl Terrain { chunk_pos.y + chunk_sz / 2.0, (chunk.z_bounds.0 + chunk.z_bounds.1) * 0.5, ); - let chunk_radius = (chunk.z_bounds.1 - chunk.z_bounds.0) + let chunk_radius = ((chunk.z_bounds.1 - chunk.z_bounds.0) / 2.0) .max(chunk_sz / 2.0) .powf(2.0) .mul(2.0) From f62725135a98b48080d52501428f263fb13fe666 Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Sun, 9 Jun 2019 19:46:30 +0100 Subject: [PATCH 08/30] Rescaled mountains --- world/src/block/mod.rs | 4 ++-- world/src/column/mod.rs | 2 +- world/src/config.rs | 2 +- world/src/sim/mod.rs | 24 +++++++++++++----------- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/world/src/block/mod.rs b/world/src/block/mod.rs index 937fc4396e..001be8fb9f 100644 --- a/world/src/block/mod.rs +++ b/world/src/block/mod.rs @@ -61,10 +61,10 @@ impl<'a> Sampler for BlockGen<'a> { let warp = (self.world.sim() .gen_ctx .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) .mul((chaos - 0.1).max(0.0)) - .mul(110.0); + .mul(100.0); let height = alt + warp; diff --git a/world/src/column/mod.rs b/world/src/column/mod.rs index 2d2201f327..af72585c1a 100644 --- a/world/src/column/mod.rs +++ b/world/src/column/mod.rs @@ -121,7 +121,7 @@ impl<'a> Sampler for ColumnGen<'a> { - marble * 24.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 (alt - CONFIG.sea_level - 2.0) / 5.0, diff --git a/world/src/config.rs b/world/src/config.rs index 3dd6f6e09e..1d7238db35 100644 --- a/world/src/config.rs +++ b/world/src/config.rs @@ -5,5 +5,5 @@ pub struct Config { pub const CONFIG: Config = Config { sea_level: 128.0, - mountain_scale: 900.0, + mountain_scale: 1200.0, }; diff --git a/world/src/sim/mod.rs b/world/src/sim/mod.rs index e062e5d293..7aea57b935 100644 --- a/world/src/sim/mod.rs +++ b/world/src/sim/mod.rs @@ -8,7 +8,10 @@ use common::{ terrain::TerrainChunkSize, vol::VolSize, }; -use crate::util::StructureGen2d; +use crate::{ + CONFIG, + util::StructureGen2d, +}; pub const WORLD_SIZE: Vec2 = 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); pub struct SimChunk { @@ -167,10 +167,10 @@ impl SimChunk { .add(0.3) .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) .mul(0.5) - .powf(1.5) + .powf(1.6) .add(0.1 * hill); 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)) .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 + (0.0 + alt_main @@ -194,7 +196,7 @@ impl SimChunk { .add(1.0) .mul(0.5) .mul(chaos) - .mul(MOUNTAIN_HEIGHT); + .mul(CONFIG.mountain_scale); Self { chaos, @@ -210,7 +212,7 @@ impl SimChunk { .mul(0.5) .mul(1.0 - chaos * 0.85) .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 { - (self.alt + Z_TOLERANCE.1).max(SEA_LEVEL + 1.0) + (self.alt + Z_TOLERANCE.1).max(CONFIG.sea_level + 1.0) } } From 264b1efdff170e1bd5fe2ec79d3298c109e0dca7 Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Sun, 9 Jun 2019 22:58:09 +0100 Subject: [PATCH 09/30] Adjusted mountain steepness --- world/src/block/mod.rs | 2 +- world/src/column/mod.rs | 2 +- world/src/sim/mod.rs | 14 +++++++------- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/world/src/block/mod.rs b/world/src/block/mod.rs index 001be8fb9f..ab9861556f 100644 --- a/world/src/block/mod.rs +++ b/world/src/block/mod.rs @@ -64,7 +64,7 @@ impl<'a> Sampler for BlockGen<'a> { .get((wposf.div(Vec3::new(120.0, 120.0, 140.0))).into_array()) as f32) .mul((chaos - 0.1).max(0.0)) - .mul(100.0); + .mul(90.0); let height = alt + warp; diff --git a/world/src/column/mod.rs b/world/src/column/mod.rs index af72585c1a..78146357da 100644 --- a/world/src/column/mod.rs +++ b/world/src/column/mod.rs @@ -115,7 +115,7 @@ impl<'a> Sampler for ColumnGen<'a> { cliff, snow, (alt - CONFIG.sea_level - - 0.3 * CONFIG.mountain_scale + - 0.35 * CONFIG.mountain_scale - alt_base - temp * 96.0 - marble * 24.0) diff --git a/world/src/sim/mod.rs b/world/src/sim/mod.rs index 7aea57b935..567ef9c09b 100644 --- a/world/src/sim/mod.rs +++ b/world/src/sim/mod.rs @@ -158,20 +158,20 @@ impl SimChunk { let hill = (0.0 + gen_ctx .hill_nz - .get((wposf.div(3_500.0)).into_array()) + .get((wposf.div(1_500.0)).into_array()) .mul(1.0) as f32 + gen_ctx .hill_nz - .get((wposf.div(1_000.0)).into_array()) + .get((wposf.div(500.0)).into_array()) .mul(0.3) as f32) .add(0.3) .max(0.0); - let chaos = (gen_ctx.chaos_nz.get((wposf.div(5_000.0)).into_array()) as f32) + let chaos = (gen_ctx.chaos_nz.get((wposf.div(6_000.0)).into_array()) as f32) .add(1.0) .mul(0.5) - .powf(1.6) - .add(0.1 * hill); + .powf(1.4) + .add(0.05 * hill); let chaos = chaos + chaos.mul(16.0).sin().mul(0.02); @@ -181,9 +181,9 @@ impl SimChunk { .add(alt_base.mul(128.0).sin().mul(0.005)) .mul(800.0); - let alt_main = (gen_ctx.alt_nz.get((wposf.div(2_000.0)).into_array()) as f32) + let alt_main = (gen_ctx.alt_nz.get((wposf.div(1_200.0)).into_array()) as f32) .abs() - .powf(1.4); + .powf(1.5); let alt = CONFIG.sea_level + alt_base From 414b730b59aae4903ea1cf95533d298a71235d1a Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Sun, 9 Jun 2019 23:21:51 +0100 Subject: [PATCH 10/30] Reduced peak scale --- world/src/sim/mod.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/world/src/sim/mod.rs b/world/src/sim/mod.rs index 567ef9c09b..f0541d3c17 100644 --- a/world/src/sim/mod.rs +++ b/world/src/sim/mod.rs @@ -171,7 +171,7 @@ impl SimChunk { .add(1.0) .mul(0.5) .powf(1.4) - .add(0.05 * hill); + .add(0.1 * hill); let chaos = chaos + chaos.mul(16.0).sin().mul(0.02); @@ -181,9 +181,9 @@ impl SimChunk { .add(alt_base.mul(128.0).sin().mul(0.005)) .mul(800.0); - let alt_main = (gen_ctx.alt_nz.get((wposf.div(1_200.0)).into_array()) as f32) + let alt_main = (gen_ctx.alt_nz.get((wposf.div(1_000.0)).into_array()) as f32) .abs() - .powf(1.5); + .powf(1.7); let alt = CONFIG.sea_level + alt_base From 7f5a0970f1f06cf4df53e861311b65acf8d72bf5 Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Mon, 10 Jun 2019 00:40:16 +0100 Subject: [PATCH 11/30] Crazy cliffs --- world/src/block/mod.rs | 16 +++++++++++++++- world/src/sim/mod.rs | 4 ++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/world/src/block/mod.rs b/world/src/block/mod.rs index ab9861556f..7c3b531206 100644 --- a/world/src/block/mod.rs +++ b/world/src/block/mod.rs @@ -66,7 +66,21 @@ impl<'a> Sampler for BlockGen<'a> { .mul((chaos - 0.1).max(0.0)) .mul(90.0); - let height = alt + warp; + let cliff = (self.world.sim() + .gen_ctx + .warp_nz + .get((wposf.div(Vec3::new(150.0, 150.0, 150.0))).into_array()) + as f32) + //.add(0.6) + .mul(130.0); + + let is_cliff = (self.world.sim() + .gen_ctx + .warp_nz + .get((wposf.div(Vec3::new(100.0, 100.0, 100.0))).into_array()) + as f32) > 0.0;//4; + + let height = alt + warp + if is_cliff { cliff } else { 0.0 }; // Sample blocks diff --git a/world/src/sim/mod.rs b/world/src/sim/mod.rs index f0541d3c17..ec6e91abe0 100644 --- a/world/src/sim/mod.rs +++ b/world/src/sim/mod.rs @@ -140,7 +140,7 @@ impl WorldSim { } } -const Z_TOLERANCE: (f32, f32) = (128.0, 64.0); +const Z_TOLERANCE: (f32, f32) = (128.0, 128.0); pub struct SimChunk { pub chaos: f32, @@ -179,7 +179,7 @@ impl SimChunk { let alt_base = alt_base .mul(0.4) .add(alt_base.mul(128.0).sin().mul(0.005)) - .mul(800.0); + .mul(400.0); let alt_main = (gen_ctx.alt_nz.get((wposf.div(1_000.0)).into_array()) as f32) .abs() From bac7bad9f75bbabf3e544aded3be5d113bd278c5 Mon Sep 17 00:00:00 2001 From: Monty Marz Date: Mon, 10 Jun 2019 10:50:16 +0000 Subject: [PATCH 12/30] Tree fixes --- assets/world/tree/birch/1.vox | 4 ++-- assets/world/tree/birch/10.vox | 4 ++-- assets/world/tree/birch/11.vox | 4 ++-- assets/world/tree/birch/12.vox | 4 ++-- assets/world/tree/birch/2.vox | 4 ++-- assets/world/tree/birch/3.vox | 4 ++-- assets/world/tree/birch/4.vox | 4 ++-- assets/world/tree/birch/5.vox | 4 ++-- assets/world/tree/birch/6.vox | 4 ++-- assets/world/tree/birch/7.vox | 4 ++-- assets/world/tree/birch/8.vox | 4 ++-- assets/world/tree/birch/9.vox | 4 ++-- assets/world/tree/oak_green/4.vox | 4 ++-- assets/world/tree/oak_green/5.vox | 4 ++-- assets/world/tree/oak_green/6.vox | 4 ++-- assets/world/tree/oak_green/8.vox | 4 ++-- assets/world/tree/pine_green/7.vox | 2 +- assets/world/tree/pine_green_2/5.vox | 2 +- assets/world/tree/pine_green_2/6.vox | 2 +- assets/world/tree/pine_green_2/7.vox | 2 +- assets/world/tree/snow_birch/1.vox | 3 --- assets/world/tree/snow_birch/10.vox | 3 --- assets/world/tree/snow_birch/11.vox | 3 --- assets/world/tree/snow_birch/12.vox | 3 --- assets/world/tree/snow_birch/2.vox | 3 --- assets/world/tree/snow_birch/3.vox | 3 --- assets/world/tree/snow_birch/4.vox | 3 --- assets/world/tree/snow_birch/5.vox | 3 --- assets/world/tree/snow_birch/6.vox | 3 --- assets/world/tree/snow_birch/7.vox | 3 --- assets/world/tree/snow_birch/8.vox | 3 --- assets/world/tree/snow_birch/9.vox | 3 --- world/src/block/tree.rs | 31 +++++++++++++--------------- 33 files changed, 50 insertions(+), 89 deletions(-) delete mode 100644 assets/world/tree/snow_birch/1.vox delete mode 100644 assets/world/tree/snow_birch/10.vox delete mode 100644 assets/world/tree/snow_birch/11.vox delete mode 100644 assets/world/tree/snow_birch/12.vox delete mode 100644 assets/world/tree/snow_birch/2.vox delete mode 100644 assets/world/tree/snow_birch/3.vox delete mode 100644 assets/world/tree/snow_birch/4.vox delete mode 100644 assets/world/tree/snow_birch/5.vox delete mode 100644 assets/world/tree/snow_birch/6.vox delete mode 100644 assets/world/tree/snow_birch/7.vox delete mode 100644 assets/world/tree/snow_birch/8.vox delete mode 100644 assets/world/tree/snow_birch/9.vox diff --git a/assets/world/tree/birch/1.vox b/assets/world/tree/birch/1.vox index d3db900808..60e2399fe0 100644 --- a/assets/world/tree/birch/1.vox +++ b/assets/world/tree/birch/1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3c0fe6707b5bdf8f89fad26a5e1b1f879369262d7e065f77c07f6be6a8c5e717 -size 54700 +oid sha256:bc2c462afb68c98afb12c7cbbc9501e9b2d3f6fcf325f0cc5127dd808755086f +size 55718 diff --git a/assets/world/tree/birch/10.vox b/assets/world/tree/birch/10.vox index 204998f931..042eefc154 100644 --- a/assets/world/tree/birch/10.vox +++ b/assets/world/tree/birch/10.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:cd1160d82bdd836de8d4e850a96cd79d948d0a6c94b616f15135fc48c4b5e7d5 -size 51652 +oid sha256:a38a1aae8dd877392c2edc3c8b8771590967a1167dc5561f4f57742a07917221 +size 52671 diff --git a/assets/world/tree/birch/11.vox b/assets/world/tree/birch/11.vox index 4239b07ec8..d8f15f132b 100644 --- a/assets/world/tree/birch/11.vox +++ b/assets/world/tree/birch/11.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4a1b137704a88b9fcbcce7bbd741a6fa0c89b988684df0f712aa3f869355d0a6 -size 48408 +oid sha256:d8f1e99ecb0ef617f506e1889a38fe26046b6d6000f26ce9efa875bc9b704f2e +size 49427 diff --git a/assets/world/tree/birch/12.vox b/assets/world/tree/birch/12.vox index 54a54a88ce..d8f15f132b 100644 --- a/assets/world/tree/birch/12.vox +++ b/assets/world/tree/birch/12.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2da180f2beabd73abc7655bae02827e0929b7d432f54e1f7c1565232055df58b -size 50968 +oid sha256:d8f1e99ecb0ef617f506e1889a38fe26046b6d6000f26ce9efa875bc9b704f2e +size 49427 diff --git a/assets/world/tree/birch/2.vox b/assets/world/tree/birch/2.vox index c5426e1836..3fcc95b7fe 100644 --- a/assets/world/tree/birch/2.vox +++ b/assets/world/tree/birch/2.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:aa9a270158afb8a426a893e57e0de1ea8af21314473d55b77c204e330120b370 -size 52240 +oid sha256:d6dd7ee0ec36105a2ed2160ea01bb7f898c0e86a28d19d597688b450342f9d1b +size 53263 diff --git a/assets/world/tree/birch/3.vox b/assets/world/tree/birch/3.vox index ba44aa8f69..d40eb79fa1 100644 --- a/assets/world/tree/birch/3.vox +++ b/assets/world/tree/birch/3.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:797745df064b6b1020aa6c12aa140f868da6b28b36436fe08c03cdd3b5f989f3 -size 53348 +oid sha256:66c5bd4c89ee04b86637b39cb34fe82e885c26ce5cb4808b35fd9c68f564a890 +size 54370 diff --git a/assets/world/tree/birch/4.vox b/assets/world/tree/birch/4.vox index 3e52be1e19..c8c0afb6f7 100644 --- a/assets/world/tree/birch/4.vox +++ b/assets/world/tree/birch/4.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a144ae5672726ff73a4a08239bab43c84613d838d7d8f36542e95c0256046cba -size 50404 +oid sha256:8c7e56eb7eca88830ba1f299411cbbea77aa98fb4645755ecfbd6f73ff047ddb +size 51427 diff --git a/assets/world/tree/birch/5.vox b/assets/world/tree/birch/5.vox index c147235f5d..3368805a41 100644 --- a/assets/world/tree/birch/5.vox +++ b/assets/world/tree/birch/5.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:891d8cf201209259b0be75218144a3ba5cae9e4eaeda47bab95e98f04d3a15c4 -size 53252 +oid sha256:79def0c956a88ec62ebcee1a7d01c2a3db767855855b0510915ed3319f7832da +size 54270 diff --git a/assets/world/tree/birch/6.vox b/assets/world/tree/birch/6.vox index 1cf84277e2..1cd46fc796 100644 --- a/assets/world/tree/birch/6.vox +++ b/assets/world/tree/birch/6.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e0b180315df03df883987c8aef2a929c8fcb7d30b551aadb22b629c71e939982 -size 47588 +oid sha256:c3a280c4d03a0049de303654081b0ffda7ca36643a85c0d2076e8ac0d30d1249 +size 48606 diff --git a/assets/world/tree/birch/7.vox b/assets/world/tree/birch/7.vox index f91ff6ef53..b64ba51b4d 100644 --- a/assets/world/tree/birch/7.vox +++ b/assets/world/tree/birch/7.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ffed4d82b9af8d9d05bedcb295d447b82d168f4212a9091d74ad3d1ece399f82 -size 49088 +oid sha256:b2c5023855fe827cc45c4a65ace5d3d59d16213c00eb05b781f755263a6b0886 +size 50106 diff --git a/assets/world/tree/birch/8.vox b/assets/world/tree/birch/8.vox index 6714b6b64f..10f49e29d3 100644 --- a/assets/world/tree/birch/8.vox +++ b/assets/world/tree/birch/8.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a7cd4451e1c530d33c6645507295f08390d01893c5ea150d5e8dca31dbf870bb -size 51168 +oid sha256:b8349ccf7a3a71ac3d612eaa4e6ff56b1729a1d010f6f7b93773218f6c3958b4 +size 52186 diff --git a/assets/world/tree/birch/9.vox b/assets/world/tree/birch/9.vox index 7503b6f925..de882c9579 100644 --- a/assets/world/tree/birch/9.vox +++ b/assets/world/tree/birch/9.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:08b818556176ae0029537874b4edfa28e1dfa22dab3496c54621b5bbfa4f7412 -size 48720 +oid sha256:568fa985313f586b33f72520417255f1e16843c638ca29558abaadf995f07539 +size 49738 diff --git a/assets/world/tree/oak_green/4.vox b/assets/world/tree/oak_green/4.vox index d04842d512..0825eb9557 100644 --- a/assets/world/tree/oak_green/4.vox +++ b/assets/world/tree/oak_green/4.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b984ae894d1e1f22fedd7be18ac7513379d55a5dcb955a922e75c74e00cd8ecb -size 90086 +oid sha256:133a6c7a25ac684fe2c6e7ff45e522ef13fdc57070c115d8e8384091ce9801ce +size 89944 diff --git a/assets/world/tree/oak_green/5.vox b/assets/world/tree/oak_green/5.vox index 2c0e2113da..869bc27c6f 100644 --- a/assets/world/tree/oak_green/5.vox +++ b/assets/world/tree/oak_green/5.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f20ee21f4fe943a58fb526866938344d0eadea4fe7ba5eb346be38a9608f1862 -size 95770 +oid sha256:e5c2bb0810ae0a7fb933b7211c6d4b815ec03a946b16db198612341f7c659e23 +size 95628 diff --git a/assets/world/tree/oak_green/6.vox b/assets/world/tree/oak_green/6.vox index 4703debd98..5a2ab7fc4a 100644 --- a/assets/world/tree/oak_green/6.vox +++ b/assets/world/tree/oak_green/6.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:da81618dd17267b9f77288820d50cc90beb8449a5ad0359a30a95dab97f0cf68 -size 114626 +oid sha256:06f903b21f6d09415bf16ce6d74d7dadcf341e7a23f4903fd436e4fa21509c17 +size 114484 diff --git a/assets/world/tree/oak_green/8.vox b/assets/world/tree/oak_green/8.vox index 14b5e4ccfc..1fe0b01ce1 100644 --- a/assets/world/tree/oak_green/8.vox +++ b/assets/world/tree/oak_green/8.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3d27a639f1bcd6a12a015db29732f7a5524b6deee524a1746c6009a1aad102fa -size 117482 +oid sha256:6e1d9bcc717afa853c9a22592447177ea96c6689f871faa30be03631a7d0ff34 +size 117340 diff --git a/assets/world/tree/pine_green/7.vox b/assets/world/tree/pine_green/7.vox index 3ef50ffeaf..e9cb75abd3 100644 --- a/assets/world/tree/pine_green/7.vox +++ b/assets/world/tree/pine_green/7.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3158ad1e2e37a9900b0bf46a950f0fa2d885a294109a7bba2881435442a6f055 +oid sha256:dc579d8ead42e0502ad9f20ff150347824dae1f0557a606b099f0c1575df99b3 size 54812 diff --git a/assets/world/tree/pine_green_2/5.vox b/assets/world/tree/pine_green_2/5.vox index f9ccda156e..b373516f00 100644 --- a/assets/world/tree/pine_green_2/5.vox +++ b/assets/world/tree/pine_green_2/5.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9522d3e1ef3082f11157384a9ec7481ead62b84177d1f05099673cf20ace1c89 +oid sha256:f81680a7d43bebf964dd58815355dbbaca4bfa5e2a5b051772680c1b71ad1c9c size 51128 diff --git a/assets/world/tree/pine_green_2/6.vox b/assets/world/tree/pine_green_2/6.vox index f4c7127a8b..d091ef076b 100644 --- a/assets/world/tree/pine_green_2/6.vox +++ b/assets/world/tree/pine_green_2/6.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:76875a53fbad2782791351e4592483f11d84774aca96a53ed7174a920b51e718 +oid sha256:61ef309f4d08018c8894291c0559afa971e154c75c5e54b176233648bc9918da size 49053 diff --git a/assets/world/tree/pine_green_2/7.vox b/assets/world/tree/pine_green_2/7.vox index d7a7312d39..e46d1b297e 100644 --- a/assets/world/tree/pine_green_2/7.vox +++ b/assets/world/tree/pine_green_2/7.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:44f8df2859a165faa4197cb4fbe440ff9315501217de06aeef491ac91303a7c6 +oid sha256:35bcde865dff7d2023f2b42c8f60c79e13b2c44dc6d241b8f7b377f82dbaf08b size 54812 diff --git a/assets/world/tree/snow_birch/1.vox b/assets/world/tree/snow_birch/1.vox deleted file mode 100644 index 90668d827b..0000000000 --- a/assets/world/tree/snow_birch/1.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:48c7600338abb4c22b3faf934d4dbb526863d8192b478e672439d395d1e11f80 -size 45440 diff --git a/assets/world/tree/snow_birch/10.vox b/assets/world/tree/snow_birch/10.vox deleted file mode 100644 index 2cb160d29a..0000000000 --- a/assets/world/tree/snow_birch/10.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:141304b301dc41523fb8ea0ad523b7e5b8f77d3514951d34c5143196a496bc4b -size 45548 diff --git a/assets/world/tree/snow_birch/11.vox b/assets/world/tree/snow_birch/11.vox deleted file mode 100644 index e848c822ca..0000000000 --- a/assets/world/tree/snow_birch/11.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:68a6d760e102d53e573a0cc8b8a78e884b854bd342da8dd6a738bc17e2a94c47 -size 45484 diff --git a/assets/world/tree/snow_birch/12.vox b/assets/world/tree/snow_birch/12.vox deleted file mode 100644 index 5d19c2dbf5..0000000000 --- a/assets/world/tree/snow_birch/12.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:81d8a8731f64f9e26ffe44a156b210a82b6d56d1e42a1b635ed6bd4c899b6260 -size 45584 diff --git a/assets/world/tree/snow_birch/2.vox b/assets/world/tree/snow_birch/2.vox deleted file mode 100644 index 35ddfd97f4..0000000000 --- a/assets/world/tree/snow_birch/2.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:7fce148f46839a57aba9acb51f03130920e2258d0e6e5cb212ea8c59dc6600e5 -size 45408 diff --git a/assets/world/tree/snow_birch/3.vox b/assets/world/tree/snow_birch/3.vox deleted file mode 100644 index 5633fe1a9c..0000000000 --- a/assets/world/tree/snow_birch/3.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:5f0b0f3f1a28cf880d43986329dbd83bc057f526fb02acca6ffe2e7feb04d9c2 -size 45280 diff --git a/assets/world/tree/snow_birch/4.vox b/assets/world/tree/snow_birch/4.vox deleted file mode 100644 index 29307be53c..0000000000 --- a/assets/world/tree/snow_birch/4.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:2aa2ff75164c512a55baee1a8a325d1ee0b3b17dac5cf6ad59541f8ac89d6103 -size 45452 diff --git a/assets/world/tree/snow_birch/5.vox b/assets/world/tree/snow_birch/5.vox deleted file mode 100644 index 2ea066bb5c..0000000000 --- a/assets/world/tree/snow_birch/5.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:b22dc5a4bc6541595ab3aafc7c98e0edf9d5decd555f7f8a5942d031ca220af7 -size 45356 diff --git a/assets/world/tree/snow_birch/6.vox b/assets/world/tree/snow_birch/6.vox deleted file mode 100644 index 042eb23307..0000000000 --- a/assets/world/tree/snow_birch/6.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:f0f62904d3c7a9e5eed4bdb04d21a743c3063cc3079f85a6c99cd3e16de85bad -size 45236 diff --git a/assets/world/tree/snow_birch/7.vox b/assets/world/tree/snow_birch/7.vox deleted file mode 100644 index 64b1f2dd7e..0000000000 --- a/assets/world/tree/snow_birch/7.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:1a9255a5223b69a7bcce7fc544bbf47f54e6a1d321077246a0fbdcac1ec8dfad -size 45292 diff --git a/assets/world/tree/snow_birch/8.vox b/assets/world/tree/snow_birch/8.vox deleted file mode 100644 index e5a1e71a74..0000000000 --- a/assets/world/tree/snow_birch/8.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:fbf8f4e3f2dcc66a48a3836e302ffa3d854f491728685ab0df7050c2f018b7b6 -size 45236 diff --git a/assets/world/tree/snow_birch/9.vox b/assets/world/tree/snow_birch/9.vox deleted file mode 100644 index 7198d269c1..0000000000 --- a/assets/world/tree/snow_birch/9.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:aca48ec226bb2382369eb3375ac8ad9f013de03b0d48d108d8d9e21f388609b2 -size 45316 diff --git a/world/src/block/tree.rs b/world/src/block/tree.rs index 7f98b7a895..ee6dfb3015 100644 --- a/world/src/block/tree.rs +++ b/world/src/block/tree.rs @@ -1,10 +1,7 @@ +use common::{assets, terrain::Structure}; +use lazy_static::lazy_static; use std::sync::Arc; use vek::*; -use lazy_static::lazy_static; -use common::{ - assets, - terrain::Structure, -}; lazy_static! { pub static ref TREES: [Arc; 61] = [ @@ -132,40 +129,40 @@ lazy_static! { .unwrap(), // birch assets::load_map("world/tree/birch/1.vox", |s: Structure| s - .with_center(Vec3::new(12, 9, 5))) + .with_center(Vec3::new(12, 9, 10))) .unwrap(), assets::load_map("world/tree/birch/2.vox", |s: Structure| s - .with_center(Vec3::new(11, 10, 5))) + .with_center(Vec3::new(11, 10, 10))) .unwrap(), assets::load_map("world/tree/birch/3.vox", |s: Structure| s - .with_center(Vec3::new(9, 10, 5))) + .with_center(Vec3::new(9, 10, 10))) .unwrap(), assets::load_map("world/tree/birch/4.vox", |s: Structure| s - .with_center(Vec3::new(9, 10, 5))) + .with_center(Vec3::new(9, 10, 10))) .unwrap(), assets::load_map("world/tree/birch/5.vox", |s: Structure| s - .with_center(Vec3::new(9, 11, 5))) + .with_center(Vec3::new(9, 11, 10))) .unwrap(), assets::load_map("world/tree/birch/6.vox", |s: Structure| s - .with_center(Vec3::new(9, 9, 5))) + .with_center(Vec3::new(9, 9, 10))) .unwrap(), assets::load_map("world/tree/birch/7.vox", |s: Structure| s - .with_center(Vec3::new(10, 10, 5))) + .with_center(Vec3::new(10, 10, 10))) .unwrap(), assets::load_map("world/tree/birch/8.vox", |s: Structure| s - .with_center(Vec3::new(9, 9, 5))) + .with_center(Vec3::new(9, 9, 10))) .unwrap(), assets::load_map("world/tree/birch/9.vox", |s: Structure| s - .with_center(Vec3::new(9, 10, 5))) + .with_center(Vec3::new(9, 10, 10))) .unwrap(), assets::load_map("world/tree/birch/10.vox", |s: Structure| s - .with_center(Vec3::new(10, 9, 5))) + .with_center(Vec3::new(10, 9, 10))) .unwrap(), assets::load_map("world/tree/birch/11.vox", |s: Structure| s - .with_center(Vec3::new(9, 10, 5))) + .with_center(Vec3::new(9, 10, 10))) .unwrap(), assets::load_map("world/tree/birch/12.vox", |s: Structure| s - .with_center(Vec3::new(10, 9, 5))) + .with_center(Vec3::new(10, 9, 10))) .unwrap(), // poplar assets::load_map("world/tree/poplar/1.vox", |s: Structure| s From 38c836d6c591b794e283e29dcb349ea740ceb529 Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Mon, 10 Jun 2019 11:50:48 +0100 Subject: [PATCH 13/30] Simpler cliffs, camera tilt --- voxygen/src/scene/camera.rs | 5 +++++ voxygen/src/scene/mod.rs | 4 +++- world/src/block/mod.rs | 31 +++++++++++++++++++++---------- world/src/block/tree.rs | 6 +++--- world/src/column/mod.rs | 8 +++++--- 5 files changed, 37 insertions(+), 17 deletions(-) diff --git a/voxygen/src/scene/camera.rs b/voxygen/src/scene/camera.rs index 1f220e3639..40d5193a1e 100644 --- a/voxygen/src/scene/camera.rs +++ b/voxygen/src/scene/camera.rs @@ -106,6 +106,11 @@ impl Camera { self.tgt_dist = (self.tgt_dist + delta).max(0.0); } + /// Get the distance of the camera from the target + pub fn get_distance(&self) -> f32 { + self.tgt_dist + } + /// Set the distance of the camera from the target (i.e., zoom). pub fn set_distance(&mut self, dist: f32) { self.tgt_dist = dist; diff --git a/voxygen/src/scene/mod.rs b/voxygen/src/scene/mod.rs index f6f0980b06..c27f38ba1a 100644 --- a/voxygen/src/scene/mod.rs +++ b/voxygen/src/scene/mod.rs @@ -115,7 +115,9 @@ impl Scene { .map_or(Vec3::zero(), |pos| pos.0); // Alter camera position to match player. - self.camera.set_focus_pos(player_pos + Vec3::unit_z() * 2.1); + let tilt = self.camera.get_orientation().y; + let dist = self.camera.get_distance(); + self.camera.set_focus_pos(player_pos + Vec3::unit_z() * (2.1 - tilt.min(0.0) * dist * 0.5)); // Tick camera for interpolation. self.camera.update(client.state().get_time()); diff --git a/world/src/block/mod.rs b/world/src/block/mod.rs index 7c3b531206..3d5f3c07e1 100644 --- a/world/src/block/mod.rs +++ b/world/src/block/mod.rs @@ -66,19 +66,25 @@ impl<'a> Sampler for BlockGen<'a> { .mul((chaos - 0.1).max(0.0)) .mul(90.0); - let cliff = (self.world.sim() - .gen_ctx - .warp_nz - .get((wposf.div(Vec3::new(150.0, 150.0, 150.0))).into_array()) - as f32) - //.add(0.6) - .mul(130.0); + let cliff = (0.0 + + (self.world.sim() + .gen_ctx + .warp_nz + .get((wposf.div(Vec3::new(350.0, 350.0, 800.0))).into_array()) + as f32) * 0.8 + + (self.world.sim() + .gen_ctx + .warp_nz + .get((wposf.div(Vec3::new(100.0, 100.0, 100.0))).into_array()) + as f32) * 0.2) + .add(0.6) + .mul(64.0); let is_cliff = (self.world.sim() .gen_ctx .warp_nz - .get((wposf.div(Vec3::new(100.0, 100.0, 100.0))).into_array()) - as f32) > 0.0;//4; + .get((wposf.div(Vec3::new(300.0, 300.0, 800.0))).into_array()) + as f32) > 0.25;//4; let height = alt + warp + if is_cliff { cliff } else { 0.0 }; @@ -86,6 +92,7 @@ impl<'a> Sampler for BlockGen<'a> { let air = Block::empty(); let stone = Block::new(2, Rgb::new(200, 220, 255)); + let surface_stone = Block::new(1, Rgb::new(200, 220, 255)); let dirt = Block::new(1, Rgb::new(128, 90, 0)); let sand = Block::new(1, Rgb::new(180, 150, 50)); let water = Block::new(1, Rgb::new(100, 150, 255)); @@ -93,7 +100,11 @@ impl<'a> Sampler for BlockGen<'a> { let block = if (wposf.z as f32) < height - 4.0 { // Underground - Some(stone) + if (wposf.z as f32) > alt { + Some(surface_stone) + } else { + Some(stone) + } } else if (wposf.z as f32) < height { // Surface Some(Block::new(1, surface_color.map(|e| (e * 255.0) as u8))) diff --git a/world/src/block/tree.rs b/world/src/block/tree.rs index ee6dfb3015..b3f61b4ee5 100644 --- a/world/src/block/tree.rs +++ b/world/src/block/tree.rs @@ -4,7 +4,7 @@ use std::sync::Arc; use vek::*; lazy_static! { - pub static ref TREES: [Arc; 61] = [ + pub static ref TREES: [Arc; 9] = [ // green oaks assets::load_map("world/tree/oak_green/1.vox", |s: Structure| s .with_center(Vec3::new(15, 18, 14))) @@ -34,7 +34,7 @@ lazy_static! { .with_center(Vec3::new(26, 26, 14))) .unwrap(), // green pines - assets::load_map("world/tree/pine_green/1.vox", |s: Structure| s + /*assets::load_map("world/tree/pine_green/1.vox", |s: Structure| s .with_center(Vec3::new(15, 15, 14))) .unwrap(), assets::load_map("world/tree/pine_green/2.vox", |s: Structure| s @@ -196,7 +196,7 @@ lazy_static! { .with_center(Vec3::new(7, 7, 10))) .unwrap(), // palm trees - /*assets::load_map("world/tree/desert_palm/1.vox", |s: Structure| s + assets::load_map("world/tree/desert_palm/1.vox", |s: Structure| s .with_center(Vec3::new(12, 12, 10))) .unwrap(), assets::load_map("world/tree/desert_palm/2.vox", |s: Structure| s diff --git a/world/src/column/mod.rs b/world/src/column/mod.rs index 78146357da..48a5e815e9 100644 --- a/world/src/column/mod.rs +++ b/world/src/column/mod.rs @@ -45,13 +45,15 @@ impl<'a> Sampler for ColumnGen<'a> { let rock = (sim.gen_ctx.small_nz.get(Vec3::new(wposf.x, wposf.y, alt as f64).div(100.0).into_array()) as f32) .mul(rockiness) - .sub(0.35) + .sub(0.4) .max(0.0) - .mul(6.0); + .mul(8.0); let wposf3d = Vec3::new(wposf.x, wposf.y, alt as f64); - let marble = (sim.gen_ctx.hill_nz.get((wposf3d.div(48.0)).into_array()) as f32) + let marble = (0.0 + + (sim.gen_ctx.hill_nz.get((wposf3d.div(48.0)).into_array()) as f32).mul(0.75) + + (sim.gen_ctx.hill_nz.get((wposf3d.div(3.0)).into_array()) as f32).mul(0.5)) .add(1.0) .mul(0.5); From 8071670a37b000d72d04c8f51a16b8c8730962d7 Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Mon, 10 Jun 2019 12:03:49 +0100 Subject: [PATCH 14/30] More trees, adjusted camera tilt --- voxygen/src/scene/mod.rs | 2 +- world/src/block/tree.rs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/voxygen/src/scene/mod.rs b/voxygen/src/scene/mod.rs index c27f38ba1a..da476c6248 100644 --- a/voxygen/src/scene/mod.rs +++ b/voxygen/src/scene/mod.rs @@ -117,7 +117,7 @@ impl Scene { // Alter camera position to match player. let tilt = self.camera.get_orientation().y; let dist = self.camera.get_distance(); - self.camera.set_focus_pos(player_pos + Vec3::unit_z() * (2.1 - tilt.min(0.0) * dist * 0.5)); + self.camera.set_focus_pos(player_pos + Vec3::unit_z() * (2.1 - tilt.min(0.0) * dist * 0.75)); // Tick camera for interpolation. self.camera.update(client.state().get_time()); diff --git a/world/src/block/tree.rs b/world/src/block/tree.rs index b3f61b4ee5..1568aa88bd 100644 --- a/world/src/block/tree.rs +++ b/world/src/block/tree.rs @@ -4,7 +4,7 @@ use std::sync::Arc; use vek::*; lazy_static! { - pub static ref TREES: [Arc; 9] = [ + pub static ref TREES: [Arc; 81] = [ // green oaks assets::load_map("world/tree/oak_green/1.vox", |s: Structure| s .with_center(Vec3::new(15, 18, 14))) @@ -34,7 +34,7 @@ lazy_static! { .with_center(Vec3::new(26, 26, 14))) .unwrap(), // green pines - /*assets::load_map("world/tree/pine_green/1.vox", |s: Structure| s + assets::load_map("world/tree/pine_green/1.vox", |s: Structure| s .with_center(Vec3::new(15, 15, 14))) .unwrap(), assets::load_map("world/tree/pine_green/2.vox", |s: Structure| s @@ -251,6 +251,7 @@ lazy_static! { assets::load_map("world/tree/snow_pine/8.vox", |s: Structure| s .with_center(Vec3::new(12, 10, 12))) .unwrap(), + /* // snow birches -> need roots! assets::load_map("world/tree/snow_birch/1.vox", |s: Structure| s .with_center(Vec3::new(12, 9, 4))) @@ -288,6 +289,7 @@ lazy_static! { assets::load_map("world/tree/snow_birch/12.vox", |s: Structure| s .with_center(Vec3::new(10, 9, 4))) .unwrap(), + */ // willows assets::load_map("world/tree/willow/1.vox", |s: Structure| s .with_center(Vec3::new(15, 14, 1))) @@ -295,7 +297,5 @@ lazy_static! { assets::load_map("world/tree/willow/2.vox", |s: Structure| s .with_center(Vec3::new(11, 12, 1))) .unwrap(), - */ - ]; } From df2594cbb43df6546d2a2a8274f0da82bb7fd292 Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Mon, 10 Jun 2019 15:22:59 +0100 Subject: [PATCH 15/30] Added more terrain noise, better snow --- world/src/block/mod.rs | 37 +++++++++++++++++++++++-------------- world/src/column/mod.rs | 25 ++++++++++++++++--------- world/src/sim/mod.rs | 11 ++++++++++- 3 files changed, 49 insertions(+), 24 deletions(-) diff --git a/world/src/block/mod.rs b/world/src/block/mod.rs index 3d5f3c07e1..48c6f521fc 100644 --- a/world/src/block/mod.rs +++ b/world/src/block/mod.rs @@ -52,6 +52,7 @@ impl<'a> Sampler for BlockGen<'a> { cave_xy, cave_alt, rock, + cliff, } = self.sample_column(Vec2::from(wpos))?; let wposf = wpos.map(|e| e as f64); @@ -64,9 +65,20 @@ impl<'a> Sampler for BlockGen<'a> { .get((wposf.div(Vec3::new(120.0, 120.0, 140.0))).into_array()) as f32) .mul((chaos - 0.1).max(0.0)) - .mul(90.0); + .mul(120.0); - let cliff = (0.0 + let is_cliff = if cliff > 0.0 { + (self.world.sim() + .gen_ctx + .warp_nz + .get((wposf.div(Vec3::new(300.0, 300.0, 800.0))).into_array()) + as f32) * cliff > 0.3 + } else { + false + }; + + let cliff = if is_cliff { + (0.0 + (self.world.sim() .gen_ctx .warp_nz @@ -75,18 +87,15 @@ impl<'a> Sampler for BlockGen<'a> { + (self.world.sim() .gen_ctx .warp_nz - .get((wposf.div(Vec3::new(100.0, 100.0, 100.0))).into_array()) - as f32) * 0.2) - .add(0.6) - .mul(64.0); + .get((wposf.div(Vec3::new(100.0, 100.0, 70.0))).into_array()) + as f32) * 0.3) + .add(0.4) + .mul(64.0) + } else { + 0.0 + }; - let is_cliff = (self.world.sim() - .gen_ctx - .warp_nz - .get((wposf.div(Vec3::new(300.0, 300.0, 800.0))).into_array()) - as f32) > 0.25;//4; - - let height = alt + warp + if is_cliff { cliff } else { 0.0 }; + let height = alt + warp + cliff; // Sample blocks @@ -98,7 +107,7 @@ impl<'a> Sampler for BlockGen<'a> { let water = Block::new(1, Rgb::new(100, 150, 255)); let warm_stone = Block::new(1, Rgb::new(165, 165, 90)); - let block = if (wposf.z as f32) < height - 4.0 { + let block = if (wposf.z as f32) < height - 2.0 { // Underground if (wposf.z as f32) > alt { Some(surface_stone) diff --git a/world/src/column/mod.rs b/world/src/column/mod.rs index 48a5e815e9..fc625b5d67 100644 --- a/world/src/column/mod.rs +++ b/world/src/column/mod.rs @@ -36,6 +36,7 @@ impl<'a> Sampler for ColumnGen<'a> { let chaos = sim.get_interpolated(wpos, |chunk| chunk.chaos)?; let temp = sim.get_interpolated(wpos, |chunk| chunk.temp)?; let rockiness = sim.get_interpolated(wpos, |chunk| chunk.rockiness)?; + let cliffiness = sim.get_interpolated(wpos, |chunk| chunk.cliffiness)?; let tree_density = sim.get_interpolated(wpos, |chunk| chunk.tree_density)?; let alt = sim.get_interpolated(wpos, |chunk| chunk.alt)? @@ -53,26 +54,30 @@ impl<'a> Sampler for ColumnGen<'a> { let marble = (0.0 + (sim.gen_ctx.hill_nz.get((wposf3d.div(48.0)).into_array()) as f32).mul(0.75) - + (sim.gen_ctx.hill_nz.get((wposf3d.div(3.0)).into_array()) as f32).mul(0.5)) + + (sim.gen_ctx.hill_nz.get((wposf3d.div(3.0)).into_array()) as f32).mul(0.25)) .add(1.0) .mul(0.5); // Colours - let cold_grass = Rgb::new(0.0, 0.4, 0.1); - let warm_grass = Rgb::new(0.25, 0.8, 0.05); + let cold_grass = Rgb::new(0.0, 0.3, 0.1); + let warm_grass = Rgb::new(0.25, 0.9, 0.05); let cold_stone = Rgb::new(0.55, 0.7, 0.75); let warm_stone = Rgb::new(0.65, 0.65, 0.35); - let beach_sand = Rgb::new(0.93, 0.84, 0.33); - let desert_sand = Rgb::new(0.97, 0.84, 0.23); + let beach_sand = Rgb::new(0.93, 0.84, 0.4); + let desert_sand = Rgb::new(0.98, 0.8, 0.15); let snow = Rgb::broadcast(1.0); let grass = Rgb::lerp(cold_grass, warm_grass, marble); - let grassland = grass; //Rgb::lerp(grass, warm_stone, rock.mul(5.0).min(0.8)); + let sand = Rgb::lerp(beach_sand, desert_sand, marble); let cliff = Rgb::lerp(cold_stone, warm_stone, marble); let ground = Rgb::lerp( - Rgb::lerp(snow, grassland, temp.add(0.4).mul(32.0).sub(0.4)), - desert_sand, + Rgb::lerp( + snow, + grass, + temp.add(0.4).add(marble * 0.05).mul(256.0).sub(0.4), + ), + sand, temp.sub(0.4).mul(32.0).add(0.4), ); @@ -108,7 +113,7 @@ impl<'a> Sampler for ColumnGen<'a> { alt, chaos, surface_color: Rgb::lerp( - beach_sand, + sand, // Land Rgb::lerp( ground, @@ -133,6 +138,7 @@ impl<'a> Sampler for ColumnGen<'a> { cave_xy, cave_alt, rock, + cliff: cliffiness, }) } } @@ -147,4 +153,5 @@ pub struct ColumnSample { pub cave_xy: f32, pub cave_alt: f32, pub rock: f32, + pub cliff: f32, } diff --git a/world/src/sim/mod.rs b/world/src/sim/mod.rs index ec6e91abe0..38bd431fa2 100644 --- a/world/src/sim/mod.rs +++ b/world/src/sim/mod.rs @@ -24,6 +24,7 @@ pub(crate) struct GenCtx { pub temp_nz: SuperSimplex, pub small_nz: BasicMulti, pub rock_nz: HybridMulti, + pub cliff_nz: HybridMulti, pub warp_nz: BasicMulti, pub tree_nz: BasicMulti, @@ -53,6 +54,7 @@ impl WorldSim { temp_nz: SuperSimplex::new().set_seed(seed + 5), small_nz: BasicMulti::new().set_octaves(2).set_seed(seed + 6), rock_nz: HybridMulti::new().set_persistence(0.3).set_seed(seed + 7), + cliff_nz: HybridMulti::new().set_persistence(0.3).set_seed(seed + 7), warp_nz: BasicMulti::new().set_octaves(3).set_seed(seed + 8), tree_nz: BasicMulti::new() .set_octaves(12) @@ -140,7 +142,7 @@ impl WorldSim { } } -const Z_TOLERANCE: (f32, f32) = (128.0, 128.0); +const Z_TOLERANCE: (f32, f32) = (128.0, 96.0); pub struct SimChunk { pub chaos: f32, @@ -148,6 +150,7 @@ pub struct SimChunk { pub alt: f32, pub temp: f32, pub rockiness: f32, + pub cliffiness: f32, pub tree_density: f32, } @@ -207,6 +210,12 @@ impl SimChunk { .sub(0.1) .mul(1.2) .max(0.0), + cliffiness: (gen_ctx.cliff_nz.get((wposf.div(2048.0)).into_array()) as f32) + .sub(0.15) + .mul(3.0) + .mul(1.1 - chaos) + .max(0.0) + .min(1.0), tree_density: (gen_ctx.tree_nz.get((wposf.div(1024.0)).into_array()) as f32) .add(1.0) .mul(0.5) From e671d8473c775ba6fdcf7794228cd7626c71db8b Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Mon, 10 Jun 2019 16:16:54 +0100 Subject: [PATCH 16/30] Bluer snow, altered rock colour --- voxygen/shaders/terrain.vert | 2 +- voxygen/src/render/pipelines/terrain.rs | 6 +++--- world/src/block/mod.rs | 8 ++++---- world/src/column/mod.rs | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/voxygen/shaders/terrain.vert b/voxygen/shaders/terrain.vert index 1a448dbba3..7b1d416925 100644 --- a/voxygen/shaders/terrain.vert +++ b/voxygen/shaders/terrain.vert @@ -28,7 +28,7 @@ void main() { float((v_col_light >> 8) & 0xFFu), float((v_col_light >> 16) & 0xFFu), float((v_col_light >> 24) & 0xFFu) - ) / 255.0; + ) / 200.0; f_light = float(v_col_light & 0xFFu) / 255.0; diff --git a/voxygen/src/render/pipelines/terrain.rs b/voxygen/src/render/pipelines/terrain.rs index 324767b735..83d7c9b554 100644 --- a/voxygen/src/render/pipelines/terrain.rs +++ b/voxygen/src/render/pipelines/terrain.rs @@ -53,9 +53,9 @@ impl Vertex { | ((pos.z as u32) & 0x1FFF) << 16 | ((norm_bits as u32) & 0x7) << 29, col_light: 0 - | ((col.r.mul(255.0) as u32) & 0xFF) << 8 - | ((col.g.mul(255.0) as u32) & 0xFF) << 16 - | ((col.b.mul(255.0) as u32) & 0xFF) << 24 + | ((col.r.mul(200.0) as u32) & 0xFF) << 8 + | ((col.g.mul(200.0) as u32) & 0xFF) << 16 + | ((col.b.mul(200.0) as u32) & 0xFF) << 24 | ((light.mul(255.0) as u32) & 0xFF) << 0, } } diff --git a/world/src/block/mod.rs b/world/src/block/mod.rs index 48c6f521fc..0d8f6014d4 100644 --- a/world/src/block/mod.rs +++ b/world/src/block/mod.rs @@ -62,16 +62,16 @@ impl<'a> Sampler for BlockGen<'a> { let warp = (self.world.sim() .gen_ctx .warp_nz - .get((wposf.div(Vec3::new(120.0, 120.0, 140.0))).into_array()) + .get((wposf.div(Vec3::new(150.0, 150.0, 150.0))).into_array()) as f32) .mul((chaos - 0.1).max(0.0)) - .mul(120.0); + .mul(130.0); let is_cliff = if cliff > 0.0 { (self.world.sim() .gen_ctx .warp_nz - .get((wposf.div(Vec3::new(300.0, 300.0, 800.0))).into_array()) + .get((wposf.div(Vec3::new(300.0, 300.0, 1500.0))).into_array()) as f32) * cliff > 0.3 } else { false @@ -105,7 +105,7 @@ impl<'a> Sampler for BlockGen<'a> { let dirt = Block::new(1, Rgb::new(128, 90, 0)); let sand = Block::new(1, Rgb::new(180, 150, 50)); let water = Block::new(1, Rgb::new(100, 150, 255)); - let warm_stone = Block::new(1, Rgb::new(165, 165, 90)); + let warm_stone = Block::new(1, Rgb::new(165, 165, 130)); let block = if (wposf.z as f32) < height - 2.0 { // Underground diff --git a/world/src/column/mod.rs b/world/src/column/mod.rs index fc625b5d67..7faa8b104d 100644 --- a/world/src/column/mod.rs +++ b/world/src/column/mod.rs @@ -65,7 +65,7 @@ impl<'a> Sampler for ColumnGen<'a> { let warm_stone = Rgb::new(0.65, 0.65, 0.35); let beach_sand = Rgb::new(0.93, 0.84, 0.4); let desert_sand = Rgb::new(0.98, 0.8, 0.15); - let snow = Rgb::broadcast(1.0); + let snow = Rgb::new(0.9, 0.9, 1.3); let grass = Rgb::lerp(cold_grass, warm_grass, marble); let sand = Rgb::lerp(beach_sand, desert_sand, marble); From fa8f3a4b498227e0ecf4c6559931fab23e91589b Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Mon, 10 Jun 2019 17:28:02 +0100 Subject: [PATCH 17/30] Tweaked lighting and AO --- voxygen/shaders/terrain.frag | 4 ++-- voxygen/src/mesh/vol.rs | 2 +- world/src/block/mod.rs | 2 +- world/src/config.rs | 2 +- world/src/sim/location.rs | 1 + world/src/sim/mod.rs | 22 +++++++++++++++++++--- 6 files changed, 25 insertions(+), 8 deletions(-) create mode 100644 world/src/sim/location.rs diff --git a/voxygen/shaders/terrain.frag b/voxygen/shaders/terrain.frag index b45d545ae4..2c56dbf007 100644 --- a/voxygen/shaders/terrain.frag +++ b/voxygen/shaders/terrain.frag @@ -28,9 +28,9 @@ void main() { f_norm = vec3(0.0, 0.0, 1.0) * norm_dir; } - float glob_ambience = 0.001; + float glob_ambience = 0.0005; - float sun_ambience = 0.9; + float sun_ambience = 0.8; vec3 sun_dir = normalize(vec3(1.3, 1.7, 2.1)); diff --git a/voxygen/src/mesh/vol.rs b/voxygen/src/mesh/vol.rs index e07456c896..7223a46af7 100644 --- a/voxygen/src/mesh/vol.rs +++ b/voxygen/src/mesh/vol.rs @@ -53,7 +53,7 @@ fn create_quad, Vec3, Rgb) -> P::Vertex>( let ao_scale = 0.95; let dark = col * (1.0 - ao_scale); - let ao_map = ao.map(|e| e.powf(1.5)); + let ao_map = ao.map(|e| 0.15 + e.powf(2.0) * 0.85); if ao[0].min(ao[2]) < ao[1].min(ao[3]) { Quad::new( diff --git a/world/src/block/mod.rs b/world/src/block/mod.rs index 0d8f6014d4..429c221d17 100644 --- a/world/src/block/mod.rs +++ b/world/src/block/mod.rs @@ -107,7 +107,7 @@ impl<'a> Sampler for BlockGen<'a> { let water = Block::new(1, Rgb::new(100, 150, 255)); let warm_stone = Block::new(1, Rgb::new(165, 165, 130)); - let block = if (wposf.z as f32) < height - 2.0 { + let block = if (wposf.z as f32) < height - 3.0 { // Underground if (wposf.z as f32) > alt { Some(surface_stone) diff --git a/world/src/config.rs b/world/src/config.rs index 1d7238db35..3e5d801e42 100644 --- a/world/src/config.rs +++ b/world/src/config.rs @@ -4,6 +4,6 @@ pub struct Config { } pub const CONFIG: Config = Config { - sea_level: 128.0, + sea_level: 140.0, mountain_scale: 1200.0, }; diff --git a/world/src/sim/location.rs b/world/src/sim/location.rs new file mode 100644 index 0000000000..fb02b051d4 --- /dev/null +++ b/world/src/sim/location.rs @@ -0,0 +1 @@ +pub struct Location; diff --git a/world/src/sim/mod.rs b/world/src/sim/mod.rs index 38bd431fa2..19c999a2bf 100644 --- a/world/src/sim/mod.rs +++ b/world/src/sim/mod.rs @@ -1,4 +1,9 @@ -use std::ops::{Add, Div, Mul, Neg, Sub}; +mod location; + +use std::{ + ops::{Add, Div, Mul, Neg, Sub}, + sync::Arc, +}; use vek::*; use noise::{ BasicMulti, RidgedMulti, SuperSimplex, HybridMulti, @@ -12,6 +17,7 @@ use crate::{ CONFIG, util::StructureGen2d, }; +use self::location::Location; pub const WORLD_SIZE: Vec2 = Vec2 { x: 1024, y: 1024 }; @@ -73,11 +79,19 @@ impl WorldSim { } } - Self { + let mut this = Self { seed, chunks, gen_ctx, - } + }; + + this.simulate(100); + + this + } + + pub fn simulate(&mut self, cycles: usize) { + // TODO } pub fn get(&self, chunk_pos: Vec2) -> Option<&SimChunk> { @@ -152,6 +166,7 @@ pub struct SimChunk { pub rockiness: f32, pub cliffiness: f32, pub tree_density: f32, + pub location: Option>, } impl SimChunk { @@ -222,6 +237,7 @@ impl SimChunk { .mul(1.0 - chaos * 0.85) .add(0.1) .mul(if alt > CONFIG.sea_level + 2.0 { 1.0 } else { 0.0 }), + location: None, } } From 43ca660e63a851f478b5ce5ba0333ff02223cb22 Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Mon, 10 Jun 2019 20:17:35 +0200 Subject: [PATCH 18/30] tree stumps, shorter pines --- assets/world/tree/oak_stump/1.vox | 3 +++ assets/world/tree/oak_stump/2.vox | 3 +++ assets/world/tree/oak_stump/3.vox | 3 +++ assets/world/tree/oak_stump/4.vox | 3 +++ assets/world/tree/oak_stump/5.vox | 3 +++ assets/world/tree/oak_stump/6.vox | 3 +++ assets/world/tree/oak_stump/7.vox | 3 +++ assets/world/tree/oak_stump/8.vox | 3 +++ assets/world/tree/oak_stump/9.vox | 3 +++ assets/world/tree/pine_blue/1.vox | 4 ++-- assets/world/tree/pine_blue/5.vox | 4 ++-- assets/world/tree/pine_blue/7.vox | 4 ++-- assets/world/tree/pine_green/1.vox | 4 ++-- assets/world/tree/pine_green/5.vox | 4 ++-- assets/world/tree/pine_green/7.vox | 4 ++-- assets/world/tree/pine_green_2/1.vox | 4 ++-- assets/world/tree/pine_green_2/5.vox | 4 ++-- assets/world/tree/pine_green_2/7.vox | 4 ++-- assets/world/tree/snow_pine/1.vox | 4 ++-- assets/world/tree/snow_pine/5.vox | 4 ++-- assets/world/tree/snow_pine/7.vox | 4 ++-- world/src/block/mod.rs | 2 +- world/src/block/tree.rs | 30 +++++++++++++++++++++++++++- 23 files changed, 81 insertions(+), 26 deletions(-) create mode 100644 assets/world/tree/oak_stump/1.vox create mode 100644 assets/world/tree/oak_stump/2.vox create mode 100644 assets/world/tree/oak_stump/3.vox create mode 100644 assets/world/tree/oak_stump/4.vox create mode 100644 assets/world/tree/oak_stump/5.vox create mode 100644 assets/world/tree/oak_stump/6.vox create mode 100644 assets/world/tree/oak_stump/7.vox create mode 100644 assets/world/tree/oak_stump/8.vox create mode 100644 assets/world/tree/oak_stump/9.vox diff --git a/assets/world/tree/oak_stump/1.vox b/assets/world/tree/oak_stump/1.vox new file mode 100644 index 0000000000..d7bbd15b3e --- /dev/null +++ b/assets/world/tree/oak_stump/1.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:728c75ce71816021ddfa934572afb2e2ba9192b13b9a12429ab568b1b8c3c0e7 +size 49680 diff --git a/assets/world/tree/oak_stump/2.vox b/assets/world/tree/oak_stump/2.vox new file mode 100644 index 0000000000..9792847c11 --- /dev/null +++ b/assets/world/tree/oak_stump/2.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:92780813912d1b3ef4f7bf6e8abec0c35d9ad7bbb7947bd0cda57ef7f8faa9be +size 49924 diff --git a/assets/world/tree/oak_stump/3.vox b/assets/world/tree/oak_stump/3.vox new file mode 100644 index 0000000000..17746d095b --- /dev/null +++ b/assets/world/tree/oak_stump/3.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:64d4b75d260f657e0c182452d571cb006b437b6a3ca322a93518c9ab69021a68 +size 50756 diff --git a/assets/world/tree/oak_stump/4.vox b/assets/world/tree/oak_stump/4.vox new file mode 100644 index 0000000000..0083b4c41e --- /dev/null +++ b/assets/world/tree/oak_stump/4.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:efdd4d2545af5cdefdebe0b3903a00f6de067b53aebfbbacafa947f092cbe1f8 +size 50108 diff --git a/assets/world/tree/oak_stump/5.vox b/assets/world/tree/oak_stump/5.vox new file mode 100644 index 0000000000..a0f2efc3c3 --- /dev/null +++ b/assets/world/tree/oak_stump/5.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f1098530d3b36bd0889121d12773f5a6c67bdc3413a0278fafcc7fef07754995 +size 49980 diff --git a/assets/world/tree/oak_stump/6.vox b/assets/world/tree/oak_stump/6.vox new file mode 100644 index 0000000000..e081020c72 --- /dev/null +++ b/assets/world/tree/oak_stump/6.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:27979a39c17eb201e7e0d549441659b559243a44a64b7a7c309ca5c304868f18 +size 52472 diff --git a/assets/world/tree/oak_stump/7.vox b/assets/world/tree/oak_stump/7.vox new file mode 100644 index 0000000000..85d47713ff --- /dev/null +++ b/assets/world/tree/oak_stump/7.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b63268a23065b4af946a5c21614d984916a355de744c4f2b8259d5d2c32b49de +size 50000 diff --git a/assets/world/tree/oak_stump/8.vox b/assets/world/tree/oak_stump/8.vox new file mode 100644 index 0000000000..d682ffff59 --- /dev/null +++ b/assets/world/tree/oak_stump/8.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f05f498370047e83c96d95b6134bd3e461ee94bb26a7719f108a9195e0b26d69 +size 51588 diff --git a/assets/world/tree/oak_stump/9.vox b/assets/world/tree/oak_stump/9.vox new file mode 100644 index 0000000000..ffb987e4f4 --- /dev/null +++ b/assets/world/tree/oak_stump/9.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:468a3f8fde94e92f66c3c452c0efdf4bab3eefc3c6bfc74092f8a1d47735d251 +size 51576 diff --git a/assets/world/tree/pine_blue/1.vox b/assets/world/tree/pine_blue/1.vox index f140c85442..29879d7aa3 100644 --- a/assets/world/tree/pine_blue/1.vox +++ b/assets/world/tree/pine_blue/1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:19fc092bec5986dea9284e7b10d5c5d2e8cb829755833168ba845b4b24c76ecd -size 50576 +oid sha256:8500f6902d1b210b2b11cbd1eaf20f2c111beab9e201057e99dbb03c570cac12 +size 50480 diff --git a/assets/world/tree/pine_blue/5.vox b/assets/world/tree/pine_blue/5.vox index 9ccbc7b768..c660faa2d8 100644 --- a/assets/world/tree/pine_blue/5.vox +++ b/assets/world/tree/pine_blue/5.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:23343587a1060a5bc60290bfdca8bb03ca0e0340421947638a23cffb5988ac9f -size 51128 +oid sha256:35ca4a8358a3ab364bbc2182d751d18adc6e128af4c296b1778c5eec895e460c +size 50952 diff --git a/assets/world/tree/pine_blue/7.vox b/assets/world/tree/pine_blue/7.vox index 8f1cca16da..7ef0ef33f8 100644 --- a/assets/world/tree/pine_blue/7.vox +++ b/assets/world/tree/pine_blue/7.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2fc0d2b6a33e77ad9bee490790f433841053121a095ad23bccb09ad63c00a1c1 -size 54812 +oid sha256:948c186fc1ab6e49dd3ae9b54a8e1b6678bed39d8eeacd6c2f73524555360bce +size 54588 diff --git a/assets/world/tree/pine_green/1.vox b/assets/world/tree/pine_green/1.vox index 071218cb68..6b5bdd81f3 100644 --- a/assets/world/tree/pine_green/1.vox +++ b/assets/world/tree/pine_green/1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b227240a70f3651fd69dcf36e2563d53715c1fcef0c5213f6293e3f833cb4a01 -size 50576 +oid sha256:3a28faec594c5b518b0138b0d2f303a88bad05d6d52fc7c326292c54040f514b +size 50448 diff --git a/assets/world/tree/pine_green/5.vox b/assets/world/tree/pine_green/5.vox index ee2a6b7cd1..407fd8d071 100644 --- a/assets/world/tree/pine_green/5.vox +++ b/assets/world/tree/pine_green/5.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5e77fe0932151bcf644b6e32e87da948d810d2511ff15a181d61da991457f834 -size 51128 +oid sha256:bb42085c354a785ce920c69edef9870417c8e0e072ba3d63e40176b7e334807a +size 50952 diff --git a/assets/world/tree/pine_green/7.vox b/assets/world/tree/pine_green/7.vox index e9cb75abd3..7c05aec37a 100644 --- a/assets/world/tree/pine_green/7.vox +++ b/assets/world/tree/pine_green/7.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:dc579d8ead42e0502ad9f20ff150347824dae1f0557a606b099f0c1575df99b3 -size 54812 +oid sha256:5c89eab1e1228ffa0915641d29f81e33121cbdf608e425f0bc711467c947d155 +size 54588 diff --git a/assets/world/tree/pine_green_2/1.vox b/assets/world/tree/pine_green_2/1.vox index 9561117f9b..6c17c395d9 100644 --- a/assets/world/tree/pine_green_2/1.vox +++ b/assets/world/tree/pine_green_2/1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:fab641dd7b3858487ac22217f6e65f01e1a384371c9761f930094bb7eee4b96d -size 50576 +oid sha256:cb7e319a52dc802a5a98a03a2a2642058f2d0d49e594495d85a1c5cf47c359da +size 50448 diff --git a/assets/world/tree/pine_green_2/5.vox b/assets/world/tree/pine_green_2/5.vox index b373516f00..0eefb26077 100644 --- a/assets/world/tree/pine_green_2/5.vox +++ b/assets/world/tree/pine_green_2/5.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f81680a7d43bebf964dd58815355dbbaca4bfa5e2a5b051772680c1b71ad1c9c -size 51128 +oid sha256:6dbeef3b8cf266b1efefd658eecff6e531bd629568715bc2543520ac3c378c54 +size 50856 diff --git a/assets/world/tree/pine_green_2/7.vox b/assets/world/tree/pine_green_2/7.vox index e46d1b297e..cfbe7d5b1f 100644 --- a/assets/world/tree/pine_green_2/7.vox +++ b/assets/world/tree/pine_green_2/7.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:35bcde865dff7d2023f2b42c8f60c79e13b2c44dc6d241b8f7b377f82dbaf08b -size 54812 +oid sha256:b4463e61a348ba8eaa022f7fa64a43bae85602b783c498afc8e19f6eb5fa5308 +size 54492 diff --git a/assets/world/tree/snow_pine/1.vox b/assets/world/tree/snow_pine/1.vox index 79b2617747..abac0b5946 100644 --- a/assets/world/tree/snow_pine/1.vox +++ b/assets/world/tree/snow_pine/1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2fcf730ceefdb6286262e5929585e76e0128f5736278d1f799effd0f46bca114 -size 54468 +oid sha256:a6a2c64ede7ef2bf95eb94b62b7666e45710dbfa58ac5c1dadff4f52078332c2 +size 54372 diff --git a/assets/world/tree/snow_pine/5.vox b/assets/world/tree/snow_pine/5.vox index bbc2595ed2..6e25e606f8 100644 --- a/assets/world/tree/snow_pine/5.vox +++ b/assets/world/tree/snow_pine/5.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:63e5f8f8aeef7e32dfd02c2b457449a913d5c2ae7164eb9e037fab2dff2e5089 -size 54000 +oid sha256:d868d90ce526271932186fcbf7fa9f06a80a00b92f9b34c201a51351b691d25e +size 53840 diff --git a/assets/world/tree/snow_pine/7.vox b/assets/world/tree/snow_pine/7.vox index fbf366bc96..b0ca97c910 100644 --- a/assets/world/tree/snow_pine/7.vox +++ b/assets/world/tree/snow_pine/7.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:631ec5ac5a5ec82e491837685936dbe2da58fb50f4770db0ae7e56886197ff02 -size 58956 +oid sha256:1357aa2c4536393bc3904ccce3210dc1382ea81f26999c6ccb54c0c89a653acd +size 58652 diff --git a/world/src/block/mod.rs b/world/src/block/mod.rs index 429c221d17..2d0dc0e1c2 100644 --- a/world/src/block/mod.rs +++ b/world/src/block/mod.rs @@ -165,7 +165,7 @@ impl<'a> Sampler for BlockGen<'a> { Vec3::new(tree_pos.x, tree_pos.y, tree_sample.alt as i32); let rpos = wpos - tree_pos3d; block.or(TREES[*tree_seed as usize % TREES.len()] - .get((rpos * 160) / 128) // Scaling + .get((rpos * 160) / 160) // Scaling .map(|b| b.clone()) .unwrap_or(Block::empty())) } diff --git a/world/src/block/tree.rs b/world/src/block/tree.rs index 1568aa88bd..061f6fec88 100644 --- a/world/src/block/tree.rs +++ b/world/src/block/tree.rs @@ -4,7 +4,7 @@ use std::sync::Arc; use vek::*; lazy_static! { - pub static ref TREES: [Arc; 81] = [ + pub static ref TREES: [Arc; 90] = [ // green oaks assets::load_map("world/tree/oak_green/1.vox", |s: Structure| s .with_center(Vec3::new(15, 18, 14))) @@ -33,6 +33,34 @@ lazy_static! { assets::load_map("world/tree/oak_green/9.vox", |s: Structure| s .with_center(Vec3::new(26, 26, 14))) .unwrap(), + // oak stumps + assets::load_map("world/tree/oak_stump/1.vox", |s: Structure| s + .with_center(Vec3::new(15, 18, 10))) + .unwrap(), + assets::load_map("world/tree/oak_stump/2.vox", |s: Structure| s + .with_center(Vec3::new(15, 18, 10))) + .unwrap(), + assets::load_map("world/tree/oak_stump/3.vox", |s: Structure| s + .with_center(Vec3::new(16, 20, 10))) + .unwrap(), + assets::load_map("world/tree/oak_stump/4.vox", |s: Structure| s + .with_center(Vec3::new(18, 21, 10))) + .unwrap(), + assets::load_map("world/tree/oak_stump/5.vox", |s: Structure| s + .with_center(Vec3::new(18, 18, 10))) + .unwrap(), + assets::load_map("world/tree/oak_stump/6.vox", |s: Structure| s + .with_center(Vec3::new(16, 21, 10))) + .unwrap(), + assets::load_map("world/tree/oak_stump/7.vox", |s: Structure| s + .with_center(Vec3::new(20, 19, 10))) + .unwrap(), + assets::load_map("world/tree/oak_stump/8.vox", |s: Structure| s + .with_center(Vec3::new(22, 20, 10))) + .unwrap(), + assets::load_map("world/tree/oak_stump/9.vox", |s: Structure| s + .with_center(Vec3::new(26, 26, 10))) + .unwrap(), // green pines assets::load_map("world/tree/pine_green/1.vox", |s: Structure| s .with_center(Vec3::new(15, 15, 14))) From e7649e1db458e85db1a5f7df4490ecc09193f507 Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Mon, 10 Jun 2019 20:26:24 +0200 Subject: [PATCH 19/30] small fixes --- assets/world/tree/oak_stump/2.vox | 4 ++-- assets/world/tree/oak_stump/5.vox | 4 ++-- assets/world/tree/oak_stump/6.vox | 4 ++-- assets/world/tree/oak_stump/7.vox | 4 ++-- assets/world/tree/oak_stump/8.vox | 4 ++-- assets/world/tree/oak_stump/9.vox | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/assets/world/tree/oak_stump/2.vox b/assets/world/tree/oak_stump/2.vox index 9792847c11..5ce3b7e4eb 100644 --- a/assets/world/tree/oak_stump/2.vox +++ b/assets/world/tree/oak_stump/2.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:92780813912d1b3ef4f7bf6e8abec0c35d9ad7bbb7947bd0cda57ef7f8faa9be -size 49924 +oid sha256:120026d00835e35c953b642e855a02cfce3d9ad4298cf2f9cba7727c9b29d098 +size 49968 diff --git a/assets/world/tree/oak_stump/5.vox b/assets/world/tree/oak_stump/5.vox index a0f2efc3c3..139c635908 100644 --- a/assets/world/tree/oak_stump/5.vox +++ b/assets/world/tree/oak_stump/5.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f1098530d3b36bd0889121d12773f5a6c67bdc3413a0278fafcc7fef07754995 -size 49980 +oid sha256:d0b05790bfa582be6f11287e74c44bf82c9fb637718764b9e729f098263e2cc1 +size 50012 diff --git a/assets/world/tree/oak_stump/6.vox b/assets/world/tree/oak_stump/6.vox index e081020c72..00b782809c 100644 --- a/assets/world/tree/oak_stump/6.vox +++ b/assets/world/tree/oak_stump/6.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:27979a39c17eb201e7e0d549441659b559243a44a64b7a7c309ca5c304868f18 -size 52472 +oid sha256:1da6272b8bf0de470adab11f85d8b5d6d68f41686bcbd4aa0bc8843da1bd566f +size 52528 diff --git a/assets/world/tree/oak_stump/7.vox b/assets/world/tree/oak_stump/7.vox index 85d47713ff..f0fc348177 100644 --- a/assets/world/tree/oak_stump/7.vox +++ b/assets/world/tree/oak_stump/7.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b63268a23065b4af946a5c21614d984916a355de744c4f2b8259d5d2c32b49de -size 50000 +oid sha256:f8eb758181bbb4365b0c9b2c122f2d112b818685b20c50836e6876cf5af234e3 +size 50052 diff --git a/assets/world/tree/oak_stump/8.vox b/assets/world/tree/oak_stump/8.vox index d682ffff59..161c58761b 100644 --- a/assets/world/tree/oak_stump/8.vox +++ b/assets/world/tree/oak_stump/8.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f05f498370047e83c96d95b6134bd3e461ee94bb26a7719f108a9195e0b26d69 -size 51588 +oid sha256:8204fd6e324d35461e2613e88f58417661365d120461428ee351b9a6a33cf2ba +size 51596 diff --git a/assets/world/tree/oak_stump/9.vox b/assets/world/tree/oak_stump/9.vox index ffb987e4f4..7921f4331b 100644 --- a/assets/world/tree/oak_stump/9.vox +++ b/assets/world/tree/oak_stump/9.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:468a3f8fde94e92f66c3c452c0efdf4bab3eefc3c6bfc74092f8a1d47735d251 -size 51576 +oid sha256:0a62847e6ca1987888f5f259433eb6cf9f7051b1c03e4ca5ed4caac74d63e2a7 +size 51648 From 9fed2c15344eff8cfb9db2097e7f44957897b5d2 Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Tue, 11 Jun 2019 19:39:25 +0100 Subject: [PATCH 20/30] Merged stumps, adjusted scale code --- Cargo.lock | 1 + client/src/lib.rs | 20 +++++++++++-- common/src/terrain/biome.rs | 2 +- common/src/terrain/chonk.rs | 4 +++ common/src/terrain/mod.rs | 20 +++++++++++++ voxygen/shaders/include/sky.glsl | 4 +-- voxygen/shaders/postprocess.frag | 3 +- voxygen/src/session.rs | 6 ++++ world/Cargo.toml | 1 + world/src/all.rs | 7 +++++ world/src/block/mod.rs | 9 ++++-- world/src/block/tree.rs | 26 +++++++++++++++-- world/src/column/mod.rs | 18 ++++++++---- world/src/config.rs | 4 +++ world/src/lib.rs | 1 + world/src/sim/location.rs | 50 +++++++++++++++++++++++++++++++- world/src/sim/mod.rs | 25 +++++++++++++--- 17 files changed, 179 insertions(+), 22 deletions(-) create mode 100644 world/src/all.rs diff --git a/Cargo.lock b/Cargo.lock index d3c7c8e832..bebb7e3540 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2676,6 +2676,7 @@ dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "minifb 0.11.2 (git+https://github.com/emoon/rust_minifb.git)", "noise 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", "vek 0.9.7 (registry+https://github.com/rust-lang/crates.io-index)", "veloren-common 0.2.0", ] diff --git a/client/src/lib.rs b/client/src/lib.rs index f491359419..83ad07f696 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -1,4 +1,4 @@ -#![feature(label_break_value, duration_float)] +#![feature(label_break_value, duration_float, euclidean_division)] pub mod error; @@ -12,13 +12,19 @@ use common::{ msg::{ClientMsg, ClientState, ServerInfo, ServerMsg}, net::PostBox, state::State, - terrain::chonk::ChonkMetrics, + terrain::{ + TerrainChunk, + TerrainChunkSize, + chonk::ChonkMetrics, + }, + vol::VolSize, }; use log::{debug, info, log_enabled}; use std::{ collections::HashMap, net::SocketAddr, time::{Duration, Instant}, + sync::Arc, }; use threadpool::ThreadPool; use vek::*; @@ -148,6 +154,16 @@ impl Client { self.loaded_distance } + pub fn current_chunk(&self) -> Option> { + let chunk_pos = Vec2::from(self + .state + .read_storage::() + .get(self.entity) + .cloned()?.0).map2(Vec2::from(TerrainChunkSize::SIZE), |e: f32, sz| (e as u32).div_euclid(sz) as i32); + + self.state.terrain().get_key_arc(chunk_pos).cloned() + } + /// Send a chat message to the server. #[allow(dead_code)] pub fn send_chat(&mut self, msg: String) { diff --git a/common/src/terrain/biome.rs b/common/src/terrain/biome.rs index b816da7079..4c5b29aacf 100644 --- a/common/src/terrain/biome.rs +++ b/common/src/terrain/biome.rs @@ -1,6 +1,6 @@ use serde_derive::{Deserialize, Serialize}; -#[derive(Debug, Clone, Serialize, Deserialize)] +#[derive(Debug, Copy, Clone, Serialize, Deserialize)] pub enum BiomeKind { Void, Grassland, diff --git a/common/src/terrain/chonk.rs b/common/src/terrain/chonk.rs index e83886b94c..50bf080449 100644 --- a/common/src/terrain/chonk.rs +++ b/common/src/terrain/chonk.rs @@ -36,6 +36,10 @@ impl Chonk { } } + pub fn meta(&self) -> &TerrainChunkMeta { + &self.meta + } + pub fn get_min_z(&self) -> i32 { self.z_offset } diff --git a/common/src/terrain/mod.rs b/common/src/terrain/mod.rs index 9c8edef0be..ef7259db90 100644 --- a/common/src/terrain/mod.rs +++ b/common/src/terrain/mod.rs @@ -27,15 +27,35 @@ impl VolSize for TerrainChunkSize { #[derive(Debug, Clone, Serialize, Deserialize)] pub struct TerrainChunkMeta { + name: Option, biome: BiomeKind, } impl TerrainChunkMeta { + pub fn new(name: Option, biome: BiomeKind) -> Self { + Self { + name, + biome, + } + } + pub fn void() -> Self { Self { + name: None, biome: BiomeKind::Void, } } + + pub fn name(&self) -> &str { + self.name + .as_ref() + .map(|s| s.as_str()) + .unwrap_or("Wilderness") + } + + pub fn biome(&self) -> BiomeKind { + self.biome + } } // Terrain type aliases diff --git a/voxygen/shaders/include/sky.glsl b/voxygen/shaders/include/sky.glsl index 6ee29fb132..3bb9b64307 100644 --- a/voxygen/shaders/include/sky.glsl +++ b/voxygen/shaders/include/sky.glsl @@ -3,8 +3,8 @@ const float PI = 3.141592; vec3 get_sky_color(vec3 dir, float time_of_day) { const float TIME_FACTOR = (PI * 2.0) / (3600.0 * 24.0); - const vec3 SKY_TOP = vec3(0.1, 0.5, 1.0); - const vec3 SKY_BOTTOM = vec3(0.025, 0.08, 0.2); + const vec3 SKY_TOP = vec3(0.05, 0.2, 0.9); + const vec3 SKY_BOTTOM = vec3(0.025, 0.1, 0.5); const vec3 SUN_HALO_COLOR = vec3(1.0, 0.7, 0.5) * 0.5; const vec3 SUN_SURF_COLOR = vec3(1.0, 0.9, 0.35) * 200.0; diff --git a/voxygen/shaders/postprocess.frag b/voxygen/shaders/postprocess.frag index 5e56224797..f1f644b4e6 100644 --- a/voxygen/shaders/postprocess.frag +++ b/voxygen/shaders/postprocess.frag @@ -166,8 +166,9 @@ void main() { vec4 fxaa_color = fxaa_apply(src_color, uv * screen_res.xy, screen_res.xy); vec4 hsva_color = vec4(rgb2hsv(fxaa_color.rgb), fxaa_color.a); - hsva_color.y *= 1.27; + hsva_color.y *= 1.3; hsva_color.x -= 0.015; + hsva_color.z *= 0.85; //hsva_color.z = 1.0 - 1.0 / (1.0 * hsva_color.z + 1.0); vec4 final_color = vec4(hsv2rgb(hsva_color.rgb), hsva_color.a); diff --git a/voxygen/src/session.rs b/voxygen/src/session.rs index 6e20d3e725..795ce25eb5 100644 --- a/voxygen/src/session.rs +++ b/voxygen/src/session.rs @@ -69,6 +69,12 @@ impl SessionState { } } + // TODO: Get rid of this + match self.client.borrow().current_chunk() { + Some(chunk) => println!("Chunk location: {:?}", chunk.meta().name()), + None => {}, + } + Ok(()) } diff --git a/world/Cargo.toml b/world/Cargo.toml index dc07295de9..d73e150608 100644 --- a/world/Cargo.toml +++ b/world/Cargo.toml @@ -10,6 +10,7 @@ vek = "0.9" noise = "0.5" fxhash = "0.2" lazy_static = "1.3" +rand = "0.5" [dev-dependencies] minifb = { git = "https://github.com/emoon/rust_minifb.git" } diff --git a/world/src/all.rs b/world/src/all.rs new file mode 100644 index 0000000000..41f8eee75a --- /dev/null +++ b/world/src/all.rs @@ -0,0 +1,7 @@ +#[derive(Copy, Clone)] +pub enum ForestKind { + Palm, + Oak, + Pine, + SnowPine, +} diff --git a/world/src/block/mod.rs b/world/src/block/mod.rs index 2d0dc0e1c2..d6a9895765 100644 --- a/world/src/block/mod.rs +++ b/world/src/block/mod.rs @@ -13,7 +13,6 @@ use crate::{ CONFIG, World, }; -use self::tree::TREES; pub struct BlockGen<'a> { world: &'a World, @@ -48,6 +47,7 @@ impl<'a> Sampler for BlockGen<'a> { chaos, surface_color, tree_density, + forest_kind, close_trees, cave_xy, cave_alt, @@ -164,8 +164,11 @@ impl<'a> Sampler for BlockGen<'a> { let tree_pos3d = Vec3::new(tree_pos.x, tree_pos.y, tree_sample.alt as i32); let rpos = wpos - tree_pos3d; - block.or(TREES[*tree_seed as usize % TREES.len()] - .get((rpos * 160) / 160) // Scaling + + let trees = tree::kinds(tree_sample.forest_kind); // Choose tree kind + + block.or(trees[*tree_seed as usize % trees.len()] + .get((rpos * 128) / 128) // Scaling .map(|b| b.clone()) .unwrap_or(Block::empty())) } diff --git a/world/src/block/tree.rs b/world/src/block/tree.rs index 061f6fec88..17bc34ec42 100644 --- a/world/src/block/tree.rs +++ b/world/src/block/tree.rs @@ -2,9 +2,19 @@ use common::{assets, terrain::Structure}; use lazy_static::lazy_static; use std::sync::Arc; use vek::*; +use crate::all::ForestKind; + +pub fn kinds(forest_kind: ForestKind) -> &'static [Arc] { + match forest_kind { + ForestKind::Palm => &PALMS, + ForestKind::Oak => &OAKS, + ForestKind::Pine => &PINES, + ForestKind::SnowPine => &SNOW_PINES, + } +} lazy_static! { - pub static ref TREES: [Arc; 90] = [ + pub static ref OAKS: Vec> = vec![ // green oaks assets::load_map("world/tree/oak_green/1.vox", |s: Structure| s .with_center(Vec3::new(15, 18, 14))) @@ -61,6 +71,9 @@ lazy_static! { assets::load_map("world/tree/oak_stump/9.vox", |s: Structure| s .with_center(Vec3::new(26, 26, 10))) .unwrap(), + ]; + + pub static ref PINES: Vec> = vec![ // green pines assets::load_map("world/tree/pine_green/1.vox", |s: Structure| s .with_center(Vec3::new(15, 15, 14))) @@ -136,6 +149,8 @@ lazy_static! { assets::load_map("world/tree/pine_blue/8.vox", |s: Structure| s .with_center(Vec3::new(12, 10, 12))) .unwrap(), + ]; + /* // temperate small assets::load_map("world/tree/temperate_small/1.vox", |s: Structure| s .with_center(Vec3::new(4, 4, 7))) @@ -223,6 +238,9 @@ lazy_static! { assets::load_map("world/tree/poplar/10.vox", |s: Structure| s .with_center(Vec3::new(7, 7, 10))) .unwrap(), + */ + + pub static ref PALMS: Vec> = vec![ // palm trees assets::load_map("world/tree/desert_palm/1.vox", |s: Structure| s .with_center(Vec3::new(12, 12, 10))) @@ -254,6 +272,9 @@ lazy_static! { assets::load_map("world/tree/desert_palm/10.vox", |s: Structure| s .with_center(Vec3::new(10, 10, 10))) .unwrap(), + ]; + + pub static ref SNOW_PINES: Vec> = vec![ // snow pines assets::load_map("world/tree/snow_pine/1.vox", |s: Structure| s .with_center(Vec3::new(15, 15, 14))) @@ -279,6 +300,7 @@ lazy_static! { assets::load_map("world/tree/snow_pine/8.vox", |s: Structure| s .with_center(Vec3::new(12, 10, 12))) .unwrap(), + ]; /* // snow birches -> need roots! assets::load_map("world/tree/snow_birch/1.vox", |s: Structure| s @@ -317,7 +339,6 @@ lazy_static! { assets::load_map("world/tree/snow_birch/12.vox", |s: Structure| s .with_center(Vec3::new(10, 9, 4))) .unwrap(), - */ // willows assets::load_map("world/tree/willow/1.vox", |s: Structure| s .with_center(Vec3::new(15, 14, 1))) @@ -326,4 +347,5 @@ lazy_static! { .with_center(Vec3::new(11, 12, 1))) .unwrap(), ]; + */ } diff --git a/world/src/column/mod.rs b/world/src/column/mod.rs index 7faa8b104d..4664d2431c 100644 --- a/world/src/column/mod.rs +++ b/world/src/column/mod.rs @@ -2,11 +2,12 @@ use std::ops::{Add, Div, Mul, Neg, Sub}; use vek::*; use noise::NoiseFn; use common::{ - terrain::Block, - vol::Vox, + terrain::{Block, TerrainChunkSize}, + vol::{Vox, VolSize}, }; use crate::{ CONFIG, + all::ForestKind, util::Sampler, World, }; @@ -29,6 +30,7 @@ impl<'a> Sampler for ColumnGen<'a> { fn get(&mut self, wpos: Vec2) -> Option { let wposf = wpos.map(|e| e as f64); + let chunk_pos = wpos.map2(Vec2::from(TerrainChunkSize::SIZE), |e, sz: u32| e as u32 / sz); let sim = self.world.sim(); @@ -39,6 +41,8 @@ impl<'a> Sampler for ColumnGen<'a> { let cliffiness = sim.get_interpolated(wpos, |chunk| chunk.cliffiness)?; let tree_density = sim.get_interpolated(wpos, |chunk| chunk.tree_density)?; + let forest_kind = sim.get(chunk_pos)?.forest_kind; + let alt = sim.get_interpolated(wpos, |chunk| chunk.alt)? + sim.gen_ctx.small_nz.get((wposf.div(256.0)).into_array()) as f32 * chaos.max(0.2) @@ -60,12 +64,12 @@ impl<'a> Sampler for ColumnGen<'a> { // Colours let cold_grass = Rgb::new(0.0, 0.3, 0.1); - let warm_grass = Rgb::new(0.25, 0.9, 0.05); + let warm_grass = Rgb::new(0.35, 1.0, 0.05); let cold_stone = Rgb::new(0.55, 0.7, 0.75); let warm_stone = Rgb::new(0.65, 0.65, 0.35); let beach_sand = Rgb::new(0.93, 0.84, 0.4); let desert_sand = Rgb::new(0.98, 0.8, 0.15); - let snow = Rgb::new(0.9, 0.9, 1.3); + let snow = Rgb::broadcast(1.0); let grass = Rgb::lerp(cold_grass, warm_grass, marble); let sand = Rgb::lerp(beach_sand, desert_sand, marble); @@ -75,10 +79,10 @@ impl<'a> Sampler for ColumnGen<'a> { Rgb::lerp( snow, grass, - temp.add(0.4).add(marble * 0.05).mul(256.0).sub(0.4), + temp.sub(CONFIG.snow_temp).sub(marble * 0.05).mul(256.0), ), sand, - temp.sub(0.4).mul(32.0).add(0.4), + temp.sub(CONFIG.desert_temp).mul(32.0), ); // Caves @@ -134,6 +138,7 @@ impl<'a> Sampler for ColumnGen<'a> { (alt - CONFIG.sea_level - 2.0) / 5.0, ), tree_density, + forest_kind, close_trees: sim.gen_ctx.tree_gen.get(wpos), cave_xy, cave_alt, @@ -149,6 +154,7 @@ pub struct ColumnSample { pub chaos: f32, pub surface_color: Rgb, pub tree_density: f32, + pub forest_kind: ForestKind, pub close_trees: [(Vec2, u32); 9], pub cave_xy: f32, pub cave_alt: f32, diff --git a/world/src/config.rs b/world/src/config.rs index 3e5d801e42..035b4c60d4 100644 --- a/world/src/config.rs +++ b/world/src/config.rs @@ -1,9 +1,13 @@ pub struct Config { pub sea_level: f32, pub mountain_scale: f32, + pub snow_temp: f32, + pub desert_temp: f32, } pub const CONFIG: Config = Config { sea_level: 140.0, mountain_scale: 1200.0, + snow_temp: -0.4, + desert_temp: 0.4, }; diff --git a/world/src/lib.rs b/world/src/lib.rs index 15289dfafa..2f5ccc01ca 100644 --- a/world/src/lib.rs +++ b/world/src/lib.rs @@ -1,6 +1,7 @@ #![feature(euclidean_division, bind_by_move_pattern_guards)] mod config; +mod all; mod util; mod block; mod column; diff --git a/world/src/sim/location.rs b/world/src/sim/location.rs index fb02b051d4..6eed4b555d 100644 --- a/world/src/sim/location.rs +++ b/world/src/sim/location.rs @@ -1 +1,49 @@ -pub struct Location; +use rand::Rng; + +#[derive(Copy, Clone, Debug)] +pub enum LocationKind { + Settlement, + Mountain, + Forest, +} + +#[derive(Clone, Debug)] +pub struct Location { + name: String, + kind: LocationKind, + kingdom: Kingdom, +} + +#[derive(Clone, Debug)] +pub struct Kingdom { + name: String, +} + +fn generate_name() -> String { + let consts = [ + "st", "tr", "b", "n", "p", "ph", "cr", "g", "c", + "d", "k", "kr", "kl", "gh", "sl", "st", "cr", "sp", + "th", "dr", "pr", "dr", "gr", "br", "ryth", "rh", "sl", + "f", "fr", "p", "pr", "qu", "s", "sh", "z", "k", + "br", "wh", "tr", "h", "bl", "sl", "r", "kl", "sl", + "w", "v", "vr", "kr", + ]; + let vowels = ["oo", "o", "oa", "au", "e", "ee", "ea", "ou", "u", "a", "i", "ie"]; + let tails = [ + "er", "in", "o", "on", "an", + "ar", "is", "oon", "er", "aru", + "ab", "um", "id", "and", "eld", + "ald", "oft", "aft", "ift", "ity", + "ell", "oll", "ill", "all", + ]; + + let mut name = String::new(); + for i in 0..rand::random::() % 2 { + name += rand::thread_rng().choose(&consts).unwrap(); + name += rand::thread_rng().choose(&vowels).unwrap(); + } + name += rand::thread_rng().choose(&consts).unwrap(); + name += rand::thread_rng().choose(&tails).unwrap(); + + name +} diff --git a/world/src/sim/mod.rs b/world/src/sim/mod.rs index 19c999a2bf..44829d60d9 100644 --- a/world/src/sim/mod.rs +++ b/world/src/sim/mod.rs @@ -15,6 +15,7 @@ use common::{ }; use crate::{ CONFIG, + all::ForestKind, util::StructureGen2d, }; use self::location::Location; @@ -69,7 +70,7 @@ impl WorldSim { cave_0_nz: SuperSimplex::new().set_seed(seed + 10), cave_1_nz: SuperSimplex::new().set_seed(seed + 11), - tree_gen: StructureGen2d::new(seed, 24, 16), + tree_gen: StructureGen2d::new(seed, 32, 24), }; let mut chunks = Vec::new(); @@ -166,6 +167,7 @@ pub struct SimChunk { pub rockiness: f32, pub cliffiness: f32, pub tree_density: f32, + pub forest_kind: ForestKind, pub location: Option>, } @@ -208,7 +210,7 @@ impl SimChunk { + (0.0 + alt_main + gen_ctx.small_nz.get((wposf.div(300.0)).into_array()) as f32 - * alt_main.max(0.05) + * alt_main.max(0.1) * chaos * 1.6) .add(1.0) @@ -216,14 +218,16 @@ impl SimChunk { .mul(chaos) .mul(CONFIG.mountain_scale); + let temp = (gen_ctx.temp_nz.get((wposf.div(8192.0)).into_array()) as f32); + Self { chaos, alt_base, alt, - temp: (gen_ctx.temp_nz.get((wposf.div(8192.0)).into_array()) as f32), + temp, rockiness: (gen_ctx.rock_nz.get((wposf.div(1024.0)).into_array()) as f32) .sub(0.1) - .mul(1.2) + .mul(1.3) .max(0.0), cliffiness: (gen_ctx.cliff_nz.get((wposf.div(2048.0)).into_array()) as f32) .sub(0.15) @@ -237,6 +241,19 @@ impl SimChunk { .mul(1.0 - chaos * 0.85) .add(0.1) .mul(if alt > CONFIG.sea_level + 2.0 { 1.0 } else { 0.0 }), + forest_kind: if temp > 0.0 { + if temp > CONFIG.desert_temp { + ForestKind::Palm + } else { + ForestKind::Oak + } + } else { + if temp > CONFIG.snow_temp { + ForestKind::Pine + } else { + ForestKind::SnowPine + } + }, location: None, } } From 29ecb14c45cc73eccb934717eb9b6b07219c5769 Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Wed, 12 Jun 2019 10:02:18 +0100 Subject: [PATCH 21/30] Added dirt/stone gradient --- world/src/block/mod.rs | 17 +++++++++++------ world/src/column/mod.rs | 2 +- world/src/sim/mod.rs | 2 +- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/world/src/block/mod.rs b/world/src/block/mod.rs index d6a9895765..ecd4790eef 100644 --- a/world/src/block/mod.rs +++ b/world/src/block/mod.rs @@ -65,7 +65,7 @@ impl<'a> Sampler for BlockGen<'a> { .get((wposf.div(Vec3::new(150.0, 150.0, 150.0))).into_array()) as f32) .mul((chaos - 0.1).max(0.0)) - .mul(130.0); + .mul(115.0); let is_cliff = if cliff > 0.0 { (self.world.sim() @@ -99,20 +99,25 @@ impl<'a> Sampler for BlockGen<'a> { // Sample blocks + let stone_col = Rgb::new(200, 220, 255); + let dirt_col = Rgb::new(79, 67, 60); + let air = Block::empty(); - let stone = Block::new(2, Rgb::new(200, 220, 255)); + let stone = Block::new(2, stone_col); let surface_stone = Block::new(1, Rgb::new(200, 220, 255)); - let dirt = Block::new(1, Rgb::new(128, 90, 0)); + let dirt = Block::new(1, dirt_col); let sand = Block::new(1, Rgb::new(180, 150, 50)); let water = Block::new(1, Rgb::new(100, 150, 255)); let warm_stone = Block::new(1, Rgb::new(165, 165, 130)); let block = if (wposf.z as f32) < height - 3.0 { + let col = Lerp::lerp(dirt_col, stone_col, (height - 4.0 - wposf.z as f32) * 0.15); + // Underground - if (wposf.z as f32) > alt { - Some(surface_stone) + if (wposf.z as f32) > alt - 32.0 * chaos { + Some(Block::new(1, col)) } else { - Some(stone) + Some(Block::new(2, col)) } } else if (wposf.z as f32) < height { // Surface diff --git a/world/src/column/mod.rs b/world/src/column/mod.rs index 4664d2431c..f4d03294c9 100644 --- a/world/src/column/mod.rs +++ b/world/src/column/mod.rs @@ -79,7 +79,7 @@ impl<'a> Sampler for ColumnGen<'a> { Rgb::lerp( snow, grass, - temp.sub(CONFIG.snow_temp).sub(marble * 0.05).mul(256.0), + temp.sub(CONFIG.snow_temp).sub((marble - 0.5) * 0.05).mul(256.0), ), sand, temp.sub(CONFIG.desert_temp).mul(32.0), diff --git a/world/src/sim/mod.rs b/world/src/sim/mod.rs index 44829d60d9..a6fb4351c9 100644 --- a/world/src/sim/mod.rs +++ b/world/src/sim/mod.rs @@ -238,7 +238,7 @@ impl SimChunk { tree_density: (gen_ctx.tree_nz.get((wposf.div(1024.0)).into_array()) as f32) .add(1.0) .mul(0.5) - .mul(1.0 - chaos * 0.85) + .mul(1.2 - chaos * 0.85) .add(0.1) .mul(if alt > CONFIG.sea_level + 2.0 { 1.0 } else { 0.0 }), forest_kind: if temp > 0.0 { From fd529b546253f9e975f9a05433cbee1e4f510cfd Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Wed, 12 Jun 2019 11:34:44 +0100 Subject: [PATCH 22/30] Added grass blending --- world/src/block/mod.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/world/src/block/mod.rs b/world/src/block/mod.rs index ecd4790eef..03c311a4e2 100644 --- a/world/src/block/mod.rs +++ b/world/src/block/mod.rs @@ -120,8 +120,13 @@ impl<'a> Sampler for BlockGen<'a> { Some(Block::new(2, col)) } } else if (wposf.z as f32) < height { + let col = Lerp::lerp( + dirt_col.map(|e| e as f32 / 255.0), + surface_color, + (wposf.z as f32 - (height - 4.0)) * 0.25, + ); // Surface - Some(Block::new(1, surface_color.map(|e| (e * 255.0) as u8))) + Some(Block::new(1, col.map(|e| (e * 255.0) as u8))) } else if (wposf.z as f32) < CONFIG.sea_level { // Ocean Some(water) From 9f5fe0231fcfa6fefc8407a02bcc0d7fb9fa7022 Mon Sep 17 00:00:00 2001 From: Monty Marz Date: Wed, 12 Jun 2019 11:52:40 +0000 Subject: [PATCH 23/30] palette changes --- assets/world/tree/birch/1.vox | 2 +- assets/world/tree/birch/10.vox | 2 +- assets/world/tree/birch/11.vox | 2 +- assets/world/tree/birch/12.vox | 2 +- assets/world/tree/birch/2.vox | 2 +- assets/world/tree/birch/3.vox | 2 +- assets/world/tree/birch/4.vox | 2 +- assets/world/tree/birch/5.vox | 2 +- assets/world/tree/birch/6.vox | 2 +- assets/world/tree/birch/7.vox | 2 +- assets/world/tree/birch/8.vox | 2 +- assets/world/tree/birch/9.vox | 2 +- assets/world/tree/desert_palm/1.vox | 2 +- assets/world/tree/desert_palm/10.vox | 2 +- assets/world/tree/desert_palm/2.vox | 2 +- assets/world/tree/desert_palm/3.vox | 2 +- assets/world/tree/desert_palm/4.vox | 2 +- assets/world/tree/desert_palm/5.vox | 2 +- assets/world/tree/desert_palm/6.vox | 2 +- assets/world/tree/desert_palm/7.vox | 2 +- assets/world/tree/desert_palm/8.vox | 2 +- assets/world/tree/desert_palm/9.vox | 2 +- assets/world/tree/oak_green/1.vox | 4 ++-- assets/world/tree/oak_green/2.vox | 4 ++-- assets/world/tree/oak_green/3.vox | 4 ++-- assets/world/tree/oak_green/4.vox | 2 +- assets/world/tree/oak_green/5.vox | 2 +- assets/world/tree/oak_green/6.vox | 2 +- assets/world/tree/oak_green/7.vox | 4 ++-- assets/world/tree/oak_green/8.vox | 2 +- assets/world/tree/oak_green/9.vox | 4 ++-- assets/world/tree/oak_stump/1.vox | 2 +- assets/world/tree/oak_stump/6.vox | 2 +- assets/world/tree/oak_stump/7.vox | 2 +- assets/world/tree/oak_stump/9.vox | 2 +- assets/world/tree/pine_blue/1.vox | 3 --- assets/world/tree/pine_blue/2.vox | 3 --- assets/world/tree/pine_blue/3.vox | 3 --- assets/world/tree/pine_blue/4.vox | 3 --- assets/world/tree/pine_blue/5.vox | 3 --- assets/world/tree/pine_blue/6.vox | 3 --- assets/world/tree/pine_blue/7.vox | 3 --- assets/world/tree/pine_blue/8.vox | 3 --- assets/world/tree/pine_green/1.vox | 2 +- assets/world/tree/pine_green/2.vox | 2 +- assets/world/tree/pine_green/3.vox | 2 +- assets/world/tree/pine_green/4.vox | 2 +- assets/world/tree/pine_green/5.vox | 2 +- assets/world/tree/pine_green/6.vox | 2 +- assets/world/tree/pine_green/7.vox | 2 +- assets/world/tree/pine_green/8.vox | 4 ++-- assets/world/tree/pine_green_2/1.vox | 3 --- assets/world/tree/pine_green_2/2.vox | 3 --- assets/world/tree/pine_green_2/3.vox | 3 --- assets/world/tree/pine_green_2/4.vox | 3 --- assets/world/tree/pine_green_2/5.vox | 3 --- assets/world/tree/pine_green_2/6.vox | 3 --- assets/world/tree/pine_green_2/7.vox | 3 --- assets/world/tree/pine_green_2/8.vox | 3 --- assets/world/tree/poplar/1.vox | 2 +- assets/world/tree/poplar/10.vox | 2 +- assets/world/tree/poplar/2.vox | 2 +- assets/world/tree/poplar/3.vox | 2 +- assets/world/tree/poplar/4.vox | 2 +- assets/world/tree/poplar/5.vox | 2 +- assets/world/tree/poplar/6.vox | 2 +- assets/world/tree/poplar/7.vox | 2 +- assets/world/tree/poplar/8.vox | 2 +- assets/world/tree/poplar/9.vox | 2 +- assets/world/tree/snow_pine/1.vox | 2 +- assets/world/tree/snow_pine/2.vox | 2 +- assets/world/tree/snow_pine/3.vox | 2 +- assets/world/tree/snow_pine/4.vox | 2 +- assets/world/tree/snow_pine/5.vox | 2 +- assets/world/tree/snow_pine/6.vox | 2 +- assets/world/tree/snow_pine/7.vox | 2 +- assets/world/tree/snow_pine/8.vox | 2 +- assets/world/tree/temperate_small/1.vox | 4 ++-- assets/world/tree/temperate_small/2.vox | 4 ++-- assets/world/tree/temperate_small/3.vox | 4 ++-- assets/world/tree/temperate_small/4.vox | 4 ++-- assets/world/tree/temperate_small/5.vox | 4 ++-- assets/world/tree/temperate_small/6.vox | 4 ++-- 83 files changed, 79 insertions(+), 127 deletions(-) delete mode 100644 assets/world/tree/pine_blue/1.vox delete mode 100644 assets/world/tree/pine_blue/2.vox delete mode 100644 assets/world/tree/pine_blue/3.vox delete mode 100644 assets/world/tree/pine_blue/4.vox delete mode 100644 assets/world/tree/pine_blue/5.vox delete mode 100644 assets/world/tree/pine_blue/6.vox delete mode 100644 assets/world/tree/pine_blue/7.vox delete mode 100644 assets/world/tree/pine_blue/8.vox delete mode 100644 assets/world/tree/pine_green_2/1.vox delete mode 100644 assets/world/tree/pine_green_2/2.vox delete mode 100644 assets/world/tree/pine_green_2/3.vox delete mode 100644 assets/world/tree/pine_green_2/4.vox delete mode 100644 assets/world/tree/pine_green_2/5.vox delete mode 100644 assets/world/tree/pine_green_2/6.vox delete mode 100644 assets/world/tree/pine_green_2/7.vox delete mode 100644 assets/world/tree/pine_green_2/8.vox diff --git a/assets/world/tree/birch/1.vox b/assets/world/tree/birch/1.vox index 60e2399fe0..376bac365c 100644 --- a/assets/world/tree/birch/1.vox +++ b/assets/world/tree/birch/1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:bc2c462afb68c98afb12c7cbbc9501e9b2d3f6fcf325f0cc5127dd808755086f +oid sha256:8d5995cb3e03475d77732b11978843c59296dca9b323c24d3c455164a6d99c9e size 55718 diff --git a/assets/world/tree/birch/10.vox b/assets/world/tree/birch/10.vox index 042eefc154..fb4b3605aa 100644 --- a/assets/world/tree/birch/10.vox +++ b/assets/world/tree/birch/10.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a38a1aae8dd877392c2edc3c8b8771590967a1167dc5561f4f57742a07917221 +oid sha256:a7c2127d5e6615001534ba2eea67164f8b0df5b89709cb57f32d39883375f8f6 size 52671 diff --git a/assets/world/tree/birch/11.vox b/assets/world/tree/birch/11.vox index d8f15f132b..aa74a8e699 100644 --- a/assets/world/tree/birch/11.vox +++ b/assets/world/tree/birch/11.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d8f1e99ecb0ef617f506e1889a38fe26046b6d6000f26ce9efa875bc9b704f2e +oid sha256:541b49672721e8e9c41d520b5c69e6d91be0b6b7b7a5f6038800ba1f92b37c77 size 49427 diff --git a/assets/world/tree/birch/12.vox b/assets/world/tree/birch/12.vox index d8f15f132b..aa74a8e699 100644 --- a/assets/world/tree/birch/12.vox +++ b/assets/world/tree/birch/12.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d8f1e99ecb0ef617f506e1889a38fe26046b6d6000f26ce9efa875bc9b704f2e +oid sha256:541b49672721e8e9c41d520b5c69e6d91be0b6b7b7a5f6038800ba1f92b37c77 size 49427 diff --git a/assets/world/tree/birch/2.vox b/assets/world/tree/birch/2.vox index 3fcc95b7fe..edeeaeb308 100644 --- a/assets/world/tree/birch/2.vox +++ b/assets/world/tree/birch/2.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d6dd7ee0ec36105a2ed2160ea01bb7f898c0e86a28d19d597688b450342f9d1b +oid sha256:49986ab8b446bbea24f93ead93925e220ab1f5546703b81d1c4c5693452b104f size 53263 diff --git a/assets/world/tree/birch/3.vox b/assets/world/tree/birch/3.vox index d40eb79fa1..4a2f445608 100644 --- a/assets/world/tree/birch/3.vox +++ b/assets/world/tree/birch/3.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:66c5bd4c89ee04b86637b39cb34fe82e885c26ce5cb4808b35fd9c68f564a890 +oid sha256:7da5056cfd960bcd076accb8c2bfabe05d796002a7421b1492b4225234263cb4 size 54370 diff --git a/assets/world/tree/birch/4.vox b/assets/world/tree/birch/4.vox index c8c0afb6f7..a3a19faaa7 100644 --- a/assets/world/tree/birch/4.vox +++ b/assets/world/tree/birch/4.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8c7e56eb7eca88830ba1f299411cbbea77aa98fb4645755ecfbd6f73ff047ddb +oid sha256:13265f6be83d77a672c3205ce4acb3c0c79125792686fba9a3063b66552707a5 size 51427 diff --git a/assets/world/tree/birch/5.vox b/assets/world/tree/birch/5.vox index 3368805a41..6962cc6474 100644 --- a/assets/world/tree/birch/5.vox +++ b/assets/world/tree/birch/5.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:79def0c956a88ec62ebcee1a7d01c2a3db767855855b0510915ed3319f7832da +oid sha256:209b1d7c98f03d75f39eabe17f96219f5a0045d8287875d307fbbce430f6a57e size 54270 diff --git a/assets/world/tree/birch/6.vox b/assets/world/tree/birch/6.vox index 1cd46fc796..a3b67e7041 100644 --- a/assets/world/tree/birch/6.vox +++ b/assets/world/tree/birch/6.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c3a280c4d03a0049de303654081b0ffda7ca36643a85c0d2076e8ac0d30d1249 +oid sha256:9be516f50418feeb94a043b04ee5f987f1f282fb06efb94a410179dbfb142a9e size 48606 diff --git a/assets/world/tree/birch/7.vox b/assets/world/tree/birch/7.vox index b64ba51b4d..b8c2484d1b 100644 --- a/assets/world/tree/birch/7.vox +++ b/assets/world/tree/birch/7.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b2c5023855fe827cc45c4a65ace5d3d59d16213c00eb05b781f755263a6b0886 +oid sha256:f78834cebfb7c1f9637831ec1e2fecbcf5f2e3aa03441a18beece740573bf5de size 50106 diff --git a/assets/world/tree/birch/8.vox b/assets/world/tree/birch/8.vox index 10f49e29d3..5b1e411dbd 100644 --- a/assets/world/tree/birch/8.vox +++ b/assets/world/tree/birch/8.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b8349ccf7a3a71ac3d612eaa4e6ff56b1729a1d010f6f7b93773218f6c3958b4 +oid sha256:6b5fce8341092805e2b913a7e7b4e6e06f01b2aad092452c3fc04cb5f8847d89 size 52186 diff --git a/assets/world/tree/birch/9.vox b/assets/world/tree/birch/9.vox index de882c9579..430268b5b3 100644 --- a/assets/world/tree/birch/9.vox +++ b/assets/world/tree/birch/9.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:568fa985313f586b33f72520417255f1e16843c638ca29558abaadf995f07539 +oid sha256:9b7753a0f5e52506796895a28e36fcab050abcd64da74c7b53235a3560e4a486 size 49738 diff --git a/assets/world/tree/desert_palm/1.vox b/assets/world/tree/desert_palm/1.vox index 122caf9a79..fff6ba1b91 100644 --- a/assets/world/tree/desert_palm/1.vox +++ b/assets/world/tree/desert_palm/1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:33a5216062bace6ff0bdfe0158e65e6f9df320f1e9adf2355640c89d8d90d317 +oid sha256:db332ddd98b5175986dce254759eee3e6561cd559dcb9f58218ad7113577a1cd size 46479 diff --git a/assets/world/tree/desert_palm/10.vox b/assets/world/tree/desert_palm/10.vox index f099da8b4c..f1d77777ec 100644 --- a/assets/world/tree/desert_palm/10.vox +++ b/assets/world/tree/desert_palm/10.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4975ba658cf6b9e3f084ca8eee419f1f81b776557ca6d7cdd03cca8258626f2b +oid sha256:3c3d3ef277cf6d52bebcd9478e51f7779dfe3c7b4f2e3fd1a611b993108249ac size 46138 diff --git a/assets/world/tree/desert_palm/2.vox b/assets/world/tree/desert_palm/2.vox index b4fe6f3d30..50d106ffcf 100644 --- a/assets/world/tree/desert_palm/2.vox +++ b/assets/world/tree/desert_palm/2.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f22bee47cccec5b0b0116215adc91f1305849dc2ef9d1199fac01b96f6224928 +oid sha256:e330bf9979b2c4f59c33e464dcdf4bb25fc4cf3348ab4e191f6f3c36bfca5f6a size 46189 diff --git a/assets/world/tree/desert_palm/3.vox b/assets/world/tree/desert_palm/3.vox index 7b144f0558..7e2c279a1d 100644 --- a/assets/world/tree/desert_palm/3.vox +++ b/assets/world/tree/desert_palm/3.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:38f4984f5bfb445414845531b96b838b4ab02ea40f9507cb094c8001c8e12135 +oid sha256:9dd9002762da1a11816e42066b937fc943d94f095ffe1cd28ad64df6f09cf7da size 46585 diff --git a/assets/world/tree/desert_palm/4.vox b/assets/world/tree/desert_palm/4.vox index 62bf649c0d..5080c63b60 100644 --- a/assets/world/tree/desert_palm/4.vox +++ b/assets/world/tree/desert_palm/4.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f7ade7dbfe38d807fcdb40f76ee6c433080166f876d3a258bdf8e3011bc22893 +oid sha256:65edf5be2cb4e192bc0f575c63c3824e20fd454bd7766b92624078404b27ba05 size 46289 diff --git a/assets/world/tree/desert_palm/5.vox b/assets/world/tree/desert_palm/5.vox index bb41f4deca..63613e35f0 100644 --- a/assets/world/tree/desert_palm/5.vox +++ b/assets/world/tree/desert_palm/5.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b91ca3454af08626b99811d0c43a0efb19cb000f2ed4650cffa7f5b3672615e5 +oid sha256:4d1507a908ac2381b29045ef6d4b52d7868e3e712bd1d3e4c7635127f86ac088 size 46145 diff --git a/assets/world/tree/desert_palm/6.vox b/assets/world/tree/desert_palm/6.vox index ac7cdfb06c..a5e24de749 100644 --- a/assets/world/tree/desert_palm/6.vox +++ b/assets/world/tree/desert_palm/6.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9b1447af67fdf618844acba42825c707e01ad7da40cf1acc4b111bb48dde3a66 +oid sha256:b1c8184dd48feaf4665fa5e866a01080894494a1893c95b9465eb34f8bcb0c5a size 46113 diff --git a/assets/world/tree/desert_palm/7.vox b/assets/world/tree/desert_palm/7.vox index 283c1b646e..1fe792529b 100644 --- a/assets/world/tree/desert_palm/7.vox +++ b/assets/world/tree/desert_palm/7.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d053d38ffa43d0a6016f99d7fd2573934e6a9f0faad3ae83a6dd25f279bb6aa1 +oid sha256:57ad80786e3e98e941693ace3c12d840de97bc13ac1c61b72f94db4ced3cd372 size 46355 diff --git a/assets/world/tree/desert_palm/8.vox b/assets/world/tree/desert_palm/8.vox index 18ec6991fa..673abcfb43 100644 --- a/assets/world/tree/desert_palm/8.vox +++ b/assets/world/tree/desert_palm/8.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0daefde6007aa84a23d837cf4a1ade258b05ae01f9a85223b11b0c886a19a0af +oid sha256:c2b901ce347828826e297c47a33000156f741ed43f33e2639317022a98f2a5dc size 46257 diff --git a/assets/world/tree/desert_palm/9.vox b/assets/world/tree/desert_palm/9.vox index 151d135d61..29756cff4b 100644 --- a/assets/world/tree/desert_palm/9.vox +++ b/assets/world/tree/desert_palm/9.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:aa673c66c5087ecce5f4b5b30a9d092d7e85334d9913ebe92e8c1a4ef223ec25 +oid sha256:557b27a10044a9e4228a77e8534e69382a22219c77a99e553feab6be4b03cc12 size 46289 diff --git a/assets/world/tree/oak_green/1.vox b/assets/world/tree/oak_green/1.vox index 203278ad8f..7127afa54f 100644 --- a/assets/world/tree/oak_green/1.vox +++ b/assets/world/tree/oak_green/1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:35751de0589d71666113dfea340a507be7fdc8dbe915ee391d65af618df2cdb2 -size 80890 +oid sha256:92988d46dde3a0c9c7af42a4042b13de2eebf2f904a0b3679e792fc917b24dea +size 80836 diff --git a/assets/world/tree/oak_green/2.vox b/assets/world/tree/oak_green/2.vox index 3d8275e987..6000db082d 100644 --- a/assets/world/tree/oak_green/2.vox +++ b/assets/world/tree/oak_green/2.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:673d193d0d764ba88c666164d7cddd611353d25a189a94e83abdaf2fc57724e8 -size 89306 +oid sha256:2f7c62ea16914827fc4e6c3030161e0b910ecbdb7d0db3f55bbe8a251e859fb5 +size 89252 diff --git a/assets/world/tree/oak_green/3.vox b/assets/world/tree/oak_green/3.vox index 7b92c5c638..4e7048ba7c 100644 --- a/assets/world/tree/oak_green/3.vox +++ b/assets/world/tree/oak_green/3.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:fdb21e9e2511957496a5393314f61f6be8e6b32ffd4ed624f9bbc0283ec08b4e -size 114974 +oid sha256:fcf106c505c957e78790ca4ad7ba2f481be82e32445d654284e541ab170f9023 +size 114920 diff --git a/assets/world/tree/oak_green/4.vox b/assets/world/tree/oak_green/4.vox index 0825eb9557..80872fb4da 100644 --- a/assets/world/tree/oak_green/4.vox +++ b/assets/world/tree/oak_green/4.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:133a6c7a25ac684fe2c6e7ff45e522ef13fdc57070c115d8e8384091ce9801ce +oid sha256:3a204b1300be9fe810f56c0f483f2fe3cacc73d35b57d0bf68d93bef5295ef44 size 89944 diff --git a/assets/world/tree/oak_green/5.vox b/assets/world/tree/oak_green/5.vox index 869bc27c6f..149167f780 100644 --- a/assets/world/tree/oak_green/5.vox +++ b/assets/world/tree/oak_green/5.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e5c2bb0810ae0a7fb933b7211c6d4b815ec03a946b16db198612341f7c659e23 +oid sha256:db82d0f9c734ca5316be1965676bd49eea6c894e38033144b8f6e6430edac8cd size 95628 diff --git a/assets/world/tree/oak_green/6.vox b/assets/world/tree/oak_green/6.vox index 5a2ab7fc4a..b3875dafee 100644 --- a/assets/world/tree/oak_green/6.vox +++ b/assets/world/tree/oak_green/6.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:06f903b21f6d09415bf16ce6d74d7dadcf341e7a23f4903fd436e4fa21509c17 +oid sha256:8dba4cac13e74efefdaf60d4e3e4d11caa092f85edb7364cee8ef9a990ae441c size 114484 diff --git a/assets/world/tree/oak_green/7.vox b/assets/world/tree/oak_green/7.vox index d775dcd39f..2d77ba69cd 100644 --- a/assets/world/tree/oak_green/7.vox +++ b/assets/world/tree/oak_green/7.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:212636f4871f396471e3a52d5bb8852b2543d67258bb677611fdabcf8d15ac56 -size 124938 +oid sha256:c662098c6d0dac131d718d4734f2eb6f4fe1ee0934eb193c52dea8015e7c8cd7 +size 124884 diff --git a/assets/world/tree/oak_green/8.vox b/assets/world/tree/oak_green/8.vox index 1fe0b01ce1..f58e824b3b 100644 --- a/assets/world/tree/oak_green/8.vox +++ b/assets/world/tree/oak_green/8.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6e1d9bcc717afa853c9a22592447177ea96c6689f871faa30be03631a7d0ff34 +oid sha256:c7a6925cf4085bfe315fc31052f82d958fd3df33492c98a165722ea794fff484 size 117340 diff --git a/assets/world/tree/oak_green/9.vox b/assets/world/tree/oak_green/9.vox index 530a03765a..fb408054fe 100644 --- a/assets/world/tree/oak_green/9.vox +++ b/assets/world/tree/oak_green/9.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5caf721dded167c252bc68339d920612c2635d6e5d90c9ca24e5032d210ee84b -size 188340 +oid sha256:1cf00092594f397180875ae4ad1f2fc4b220a526ac5782c3158f5c91f1bda08e +size 188286 diff --git a/assets/world/tree/oak_stump/1.vox b/assets/world/tree/oak_stump/1.vox index d7bbd15b3e..80a25d58f6 100644 --- a/assets/world/tree/oak_stump/1.vox +++ b/assets/world/tree/oak_stump/1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:728c75ce71816021ddfa934572afb2e2ba9192b13b9a12429ab568b1b8c3c0e7 +oid sha256:60135681a5a9565c77b3bb4b9227ac861d1c522ddbd94c03909aa0b3112848c4 size 49680 diff --git a/assets/world/tree/oak_stump/6.vox b/assets/world/tree/oak_stump/6.vox index 00b782809c..eeb323998a 100644 --- a/assets/world/tree/oak_stump/6.vox +++ b/assets/world/tree/oak_stump/6.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1da6272b8bf0de470adab11f85d8b5d6d68f41686bcbd4aa0bc8843da1bd566f +oid sha256:055279ff59c34829980312ca87c754d73a102ed8af2b189dec0f2e4f754627c6 size 52528 diff --git a/assets/world/tree/oak_stump/7.vox b/assets/world/tree/oak_stump/7.vox index f0fc348177..2d389a29d2 100644 --- a/assets/world/tree/oak_stump/7.vox +++ b/assets/world/tree/oak_stump/7.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f8eb758181bbb4365b0c9b2c122f2d112b818685b20c50836e6876cf5af234e3 +oid sha256:c5485e1bc4137a80608dbd2985ef0f7da829f2a989f14ff123cf7812f4a71487 size 50052 diff --git a/assets/world/tree/oak_stump/9.vox b/assets/world/tree/oak_stump/9.vox index 7921f4331b..c3a84e0d36 100644 --- a/assets/world/tree/oak_stump/9.vox +++ b/assets/world/tree/oak_stump/9.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0a62847e6ca1987888f5f259433eb6cf9f7051b1c03e4ca5ed4caac74d63e2a7 +oid sha256:626a92a02facc274f467c6c1f28291d1cc0b9a6fa2227945fa36e0d55c3a489e size 51648 diff --git a/assets/world/tree/pine_blue/1.vox b/assets/world/tree/pine_blue/1.vox deleted file mode 100644 index 29879d7aa3..0000000000 --- a/assets/world/tree/pine_blue/1.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:8500f6902d1b210b2b11cbd1eaf20f2c111beab9e201057e99dbb03c570cac12 -size 50480 diff --git a/assets/world/tree/pine_blue/2.vox b/assets/world/tree/pine_blue/2.vox deleted file mode 100644 index eb80d98ac3..0000000000 --- a/assets/world/tree/pine_blue/2.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:77ee6915a4df161a38c2ca922bc3a10dbf469799eab17f36e271869709a31d52 -size 54148 diff --git a/assets/world/tree/pine_blue/3.vox b/assets/world/tree/pine_blue/3.vox deleted file mode 100644 index 95d5581c4e..0000000000 --- a/assets/world/tree/pine_blue/3.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:e09d1d5ceb9583dc5dc7e9ae7f1aea8bad7e36b5bcba15e00f4464adfcdecd72 -size 56140 diff --git a/assets/world/tree/pine_blue/4.vox b/assets/world/tree/pine_blue/4.vox deleted file mode 100644 index 6c33f82235..0000000000 --- a/assets/world/tree/pine_blue/4.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:7234ddcf50a94f58fd2086ca08298b859d3846f1f87747836877b7a9f05e3a1e -size 48309 diff --git a/assets/world/tree/pine_blue/5.vox b/assets/world/tree/pine_blue/5.vox deleted file mode 100644 index c660faa2d8..0000000000 --- a/assets/world/tree/pine_blue/5.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:35ca4a8358a3ab364bbc2182d751d18adc6e128af4c296b1778c5eec895e460c -size 50952 diff --git a/assets/world/tree/pine_blue/6.vox b/assets/world/tree/pine_blue/6.vox deleted file mode 100644 index c8d78eb1ae..0000000000 --- a/assets/world/tree/pine_blue/6.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:48b1c9ea1dc2d451315693d7168deacdddf3e24d1a960dc3e5118848727dcc97 -size 49053 diff --git a/assets/world/tree/pine_blue/7.vox b/assets/world/tree/pine_blue/7.vox deleted file mode 100644 index 7ef0ef33f8..0000000000 --- a/assets/world/tree/pine_blue/7.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:948c186fc1ab6e49dd3ae9b54a8e1b6678bed39d8eeacd6c2f73524555360bce -size 54588 diff --git a/assets/world/tree/pine_blue/8.vox b/assets/world/tree/pine_blue/8.vox deleted file mode 100644 index 7576fa3f44..0000000000 --- a/assets/world/tree/pine_blue/8.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:5455caf6a1f3d33b9e5c3c8168629f6ad847a99f62a952e566918ab29d617d78 -size 50265 diff --git a/assets/world/tree/pine_green/1.vox b/assets/world/tree/pine_green/1.vox index 6b5bdd81f3..5eb72f10a6 100644 --- a/assets/world/tree/pine_green/1.vox +++ b/assets/world/tree/pine_green/1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3a28faec594c5b518b0138b0d2f303a88bad05d6d52fc7c326292c54040f514b +oid sha256:8425e0432a170d171f90da4697be6574316934b5cb70e1aab47ce23149bafce8 size 50448 diff --git a/assets/world/tree/pine_green/2.vox b/assets/world/tree/pine_green/2.vox index ac3ee6e430..24afa41987 100644 --- a/assets/world/tree/pine_green/2.vox +++ b/assets/world/tree/pine_green/2.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e2b3fa327246cd31b383d64a1270136f4bd62d37da0d933acad8ef95a9a2a8f5 +oid sha256:c95e7949bf4193e6387e80144e2d21e914b9326992223302f8f4a798cf70fd55 size 54148 diff --git a/assets/world/tree/pine_green/3.vox b/assets/world/tree/pine_green/3.vox index ab64b8174c..d78aa31454 100644 --- a/assets/world/tree/pine_green/3.vox +++ b/assets/world/tree/pine_green/3.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9cd84ae39180436b329a89e09fc44a7392ec14bc6581cc091f0d0e72fdd5eabc +oid sha256:c0fb6ae560bfd38100e37777f6da28447df0495535bb83e0dd7cceac4894a153 size 56140 diff --git a/assets/world/tree/pine_green/4.vox b/assets/world/tree/pine_green/4.vox index 19de068641..060aa15fc3 100644 --- a/assets/world/tree/pine_green/4.vox +++ b/assets/world/tree/pine_green/4.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c99570187b18f4f06a3c7fef2b9a2d3578aa71747f8518b0b6710f70e9d373e7 +oid sha256:776fd4e706994a8625f5df1c279b8b6783a056872c6d6e072e27ae908d159169 size 48309 diff --git a/assets/world/tree/pine_green/5.vox b/assets/world/tree/pine_green/5.vox index 407fd8d071..235e87c5e8 100644 --- a/assets/world/tree/pine_green/5.vox +++ b/assets/world/tree/pine_green/5.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:bb42085c354a785ce920c69edef9870417c8e0e072ba3d63e40176b7e334807a +oid sha256:4e497b28721e695dadf945e56cc0d7368bb62fcb8e903bb1f1a1ebc9776d9db1 size 50952 diff --git a/assets/world/tree/pine_green/6.vox b/assets/world/tree/pine_green/6.vox index d005f4575e..3a58cb6df0 100644 --- a/assets/world/tree/pine_green/6.vox +++ b/assets/world/tree/pine_green/6.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a828dd0f77376544424876516df8f909434b0cec04e36ed8ff27de720a2f18f2 +oid sha256:971a3eb44ddb4defd5057a5320641b13b33ee634e3f837ed3d453b2912fa5d42 size 49053 diff --git a/assets/world/tree/pine_green/7.vox b/assets/world/tree/pine_green/7.vox index 7c05aec37a..9a5db1987f 100644 --- a/assets/world/tree/pine_green/7.vox +++ b/assets/world/tree/pine_green/7.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5c89eab1e1228ffa0915641d29f81e33121cbdf608e425f0bc711467c947d155 +oid sha256:04e84e3982fda2f265169ac055f51b59dcfe4315c72a6befe16ad7308fc85b7b size 54588 diff --git a/assets/world/tree/pine_green/8.vox b/assets/world/tree/pine_green/8.vox index 1d0701d35f..60ad8714ec 100644 --- a/assets/world/tree/pine_green/8.vox +++ b/assets/world/tree/pine_green/8.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:be1ee0aa553316392d2ecd00e74cc73860cdb2da6794d51547a77c8f7ce0eed3 -size 50319 +oid sha256:f9f09a2e98e67ad2a40951854b06fedc4121df40d36fc37483875803c8736190 +size 50265 diff --git a/assets/world/tree/pine_green_2/1.vox b/assets/world/tree/pine_green_2/1.vox deleted file mode 100644 index 6c17c395d9..0000000000 --- a/assets/world/tree/pine_green_2/1.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:cb7e319a52dc802a5a98a03a2a2642058f2d0d49e594495d85a1c5cf47c359da -size 50448 diff --git a/assets/world/tree/pine_green_2/2.vox b/assets/world/tree/pine_green_2/2.vox deleted file mode 100644 index 837fb7a06c..0000000000 --- a/assets/world/tree/pine_green_2/2.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:d4597e947fdf0bdfbae6e1207ef29cf2502e2683fd31bbb336918cf8d988d10e -size 54148 diff --git a/assets/world/tree/pine_green_2/3.vox b/assets/world/tree/pine_green_2/3.vox deleted file mode 100644 index e4b0c94f57..0000000000 --- a/assets/world/tree/pine_green_2/3.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:1d195109ce7c45f6513ba1fb5b9c6de481ac2ab230eb33333b4bffaaff4f31da -size 56140 diff --git a/assets/world/tree/pine_green_2/4.vox b/assets/world/tree/pine_green_2/4.vox deleted file mode 100644 index cac28fff2e..0000000000 --- a/assets/world/tree/pine_green_2/4.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:572a4d32701175e39780a7f2baebc80d12cd32e00ad7b258d04f98933896ffbc -size 48309 diff --git a/assets/world/tree/pine_green_2/5.vox b/assets/world/tree/pine_green_2/5.vox deleted file mode 100644 index 0eefb26077..0000000000 --- a/assets/world/tree/pine_green_2/5.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:6dbeef3b8cf266b1efefd658eecff6e531bd629568715bc2543520ac3c378c54 -size 50856 diff --git a/assets/world/tree/pine_green_2/6.vox b/assets/world/tree/pine_green_2/6.vox deleted file mode 100644 index d091ef076b..0000000000 --- a/assets/world/tree/pine_green_2/6.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:61ef309f4d08018c8894291c0559afa971e154c75c5e54b176233648bc9918da -size 49053 diff --git a/assets/world/tree/pine_green_2/7.vox b/assets/world/tree/pine_green_2/7.vox deleted file mode 100644 index cfbe7d5b1f..0000000000 --- a/assets/world/tree/pine_green_2/7.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:b4463e61a348ba8eaa022f7fa64a43bae85602b783c498afc8e19f6eb5fa5308 -size 54492 diff --git a/assets/world/tree/pine_green_2/8.vox b/assets/world/tree/pine_green_2/8.vox deleted file mode 100644 index d9be5ee8b5..0000000000 --- a/assets/world/tree/pine_green_2/8.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:e2477663110a05bb5f719f88b9a4cb6d05a5e588680883c1a8774098f63b10a1 -size 50265 diff --git a/assets/world/tree/poplar/1.vox b/assets/world/tree/poplar/1.vox index 96d8ec9d58..def9050b24 100644 --- a/assets/world/tree/poplar/1.vox +++ b/assets/world/tree/poplar/1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:cb33d58d26953f65e14bd9d6d439b3f5cc1e75f49b474077a2bd85ca03ca8dec +oid sha256:22ab052663f6331b628d55d1c997581758e7a39944594a95290e362751882bf3 size 63195 diff --git a/assets/world/tree/poplar/10.vox b/assets/world/tree/poplar/10.vox index 1715f25413..a69da34efd 100644 --- a/assets/world/tree/poplar/10.vox +++ b/assets/world/tree/poplar/10.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:576e5966930ee2bb0764ecd6e5c37c65e45bd8d70e76ad4ea8b8f6120c25b80e +oid sha256:53259a9f379c965713dea6152b5ec85c48311d23a77aafc7a064702207fbf5b7 size 67107 diff --git a/assets/world/tree/poplar/2.vox b/assets/world/tree/poplar/2.vox index e22840c8c4..64c3241203 100644 --- a/assets/world/tree/poplar/2.vox +++ b/assets/world/tree/poplar/2.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e6910ab3d4e268629d94b8b2a48c670aa61f6654361da16348d168cc1514cb1b +oid sha256:db88af7a8c07b8146efbff78233f530f41022b9144fff07a46c90c72777699e9 size 61183 diff --git a/assets/world/tree/poplar/3.vox b/assets/world/tree/poplar/3.vox index 04a2bace76..fb927c3c22 100644 --- a/assets/world/tree/poplar/3.vox +++ b/assets/world/tree/poplar/3.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a09df175175dc0af80ed51265d3d74446e95304111e5b5524c1dbb5c290458f5 +oid sha256:b4c095d2f496aa2b0a531087cf64cf475217f583acc0492aa9496a20aafa9e8f size 56455 diff --git a/assets/world/tree/poplar/4.vox b/assets/world/tree/poplar/4.vox index 1a939bd81a..eab3776c31 100644 --- a/assets/world/tree/poplar/4.vox +++ b/assets/world/tree/poplar/4.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:20a1d926641e1db670a286c1981943587ca8ba9b5ce9e01144478f3c09feabf3 +oid sha256:8bca70d737f4d56202f81bd861f7891dc3c40574381cc46279c736a182cbf303 size 54823 diff --git a/assets/world/tree/poplar/5.vox b/assets/world/tree/poplar/5.vox index 87a9951180..d38ec13c58 100644 --- a/assets/world/tree/poplar/5.vox +++ b/assets/world/tree/poplar/5.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b4a64bd9c1ab8abca802de5d22c2d6090fd4c8f40b32fe73b1f4cc9582164ce5 +oid sha256:9a7f16377fe5928bba4c1019941307e02bbe1edc8749874d560a797ce93cab39 size 59219 diff --git a/assets/world/tree/poplar/6.vox b/assets/world/tree/poplar/6.vox index 2928b6ba50..f4ca924b8f 100644 --- a/assets/world/tree/poplar/6.vox +++ b/assets/world/tree/poplar/6.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ec391e4ff8527e4ba6c416e4697bb832ee89409697c1ba179697b7cf1b0ce4f6 +oid sha256:f62a65ea5a10a2e30bc1a76cea02e78b1fa28d099832629f218ae29da6596672 size 53167 diff --git a/assets/world/tree/poplar/7.vox b/assets/world/tree/poplar/7.vox index 4c88aabff7..fd11e7e94d 100644 --- a/assets/world/tree/poplar/7.vox +++ b/assets/world/tree/poplar/7.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c4124d4dd96cd3aedd8fe9b574caaa2d5fc1f44a48d24703bb3238d7f03fc68e +oid sha256:12b2c6b44bc6fc52517559636c5ff7d42a2c127449652c47e094cd1253f11a19 size 55883 diff --git a/assets/world/tree/poplar/8.vox b/assets/world/tree/poplar/8.vox index a187e86ce4..bececb963a 100644 --- a/assets/world/tree/poplar/8.vox +++ b/assets/world/tree/poplar/8.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a0f7bb1e2eb7b33bb7af48deda35205399a6210e7c5ca42608fa6381043b52d7 +oid sha256:946470b5b7f4942e539b5da12c906513601d2145725ce7074d833d48526ee242 size 59583 diff --git a/assets/world/tree/poplar/9.vox b/assets/world/tree/poplar/9.vox index b8ef5e9e7c..9c68248183 100644 --- a/assets/world/tree/poplar/9.vox +++ b/assets/world/tree/poplar/9.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b5997b87e2e44e1eed4e108962724b3ac9a7a6da40dd20c18e1cb591d04ff115 +oid sha256:bd00eb99e4be1b0274233ded21fde4e25bf7f213342ff981e90ed80d0389be90 size 58867 diff --git a/assets/world/tree/snow_pine/1.vox b/assets/world/tree/snow_pine/1.vox index abac0b5946..6339b9a45b 100644 --- a/assets/world/tree/snow_pine/1.vox +++ b/assets/world/tree/snow_pine/1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a6a2c64ede7ef2bf95eb94b62b7666e45710dbfa58ac5c1dadff4f52078332c2 +oid sha256:d35c4cf9e3dd2277889019cc03f4c44309b5025ba78605092ba18360b1570089 size 54372 diff --git a/assets/world/tree/snow_pine/2.vox b/assets/world/tree/snow_pine/2.vox index fd92351363..5634beae4e 100644 --- a/assets/world/tree/snow_pine/2.vox +++ b/assets/world/tree/snow_pine/2.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:58bcfda9bfc5e9614c98ff105505a49a2058e5809cdffe6d7bd08160c994d836 +oid sha256:8ce03fab779e7e1771e093f78680d4c04cbf7efe07def58c2fc4774063d68763 size 60716 diff --git a/assets/world/tree/snow_pine/3.vox b/assets/world/tree/snow_pine/3.vox index 55eb71f4c8..6c30c16864 100644 --- a/assets/world/tree/snow_pine/3.vox +++ b/assets/world/tree/snow_pine/3.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:da5d26637081c66f6e57e213135b523be4d07f69316990a27370eafff9e6ea5c +oid sha256:d8f85059de10e295cdec44674076b378d7433fc57a3617a5d52082478e8e2416 size 64096 diff --git a/assets/world/tree/snow_pine/4.vox b/assets/world/tree/snow_pine/4.vox index 9f7199e2c2..60ec1c30f6 100644 --- a/assets/world/tree/snow_pine/4.vox +++ b/assets/world/tree/snow_pine/4.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:41ede784f074741b19fb7ebf6d51fe9dcde0d515784ff35e21660dc331f48174 +oid sha256:837e72db50782db33f16be8c6b920b49a503c94900dfb939aa76d741130bc37a size 50181 diff --git a/assets/world/tree/snow_pine/5.vox b/assets/world/tree/snow_pine/5.vox index 6e25e606f8..98e5da85ae 100644 --- a/assets/world/tree/snow_pine/5.vox +++ b/assets/world/tree/snow_pine/5.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d868d90ce526271932186fcbf7fa9f06a80a00b92f9b34c201a51351b691d25e +oid sha256:bec2b7c67db93657fb24dd99c5f350ffb549f9982a3822d431a1bf3670b8c2ac size 53840 diff --git a/assets/world/tree/snow_pine/6.vox b/assets/world/tree/snow_pine/6.vox index e2fb8c3ab6..eebb545dc6 100644 --- a/assets/world/tree/snow_pine/6.vox +++ b/assets/world/tree/snow_pine/6.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:261b0c6636b07bfe673350f11dd60379bdc0e514989032386136f8189cd7cc06 +oid sha256:d18f06c68e8d547c3ae7ad4b06c9c06c7fc2897965e11102434e80a5e53671eb size 50893 diff --git a/assets/world/tree/snow_pine/7.vox b/assets/world/tree/snow_pine/7.vox index b0ca97c910..e0b1309529 100644 --- a/assets/world/tree/snow_pine/7.vox +++ b/assets/world/tree/snow_pine/7.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1357aa2c4536393bc3904ccce3210dc1382ea81f26999c6ccb54c0c89a653acd +oid sha256:560de0d76797b54db3a5ee5c79185c8f44a48fb63977884b13dc3e111d29a05d size 58652 diff --git a/assets/world/tree/snow_pine/8.vox b/assets/world/tree/snow_pine/8.vox index db3e71f929..363303bfa4 100644 --- a/assets/world/tree/snow_pine/8.vox +++ b/assets/world/tree/snow_pine/8.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9bd510dbdec14a5a96e574ff7b47874dc6c741e4d731bb8bf313abe31079b822 +oid sha256:9927d20847ea3f216311fbb4fc9f6bcdcf5f76befa5ed71ec9f4a04d4123f00b size 52937 diff --git a/assets/world/tree/temperate_small/1.vox b/assets/world/tree/temperate_small/1.vox index cd2bc5e392..01304a1d6a 100644 --- a/assets/world/tree/temperate_small/1.vox +++ b/assets/world/tree/temperate_small/1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:35f3f75a98d65d7ade303de43bc5a5f73f1164e4ce2109729e2e7ed2ff25241b -size 45199 +oid sha256:1e7732d8f01169d6ec8aec60e8226ff6ae3a24a372d4cd30967839714fb50fbf +size 45145 diff --git a/assets/world/tree/temperate_small/2.vox b/assets/world/tree/temperate_small/2.vox index 95aa68c7cf..57736a5011 100644 --- a/assets/world/tree/temperate_small/2.vox +++ b/assets/world/tree/temperate_small/2.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:fd52f715f8f7ec53aa6fdade3588f4eac10f8d28ced35d89156fbb6952124410 -size 45415 +oid sha256:ed87cdd4f58d1d218d7b8c5789a6b2501bb5838e902634bc14ebcd5e803f455c +size 45361 diff --git a/assets/world/tree/temperate_small/3.vox b/assets/world/tree/temperate_small/3.vox index 671519b840..5d4a123a52 100644 --- a/assets/world/tree/temperate_small/3.vox +++ b/assets/world/tree/temperate_small/3.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ecb880b8f653cb78117bbe4555931e36291f6ebd03adbb86ae051c90889015c3 -size 45395 +oid sha256:45568304006a9642619f9cc6e0a6d44240d9a6560980e9d9f20e318faba57a7b +size 45341 diff --git a/assets/world/tree/temperate_small/4.vox b/assets/world/tree/temperate_small/4.vox index a33843f02f..99ef2aaa60 100644 --- a/assets/world/tree/temperate_small/4.vox +++ b/assets/world/tree/temperate_small/4.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d8b0cc528255d725e4ffc198ac5b724b81e040ca0f406f251d677c1b64cd2181 -size 45063 +oid sha256:a75707ba1a44887e8930029f2d837d0a7f6adce86614ac8fdb45fd467278a130 +size 45009 diff --git a/assets/world/tree/temperate_small/5.vox b/assets/world/tree/temperate_small/5.vox index db8d9e5306..3c0eca03ae 100644 --- a/assets/world/tree/temperate_small/5.vox +++ b/assets/world/tree/temperate_small/5.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0c1fadff5bbc66d0ccf5a9a737e44e4ff93191dbb8baf1b809770c51f2ba416d -size 45055 +oid sha256:bd60587804d68157abf50641920baabc4463f71be7955b04bf7b39cd12078279 +size 45001 diff --git a/assets/world/tree/temperate_small/6.vox b/assets/world/tree/temperate_small/6.vox index c093a4241e..10bea0a7a7 100644 --- a/assets/world/tree/temperate_small/6.vox +++ b/assets/world/tree/temperate_small/6.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b20e5ad4149174f2d1176b22cb21f87bb5ab03a3b6edbce04191d7f65127655f -size 45231 +oid sha256:57590bd0944e1f810f4c09a0f425156ff58c7a2990c3ee7c28030a3ed7be0820 +size 45177 From 743855092ab7d606e909197c2e5f9226531a4bf8 Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Wed, 12 Jun 2019 14:16:32 +0100 Subject: [PATCH 24/30] Fixed missing assets --- world/src/block/tree.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/world/src/block/tree.rs b/world/src/block/tree.rs index 17bc34ec42..ba13c79d4b 100644 --- a/world/src/block/tree.rs +++ b/world/src/block/tree.rs @@ -99,6 +99,7 @@ lazy_static! { assets::load_map("world/tree/pine_green/8.vox", |s: Structure| s .with_center(Vec3::new(12, 10, 12))) .unwrap(), + /* // green pines 2 assets::load_map("world/tree/pine_green_2/1.vox", |s: Structure| s .with_center(Vec3::new(15, 15, 14))) @@ -149,6 +150,7 @@ lazy_static! { assets::load_map("world/tree/pine_blue/8.vox", |s: Structure| s .with_center(Vec3::new(12, 10, 12))) .unwrap(), + */ ]; /* // temperate small From 30b668d0cc2d9fcb02f1f026050e9f4657830e81 Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Wed, 12 Jun 2019 21:22:16 +0100 Subject: [PATCH 25/30] Added dynamic tree colours --- common/src/terrain/structure.rs | 57 +++++++++++++++++++++++++-------- world/src/block/mod.rs | 27 ++++++++++++++-- world/src/column/mod.rs | 2 ++ 3 files changed, 70 insertions(+), 16 deletions(-) diff --git a/common/src/terrain/structure.rs b/common/src/terrain/structure.rs index d67c275ff9..b94c1bdf00 100644 --- a/common/src/terrain/structure.rs +++ b/common/src/terrain/structure.rs @@ -7,14 +7,35 @@ use crate::{ use dot_vox::DotVoxData; use vek::*; +#[derive(Copy, Clone)] +pub enum StructureBlock { + TemperateLeaves, + PineLeaves, + PalmLeaves, + Block(Block), +} + +impl Vox for StructureBlock { + fn empty() -> Self { + StructureBlock::Block(Block::empty()) + } + + fn is_empty(&self) -> bool { + match self { + StructureBlock::Block(block) => block.is_empty(), + _ => false, + } + } +} + #[derive(Debug)] pub enum StructureError {} #[derive(Clone)] pub struct Structure { center: Vec3, - vol: Dyna, - empty: Block, + vol: Dyna, + empty: StructureBlock, } impl Structure { @@ -25,13 +46,13 @@ impl Structure { } impl BaseVol for Structure { - type Vox = Block; + type Vox = StructureBlock; type Err = StructureError; } impl ReadVol for Structure { #[inline(always)] - fn get(&self, pos: Vec3) -> Result<&Block, StructureError> { + fn get(&self, pos: Vec3) -> Result<&Self::Vox, StructureError> { match self.vol.get(pos + self.center) { Ok(block) => Ok(block), Err(DynaErr::OutOfBounds) => Ok(&self.empty), @@ -52,29 +73,37 @@ impl Asset for Structure { let mut vol = Dyna::filled( Vec3::new(model.size.x, model.size.y, model.size.z), - Block::empty(), + StructureBlock::empty(), (), ); for voxel in &model.voxels { - if let Some(&color) = palette.get(voxel.i as usize) { - let _ = vol.set( - Vec3::new(voxel.x, voxel.y, voxel.z).map(|e| e as i32), - Block::new(1, color), - ); - } + let block = match voxel.i { + 0 => StructureBlock::TemperateLeaves, + 1 => StructureBlock::PineLeaves, + 2 => StructureBlock::PalmLeaves, + index => { + let color = palette.get(index as usize).copied().unwrap_or(Rgb::broadcast(0)); + StructureBlock::Block(Block::new(1, color)) + } + }; + + let _ = vol.set( + Vec3::new(voxel.x, voxel.y, voxel.z).map(|e| e as i32), + block + ); } Ok(Structure { center: Vec3::zero(), vol, - empty: Block::empty(), + empty: StructureBlock::empty(), }) } else { Ok(Self { center: Vec3::zero(), - vol: Dyna::filled(Vec3::zero(), Block::empty(), ()), - empty: Block::empty(), + vol: Dyna::filled(Vec3::zero(), StructureBlock::empty(), ()), + empty: StructureBlock::empty(), }) } } diff --git a/world/src/block/mod.rs b/world/src/block/mod.rs index 03c311a4e2..fc89775334 100644 --- a/world/src/block/mod.rs +++ b/world/src/block/mod.rs @@ -4,7 +4,7 @@ use std::ops::{Add, Div, Mul, Neg, Sub}; use noise::NoiseFn; use vek::*; use common::{ - terrain::Block, + terrain::{Block, structure::StructureBlock}, vol::{Vox, ReadVol}, }; use crate::{ @@ -53,6 +53,7 @@ impl<'a> Sampler for BlockGen<'a> { cave_alt, rock, cliff, + temp, } = self.sample_column(Vec2::from(wpos))?; let wposf = wpos.map(|e| e as f64); @@ -161,6 +162,28 @@ impl<'a> Sampler for BlockGen<'a> { } }); + fn block_from_structure(sblock: StructureBlock, structure_pos: Vec2, sample: &ColumnSample) -> Block { + let temp_lerp = sample.temp * 4.0; + match sblock { + StructureBlock::TemperateLeaves => Block::new(1, Lerp::lerp( + Rgb::new(0.0, 150.0, 50.0), + Rgb::new(200.0, 255.0, 0.0), + temp_lerp, + ).map(|e| e as u8)), + StructureBlock::PineLeaves => Block::new(1, Lerp::lerp( + Rgb::new(0.0, 100.0, 90.0), + Rgb::new(50.0, 150.0, 50.0), + temp_lerp, + ).map(|e| e as u8)), + StructureBlock::PalmLeaves => Block::new(1, Lerp::lerp( + Rgb::new(80.0, 150.0, 0.0), + Rgb::new(180.0, 255.0, 0.0), + temp_lerp, + ).map(|e| e as u8)), + StructureBlock::Block(block) => block, + } + } + let block = match block { Some(block) => block, None => (&close_trees) @@ -179,7 +202,7 @@ impl<'a> Sampler for BlockGen<'a> { block.or(trees[*tree_seed as usize % trees.len()] .get((rpos * 128) / 128) // Scaling - .map(|b| b.clone()) + .map(|b| block_from_structure(*b, *tree_pos, &tree_sample)) .unwrap_or(Block::empty())) } _ => block, diff --git a/world/src/column/mod.rs b/world/src/column/mod.rs index f4d03294c9..f11548a393 100644 --- a/world/src/column/mod.rs +++ b/world/src/column/mod.rs @@ -144,6 +144,7 @@ impl<'a> Sampler for ColumnGen<'a> { cave_alt, rock, cliff: cliffiness, + temp, }) } } @@ -160,4 +161,5 @@ pub struct ColumnSample { pub cave_alt: f32, pub rock: f32, pub cliff: f32, + pub temp: f32, } From a9d30bbfb669d3b48a03bc0157e9a46700883ff2 Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Sat, 15 Jun 2019 11:36:26 +0100 Subject: [PATCH 26/30] Adjusted tree colour variation --- client/src/lib.rs | 23 +++--- common/src/net/post2.rs | 6 +- common/src/terrain/mod.rs | 5 +- common/src/terrain/structure.rs | 7 +- voxygen/shaders/terrain.frag | 2 +- voxygen/src/scene/mod.rs | 3 +- voxygen/src/session.rs | 2 +- world/src/block/mod.rs | 126 ++++++++++++++++++++------------ world/src/block/tree.rs | 2 +- world/src/column/mod.rs | 39 +++++----- world/src/lib.rs | 16 ++-- world/src/sim/location.rs | 21 +++--- world/src/sim/mod.rs | 24 +++--- world/src/util/hash_cache.rs | 2 +- world/src/util/mod.rs | 6 +- world/src/util/random.rs | 41 +++++++++++ world/src/util/sampler.rs | 7 ++ world/src/util/structure.rs | 45 +++++------- 18 files changed, 225 insertions(+), 152 deletions(-) create mode 100644 world/src/util/random.rs diff --git a/client/src/lib.rs b/client/src/lib.rs index 83ad07f696..6d4da2a5e7 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -12,19 +12,15 @@ use common::{ msg::{ClientMsg, ClientState, ServerInfo, ServerMsg}, net::PostBox, state::State, - terrain::{ - TerrainChunk, - TerrainChunkSize, - chonk::ChonkMetrics, - }, + terrain::{chonk::ChonkMetrics, TerrainChunk, TerrainChunkSize}, vol::VolSize, }; use log::{debug, info, log_enabled}; use std::{ collections::HashMap, net::SocketAddr, - time::{Duration, Instant}, sync::Arc, + time::{Duration, Instant}, }; use threadpool::ThreadPool; use vek::*; @@ -155,11 +151,16 @@ impl Client { } pub fn current_chunk(&self) -> Option> { - let chunk_pos = Vec2::from(self - .state - .read_storage::() - .get(self.entity) - .cloned()?.0).map2(Vec2::from(TerrainChunkSize::SIZE), |e: f32, sz| (e as u32).div_euclid(sz) as i32); + let chunk_pos = Vec2::from( + self.state + .read_storage::() + .get(self.entity) + .cloned()? + .0, + ) + .map2(Vec2::from(TerrainChunkSize::SIZE), |e: f32, sz| { + (e as u32).div_euclid(sz) as i32 + }); self.state.terrain().get_key_arc(chunk_pos).cloned() } diff --git a/common/src/net/post2.rs b/common/src/net/post2.rs index 55cf64c3ee..724ac77984 100644 --- a/common/src/net/post2.rs +++ b/common/src/net/post2.rs @@ -267,9 +267,9 @@ impl PostBox { for _ in 0..100 { match incoming_buf.get(0..9) { Some(len_bytes) => { - let len = u64::from_le_bytes( - <[u8; 8]>::try_from(&len_bytes[0..8]).unwrap(), - ) as usize; // Can't fail + let len = + u64::from_le_bytes(<[u8; 8]>::try_from(&len_bytes[0..8]).unwrap()) + as usize; // Can't fail if len > MAX_MSG_SIZE { recv_tx.send(Err(Error::InvalidMessage)).unwrap(); diff --git a/common/src/terrain/mod.rs b/common/src/terrain/mod.rs index ef7259db90..96f70ac059 100644 --- a/common/src/terrain/mod.rs +++ b/common/src/terrain/mod.rs @@ -33,10 +33,7 @@ pub struct TerrainChunkMeta { impl TerrainChunkMeta { pub fn new(name: Option, biome: BiomeKind) -> Self { - Self { - name, - biome, - } + Self { name, biome } } pub fn void() -> Self { diff --git a/common/src/terrain/structure.rs b/common/src/terrain/structure.rs index b94c1bdf00..a218d62a99 100644 --- a/common/src/terrain/structure.rs +++ b/common/src/terrain/structure.rs @@ -83,14 +83,17 @@ impl Asset for Structure { 1 => StructureBlock::PineLeaves, 2 => StructureBlock::PalmLeaves, index => { - let color = palette.get(index as usize).copied().unwrap_or(Rgb::broadcast(0)); + let color = palette + .get(index as usize) + .copied() + .unwrap_or(Rgb::broadcast(0)); StructureBlock::Block(Block::new(1, color)) } }; let _ = vol.set( Vec3::new(voxel.x, voxel.y, voxel.z).map(|e| e as i32), - block + block, ); } diff --git a/voxygen/shaders/terrain.frag b/voxygen/shaders/terrain.frag index 2c56dbf007..3678ec803d 100644 --- a/voxygen/shaders/terrain.frag +++ b/voxygen/shaders/terrain.frag @@ -32,7 +32,7 @@ void main() { float sun_ambience = 0.8; - vec3 sun_dir = normalize(vec3(1.3, 1.7, 2.1)); + vec3 sun_dir = normalize(vec3(0.7, 1.3, 2.1)); float sun_diffuse = dot(sun_dir, f_norm); float sun_light = sun_ambience + sun_diffuse; diff --git a/voxygen/src/scene/mod.rs b/voxygen/src/scene/mod.rs index da476c6248..9d7c09f608 100644 --- a/voxygen/src/scene/mod.rs +++ b/voxygen/src/scene/mod.rs @@ -117,7 +117,8 @@ impl Scene { // Alter camera position to match player. let tilt = self.camera.get_orientation().y; let dist = self.camera.get_distance(); - self.camera.set_focus_pos(player_pos + Vec3::unit_z() * (2.1 - tilt.min(0.0) * dist * 0.75)); + self.camera + .set_focus_pos(player_pos + Vec3::unit_z() * (2.1 - tilt.min(0.0) * dist * 0.75)); // Tick camera for interpolation. self.camera.update(client.state().get_time()); diff --git a/voxygen/src/session.rs b/voxygen/src/session.rs index 795ce25eb5..49b1965ce6 100644 --- a/voxygen/src/session.rs +++ b/voxygen/src/session.rs @@ -72,7 +72,7 @@ impl SessionState { // TODO: Get rid of this match self.client.borrow().current_chunk() { Some(chunk) => println!("Chunk location: {:?}", chunk.meta().name()), - None => {}, + None => {} } Ok(()) diff --git a/world/src/block/mod.rs b/world/src/block/mod.rs index fc89775334..c09efbd5c9 100644 --- a/world/src/block/mod.rs +++ b/world/src/block/mod.rs @@ -1,18 +1,17 @@ mod tree; -use std::ops::{Add, Div, Mul, Neg, Sub}; -use noise::NoiseFn; -use vek::*; -use common::{ - terrain::{Block, structure::StructureBlock}, - vol::{Vox, ReadVol}, -}; use crate::{ - util::{Sampler, HashCache}, column::{ColumnGen, ColumnSample}, - CONFIG, - World, + util::{HashCache, RandomField, Sampler, SamplerMut}, + World, CONFIG, }; +use common::{ + terrain::{structure::StructureBlock, Block}, + vol::{ReadVol, Vox}, +}; +use noise::NoiseFn; +use std::ops::{Add, Div, Mul, Neg, Sub}; +use vek::*; pub struct BlockGen<'a> { world: &'a World, @@ -37,7 +36,7 @@ impl<'a> BlockGen<'a> { } } -impl<'a> Sampler for BlockGen<'a> { +impl<'a> SamplerMut for BlockGen<'a> { type Index = Vec3; type Sample = Option; @@ -60,7 +59,9 @@ impl<'a> Sampler for BlockGen<'a> { // Apply warping - let warp = (self.world.sim() + let warp = (self + .world + .sim() .gen_ctx .warp_nz .get((wposf.div(Vec3::new(150.0, 150.0, 150.0))).into_array()) @@ -69,29 +70,37 @@ impl<'a> Sampler for BlockGen<'a> { .mul(115.0); let is_cliff = if cliff > 0.0 { - (self.world.sim() - .gen_ctx - .warp_nz - .get((wposf.div(Vec3::new(300.0, 300.0, 1500.0))).into_array()) - as f32) * cliff > 0.3 + (self + .world + .sim() + .gen_ctx + .warp_nz + .get((wposf.div(Vec3::new(300.0, 300.0, 1500.0))).into_array()) as f32) + * cliff + > 0.3 } else { false }; let cliff = if is_cliff { - (0.0 - + (self.world.sim() + (0.0 + (self + .world + .sim() .gen_ctx .warp_nz .get((wposf.div(Vec3::new(350.0, 350.0, 800.0))).into_array()) - as f32) * 0.8 - + (self.world.sim() - .gen_ctx - .warp_nz - .get((wposf.div(Vec3::new(100.0, 100.0, 70.0))).into_array()) - as f32) * 0.3) - .add(0.4) - .mul(64.0) + as f32) + * 0.8 + + (self + .world + .sim() + .gen_ctx + .warp_nz + .get((wposf.div(Vec3::new(100.0, 100.0, 70.0))).into_array()) + as f32) + * 0.3) + .add(0.4) + .mul(75.0) } else { 0.0 }; @@ -162,24 +171,43 @@ impl<'a> Sampler for BlockGen<'a> { } }); - fn block_from_structure(sblock: StructureBlock, structure_pos: Vec2, sample: &ColumnSample) -> Block { - let temp_lerp = sample.temp * 4.0; + fn block_from_structure( + sblock: StructureBlock, + pos: Vec3, + structure_pos: Vec2, + structure_seed: u32, + sample: &ColumnSample, + ) -> Block { + let field = RandomField::new(structure_seed + 0); + + let lerp = 0.5 + + ((field.get(Vec3::from(structure_pos)) % 256) as f32 / 256.0 - 0.5) * 0.75 + + ((field.get(Vec3::from(pos)) % 256) as f32 / 256.0 - 0.5) * 0.2; + match sblock { - StructureBlock::TemperateLeaves => Block::new(1, Lerp::lerp( - Rgb::new(0.0, 150.0, 50.0), - Rgb::new(200.0, 255.0, 0.0), - temp_lerp, - ).map(|e| e as u8)), - StructureBlock::PineLeaves => Block::new(1, Lerp::lerp( - Rgb::new(0.0, 100.0, 90.0), - Rgb::new(50.0, 150.0, 50.0), - temp_lerp, - ).map(|e| e as u8)), - StructureBlock::PalmLeaves => Block::new(1, Lerp::lerp( - Rgb::new(80.0, 150.0, 0.0), - Rgb::new(180.0, 255.0, 0.0), - temp_lerp, - ).map(|e| e as u8)), + StructureBlock::TemperateLeaves => Block::new( + 1, + Lerp::lerp( + Rgb::new(0.0, 80.0, 40.0), + Rgb::new(120.0, 255.0, 10.0), + lerp, + ) + .map(|e| e as u8), + ), + StructureBlock::PineLeaves => Block::new( + 1, + Lerp::lerp(Rgb::new(0.0, 60.0, 50.0), Rgb::new(30.0, 100.0, 10.0), lerp) + .map(|e| e as u8), + ), + StructureBlock::PalmLeaves => Block::new( + 1, + Lerp::lerp( + Rgb::new(30.0, 100.0, 30.0), + Rgb::new(120.0, 255.0, 0.0), + lerp, + ) + .map(|e| e as u8), + ), StructureBlock::Block(block) => block, } } @@ -202,7 +230,15 @@ impl<'a> Sampler for BlockGen<'a> { block.or(trees[*tree_seed as usize % trees.len()] .get((rpos * 128) / 128) // Scaling - .map(|b| block_from_structure(*b, *tree_pos, &tree_sample)) + .map(|b| { + block_from_structure( + *b, + rpos, + *tree_pos, + *tree_seed, + &tree_sample, + ) + }) .unwrap_or(Block::empty())) } _ => block, diff --git a/world/src/block/tree.rs b/world/src/block/tree.rs index ba13c79d4b..2248e28a07 100644 --- a/world/src/block/tree.rs +++ b/world/src/block/tree.rs @@ -1,8 +1,8 @@ +use crate::all::ForestKind; use common::{assets, terrain::Structure}; use lazy_static::lazy_static; use std::sync::Arc; use vek::*; -use crate::all::ForestKind; pub fn kinds(forest_kind: ForestKind) -> &'static [Arc] { match forest_kind { diff --git a/world/src/column/mod.rs b/world/src/column/mod.rs index f11548a393..0783aa4dd5 100644 --- a/world/src/column/mod.rs +++ b/world/src/column/mod.rs @@ -1,16 +1,11 @@ -use std::ops::{Add, Div, Mul, Neg, Sub}; -use vek::*; -use noise::NoiseFn; +use crate::{all::ForestKind, util::Sampler, World, CONFIG}; use common::{ terrain::{Block, TerrainChunkSize}, - vol::{Vox, VolSize}, -}; -use crate::{ - CONFIG, - all::ForestKind, - util::Sampler, - World, + vol::{VolSize, Vox}, }; +use noise::NoiseFn; +use std::ops::{Add, Div, Mul, Neg, Sub}; +use vek::*; pub struct ColumnGen<'a> { world: &'a World, @@ -18,9 +13,7 @@ pub struct ColumnGen<'a> { impl<'a> ColumnGen<'a> { pub fn new(world: &'a World) -> Self { - Self { - world, - } + Self { world } } } @@ -28,9 +21,11 @@ impl<'a> Sampler for ColumnGen<'a> { type Index = Vec2; type Sample = Option; - fn get(&mut self, wpos: Vec2) -> Option { + fn get(&self, wpos: Vec2) -> Option { let wposf = wpos.map(|e| e as f64); - let chunk_pos = wpos.map2(Vec2::from(TerrainChunkSize::SIZE), |e, sz: u32| e as u32 / sz); + let chunk_pos = wpos.map2(Vec2::from(TerrainChunkSize::SIZE), |e, sz: u32| { + e as u32 / sz + }); let sim = self.world.sim(); @@ -48,7 +43,11 @@ impl<'a> Sampler for ColumnGen<'a> { * chaos.max(0.2) * 64.0; - let rock = (sim.gen_ctx.small_nz.get(Vec3::new(wposf.x, wposf.y, alt as f64).div(100.0).into_array()) as f32) + let rock = (sim.gen_ctx.small_nz.get( + Vec3::new(wposf.x, wposf.y, alt as f64) + .div(100.0) + .into_array(), + ) as f32) .mul(rockiness) .sub(0.4) .max(0.0) @@ -59,8 +58,8 @@ impl<'a> Sampler for ColumnGen<'a> { let marble = (0.0 + (sim.gen_ctx.hill_nz.get((wposf3d.div(48.0)).into_array()) as f32).mul(0.75) + (sim.gen_ctx.hill_nz.get((wposf3d.div(3.0)).into_array()) as f32).mul(0.25)) - .add(1.0) - .mul(0.5); + .add(1.0) + .mul(0.5); // Colours let cold_grass = Rgb::new(0.0, 0.3, 0.1); @@ -79,7 +78,9 @@ impl<'a> Sampler for ColumnGen<'a> { Rgb::lerp( snow, grass, - temp.sub(CONFIG.snow_temp).sub((marble - 0.5) * 0.05).mul(256.0), + temp.sub(CONFIG.snow_temp) + .sub((marble - 0.5) * 0.05) + .mul(256.0), ), sand, temp.sub(CONFIG.desert_temp).mul(32.0), diff --git a/world/src/lib.rs b/world/src/lib.rs index 2f5ccc01ca..773b887942 100644 --- a/world/src/lib.rs +++ b/world/src/lib.rs @@ -1,26 +1,26 @@ #![feature(euclidean_division, bind_by_move_pattern_guards)] -mod config; mod all; -mod util; mod block; mod column; +mod config; mod sim; +mod util; // Reexports pub use crate::config::CONFIG; +use crate::{ + block::BlockGen, + column::ColumnGen, + util::{HashCache, Sampler, SamplerMut}, +}; use common::{ terrain::{Block, TerrainChunk, TerrainChunkMeta, TerrainChunkSize}, vol::{VolSize, Vox, WriteVol}, }; use std::time::Duration; use vek::*; -use crate::{ - util::{Sampler, HashCache}, - column::ColumnGen, - block::BlockGen, -}; #[derive(Debug)] pub enum Error { @@ -46,7 +46,7 @@ impl World { // TODO } - pub fn sample(&self) -> impl Sampler, Sample=Option> + '_ { + pub fn sample(&self) -> impl SamplerMut, Sample = Option> + '_ { BlockGen::new(self, ColumnGen::new(self)) } diff --git a/world/src/sim/location.rs b/world/src/sim/location.rs index 6eed4b555d..892e8e62a8 100644 --- a/world/src/sim/location.rs +++ b/world/src/sim/location.rs @@ -21,20 +21,17 @@ pub struct Kingdom { fn generate_name() -> String { let consts = [ - "st", "tr", "b", "n", "p", "ph", "cr", "g", "c", - "d", "k", "kr", "kl", "gh", "sl", "st", "cr", "sp", - "th", "dr", "pr", "dr", "gr", "br", "ryth", "rh", "sl", - "f", "fr", "p", "pr", "qu", "s", "sh", "z", "k", - "br", "wh", "tr", "h", "bl", "sl", "r", "kl", "sl", - "w", "v", "vr", "kr", + "st", "tr", "b", "n", "p", "ph", "cr", "g", "c", "d", "k", "kr", "kl", "gh", "sl", "st", + "cr", "sp", "th", "dr", "pr", "dr", "gr", "br", "ryth", "rh", "sl", "f", "fr", "p", "pr", + "qu", "s", "sh", "z", "k", "br", "wh", "tr", "h", "bl", "sl", "r", "kl", "sl", "w", "v", + "vr", "kr", + ]; + let vowels = [ + "oo", "o", "oa", "au", "e", "ee", "ea", "ou", "u", "a", "i", "ie", ]; - let vowels = ["oo", "o", "oa", "au", "e", "ee", "ea", "ou", "u", "a", "i", "ie"]; let tails = [ - "er", "in", "o", "on", "an", - "ar", "is", "oon", "er", "aru", - "ab", "um", "id", "and", "eld", - "ald", "oft", "aft", "ift", "ity", - "ell", "oll", "ill", "all", + "er", "in", "o", "on", "an", "ar", "is", "oon", "er", "aru", "ab", "um", "id", "and", + "eld", "ald", "oft", "aft", "ift", "ity", "ell", "oll", "ill", "all", ]; let mut name = String::new(); diff --git a/world/src/sim/mod.rs b/world/src/sim/mod.rs index a6fb4351c9..1496e2dfca 100644 --- a/world/src/sim/mod.rs +++ b/world/src/sim/mod.rs @@ -1,24 +1,14 @@ mod location; +use self::location::Location; +use crate::{all::ForestKind, util::StructureGen2d, CONFIG}; +use common::{terrain::TerrainChunkSize, vol::VolSize}; +use noise::{BasicMulti, HybridMulti, MultiFractal, NoiseFn, RidgedMulti, Seedable, SuperSimplex}; use std::{ ops::{Add, Div, Mul, Neg, Sub}, sync::Arc, }; use vek::*; -use noise::{ - BasicMulti, RidgedMulti, SuperSimplex, HybridMulti, - MultiFractal, NoiseFn, Seedable, -}; -use common::{ - terrain::TerrainChunkSize, - vol::VolSize, -}; -use crate::{ - CONFIG, - all::ForestKind, - util::StructureGen2d, -}; -use self::location::Location; pub const WORLD_SIZE: Vec2 = Vec2 { x: 1024, y: 1024 }; @@ -240,7 +230,11 @@ impl SimChunk { .mul(0.5) .mul(1.2 - chaos * 0.85) .add(0.1) - .mul(if alt > CONFIG.sea_level + 2.0 { 1.0 } else { 0.0 }), + .mul(if alt > CONFIG.sea_level + 5.0 { + 1.0 + } else { + 0.0 + }), forest_kind: if temp > 0.0 { if temp > CONFIG.desert_temp { ForestKind::Palm diff --git a/world/src/util/hash_cache.rs b/world/src/util/hash_cache.rs index ffdd3eebfd..a797d6c146 100644 --- a/world/src/util/hash_cache.rs +++ b/world/src/util/hash_cache.rs @@ -1,5 +1,5 @@ -use std::hash::Hash; use fxhash::FxHashMap; +use std::hash::Hash; pub struct HashCache { capacity: usize, diff --git a/world/src/util/mod.rs b/world/src/util/mod.rs index c5f27e4ace..a9c3cb8ae9 100644 --- a/world/src/util/mod.rs +++ b/world/src/util/mod.rs @@ -1,10 +1,12 @@ -pub mod sampler; pub mod hash_cache; +pub mod random; +pub mod sampler; pub mod structure; // Reexports pub use self::{ - sampler::Sampler, hash_cache::HashCache, + random::RandomField, + sampler::{Sampler, SamplerMut}, structure::StructureGen2d, }; diff --git a/world/src/util/random.rs b/world/src/util/random.rs new file mode 100644 index 0000000000..f7ec6696c2 --- /dev/null +++ b/world/src/util/random.rs @@ -0,0 +1,41 @@ +use super::Sampler; +use vek::*; + +pub struct RandomField { + seed: u32, +} + +impl RandomField { + pub fn new(seed: u32) -> Self { + Self { seed } + } +} + +impl Sampler for RandomField { + type Index = Vec3; + type Sample = u32; + + fn get(&self, pos: Self::Index) -> Self::Sample { + let pos = pos.map(|e| (e * 13 + (1 << 31)) as u32); + + let next = self.seed.wrapping_mul(0x168E3D1F).wrapping_add(0xDEADBEAD); + let next = next + .rotate_left(13) + .wrapping_mul(133227) + .wrapping_add(pos.x); + let next = next.rotate_left(13).wrapping_mul(318912) ^ 0x42133742; + let next = next + .rotate_left(13) + .wrapping_mul(938219) + .wrapping_add(pos.y); + let next = next.rotate_left(13).wrapping_mul(318912) ^ 0x23341753; + let next = next + .rotate_left(13) + .wrapping_mul(938219) + .wrapping_add(pos.z); + let next = next.rotate_left(13).wrapping_mul(313322) ^ 0xDEADBEEF; + let next = next.rotate_left(13).wrapping_mul(929009) ^ 0xFF329DE3; + let next = next.rotate_left(13).wrapping_mul(422671) ^ 0x42892942; + next + } +} diff --git a/world/src/util/sampler.rs b/world/src/util/sampler.rs index 20d6c74080..921ffc7f33 100644 --- a/world/src/util/sampler.rs +++ b/world/src/util/sampler.rs @@ -2,5 +2,12 @@ pub trait Sampler: Sized { type Index; type Sample; + fn get(&self, index: Self::Index) -> Self::Sample; +} + +pub trait SamplerMut: Sized { + type Index; + type Sample; + fn get(&mut self, index: Self::Index) -> Self::Sample; } diff --git a/world/src/util/structure.rs b/world/src/util/structure.rs index 920e689f95..512acd671d 100644 --- a/world/src/util/structure.rs +++ b/world/src/util/structure.rs @@ -1,38 +1,31 @@ +use super::{RandomField, Sampler}; use vek::*; pub struct StructureGen2d { - seed: u32, freq: u32, spread: u32, + x_field: RandomField, + y_field: RandomField, + seed_field: RandomField, } impl StructureGen2d { pub fn new(seed: u32, freq: u32, spread: u32) -> Self { - Self { seed, freq, spread } + Self { + freq, + spread, + x_field: RandomField::new(seed + 0), + y_field: RandomField::new(seed + 1), + seed_field: RandomField::new(seed + 2), + } } +} - fn random(&self, seed: u32, pos: Vec2) -> u32 { - let pos = pos.map(|e| (e * 13 + (1 << 31)) as u32); +impl Sampler for StructureGen2d { + type Index = Vec2; + type Sample = [(Vec2, u32); 9]; - let next = (self.seed + seed) - .wrapping_mul(0x168E3D1F) - .wrapping_add(0xDEADBEAD); - let next = next - .rotate_left(13) - .wrapping_mul(133227) - .wrapping_add(pos.x); - let next = next.rotate_left(13).wrapping_mul(318912) ^ 0x42133742; - let next = next - .rotate_left(13) - .wrapping_mul(938219) - .wrapping_add(pos.y); - let next = next.rotate_left(13).wrapping_mul(313322) ^ 0xDEADBEEF; - let next = next.rotate_left(13).wrapping_mul(929009) ^ 0xFF329DE3; - let next = next.rotate_left(13).wrapping_mul(422671) ^ 0x42892942; - next - } - - pub fn get(&self, sample_pos: Vec2) -> [(Vec2, u32); 9] { + fn get(&self, sample_pos: Self::Index) -> Self::Sample { let mut samples = [(Vec2::zero(), 0); 9]; let sample_closest = sample_pos.map(|e| e - e.rem_euclid(self.freq as i32)); @@ -45,12 +38,12 @@ impl StructureGen2d { samples[i * 3 + j] = ( center + Vec2::new( - (self.random(1, center) % (self.spread * 2)) as i32 + (self.x_field.get(Vec3::from(center)) % (self.spread * 2)) as i32 - self.spread as i32, - (self.random(2, center) % (self.spread * 2)) as i32 + (self.y_field.get(Vec3::from(center)) % (self.spread * 2)) as i32 - self.spread as i32, ), - self.random(3, center), + self.seed_field.get(Vec3::from(center)), ); } } From bab7746a8ae69566e0169b3c040305abe5dde4c6 Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Sat, 15 Jun 2019 13:34:28 +0100 Subject: [PATCH 27/30] Updated and fixed world viewer example --- world/examples/view.rs | 10 +++++----- world/src/lib.rs | 16 +++++++++++----- world/src/sim/mod.rs | 2 +- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/world/examples/view.rs b/world/examples/view.rs index 5f30cc097e..98e8ab1892 100644 --- a/world/examples/view.rs +++ b/world/examples/view.rs @@ -1,6 +1,6 @@ use std::ops::{Add, Mul, Sub}; use vek::*; -use veloren_world::World; +use veloren_world::{util::Sampler, World}; const W: usize = 640; const H: usize = 480; @@ -8,6 +8,8 @@ const H: usize = 480; fn main() { let world = World::generate(0); + let sampler = world.sample_columns(); + let mut win = minifb::Window::new("World Viewer", W, H, minifb::WindowOptions::default()).unwrap(); @@ -21,10 +23,8 @@ fn main() { for j in 0..H { let pos = focus + Vec2::new(i as i32, j as i32) * 4; - let alt = world - .sim() - .sampler() - .sample_2d(pos) + let alt = sampler + .get(pos) .map(|sample| sample.alt.sub(64.0).add(gain).mul(0.7).max(0.0).min(255.0) as u8) .unwrap_or(0); diff --git a/world/src/lib.rs b/world/src/lib.rs index 773b887942..e3528616c4 100644 --- a/world/src/lib.rs +++ b/world/src/lib.rs @@ -3,16 +3,16 @@ mod all; mod block; mod column; -mod config; +pub mod config; mod sim; -mod util; +pub mod util; // Reexports pub use crate::config::CONFIG; use crate::{ block::BlockGen, - column::ColumnGen, + column::{ColumnGen, ColumnSample}, util::{HashCache, Sampler, SamplerMut}, }; use common::{ @@ -46,7 +46,13 @@ impl World { // TODO } - pub fn sample(&self) -> impl SamplerMut, Sample = Option> + '_ { + pub fn sample_columns( + &self, + ) -> impl Sampler, Sample = Option> + '_ { + ColumnGen::new(self) + } + + pub fn sample_blocks(&self) -> impl SamplerMut, Sample = Option> + '_ { BlockGen::new(self, ColumnGen::new(self)) } @@ -66,7 +72,7 @@ impl World { let mut chunk = TerrainChunk::new(base_z - 8, stone, air, TerrainChunkMeta::void()); - let mut sampler = self.sample(); + let mut sampler = self.sample_blocks(); for x in 0..TerrainChunkSize::SIZE.x as i32 { for y in 0..TerrainChunkSize::SIZE.y as i32 { diff --git a/world/src/sim/mod.rs b/world/src/sim/mod.rs index 1496e2dfca..501e95f5dd 100644 --- a/world/src/sim/mod.rs +++ b/world/src/sim/mod.rs @@ -177,7 +177,7 @@ impl SimChunk { .add(0.3) .max(0.0); - let chaos = (gen_ctx.chaos_nz.get((wposf.div(6_000.0)).into_array()) as f32) + let chaos = (gen_ctx.chaos_nz.get((wposf.div(4_000.0)).into_array()) as f32) .add(1.0) .mul(0.5) .powf(1.4) From 73e999af87e4766f696629eaba07afa539d07dd0 Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Sat, 15 Jun 2019 13:44:50 +0100 Subject: [PATCH 28/30] Stopped printing chunk location every frame --- voxygen/src/session.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/voxygen/src/session.rs b/voxygen/src/session.rs index 49b1965ce6..1eb563bf8a 100644 --- a/voxygen/src/session.rs +++ b/voxygen/src/session.rs @@ -69,11 +69,13 @@ impl SessionState { } } - // TODO: Get rid of this + // TODO: Get rid of this when we're done with it (we're not yet) + /* match self.client.borrow().current_chunk() { Some(chunk) => println!("Chunk location: {:?}", chunk.meta().name()), None => {} } + */ Ok(()) } From 4da01fba9a6a7e06f44c87b4a8624fdbf1080ff1 Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Sat, 15 Jun 2019 15:50:54 +0100 Subject: [PATCH 29/30] Fixed world viewer stack overflow on Windows --- world/examples/view.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/world/examples/view.rs b/world/examples/view.rs index 98e8ab1892..e358924625 100644 --- a/world/examples/view.rs +++ b/world/examples/view.rs @@ -17,7 +17,7 @@ fn main() { let mut gain = 1.0; while win.is_open() { - let mut buf = [0; W * H]; + let mut buf = vec![0; W * H]; for i in 0..W { for j in 0..H { From 76344d142ef9c4568d34cb7c2c2f41c95cf3d521 Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Sat, 15 Jun 2019 18:23:01 +0100 Subject: [PATCH 30/30] Added clouds --- voxygen/shaders/include/sky.glsl | 51 ++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 3 deletions(-) diff --git a/voxygen/shaders/include/sky.glsl b/voxygen/shaders/include/sky.glsl index 3bb9b64307..4c917ca47a 100644 --- a/voxygen/shaders/include/sky.glsl +++ b/voxygen/shaders/include/sky.glsl @@ -1,10 +1,41 @@ const float PI = 3.141592; +float mod289(float x){return x - floor(x * (1.0 / 289.0)) * 289.0;} +vec4 mod289(vec4 x){return x - floor(x * (1.0 / 289.0)) * 289.0;} +vec4 perm(vec4 x){return mod289(((x * 34.0) + 1.0) * x);} + +float noise(vec3 p){ + vec3 a = floor(p); + vec3 d = p - a; + d = d * d * (3.0 - 2.0 * d); + + vec4 b = a.xxyy + vec4(0.0, 1.0, 0.0, 1.0); + vec4 k1 = perm(b.xyxy); + vec4 k2 = perm(k1.xyxy + b.zzww); + + vec4 c = k2 + a.zzzz; + vec4 k3 = perm(c); + vec4 k4 = perm(c + 1.0); + + vec4 o1 = fract(k3 * (1.0 / 41.0)); + vec4 o2 = fract(k4 * (1.0 / 41.0)); + + vec4 o3 = o2 * d.z + o1 * (1.0 - d.z); + vec2 o4 = o3.yw * d.x + o3.xz * (1.0 - d.x); + + return o4.y * d.y + o4.x * (1.0 - d.y); +} + vec3 get_sky_color(vec3 dir, float time_of_day) { + bool objects = true; + const float TIME_FACTOR = (PI * 2.0) / (3600.0 * 24.0); - const vec3 SKY_TOP = vec3(0.05, 0.2, 0.9); - const vec3 SKY_BOTTOM = vec3(0.025, 0.1, 0.5); + vec2 pos2d = dir.xy / dir.z; + + const vec3 SKY_TOP = vec3(0.2, 0.3, 0.9); + const vec3 SKY_MIDDLE = vec3(0.1, 0.15, 0.7); + const vec3 SKY_BOTTOM = vec3(0.025, 0.15, 0.35); const vec3 SUN_HALO_COLOR = vec3(1.0, 0.7, 0.5) * 0.5; const vec3 SUN_SURF_COLOR = vec3(1.0, 0.9, 0.35) * 200.0; @@ -16,7 +47,21 @@ vec3 get_sky_color(vec3 dir, float time_of_day) { vec3 sun_surf = pow(max(dot(dir, sun_dir) - 0.0045, 0.0), 1000.0) * SUN_SURF_COLOR; vec3 sun_light = sun_halo + sun_surf; - return mix(SKY_BOTTOM, SKY_TOP, (dir.z + 1.0) / 2.0) + sun_light; + vec3 sky_top; + if (objects) { + vec3 p = vec3(pos2d + time_of_day * 0.0002, time_of_day * 0.0001); + sky_top = mix(SKY_TOP, vec3(1), pow(noise(p) * 0.8 + noise(p * 3.0) * 0.2, 2.5) * 3.0); + } else { + sky_top = SKY_TOP; + } + + vec3 sky_color = mix(mix(SKY_MIDDLE, sky_top, clamp(dir.z, 0, 1)), SKY_BOTTOM, clamp(-dir.z * 5.0, 0, 1)); + + if (objects) { + sky_color += sun_light; + } + + return sky_color; } float fog(vec2 f_pos, vec2 focus_pos) {