diff --git a/src/main.rs b/src/main.rs index 724963c..93bfb0b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -193,8 +193,6 @@ impl State required_features: Features::IMMEDIATES | Features::SHADER_EARLY_DEPTH_TEST | Features::TIMESTAMP_QUERY - | Features::SHADER_I16 - | Features::SHADER_F16 | Features::TIMESTAMP_QUERY_INSIDE_ENCODERS | Features::TIMESTAMP_QUERY_INSIDE_PASSES | Features::STORAGE_RESOURCE_BINDING_ARRAY @@ -1151,6 +1149,11 @@ impl State self.insert_profile .lock() .show_flamegraph("second_profile".into(), q, ui); + + ui.label(format!( + "{:.2} {:.2} {:.2}", + self.camera.position.x, self.camera.position.y, self.camera.position.z + )); }, ); diff --git a/src/producers.rs b/src/producers.rs index 249633d..f19d1e6 100644 --- a/src/producers.rs +++ b/src/producers.rs @@ -515,14 +515,6 @@ where p[0].fract() } - let col_r = hash([ - chunk_pos.0 as f32 * 93487., - 912873. + 348. * chunk_pos.1 as f32, - 0., - ]); - let col_g = hash([chunk_pos.1 as f32 * 12093., 92837. * chunk_pos.0 as f32, 0.]); - let col_b = hash([0., 981882. * chunk_pos.0 as f32, 9092. * chunk_pos.1 as f32]); - // let sdf = |x: f32, y: f32, z: f32| { // Vec3::new((x % 1024.) - 512., (y % 1024.) - 512., (z % 1024.) - 512.).length() - 512. // }; @@ -676,12 +668,7 @@ where // alpha, // )); children.push(ChildInformation::new(subdivided, subdivided || alpha != 0.)); - children_color.push(Color( - color + random::() * 0.02 + col_r, - color + col_g, - color + col_b, - alpha, - )); + children_color.push(Color(color + random::() * 0.02, color, color, alpha)); children_normals.push((normal.x, normal.y, normal.z)); //children_color.push(Color(normal.x, normal.y, normal.z, alpha)); } diff --git a/src/terrain.rs b/src/terrain.rs index 9a6986e..680051c 100644 --- a/src/terrain.rs +++ b/src/terrain.rs @@ -131,34 +131,32 @@ impl ToroidalStructureTable /// Given the structure id, returns the position of the requesting chunk pub fn get_request_position(&self, structure_id: u32) -> (isize, isize, isize) { - // Where the block offset lies in the tore - let offset_tore_x = self.current_offset.0.rem_euclid(self.extent.0 as isize); - let offset_tore_y = self.current_offset.1.rem_euclid(self.extent.1 as isize); - let offset_tore_z = self.current_offset.2.rem_euclid(self.extent.2 as isize); + let (ex, ey, ez) = ( + self.extent.0 as isize, + self.extent.1 as isize, + self.extent.2 as isize, + ); + let id = structure_id as isize; - // Local coordinate within the fixed table - let x = structure_id as isize % self.extent.0 as isize; - let z = (structure_id as isize / self.extent.0 as isize) % self.extent.2 as isize; - let y = structure_id as isize / (self.extent.0 * self.extent.2) as isize; + let sx = id % ex; + let sz = (id / ex) % ez; + let sy = id / (ex * ez); - // Coordinates in the tore, centered on the offset - let x = (x - offset_tore_x).rem_euclid(self.extent.0 as isize); - let y = (y - offset_tore_y).rem_euclid(self.extent.1 as isize); - let z = (z - offset_tore_z).rem_euclid(self.extent.2 as isize); + let (ox, oy, oz) = self.current_offset; ( - x + self.current_offset.0, - y + self.current_offset.1, - z + self.current_offset.2, + ox + (sx - ox).rem_euclid(ex), + oy + (sy - oy).rem_euclid(ey), + oz + (sz - oz).rem_euclid(ez), ) } fn offset_from_center(extent: (usize, usize, usize), position: Vec3) -> (isize, isize, isize) { ( - position.x as isize - (extent.0 as isize / 2), - position.y as isize - (extent.1 as isize / 2), - position.z as isize - (extent.2 as isize / 2), + position.x.floor() as isize - (extent.0 as isize / 2), + position.y.floor() as isize - (extent.1 as isize / 2), + position.z.floor() as isize - (extent.2 as isize / 2), ) } diff --git a/src/terrain/shaders/toroidal_structure.wgsl b/src/terrain/shaders/toroidal_structure.wgsl index 6c243b0..f5adf6b 100644 --- a/src/terrain/shaders/toroidal_structure.wgsl +++ b/src/terrain/shaders/toroidal_structure.wgsl @@ -34,13 +34,7 @@ fn invalidate_new(@builtin(global_invocation_id) gid: vec3) fn get_position(block_position: vec3, offset: vec3) -> vec3 { - // Tore origin within block - let origin = imodv(offset, vec3(immediates.extent)); - - // Position in tore coordinate - let tore_position = imodv((block_position - origin), vec3(immediates.extent)); - - return tore_position + offset; + return offset + imodv((block_position - offset), vec3(immediates.extent)); } fn imod(x: i32, n: i32) -> i32 {