 (defn normal
   ""
   [f ^Vec3 v t]
-  (let [eps (max 0.02 (* 0.001 t))]
+  (let [eps (max 0.002 (* 0.0001 t))]
     (v/normalize (Vec3. (- (f (- (.x v) eps) (.z v))
                            (f (+ (.x v) eps) (.z v)))
                         (+ eps eps)

          h (max 0.0 (f (.x p) (.z p)))
          newres (min res (/ (* k h) t))]
      (if (or (< h 0.0001)
              (> i 50))
        (m/constrain newres 0.0 1.0)
        (recur (unchecked-inc i) newres (+ t (m/constrain h 0.02 0.5)))))))


(def terrain-f (comp (var/make-variation :sinusoidal 1.0 {})
                     (var/make-variation :auger 1.0 {})))

(defn terrain
  ""

(def ^Vec3 glow-color (v/div (Vec3. 255 153 51) 255.0))

(def ^Vec3 sun-lin (Vec3. 1.2 0.5 1.8)) ;; material color

(do
  (def ^Vec3 ro (Vec3. 0.0 5.0 10.0)) ;; ray origin
