From 86bb2771166146d6b102268ceadee58eca2a3f70 Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Wed, 22 May 2019 17:24:08 +0100 Subject: [PATCH] Added snow to mountains, fixed hash sub-chunk allocation failure Former-commit-id: 45bb3063172b980f7cd7aa5bd2b50a1a53480120 --- common/src/terrain/chonk.rs | 15 ++++++++++++++- voxygen/shaders/postprocess.frag | 4 ++-- world/src/sim.rs | 19 +++++++++++++++---- 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/common/src/terrain/chonk.rs b/common/src/terrain/chonk.rs index 797ccedafa..a15e521e83 100644 --- a/common/src/terrain/chonk.rs +++ b/common/src/terrain/chonk.rs @@ -114,12 +114,13 @@ impl WriteVol for Chonk { self.sub_chunks[sub_chunk_idx] = SubChunk::Hash(*cblock, map); Ok(()) }, - SubChunk::Hash(cblock, map) if map.len() < 4096 => { + SubChunk::Hash(cblock, map) if map.len() < 1024 => { map.insert(rpos, block); Ok(()) }, SubChunk::Hash(cblock, map) => { let mut new_chunk = Chunk::filled(*cblock, ()); + new_chunk.set(rpos, block).unwrap(); // Can't fail (I hope) for (map_pos, map_block) in map { new_chunk.set(*map_pos, *map_block).unwrap(); // Can't fail (I hope!) @@ -128,9 +129,21 @@ impl WriteVol for Chonk { self.sub_chunks[sub_chunk_idx] = SubChunk::Heterogeneous(new_chunk); Ok(()) } + + /* + SubChunk::Homogeneous(cblock) => { + let mut new_chunk = Chunk::filled(*cblock, ()); + + new_chunk.set(rpos, block).unwrap(); // Can't fail (I hope!) + + self.sub_chunks[sub_chunk_idx] = SubChunk::Heterogeneous(new_chunk); + Ok(()) + } + */ SubChunk::Heterogeneous(chunk) => chunk .set(rpos, block) .map_err(|err| ChonkError::ChunkError(err)), + //_ => unimplemented!(), } } } diff --git a/voxygen/shaders/postprocess.frag b/voxygen/shaders/postprocess.frag index 7602776032..304a0de91c 100644 --- a/voxygen/shaders/postprocess.frag +++ b/voxygen/shaders/postprocess.frag @@ -166,9 +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 += 0.27; + hsva_color.y *= 1.27; hsva_color.x -= 0.015; - hsva_color.z = 1.0 - 1.0 / (1.0 * hsva_color.z + 1.0); + //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); tgt_color = final_color; diff --git a/world/src/sim.rs b/world/src/sim.rs index d0a0284317..50eac139c2 100644 --- a/world/src/sim.rs +++ b/world/src/sim.rs @@ -142,7 +142,8 @@ impl WorldSim { let warm_grass = Rgb::new(0.55, 0.9, 0.0); let cold_stone = Rgb::new(0.78, 0.86, 1.0); let warm_stone = Rgb::new(0.72, 0.7, 0.33); - let sand = Rgb::new(0.93, 0.84, 0.23); + let sand = Rgb::new(0.93, 0.84, 0.33); + let snow = Rgb::broadcast(1.0); let grass = Rgb::lerp(cold_grass, warm_grass, temp); let ground = Rgb::lerp(grass, warm_stone, rock.mul(5.0).min(0.8)); @@ -154,7 +155,16 @@ impl WorldSim { surface_color: Rgb::lerp( sand, // Land - Rgb::lerp(ground, cliff, (alt - SEA_LEVEL - 100.0) / 150.0), + Rgb::lerp( + ground, + // Mountain + Rgb::lerp( + cliff, + snow, + (alt - SEA_LEVEL - 215.0 - temp * 24.0) / 4.0, + ), + (alt - SEA_LEVEL - 100.0) / 100.0 + ), // Beach (alt - SEA_LEVEL - 2.0) / 5.0, ), @@ -203,7 +213,8 @@ impl SimChunk { let chaos = chaos + chaos.mul(20.0).sin().mul(0.05); - let alt_base = gen_ctx.alt_nz.get((wposf.div(5000.0)).into_array()) as f32 * 0.4; + let alt_base = gen_ctx.alt_nz.get((wposf.div(5000.0)).into_array()) as f32; + let alt_base = alt_base * 0.4 + alt_base.mul(16.0).sin().mul(0.01); let alt_main = gen_ctx.alt_nz.get((wposf.div(750.0)).into_array()) as f32; @@ -232,7 +243,7 @@ impl SimChunk { } pub fn get_base_z(&self) -> f32 { - self.alt - Z_TOLERANCE.0 + self.alt - Z_TOLERANCE.0 * (self.chaos + 0.1) } pub fn get_max_z(&self) -> f32 {