From a9d30bbfb669d3b48a03bc0157e9a46700883ff2 Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Sat, 15 Jun 2019 11:36:26 +0100 Subject: [PATCH] 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)), ); } }