|
11 | 11 | :tags [:visualization]}}} |
12 | 12 |
|
13 | 13 | (ns volumetric-clouds.main |
14 | | - (:require [clojure.math :refer (PI sqrt cos sin tan to-radians pow)] |
| 14 | + (:require [clojure.math :refer (PI sqrt cos sin tan to-radians pow floor)] |
15 | 15 | [midje.sweet :refer (fact facts tabular => roughly)] |
16 | 16 | [fastmath.vector :refer (vec2 vec3 add mult sub div mag dot normalize)] |
17 | 17 | [fastmath.matrix :refer (mat->float-array mulm mulv inverse |
|
177 | 177 | (wrap-get (wrap-get t 5) 3) => (vec2 1 3))) |
178 | 178 |
|
179 | 179 |
|
| 180 | +;; The following function converts a noise coordinate to the index of a cell in the random point array. |
180 | 181 | (defn division-index |
181 | 182 | [{:keys [cellsize]} x] |
182 | | - (int (/ x cellsize))) |
183 | | - |
| 183 | + (int (floor (/ x cellsize)))) |
184 | 184 |
|
185 | 185 | (facts "Convert coordinate to division index" |
186 | | - (division-index {:cellsize 4} 3.5) => 0 |
187 | | - (division-index {:cellsize 4} 7.5) => 1) |
188 | | - |
| 186 | + (division-index {:cellsize 4} 3.5) => 0 |
| 187 | + (division-index {:cellsize 4} 7.5) => 1 |
| 188 | + (division-index {:cellsize 4} -0.5) => -1) |
189 | 189 |
|
| 190 | +;; ### Getting indices of Neighbours |
| 191 | +;; |
| 192 | +;; The following function determines the neighbouring indices of a cell.recursing over each dimension. |
190 | 193 | (defn neighbours |
191 | 194 | [& args] |
192 | 195 | (if (seq args) |
|
197 | 200 |
|
198 | 201 | (facts "Get neighbouring indices" |
199 | 202 | (neighbours) => [[]] |
| 203 | + (neighbours 0) => [[-1] [0] [1]] |
200 | 204 | (neighbours 3) => [[2] [3] [4]] |
201 | 205 | (neighbours 1 10) => [[0 9] [1 9] [2 9] [0 10] [1 10] [2 10] [0 11] [1 11] [2 11]]) |
202 | 206 |
|
@@ -1226,7 +1230,7 @@ void main() |
1226 | 1230 | (+ 0.75 (* 0.25 (scatter-amount (to-radians theta)))))) |
1227 | 1231 | (range 361)) })] |
1228 | 1232 | (-> scatter |
1229 | | - (plotly/base {:=title "Mie scattering" :=mode "lines"}) |
| 1233 | + (plotly/base {:=title "Mixed Mie and isotropic scattering" :=mode "lines"}) |
1230 | 1234 | (plotly/layer-point {:=x :x :=y :y}) |
1231 | 1235 | plotly/plot |
1232 | 1236 | (assoc-in [:layout :yaxis :scaleanchor] "x"))) |
@@ -1279,7 +1283,8 @@ float shadow(vec3 point) |
1279 | 1283 | (GLFW/glfwTerminate) |
1280 | 1284 |
|
1281 | 1285 | ;; ## Further topics |
1282 | | -;; * vertical cloud profile |
1283 | | -;; * powder function |
1284 | | -;; * curl noise |
1285 | | -;; * deep opacity maps https://www.wedesoft.de/software/2023/05/03/volumetric-clouds/ |
| 1286 | +;; |
| 1287 | +;; * [Vertical density profile](https://www.wedesoft.de/software/2023/05/03/volumetric-clouds/) |
| 1288 | +;; * [Powder function](https://advances.realtimerendering.com/s2015/index.html) |
| 1289 | +;; * [Curl noise](https://www.wedesoft.de/software/2023/03/20/procedural-global-cloud-cover/) |
| 1290 | +;; * [Deep opacity maps](https://www.wedesoft.de/software/2023/05/03/volumetric-clouds/) |
0 commit comments