diff --git a/DEVELOPING_NODES.md b/DEVELOPING_NODES.md index e69de29..a4465f8 100644 --- a/DEVELOPING_NODES.md +++ b/DEVELOPING_NODES.md @@ -0,0 +1 @@ +# Developing Nodes diff --git a/README.md b/README.md index ec97e17..3792888 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Nodarium Nodarium is a WebAssembly based visual programming language.

- + diff --git a/app/src/lib/graph-interface/AddMenu.svelte b/app/src/lib/graph-interface/AddMenu.svelte index 3b11502..be42839 100644 --- a/app/src/lib/graph-interface/AddMenu.svelte +++ b/app/src/lib/graph-interface/AddMenu.svelte @@ -117,15 +117,20 @@ diff --git a/nodes/max/plantarium/branch/src/lib.rs b/nodes/max/plantarium/branch/src/lib.rs index f1de805..7d47ea0 100644 --- a/nodes/max/plantarium/branch/src/lib.rs +++ b/nodes/max/plantarium/branch/src/lib.rs @@ -33,8 +33,8 @@ pub fn execute(input: &[i32]) -> Vec { } for path_data in paths.iter() { - // if this is not a path don't modify it - if path_data[2] != 0 || path_data[3] < (max_depth - depth) { + // if this is not a path ignore it + if path_data[2] != 0 || path_data[3] < (max_depth - depth + 1) { output.push(path_data.to_vec()); continue; } diff --git a/nodes/max/plantarium/gravity/src/lib.rs b/nodes/max/plantarium/gravity/src/lib.rs index 8a61249..178f18a 100644 --- a/nodes/max/plantarium/gravity/src/lib.rs +++ b/nodes/max/plantarium/gravity/src/lib.rs @@ -50,38 +50,14 @@ pub fn execute(input: &[i32]) -> Vec { let start_point = Vec3::from_slice(&path.points[start_index..start_index + 3]); let end_point = Vec3::from_slice(&path.points[end_index..end_index + 3]); - log!("--------------------------------"); - - log!( - "start_index: {:?} end_index: {:?} length:{}", - start_index, - end_index, - path.points.len() - ); - if start_point[0].is_nan() { - log!("start_point is nan {:?}", path.points); - continue; - } - log!("start_point: {:?}", start_point); - log!("end_point: {:?}", end_point); let length = (end_point - start_point).length(); let normalised = (end_point - start_point).normalize(); - if normalised[0].is_nan() { - log!("normalised is nan {:?}", normalised); - continue; - } - let strength = evaluate_float(args[1]); let down_point = Vec3::new(0.0, -length * strength, 0.0); - if down_point[0].is_nan() { - log!("down_point is nan {:?}", down_point); - continue; - } - let curviness = evaluate_float(args[2]); let mut mid_point = lerp_vec3( @@ -90,13 +66,6 @@ pub fn execute(input: &[i32]) -> Vec { curviness * (i as f32 / path.length as f32).sqrt(), ); - if mid_point[0].is_nan() { - log!("mid_point is nan {:?}", mid_point); - log!("normalised: {:?}", normalised); - log!("curviness: {:?}", curviness); - continue; - } - if mid_point[0] == 0.0 && mid_point[2] == 0.0 { mid_point[0] += 0.0001; mid_point[2] += 0.0001; @@ -109,11 +78,6 @@ pub fn execute(input: &[i32]) -> Vec { let final_end_point = start_point + mid_point; let offset_end_point = end_point + offset_vec; - if offset_end_point[0].is_nan() { - log!("offset_end_point is nan {:?}", offset_end_point); - continue; - } - path.points[end_index] = offset_end_point[0]; path.points[end_index + 1] = offset_end_point[1]; path.points[end_index + 2] = offset_end_point[2]; diff --git a/nodes/max/plantarium/noise/src/input.json b/nodes/max/plantarium/noise/src/input.json index a91f483..3976e1a 100644 --- a/nodes/max/plantarium/noise/src/input.json +++ b/nodes/max/plantarium/noise/src/input.json @@ -19,7 +19,7 @@ }, "fixBottom": { "type": "float", - "label": "Fixate bottom of plant", + "label": "Fix bottom of plant", "hidden": true, "value": 1.0, "min": 0, @@ -43,6 +43,13 @@ "max": 10, "value": 1, "hidden": true + }, + "octaves": { + "type": "integer", + "min": 1, + "max": 5, + "value": 1, + "hidden": true } } } diff --git a/nodes/max/plantarium/noise/src/lib.rs b/nodes/max/plantarium/noise/src/lib.rs index a1f4933..f8c2ec0 100644 --- a/nodes/max/plantarium/noise/src/lib.rs +++ b/nodes/max/plantarium/noise/src/lib.rs @@ -1,6 +1,6 @@ use glam::Vec3; use macros::include_definition_file; -use noise::{core::open_simplex::open_simplex_2d, permutationtable::PermutationTable, Vector2}; +use noise::{HybridMulti, MultiFractal, NoiseFn, OpenSimplex}; use utils::{ concat_args, evaluate_float, evaluate_int, evaluate_vec3, geometry::wrap_path_mut, reset_call_count, set_panic_hook, split_args, @@ -32,7 +32,14 @@ pub fn execute(input: &[i32]) -> Vec { let depth = evaluate_int(args[6]); - let hasher = PermutationTable::new(seed as u32); + let octaves = evaluate_int(args[7]); + + let noise_x: HybridMulti = + HybridMulti::new(seed as u32 + 1).set_octaves(octaves as usize); + let noise_y: HybridMulti = + HybridMulti::new(seed as u32 + 2).set_octaves(octaves as usize); + let noise_z: HybridMulti = + HybridMulti::new(seed as u32 + 3).set_octaves(octaves as usize); let mut max_depth = 0; for path_data in plants.iter() { @@ -72,31 +79,21 @@ pub fn execute(input: &[i32]) -> Vec { for i in 0..path.length { let a = i as f64 / (path.length - 1) as f64; - let px = Vector2::new(1000.0 + j as f64 + a * length * scale, a * scale as f64); - let py = Vector2::new(2000.0 + j as f64 + a * length * scale, a * scale as f64); - let pz = Vector2::new(3000.0 + j as f64 + a * length * scale, a * scale as f64); + let px = j as f64 + a * length * scale; + let py = a * scale as f64; - let nx = open_simplex_2d(px, &hasher) as f32 - * strength - * 0.1 + path.points[i * 4] += noise_x.get([px, py]) as f32 * directional_strength[0] - * lerp(1.0, a as f32, fix_bottom); - - let ny = open_simplex_2d(py, &hasher) as f32 * strength - * 0.1 + * lerp(1.0, a as f32, fix_bottom); + path.points[i * 4 + 1] += noise_y.get([px, py]) as f32 * directional_strength[1] - * lerp(1.0, a as f32, fix_bottom); - - let nz = open_simplex_2d(pz, &hasher) as f32 * strength - * 0.1 - * directional_strength[2] * lerp(1.0, a as f32, fix_bottom); - - path.points[i * 4] += nx; - path.points[i * 4 + 1] += ny; - path.points[i * 4 + 2] += nz; + path.points[i * 4 + 2] += noise_z.get([px, py]) as f32 + * directional_strength[2] + * strength + * lerp(1.0, a as f32, fix_bottom); } path_data }) diff --git a/packages/ui/src/lib/app.css b/packages/ui/src/lib/app.css index 9eb0e8f..a57f307 100644 --- a/packages/ui/src/lib/app.css +++ b/packages/ui/src/lib/app.css @@ -52,7 +52,7 @@ body { /* Secondary color */ --secondary-color: #6c757d; - --layer-0: var(--neutral-800); + --layer-0: var(--neutral-900); --layer-1: var(--neutral-500); --layer-2: var(--neutral-400); --layer-3: var(--neutral-200); diff --git a/packages/ui/src/lib/elements/Float.svelte b/packages/ui/src/lib/elements/Float.svelte index 9f774e4..28e59c1 100644 --- a/packages/ui/src/lib/elements/Float.svelte +++ b/packages/ui/src/lib/elements/Float.svelte @@ -1,6 +1,5 @@