Skip to content

Commit

Permalink
fix the brot
Browse files Browse the repository at this point in the history
  • Loading branch information
boralg committed Jun 26, 2024
1 parent 23701af commit d9b1ae7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions examples/src/mandelbrot/assets/shader.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ struct Uniforms {
translation: vec2<f32>,
cursor_pos: vec2<f32>,
scale: f32,
padding: f32
_padding1: f32
};

@group(0) @binding(0) var<uniform> uniforms: Uniforms;
Expand Down Expand Up @@ -48,7 +48,7 @@ fn fs_main(@location(0) fragUV: vec2<f32>) -> @location(0) vec4<f32> {
iter = iter + 1u;
}

if iter == max_iter {
if (iter == max_iter) {
return vec4<f32>(0.0, 0.0, 0.0, 1.0); // Inside the Mandelbrot set
} else {
let t: f32 = f32(iter) / f32(max_iter);
Expand Down
12 changes: 6 additions & 6 deletions examples/src/mandelbrot/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,17 @@ struct MandelbrotState {
#[repr(C)]
#[derive(Copy, Clone, Pod, Zeroable)]
pub struct Uniforms {
translation: [f32; 2],
cursor_pos: [f32; 2],
scale: f32,
_padding: f32,
translation: [f32; 2], // 8 bytes
cursor_pos: [f32; 2], // 8 bytes
scale: f32, // 4 bytes
_padding: [f32; 1],
}

fn init(display: &mut Display) -> MandelbrotState {
let device = &display.device;

let shader = create_shader(device, include_str!("assets/shader.wgsl"));
let (uniform_buffer, uniform_bind_group_layout, uniform_bind_group ) = create_uniforms(device, Uniforms { translation: Vector2::zero().into(), cursor_pos: Vector2::zero().into(), scale: 4f32, _padding: 0f32 }, 0);
let (uniform_buffer, uniform_bind_group_layout, uniform_bind_group ) = create_uniforms(device, Uniforms { translation: Vector2::zero().into(), cursor_pos: Vector2::zero().into(), scale: 4f32, _padding: [0f32] }, 0);

let pipeline_layout = device.create_pipeline_layout(&PipelineLayoutDescriptor {
label: None,
Expand Down Expand Up @@ -127,7 +127,7 @@ fn init(display: &mut Display) -> MandelbrotState {
vertex_buffer,
uniform_buffer,
uniform_bind_group,
uniforms: Uniforms { translation: Vector2::zero().into(), cursor_pos: Vector2::zero().into(), scale: 4f32, _padding: 0f32 },
uniforms: Uniforms { translation: Vector2::zero().into(), cursor_pos: Vector2::zero().into(), scale: 4f32, _padding: [0f32] },
scale_speed: 1.0f32 - 0.001f32,
last_cursor_location: PhysicalPosition::new(0f32, 0f32),
cursor_location: PhysicalPosition::new(0f32, 0f32),
Expand Down

0 comments on commit d9b1ae7

Please sign in to comment.