Skip to content

Commit 3103ac7

Browse files
committed
Finished explanation
1 parent 60621ef commit 3103ac7

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

src/volumetric_clouds/main.clj

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1341,7 +1341,7 @@ void main()
13411341
plotly/plot
13421342
(assoc-in [:layout :yaxis :scaleanchor] "x")))
13431343

1344-
;; Now the clouds look a bit more realistic.
1344+
;; We replace the `in_scatter` placeholder from earlier with the Mie scattering and now the clouds look a bit more realistic.
13451345
(rgba-array->bufimg
13461346
(render-noise 640 480 (mie-scatter 0.76) no-shadow (cloud-transfer "remap_noise" 0.01)
13471347
remap-clamp (remap-noise "octaves" 0.45 0.9 cloud-strength)
@@ -1350,6 +1350,10 @@ void main()
13501350

13511351

13521352
;; ### Self-shading of clouds
1353+
;;
1354+
;; Finally we can implement the shadow function by also sampling towards the light source to compute the shading value at each point.
1355+
;; Testing the function requires extending the `render-pixel` function to accept a function for setting the `light` uniform.
1356+
;; We leave this as an exercise for the interested reader 😉.
13531357
(def shadow
13541358
(template/fn [noise step]
13551359
"#version 130
@@ -1369,16 +1373,18 @@ float shadow(vec3 point)
13691373
return result;
13701374
}"))
13711375

1372-
1376+
;; The final result is starting to look realistic.
13731377
(rgba-array->bufimg
13741378
(render-noise 640 480
1375-
(mie-scatter 0.76) (shadow "remap_noise" 0.01)
1379+
(mie-scatter 0.76) (shadow "remap_noise" 0.05)
13761380
(cloud-transfer "remap_noise" 0.01) remap-clamp
13771381
(remap-noise "octaves" 0.45 0.9 cloud-strength)
13781382
(noise-octaves (octaves 4 0.5)) noise-shader)
13791383
640 480)
13801384

13811385
;; ### Tidy up
1386+
;;
1387+
;; Finally we free the texture, destroy the window, and terminate GLFW.
13821388
(GL11/glBindTexture GL12/GL_TEXTURE_3D 0)
13831389
(GL11/glDeleteTextures noise-texture)
13841390

@@ -1388,6 +1394,8 @@ float shadow(vec3 point)
13881394

13891395
;; ## Further topics
13901396
;;
1397+
;; Here are some references to get from a cloud prototype to more realistic clouds.
1398+
;;
13911399
;; * [Vertical density profile](https://www.wedesoft.de/software/2023/05/03/volumetric-clouds/)
13921400
;; * [Powder function](https://advances.realtimerendering.com/s2015/index.html)
13931401
;; * [Curl noise](https://www.wedesoft.de/software/2023/03/20/procedural-global-cloud-cover/)

0 commit comments

Comments
 (0)