Skip to content

Commit 534690f

Browse files
committed
Explain interpolation
1 parent 28aa17e commit 534690f

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

src/volumetric_clouds/main.clj

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -476,12 +476,19 @@
476476
;; Finally one can display the noise.
477477
(bufimg/tensor->image perlin-norm)
478478

479-
;; ## Combination of Worley and Perlin noise
479+
;; ## Mixing noise values
480+
;;
481+
;; ### Combination of Worley and Perlin noise
482+
;;
483+
;; One can mix Worley and Perlin noise by simply doing a linear combination of the two.
480484
(def perlin-worley-norm (dfn/+ (dfn/* 0.3 perlin-norm) (dfn/* 0.7 worley-norm)))
481485

486+
;; Here for example is the average of Perlin and Worley noise.
482487
(bufimg/tensor->image (dfn/+ (dfn/* 0.5 perlin-norm) (dfn/* 0.5 worley-norm)))
483488

484-
;; ## Interpolation
489+
;; ### Interpolation
490+
;;
491+
;; One can linearly interpolate tensor values by recursing over the dimensions as follows.
485492
(defn interpolate
486493
[tensor & args]
487494
(if (seq args)
@@ -493,7 +500,7 @@
493500
(* xf (apply interpolate (wrap-get tensor (inc x0)) (rest args)))))
494501
tensor))
495502

496-
503+
;; Here x-, y-, and z-ramps are used to test that interpolation works.
497504
(facts "Interpolate values of tensor"
498505
(let [x2 (tensor/compute-tensor [4 6] (fn [_y x] x))
499506
y2 (tensor/compute-tensor [4 6] (fn [y _x] y))
@@ -510,7 +517,7 @@
510517
(interpolate y3 2.5 3.5 3.0) => 3.0
511518
(interpolate z3 2.5 3.5 5.5) => 2.0))
512519

513-
;; ## Octaves of noise
520+
;; ### Octaves of noise
514521
(defn fractal-brownian-motion
515522
[base octaves & args]
516523
(let [scales (take (count octaves) (iterate #(* 2 %) 1))]

0 commit comments

Comments
 (0)