From 9148f5cb963f05973a5e3d403e6c554f775ff642 Mon Sep 17 00:00:00 2001 From: pommicket Date: Thu, 26 Jan 2023 09:53:29 -0500 Subject: ProjectX/Y/Z --- src/main.rs | 2 -- src/sdf.rs | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index 4403252..5f94c12 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,9 +1,7 @@ /* @TODO: -- let user go back&forth through past sdfs using scenes.txt file - RnToRn functions (& add back in RToR) - also add PerComponent(Box,Box,Box) in R3ToR3 -- ProjectX, ProjectY, ProjectZ in R3ToR? - documentation - GenRandom integers (just use 0..u32::MAX and add a modulus) - blender-style rendering the picture in multiple frames diff --git a/src/sdf.rs b/src/sdf.rs index 929c324..8a68c06 100644 --- a/src/sdf.rs +++ b/src/sdf.rs @@ -261,6 +261,12 @@ pub enum R3ToR { #[prob(2)] #[only_if(params.max_depth >= 0)] Min(Box, Box), + #[prob(0.1)] + ProjectX, + #[prob(0.1)] + ProjectY, + #[prob(0.1)] + ProjectZ, } impl R3ToR3 { @@ -685,6 +691,21 @@ impl Function for R3ToR { let f_output = f.to_glsl(pre_output, code, var); post.to_glsl(f_output, code, var) } + ProjectX => { + let output = var.next(); + write_str!(code, "float {output} = {input}.x;\n"); + output + } + ProjectY => { + let output = var.next(); + write_str!(code, "float {output} = {input}.y;\n"); + output + } + ProjectZ => { + let output = var.next(); + write_str!(code, "float {output} = {input}.z;\n"); + output + } } } } -- cgit v1.2.3