Skip to content

Commit 2864036

Browse files
committed
fixes
1 parent cecc122 commit 2864036

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

src/chunk.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ impl Chunk {
332332
z = NOISE_SIZE as i32 + (z % (NOISE_CHUNK_PER_ROW * CHUNK_SIZE) as i32);
333333
}
334334

335-
let y_top = (noise_data[((z * NOISE_SIZE as i32) + x) as usize] + 1.0) * 0.5;
335+
let y_top = (noise_data[((z * (NOISE_SIZE - 1) as i32) + x) as usize] + 1.0) * 0.5;
336336
return (f32::powf(100.0, y_top) - 1.0) as u32;
337337
}
338338

src/main.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use state::State;
66
use std::sync::{Arc, Mutex};
77
use std::time::Instant;
8+
use winit::dpi::LogicalSize;
89
use winit::window::CursorGrabMode;
910
use winit::{
1011
dpi::PhysicalSize,
@@ -45,7 +46,7 @@ async fn run(event_loop: EventLoop<()>, window: Window) {
4546

4647
let mut size = window.inner_size();
4748
size.width = size.width.max(1);
48-
size.width = size.height.max(1);
49+
size.height = size.height.max(1);
4950

5051
window.set_cursor_grab(CursorGrabMode::Confined).unwrap();
5152
window.set_cursor_visible(false);
@@ -152,8 +153,9 @@ async fn run(event_loop: EventLoop<()>, window: Window) {
152153
fn main() {
153154
let event_loop = EventLoop::new().unwrap();
154155
let builder = winit::window::WindowBuilder::new();
156+
155157
let window = builder
156-
.with_inner_size(PhysicalSize::new(
158+
.with_inner_size(LogicalSize::new(
157159
DEFAULT_WINDOW_WIDTH,
158160
DEFAULT_WINDOW_HEIGHT,
159161
))

src/shaders/shader.wgsl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ fn vs_main(in: VertexInput, instance_data: InstanceInput) -> VertexOutput {
5151

5252
let player_dist = distance(player_position, block_position);
5353

54-
let r = f32(16 * (i32(chunks_per_row) / 2));
55-
out.fog = clamp((player_dist - r) / 8.0, 0.0, 1.0);
54+
let r = (f32(chunks_per_row) - 1.0) * 8.0;
55+
out.fog = 1.0 - clamp((r - player_dist) / 8.0, 0.0, 1.0);
5656

5757
// out.fog = min(pow(player_dist / 80.0, 6.0), 1.0);
5858
out.clip_position = projection * view * (vec4<f32>(block_position, 1.0));

src/shaders/water_shader.wgsl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ fn vs_main(in: VertexInput, instance_data: InstanceInput) -> VertexOutput {
4949

5050
let player_dist = distance(player_position, block_position);
5151

52-
let r = f32(16 * (i32(chunks_per_row) / 2));
53-
out.fog = clamp((player_dist - r) / 8.0, 0.0, 1.0);
52+
let r = (f32(chunks_per_row) - 1.0) * 8.0;
53+
out.fog = 1.0 - clamp((r - player_dist) / 8.0, 0.0, 1.0);
5454

5555
out.clip_position = projection * view * (vec4<f32>(block_position, 1.0));
5656
out.normals = in.normal;
@@ -77,6 +77,5 @@ fn fs_main(in: FragmentInput) -> @location(0) vec4<f32> {
7777
color.a = 0.6;
7878
color = mix(color, vec4<f32>(0.03, 0.64, 0.97, 1.0), in.fog);
7979

80-
8180
return color;
8281
}

0 commit comments

Comments
 (0)