diff options
-rw-r--r-- | src/main.rs | 3 | ||||
-rw-r--r-- | src/sdf.rs | 24 |
2 files changed, 24 insertions, 3 deletions
diff --git a/src/main.rs b/src/main.rs index 9ac7191..9627936 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,9 +1,6 @@ /* @TODO: -- RnToRn functions (& add back in RToR) - - also add PerComponent(Box<RToR>,Box<RToR>,Box<RToR>) in R3ToR3 - documentation -- GenRandom integers (just use 0..u32::MAX and add a modulus) - is it the function generation or the shader compililng that's slow for large functions? - record a cool video */ @@ -198,6 +198,9 @@ pub enum R3ToR3 { Compose(Box<R3ToR3>, Box<R3ToR3>), #[prob(4)] #[only_if(params.max_depth >= 0)] + PerComponent(Box<RToR>, Box<RToR>, Box<RToR>), + #[prob(4)] + #[only_if(params.max_depth >= 0)] Mix(Box<R3ToR3>, Box<R3ToR3>, Constant), #[prob(0.5)] Translate(Constant3), @@ -238,6 +241,8 @@ pub enum RToR { Compose(Box<RToR>, Box<RToR>), #[prob(0)] Subtract(Constant), + #[prob(2)] + NToN(Box<RnToRn>) } #[derive(GenRandom, Debug, Serialize, Deserialize)] @@ -547,6 +552,9 @@ impl Function for RToR { let a_output = a.to_glsl(input, code, var); b.to_glsl(a_output, code, var) } + NToN(f) => { + f.to_glsl(input, code, var, 1) + } } } } @@ -569,6 +577,22 @@ impl Function for R3ToR3 { let a_output = a.to_glsl(input, code, var); b.to_glsl(a_output, code, var) } + PerComponent(fx, fy, fz) => { + let x_input = var.next(); + let y_input = var.next(); + let z_input = var.next(); + let output = var.next(); + write_str!(code, + "float {x_input} = {input}.x;\n + float {y_input} = {input}.y;\n + float {z_input} = {input}.z;\n"); + let x_output = fx.to_glsl(x_input, code, var); + let y_output = fy.to_glsl(y_input, code, var); + let z_output = fz.to_glsl(z_input, code, var); + write_str!(code, + "vec3 {output} = vec3({x_output}, {y_output}, {z_output});\n"); + output + } Mix(a, b, t) => { let a_output = a.to_glsl(input, code, var); let b_output = b.to_glsl(input, code, var); |