diff --git a/voxygen/shaders/postprocess.frag b/voxygen/shaders/postprocess.frag index dd32d414f2..7602776032 100644 --- a/voxygen/shaders/postprocess.frag +++ b/voxygen/shaders/postprocess.frag @@ -166,7 +166,7 @@ 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.17; + hsva_color.y += 0.27; hsva_color.x -= 0.015; 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/mesh/vol.rs b/voxygen/src/mesh/vol.rs index d2e1cd2924..f24ad3c31b 100644 --- a/voxygen/src/mesh/vol.rs +++ b/voxygen/src/mesh/vol.rs @@ -50,22 +50,24 @@ fn create_quad, Vec3, Rgb) -> P::Vertex>( ao: Vec4, vcons: &F, ) -> Quad

{ - let ao_scale = 1.0; + let ao_scale = 0.95; let dark = col * (1.0 - ao_scale); + let ao_map = ao.map(|e| e.powf(2.0)); + if ao[0] + ao[2] < ao[1] + ao[3] { Quad::new( - vcons(origin + unit_y, norm, Rgb::lerp(dark, col, ao[3])), - vcons(origin, norm, Rgb::lerp(dark, col, ao[0])), - vcons(origin + unit_x, norm, Rgb::lerp(dark, col, ao[1])), - vcons(origin + unit_x + unit_y, norm, Rgb::lerp(dark, col, ao[2])), + vcons(origin + unit_y, norm, Rgb::lerp(dark, col, ao_map[3])), + vcons(origin, norm, Rgb::lerp(dark, col, ao_map[0])), + vcons(origin + unit_x, norm, Rgb::lerp(dark, col, ao_map[1])), + vcons(origin + unit_x + unit_y, norm, Rgb::lerp(dark, col, ao_map[2])), ) } else { Quad::new( - vcons(origin, norm, Rgb::lerp(dark, col, ao[0])), - vcons(origin + unit_x, norm, Rgb::lerp(dark, col, ao[1])), - vcons(origin + unit_x + unit_y, norm, Rgb::lerp(dark, col, ao[2])), - vcons(origin + unit_y, norm, Rgb::lerp(dark, col, ao[3])), + vcons(origin, norm, Rgb::lerp(dark, col, ao_map[0])), + vcons(origin + unit_x, norm, Rgb::lerp(dark, col, ao_map[1])), + vcons(origin + unit_x + unit_y, norm, Rgb::lerp(dark, col, ao_map[2])), + vcons(origin + unit_y, norm, Rgb::lerp(dark, col, ao_map[3])), ) } } diff --git a/world/src/lib.rs b/world/src/lib.rs index 0201e1614d..a63a2a4e90 100644 --- a/world/src/lib.rs +++ b/world/src/lib.rs @@ -1,10 +1,10 @@ mod sim; use std::{ - ops::{Add, Mul, Div, Neg}, + ops::{Add, Sub, Mul, Div, Neg}, time::Duration, }; -use noise::{NoiseFn, Perlin, Seedable}; +use noise::{NoiseFn, BasicMulti, Perlin, Seedable, MultiFractal}; use vek::*; use common::{ terrain::{Block, TerrainChunk, TerrainChunkMeta, TerrainChunkSize}, @@ -45,7 +45,14 @@ impl World { let warp_nz = Perlin::new().set_seed(self.sim.seed + 0); let temp_nz = Perlin::new().set_seed(self.sim.seed + 1); - let ridge_nz = Perlin::new().set_seed(self.sim.seed + 2); + /* + let cliff_nz = BasicMulti::new() + .set_octaves(2) + .set_seed(self.sim.seed + 2); + let cliff_mask_nz = BasicMulti::new() + .set_octaves(4) + .set_seed(self.sim.seed + 3); + */ let base_z = match self.sim.get_base_z(chunk_pos.map(|e| e as u32)) { Some(base_z) => base_z as i32, @@ -78,7 +85,20 @@ impl World { + Vec3::from(chunk_pos) * TerrainChunkSize::SIZE.map(|e| e as i32); let wposf = wpos.map(|e| e as f64); - let height = alt; + /* + let cliff_mask = cliff_mask_nz.get((wposf.div(Vec3::new(512.0, 512.0, 2048.0))).into_array()) + .sub(0.1) + .max(0.0) + .mul(1.5) + .round() as f32; + let cliff = (cliff_nz.get((wposf.div(Vec3::new(256.0, 256.0, 128.0))).into_array()) as f32) + .mul(cliff_mask) + //.mul((30.0).div((wposf.z as f32 - alt)).max(0.0)) + .mul(150.0) + .min(64.0); + */ + + let height = alt;// + cliff; let temp = 0.0; let z = wposf.z as f32; diff --git a/world/src/sim.rs b/world/src/sim.rs index 9686093424..4c064dc593 100644 --- a/world/src/sim.rs +++ b/world/src/sim.rs @@ -27,13 +27,20 @@ impl WorldSim { chaos_nz: RidgedMulti::new() .set_octaves(7) .set_seed(seed + 2), + hill_nz: SuperSimplex::new() + .set_seed(seed + 3), alt_nz: HybridMulti::new() .set_octaves(7) .set_persistence(0.1) - .set_seed(seed + 3), - small_nz: BasicMulti::new() - .set_octaves(1) .set_seed(seed + 4), + 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), }; let mut chunks = Vec::new(); @@ -114,17 +121,31 @@ impl WorldSim { );*/ let chaos = self.get_interpolated(pos, |chunk| chunk.chaos)?; + let temp = self.get_interpolated(pos, |chunk| chunk.temp)?; + let rockiness = self.get_interpolated(pos, |chunk| chunk.rockiness)?; + + let rock = (self.gen_ctx.small_nz.get((wposf.div(200.0)).into_array()) as f32) + .mul(rockiness) + .sub(0.3) + .max(0.0) + .mul(2.5); let alt = self.get_interpolated(pos, |chunk| chunk.alt)? - + self.gen_ctx.small_nz.get((wposf.div(128.0)).into_array()) as f32 * chaos.max(0.2) * 32.0; + + self.gen_ctx.small_nz.get((wposf.div(128.0)).into_array()) as f32 * chaos.max(0.2) * 32.0 + + rock * 30.0; // Colours - let grass = Rgb::new(0.0, 0.765, 0.05); - let stone = Rgb::new(0.695, 0.66, 0.551); + let cold_grass = Rgb::new(0.0, 0.75, 0.25); + let warm_grass = Rgb::new(0.55, 0.9, 0.0); + let stone = Rgb::new(0.8, 0.7, 0.551); + + let grass = Rgb::lerp(cold_grass, warm_grass, temp); + let ground = Rgb::lerp(grass, stone, rock.mul(5.0).min(0.8)); + let cliff = stone; Some(Sample { alt, - surface_color: Lerp::lerp(grass, stone, (alt - SEA_LEVEL) / 300.0), + surface_color: Rgb::lerp(ground, cliff, (alt - SEA_LEVEL) / 150.0), }) } } @@ -139,43 +160,77 @@ struct GenCtx { turb_y_nz: BasicMulti, chaos_nz: RidgedMulti, alt_nz: HybridMulti, + hill_nz: SuperSimplex, + temp_nz: SuperSimplex, small_nz: BasicMulti, + rock_nz: HybridMulti, } -const Z_TOLERANCE: f32 = 32.0; +const Z_TOLERANCE: (f32, f32) = (32.0, 64.0); const SEA_LEVEL: f32 = 64.0; pub struct SimChunk { pub chaos: f32, pub alt: f32, + pub temp: f32, + pub rockiness: f32, } impl SimChunk { fn generate(pos: Vec2, gen_ctx: &mut GenCtx) -> Self { let wposf = (pos * Vec2::from(TerrainChunkSize::SIZE)).map(|e| e as f64); + let hill = (gen_ctx.hill_nz + .get((wposf.div(3500.0)).into_array()) as f32) + .add(1.0).mul(0.5); + let chaos = (gen_ctx.chaos_nz .get((wposf.div(3500.0)).into_array()) as f32) .add(1.0).mul(0.5) - .powf(1.85); + .powf(1.9) + .add(0.25 * hill); let chaos = chaos + chaos.mul(20.0).sin().mul(0.05); + let alt_main = gen_ctx.alt_nz.get((wposf.div(750.0)).into_array()) as f32; + Self { chaos, - alt: SEA_LEVEL + (gen_ctx.alt_nz - .get((wposf.div(750.0)).into_array()) as f32) + alt: SEA_LEVEL + (0.0 + + alt_main + + gen_ctx.small_nz.get((wposf.div(300.0)).into_array()) as f32 * alt_main * 1.3) .add(1.0).mul(0.5) .mul(chaos) - .mul(650.0), + .mul(750.0), + temp: (gen_ctx.temp_nz.get((wposf.div(48.0)).into_array()) as f32) + .add(1.0).mul(0.5), + rockiness: (gen_ctx.rock_nz.get((wposf.div(1024.0)).into_array()) as f32) + .sub(0.1) + .mul(1.2) + .max(0.0), } } pub fn get_base_z(&self) -> f32 { - self.alt - Z_TOLERANCE + self.alt - Z_TOLERANCE.0 } pub fn get_max_z(&self) -> f32 { - self.alt + Z_TOLERANCE + self.alt + Z_TOLERANCE.1 + } +} + +trait Hsv { + fn into_hsv(self) -> Self; + fn into_rgb(self) -> Self; +} + +impl Hsv for Rgb { + fn into_hsv(mut self) -> Self { + unimplemented!() + } + + fn into_rgb(mut self) -> Self { + unimplemented!() } }