From 185b1c3053da62bf4f0711fd6a5be8d4e72d8a48 Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Sun, 7 Feb 2021 23:50:05 +0000 Subject: [PATCH] Specialised giant trees --- assets/voxygen/shaders/particle-vert.glsl | 2 +- common/src/terrain/block.rs | 4 +-- world/src/all.rs | 14 ++++++---- world/src/layer/tree.rs | 31 ++++++++++++++++++++++- world/src/sim/mod.rs | 6 ++--- 5 files changed, 45 insertions(+), 12 deletions(-) diff --git a/assets/voxygen/shaders/particle-vert.glsl b/assets/voxygen/shaders/particle-vert.glsl index 8024371b04..e07c0b90b9 100644 --- a/assets/voxygen/shaders/particle-vert.glsl +++ b/assets/voxygen/shaders/particle-vert.glsl @@ -275,7 +275,7 @@ void main() { vec3(0, 0, -2) ) + vec3(sin(lifetime), sin(lifetime + 0.7), sin(lifetime * 0.5)) * 2.0, vec3(4), - vec4(vec3(0.2 + rand7 * 0.2, 0.2 + (0.5 + rand6 * 0.5) * 0.6, 0) * (0.25 + rand1 * 0.5), 1), + vec4(vec3(0.2 + rand7 * 0.2, 0.2 + (0.25 + rand6 * 0.5) * 0.3, 0) * (0.75 + rand1 * 0.5), 1), spin_in_axis(vec3(rand6, rand7, rand8), rand9 * 3 + lifetime * 5) ); } else if (inst_mode == SNOW) { diff --git a/common/src/terrain/block.rs b/common/src/terrain/block.rs index 52552b41e7..37d1d5d3c7 100644 --- a/common/src/terrain/block.rs +++ b/common/src/terrain/block.rs @@ -196,8 +196,8 @@ impl Block { #[inline] pub fn get_max_sunlight(&self) -> Option { match self.kind() { - BlockKind::Water => Some(3), - BlockKind::Leaves => Some(6), + BlockKind::Water => Some(4), + BlockKind::Leaves => Some(10), _ if self.is_opaque() => Some(0), _ => None, } diff --git a/world/src/all.rs b/world/src/all.rs index 2ce6f1ccd8..2630d78b05 100644 --- a/world/src/all.rs +++ b/world/src/all.rs @@ -13,6 +13,7 @@ pub enum ForestKind { Birch, Mangrove, Swamp, + Giant, } pub struct Environment { @@ -25,26 +26,28 @@ impl ForestKind { pub fn humid_range(&self) -> Range { match self { ForestKind::Palm => 0.25..1.4, - ForestKind::Acacia => 0.1..0.6, + ForestKind::Acacia => 0.05..0.55, ForestKind::Baobab => 0.2..0.6, - ForestKind::Oak => 0.5..1.5, + ForestKind::Oak => 0.35..1.5, ForestKind::Pine => 0.2..1.4, ForestKind::Birch => 0.0..0.6, - ForestKind::Mangrove => 0.7..1.3, + ForestKind::Mangrove => 0.65..1.3, ForestKind::Swamp => 0.5..1.1, + _ => 0.0..0.0 } } pub fn temp_range(&self) -> Range { match self { ForestKind::Palm => 0.4..1.6, - ForestKind::Acacia => 0.4..1.6, + ForestKind::Acacia => 0.3..1.6, ForestKind::Baobab => 0.4..0.9, - ForestKind::Oak => -0.35..0.5, + ForestKind::Oak => -0.35..0.6, ForestKind::Pine => -1.8..-0.2, ForestKind::Birch => -0.7..0.25, ForestKind::Mangrove => 0.4..1.6, ForestKind::Swamp => -0.6..0.8, + _ => 0.0..0.0, } } @@ -67,6 +70,7 @@ impl ForestKind { ForestKind::Birch => 0.65, ForestKind::Mangrove => 1.0, ForestKind::Swamp => 1.0, + _ => 0.0, } } diff --git a/world/src/layer/tree.rs b/world/src/layer/tree.rs index 13e28a8fe4..c1e178a188 100644 --- a/world/src/layer/tree.rs +++ b/world/src/layer/tree.rs @@ -124,6 +124,15 @@ pub fn apply_trees_to(canvas: &mut Canvas) { ForestKind::Birch => *BIRCHES, ForestKind::Mangrove => *MANGROVE_TREES, ForestKind::Swamp => *SWAMP_TREES, + ForestKind::Giant => { + break 'model TreeModel::Procedural( + ProceduralTree::generate( + TreeConfig::giant(&mut RandomPerm::new(seed), scale), + &mut RandomPerm::new(seed), + ), + StructureBlock::TemperateLeaves, + ); + }, } }; @@ -283,12 +292,32 @@ impl TreeConfig { straightness: 0.0, max_depth: 1, splits: 50.0..70.0, - split_range: 0.2..1.2, + split_range: 0.1..1.2, branch_len_bias: 0.75, leaf_vertical_scale: 0.3, proportionality: 1.0, } } + + pub fn giant(rng: &mut impl Rng, scale: f32) -> Self { + let scale = scale * (1.0 + rng.gen::().powi(4)); + let log_scale = 1.0 + scale.log2().max(0.0); + + Self { + trunk_len: 9.0 * scale, + trunk_radius: 4.0 * scale, + branch_child_len: 0.9, + branch_child_radius: 0.7, + leaf_radius: 1.5 * log_scale..2.0 * log_scale, + straightness: 0.4, + max_depth: (6.0 + log_scale) as usize, + splits: 1.8..3.0, + split_range: 0.8..1.5, + branch_len_bias: 0.0, + leaf_vertical_scale: 1.0, + proportionality: 0.0, + } + } } // TODO: Rename this to `Tree` when the name conflict is gone diff --git a/world/src/sim/mod.rs b/world/src/sim/mod.rs index ebe2ef1222..7e10508125 100644 --- a/world/src/sim/mod.rs +++ b/world/src/sim/mod.rs @@ -2017,7 +2017,7 @@ impl WorldSim { .enumerate() .map(|(i, fk)| { const CLUSTER_SIZE: f64 = 48.0; - let nz = (FastNoise2d::new(i as u32).get(wpos.map(|e| e as f64) / CLUSTER_SIZE) + 1.0) / 2.0; + let nz = (FastNoise2d::new(i as u32).get(pos.map(|e| e as f64) / CLUSTER_SIZE) + 1.0) / 2.0; (fk.proclivity(&env) * nz, fk) }) .collect::>()) @@ -2029,8 +2029,8 @@ impl WorldSim { .map(move |(pos, seed)| TreeAttr { pos, seed, - scale: 4.0, - forest_kind: ForestKind::Oak, + scale: 5.0, + forest_kind: ForestKind::Giant, }); normal_trees.chain(giant_trees)