summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.rs7
-rw-r--r--src/sdf.rs27
2 files changed, 30 insertions, 4 deletions
diff --git a/src/main.rs b/src/main.rs
index 2c42e97..cf2317d 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -18,9 +18,12 @@
-----
cool seeds:
-commit ae29a61c9917da5ad9fbb7a24151bff506669ffb
+commit ae29a61c9917da5ad9fbb7a24151bff506669ffb "cool stuff"
18413841503509874975
**17878446840930313726
+commit 35cbbb40298389efcd2fe87a9c6458d49c1c567e "add torus, box frame"
+2876923889725946210
+*12145962426879404199
*/
extern crate nalgebra;
@@ -147,7 +150,7 @@ vec3 get_color(vec3 p) {
} else {
// in theory we should clamp this but it actually looks better if we don't
// (it makes the object glow)
- return get_color_(p);
+ return mix(get_color_(p), vec3(1.0), 0.2);
}
}
diff --git a/src/sdf.rs b/src/sdf.rs
index 6eb6ee3..5318990 100644
--- a/src/sdf.rs
+++ b/src/sdf.rs
@@ -102,16 +102,26 @@ pub enum R3ToR3 {
#[prob(1)]
Translate(Constant3),
#[prob(2)]
- Sin(Constant),
+ #[bias(0.01)] // prevent division by 0
+ Sin(Constant), // 1/c sin(cx)
#[prob(2)]
+ #[bias(0.01)]
InfiniteMirrors(Constant),
#[prob(2)]
#[scale(2 * std::f32::consts::PI)]
Rotate(Constant3),
#[prob(2)]
- Arctan(Constant) // arctan(c x) / c
+ Arctan(Constant), // arctan(c x) / c
+ #[prob(2)]
+ #[bias(0.01)]
+ SqSin(Constant), // based on 1/x² sin(x²)
+ #[prob(2)]
+ #[bias(0.01)]
+ Sigmoid //based on sigmoid(x) = 1 / (1 + e^-x)
}
+// note : i dont think R → R transformations really accomplish that much
+// that can't be done with R³ → R³.
#[derive(GenRandom, Debug)]
pub enum RToR {
#[prob(1)]
@@ -374,6 +384,19 @@ impl Function for R3ToR3 {
write_str!(code, "vec3 {output} = {m} * {input};\n");
output
}
+ SqSin(c) => {
+ let output = var.next();
+ let a = var.next();
+ write_str!(code, "vec3 {a} = 0.1 + abs({input});\n");
+ write_str!(code, "{a} *= {a};\n");
+ write_str!(code, "vec3 {output} = 0.7593/(pow({c},1.5)*{a}) * sin({c}*{a});\n");
+ output
+ }
+ Sigmoid => {
+ let output = var.next();
+ write_str!(code, "vec3 {output} = 2.0 - abs(4.0 / (1.0 + exp(-{input})) - 2.0);\n");
+ output
+ }
}
}
}