Skip to content

Commit

Permalink
finish mandelbrot
Browse files Browse the repository at this point in the history
  • Loading branch information
boralg committed Jun 26, 2024
1 parent 96d6491 commit 96c8a73
Show file tree
Hide file tree
Showing 7 changed files with 154 additions and 235 deletions.
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions examples/src/mandelbrot/assets/shader.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,14 @@ fn vs_main(@location(0) position: vec3<f32>, @location(1) uv: vec2<f32>) -> Vert
fn fs_main(@location(0) fragUV: vec2<f32>) -> @location(0) vec4<f32> {
let max_iter: u32 = 100u;

// Translate fragUV to the complex plane using cursor position
let c = uniforms.translation + uniforms.scale * (fragUV);
// Calculate the coordinates in the complex plane
let centered_uv = (fragUV * 2.0 - vec2<f32>(1.0, 1.0)); // Convert [0,1] range to [-1,1]

// Adjust coordinates based on translation and scale, without affecting rotation
let c = uniforms.translation + vec2<f32>(
centered_uv.x * uniforms.scale,
centered_uv.y * uniforms.scale
);

var z: vec2<f32> = vec2<f32>(0.0, 0.0);
var iter: u32 = 0u;
Expand Down
Loading

0 comments on commit 96c8a73

Please sign in to comment.