Skip to content

Commit 46cad4a

Browse files
committed
Add Mie plot
1 parent cf0c6b2 commit 46cad4a

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

src/volumetric_clouds/main.clj

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
:tags [:visualization]}}}
1212

1313
(ns volumetric-clouds.main
14-
(:require [clojure.math :refer (PI sqrt tan to-radians pow)]
14+
(:require [clojure.math :refer (PI sqrt cos sin tan to-radians pow)]
1515
[midje.sweet :refer (fact facts tabular => roughly)]
1616
[fastmath.vector :refer (vec2 vec3 add mult sub div mag dot normalize)]
1717
[fastmath.matrix :refer (mat->float-array mulm mulv inverse rotation-matrix-3d-x rotation-matrix-3d-y)]
@@ -1111,6 +1111,23 @@ void main()
11111111
0.5 1 (/ (* 6 0.75) (* 8 PI 2.25 (pow 0.25 1.5))))
11121112

11131113

1114+
(defn scatter-amount [theta]
1115+
(first (render-pixel [vertex-test] [(mie-scatter 0.76) (mie-probe (cos theta))])))
1116+
1117+
1118+
(let [scatter (tc/dataset {:x (map (fn [theta] (* (cos (to-radians theta))
1119+
(+ 0.75 (* 0.25 (scatter-amount (to-radians theta))))))
1120+
(range 361))
1121+
:y (map (fn [theta] (* (sin (to-radians theta))
1122+
(+ 0.75 (* 0.25 (scatter-amount (to-radians theta))))))
1123+
(range 361)) })]
1124+
(-> scatter
1125+
(plotly/base {:=title "Mie scattering" :=mode "lines"})
1126+
(plotly/layer-point {:=x :x :=y :y})
1127+
plotly/plot
1128+
(assoc-in [:layout :yaxis :scaleanchor] "x")))
1129+
1130+
11141131
(bufimg/tensor->image (rgba-array->bufimg (render-noise 640 480 (mie-scatter 0.76) no-shadow (cloud-transfer "remap_noise" 0.01) remap-clamp (remap-noise "octaves" 0.45 0.9 cloud-strength) (noise-octaves (octaves 4 0.5)) noise-shader) 640 480))
11151132

11161133

0 commit comments

Comments
 (0)