Skip to content

Commit

Permalink
deprecate cabs_squared in favour of length, remove deprecated functio…
Browse files Browse the repository at this point in the history
…ns from readme
  • Loading branch information
arthomnix committed Oct 7, 2023
1 parent aad4b89 commit 88a3745
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "fractal_viewer"
version = "0.5.0"
version = "0.5.1"
edition = "2021"
description = "Cross-platform GPU-accelerated viewer for the Mandelbrot set and related fractals"
repository = "https://github.com/arthomnix/fractal_viewer"
Expand Down
2 changes: 0 additions & 2 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ A cross-platform, GPU-accelerated viewer for the Mandelbrot Set and related frac
Scroll wheel to zoom, click and drag to pan. Change the initial value of z or c by right-clicking.

Custom functions should be valid WGSL expressions, with the following extra functions available:
* `cabs(vec2<f32>) -> f32`: absolute value of a complex number (deprecated: use builtin length(z) instead)
* `cabs_squared(vec2<f32>) -> f32`: square of the absolute value of a complex number, (marginally) faster as it avoids a square root
* `csquare(vec2<f32>) -> vec2<f32>`: square of a complex number
* `cpow(vec2<f32>, f32) -> vec2<f32>`: real power of a complex number (can cause precision issues)
* `ccpow(vec2<f32>, vec2<f32>) -> vec2<f32>`: complex power of a complex number
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -702,8 +702,8 @@ impl State {
ui.add(
egui::Slider::new(
&mut self.settings.escape_threshold,
1.0..=13043817825300000000.0,
) // approximate square root of maximum f32
1.0..=f32::MAX,
)
.logarithmic(true),
);
});
Expand Down
5 changes: 3 additions & 2 deletions src/shader.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ fn vs_main(@builtin(vertex_index) in_vertex_index: u32) -> @builtin(position) ve
return vertex_positions[in_vertex_index];
}

// deprecated: use length(z)^2 instead
fn cabs_squared(z: vec2<f32>) -> f32 {
return (z.x * z.x + z.y * z.y);
}
Expand Down Expand Up @@ -113,7 +114,7 @@ fn get_fragment_colour(c: vec2<f32>) -> vec4<f32> {

for (
z += uniforms.initial_value;
cabs_squared(z) < uniforms.escape_threshold * uniforms.escape_threshold;
length(z) < uniforms.escape_threshold;
z = REPLACE_FRACTAL_EQN // gets replaced by user-defined expression
) {
i++;
Expand All @@ -129,7 +130,7 @@ fn get_fragment_colour(c: vec2<f32>) -> vec4<f32> {
z = c;
var c: vec2<f32> = uniforms.initial_value;
for (;
cabs_squared(z) < uniforms.escape_threshold * uniforms.escape_threshold;
length(z) < uniforms.escape_threshold;
z = REPLACE_FRACTAL_EQN // gets replaced by user-defined expression
) {
i++;
Expand Down

0 comments on commit 88a3745

Please sign in to comment.