File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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)
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))
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 ))]
You can’t perform that action at this time.
0 commit comments