webgpu-trees 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (322) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1541 -2
  3. package/assets/SOURCES.md +255 -0
  4. package/assets/bark/alder.albedo.avif +0 -0
  5. package/assets/bark/alder.normal.avif +0 -0
  6. package/assets/bark/aleppoPine.albedo.avif +0 -0
  7. package/assets/bark/aleppoPine.normal.avif +0 -0
  8. package/assets/bark/ash.albedo.avif +0 -0
  9. package/assets/bark/ash.normal.avif +0 -0
  10. package/assets/bark/aspen.albedo.avif +0 -0
  11. package/assets/bark/aspen.normal.avif +0 -0
  12. package/assets/bark/beech.albedo.avif +0 -0
  13. package/assets/bark/beech.normal.avif +0 -0
  14. package/assets/bark/birch.albedo.avif +0 -0
  15. package/assets/bark/birch.normal.avif +0 -0
  16. package/assets/bark/birchFoot.albedo.avif +0 -0
  17. package/assets/bark/birchFoot.normal.avif +0 -0
  18. package/assets/bark/corsicanPine.albedo.avif +0 -0
  19. package/assets/bark/corsicanPine.normal.avif +0 -0
  20. package/assets/bark/cypress.albedo.avif +0 -0
  21. package/assets/bark/cypress.normal.avif +0 -0
  22. package/assets/bark/douglas.albedo.avif +0 -0
  23. package/assets/bark/douglas.normal.avif +0 -0
  24. package/assets/bark/eucalyptus.albedo.avif +0 -0
  25. package/assets/bark/eucalyptus.normal.avif +0 -0
  26. package/assets/bark/eucalyptusUpper.albedo.avif +0 -0
  27. package/assets/bark/eucalyptusUpper.normal.avif +0 -0
  28. package/assets/bark/fibrous.albedo.avif +0 -0
  29. package/assets/bark/fibrous.normal.avif +0 -0
  30. package/assets/bark/hemlock.albedo.avif +0 -0
  31. package/assets/bark/hemlock.normal.avif +0 -0
  32. package/assets/bark/hornbeam.albedo.avif +0 -0
  33. package/assets/bark/hornbeam.normal.avif +0 -0
  34. package/assets/bark/larch.albedo.avif +0 -0
  35. package/assets/bark/larch.normal.avif +0 -0
  36. package/assets/bark/lime.albedo.avif +0 -0
  37. package/assets/bark/lime.normal.avif +0 -0
  38. package/assets/bark/liveOak.albedo.avif +0 -0
  39. package/assets/bark/liveOak.normal.avif +0 -0
  40. package/assets/bark/maple.albedo.avif +0 -0
  41. package/assets/bark/maple.normal.avif +0 -0
  42. package/assets/bark/montereyPine.albedo.avif +0 -0
  43. package/assets/bark/montereyPine.normal.avif +0 -0
  44. package/assets/bark/norMaple.albedo.avif +0 -0
  45. package/assets/bark/norMaple.normal.avif +0 -0
  46. package/assets/bark/oak.albedo.avif +0 -0
  47. package/assets/bark/oak.normal.avif +0 -0
  48. package/assets/bark/palmLattice.albedo.avif +0 -0
  49. package/assets/bark/palmLattice.normal.avif +0 -0
  50. package/assets/bark/palmPineapple.albedo.avif +0 -0
  51. package/assets/bark/palmPineapple.normal.avif +0 -0
  52. package/assets/bark/palmRings.albedo.avif +0 -0
  53. package/assets/bark/palmRings.normal.avif +0 -0
  54. package/assets/bark/pine.albedo.avif +0 -0
  55. package/assets/bark/pine.normal.avif +0 -0
  56. package/assets/bark/pineFlakes.albedo.avif +0 -0
  57. package/assets/bark/pineFlakes.normal.avif +0 -0
  58. package/assets/bark/plane.albedo.avif +0 -0
  59. package/assets/bark/plane.normal.avif +0 -0
  60. package/assets/bark/poplar.albedo.avif +0 -0
  61. package/assets/bark/poplar.normal.avif +0 -0
  62. package/assets/bark/redAlder.albedo.avif +0 -0
  63. package/assets/bark/redAlder.normal.avif +0 -0
  64. package/assets/bark/redOak.albedo.avif +0 -0
  65. package/assets/bark/redOak.normal.avif +0 -0
  66. package/assets/bark/ridged.albedo.avif +0 -0
  67. package/assets/bark/ridged.normal.avif +0 -0
  68. package/assets/bark/sitkaSpruce.albedo.avif +0 -0
  69. package/assets/bark/sitkaSpruce.normal.avif +0 -0
  70. package/assets/bark/spruce.albedo.avif +0 -0
  71. package/assets/bark/spruce.normal.avif +0 -0
  72. package/assets/bark/stonePine.albedo.avif +0 -0
  73. package/assets/bark/stonePine.normal.avif +0 -0
  74. package/assets/bark/sycMaple.albedo.avif +0 -0
  75. package/assets/bark/sycMaple.normal.avif +0 -0
  76. package/assets/bark/torreyPine.albedo.avif +0 -0
  77. package/assets/bark/torreyPine.normal.avif +0 -0
  78. package/assets/bark/whitePine.albedo.avif +0 -0
  79. package/assets/bark/whitePine.normal.avif +0 -0
  80. package/assets/bark/whiteSpruce.albedo.avif +0 -0
  81. package/assets/bark/whiteSpruce.normal.avif +0 -0
  82. package/assets/bark/whiteWillow.albedo.avif +0 -0
  83. package/assets/bark/whiteWillow.normal.avif +0 -0
  84. package/assets/bark/willow.albedo.avif +0 -0
  85. package/assets/bark/willow.normal.avif +0 -0
  86. package/assets/leaves/alder.albedo.avif +0 -0
  87. package/assets/leaves/alder.normal.avif +0 -0
  88. package/assets/leaves/ash.albedo.avif +0 -0
  89. package/assets/leaves/ash.normal.avif +0 -0
  90. package/assets/leaves/aspen.albedo.avif +0 -0
  91. package/assets/leaves/aspen.normal.avif +0 -0
  92. package/assets/leaves/beech.albedo.avif +0 -0
  93. package/assets/leaves/beech.normal.avif +0 -0
  94. package/assets/leaves/birch.albedo.avif +0 -0
  95. package/assets/leaves/birch.normal.avif +0 -0
  96. package/assets/leaves/blackthorn.albedo.avif +0 -0
  97. package/assets/leaves/blackthorn.normal.avif +0 -0
  98. package/assets/leaves/blade.albedo.avif +0 -0
  99. package/assets/leaves/blade.normal.avif +0 -0
  100. package/assets/leaves/broomSprig.albedo.avif +0 -0
  101. package/assets/leaves/broomSprig.normal.avif +0 -0
  102. package/assets/leaves/corsicanShoot.albedo.avif +0 -0
  103. package/assets/leaves/corsicanShoot.normal.avif +0 -0
  104. package/assets/leaves/cypress.albedo.avif +0 -0
  105. package/assets/leaves/cypress.normal.avif +0 -0
  106. package/assets/leaves/cypressPad.albedo.avif +0 -0
  107. package/assets/leaves/cypressPad.normal.avif +0 -0
  108. package/assets/leaves/deadFronds.albedo.avif +0 -0
  109. package/assets/leaves/deadFronds.normal.avif +0 -0
  110. package/assets/leaves/deltoid.albedo.avif +0 -0
  111. package/assets/leaves/deltoid.normal.avif +0 -0
  112. package/assets/leaves/douglasShoot.albedo.avif +0 -0
  113. package/assets/leaves/douglasShoot.normal.avif +0 -0
  114. package/assets/leaves/elderSprig.albedo.avif +0 -0
  115. package/assets/leaves/elderSprig.normal.avif +0 -0
  116. package/assets/leaves/elliptic.albedo.avif +0 -0
  117. package/assets/leaves/elliptic.normal.avif +0 -0
  118. package/assets/leaves/eucalyptus.albedo.avif +0 -0
  119. package/assets/leaves/eucalyptus.normal.avif +0 -0
  120. package/assets/leaves/fan.albedo.avif +0 -0
  121. package/assets/leaves/fan.normal.avif +0 -0
  122. package/assets/leaves/fanB.albedo.avif +0 -0
  123. package/assets/leaves/fanB.normal.avif +0 -0
  124. package/assets/leaves/fir.albedo.avif +0 -0
  125. package/assets/leaves/fir.normal.avif +0 -0
  126. package/assets/leaves/frond.albedo.avif +0 -0
  127. package/assets/leaves/frond.normal.avif +0 -0
  128. package/assets/leaves/gorse.albedo.avif +0 -0
  129. package/assets/leaves/gorse.normal.avif +0 -0
  130. package/assets/leaves/hawthorn.albedo.avif +0 -0
  131. package/assets/leaves/hawthorn.normal.avif +0 -0
  132. package/assets/leaves/hemlockShoot.albedo.avif +0 -0
  133. package/assets/leaves/hemlockShoot.normal.avif +0 -0
  134. package/assets/leaves/hornbeam.albedo.avif +0 -0
  135. package/assets/leaves/hornbeam.normal.avif +0 -0
  136. package/assets/leaves/lance.albedo.avif +0 -0
  137. package/assets/leaves/lance.normal.avif +0 -0
  138. package/assets/leaves/larchShoot.albedo.avif +0 -0
  139. package/assets/leaves/larchShoot.normal.avif +0 -0
  140. package/assets/leaves/lime.albedo.avif +0 -0
  141. package/assets/leaves/lime.normal.avif +0 -0
  142. package/assets/leaves/liveOak.albedo.avif +0 -0
  143. package/assets/leaves/liveOak.normal.avif +0 -0
  144. package/assets/leaves/londonPlane.albedo.avif +0 -0
  145. package/assets/leaves/londonPlane.normal.avif +0 -0
  146. package/assets/leaves/maple.albedo.avif +0 -0
  147. package/assets/leaves/maple.normal.avif +0 -0
  148. package/assets/leaves/norMaple.albedo.avif +0 -0
  149. package/assets/leaves/norMaple.normal.avif +0 -0
  150. package/assets/leaves/oak.albedo.avif +0 -0
  151. package/assets/leaves/oak.normal.avif +0 -0
  152. package/assets/leaves/paintFan.albedo.avif +0 -0
  153. package/assets/leaves/paintFan.normal.avif +0 -0
  154. package/assets/leaves/paintFrond.albedo.avif +0 -0
  155. package/assets/leaves/paintFrond.normal.avif +0 -0
  156. package/assets/leaves/pine.albedo.avif +0 -0
  157. package/assets/leaves/pine.normal.avif +0 -0
  158. package/assets/leaves/pineClumpDark.albedo.avif +0 -0
  159. package/assets/leaves/pineClumpDark.normal.avif +0 -0
  160. package/assets/leaves/pineClumpLight.albedo.avif +0 -0
  161. package/assets/leaves/pineClumpLight.normal.avif +0 -0
  162. package/assets/leaves/poplar.albedo.avif +0 -0
  163. package/assets/leaves/poplar.normal.avif +0 -0
  164. package/assets/leaves/queenFrond.albedo.avif +0 -0
  165. package/assets/leaves/queenFrond.normal.avif +0 -0
  166. package/assets/leaves/redAlder.albedo.avif +0 -0
  167. package/assets/leaves/redAlder.normal.avif +0 -0
  168. package/assets/leaves/redOak.albedo.avif +0 -0
  169. package/assets/leaves/redOak.normal.avif +0 -0
  170. package/assets/leaves/round.albedo.avif +0 -0
  171. package/assets/leaves/round.normal.avif +0 -0
  172. package/assets/leaves/scale.albedo.avif +0 -0
  173. package/assets/leaves/scale.normal.avif +0 -0
  174. package/assets/leaves/scotsPineClump.albedo.avif +0 -0
  175. package/assets/leaves/scotsPineClump.normal.avif +0 -0
  176. package/assets/leaves/seaBuckthornSprig.albedo.avif +0 -0
  177. package/assets/leaves/seaBuckthornSprig.normal.avif +0 -0
  178. package/assets/leaves/serrate.albedo.avif +0 -0
  179. package/assets/leaves/serrate.normal.avif +0 -0
  180. package/assets/leaves/sitkaShoot.albedo.avif +0 -0
  181. package/assets/leaves/sitkaShoot.normal.avif +0 -0
  182. package/assets/leaves/stonePineCanopy.albedo.avif +0 -0
  183. package/assets/leaves/stonePineCanopy.normal.avif +0 -0
  184. package/assets/leaves/stonePineCushion.albedo.avif +0 -0
  185. package/assets/leaves/stonePineCushion.normal.avif +0 -0
  186. package/assets/leaves/sycamore.albedo.avif +0 -0
  187. package/assets/leaves/sycamore.normal.avif +0 -0
  188. package/assets/leaves/torreyPine.albedo.avif +0 -0
  189. package/assets/leaves/torreyPine.normal.avif +0 -0
  190. package/assets/leaves/whitePine.albedo.avif +0 -0
  191. package/assets/leaves/whitePine.normal.avif +0 -0
  192. package/assets/leaves/whiteSpruceShoot.albedo.avif +0 -0
  193. package/assets/leaves/whiteSpruceShoot.normal.avif +0 -0
  194. package/assets/leaves/whiteWillow.albedo.avif +0 -0
  195. package/assets/leaves/whiteWillow.normal.avif +0 -0
  196. package/assets/leaves/willow.albedo.avif +0 -0
  197. package/assets/leaves/willow.normal.avif +0 -0
  198. package/assets/marks/marks.json +894 -0
  199. package/assets/marks/painterly.avif +0 -0
  200. package/assets/marks/sheets.avif +0 -0
  201. package/assets/scans.json +6066 -0
  202. package/lib/age.d.ts +36 -0
  203. package/lib/age.d.ts.map +1 -0
  204. package/lib/age.js +170 -0
  205. package/lib/age.js.map +1 -0
  206. package/lib/atmosphere.d.ts +64 -0
  207. package/lib/atmosphere.d.ts.map +1 -0
  208. package/lib/atmosphere.js +260 -0
  209. package/lib/atmosphere.js.map +1 -0
  210. package/lib/dabs.d.ts +4 -0
  211. package/lib/dabs.d.ts.map +1 -0
  212. package/lib/dabs.js +77 -0
  213. package/lib/dabs.js.map +1 -0
  214. package/lib/engine.d.ts +211 -0
  215. package/lib/engine.d.ts.map +1 -0
  216. package/lib/engine.js +3808 -0
  217. package/lib/engine.js.map +1 -0
  218. package/lib/genetics.d.ts +129 -0
  219. package/lib/genetics.d.ts.map +1 -0
  220. package/lib/genetics.js +721 -0
  221. package/lib/genetics.js.map +1 -0
  222. package/lib/geometry.d.ts +237 -0
  223. package/lib/geometry.d.ts.map +1 -0
  224. package/lib/geometry.js +1944 -0
  225. package/lib/geometry.js.map +1 -0
  226. package/lib/grow.d.ts +83 -0
  227. package/lib/grow.d.ts.map +1 -0
  228. package/lib/grow.js +3851 -0
  229. package/lib/grow.js.map +1 -0
  230. package/lib/hiz.d.ts +74 -0
  231. package/lib/hiz.d.ts.map +1 -0
  232. package/lib/hiz.js +161 -0
  233. package/lib/hiz.js.map +1 -0
  234. package/lib/impostor.d.ts +106 -0
  235. package/lib/impostor.d.ts.map +1 -0
  236. package/lib/impostor.js +450 -0
  237. package/lib/impostor.js.map +1 -0
  238. package/lib/index.d.ts +17 -0
  239. package/lib/index.d.ts.map +1 -0
  240. package/lib/index.js +16 -0
  241. package/lib/index.js.map +1 -0
  242. package/lib/leaves.d.ts +30 -0
  243. package/lib/leaves.d.ts.map +1 -0
  244. package/lib/leaves.js +829 -0
  245. package/lib/leaves.js.map +1 -0
  246. package/lib/light.d.ts +110 -0
  247. package/lib/light.d.ts.map +1 -0
  248. package/lib/light.js +430 -0
  249. package/lib/light.js.map +1 -0
  250. package/lib/lobes.d.ts +25 -0
  251. package/lib/lobes.d.ts.map +1 -0
  252. package/lib/lobes.js +151 -0
  253. package/lib/lobes.js.map +1 -0
  254. package/lib/marks.d.ts +63 -0
  255. package/lib/marks.d.ts.map +1 -0
  256. package/lib/marks.js +553 -0
  257. package/lib/marks.js.map +1 -0
  258. package/lib/mips.d.ts +42 -0
  259. package/lib/mips.d.ts.map +1 -0
  260. package/lib/mips.js +220 -0
  261. package/lib/mips.js.map +1 -0
  262. package/lib/paintedMarks.d.ts +21 -0
  263. package/lib/paintedMarks.d.ts.map +1 -0
  264. package/lib/paintedMarks.js +53 -0
  265. package/lib/paintedMarks.js.map +1 -0
  266. package/lib/palm.d.ts +162 -0
  267. package/lib/palm.d.ts.map +1 -0
  268. package/lib/palm.js +779 -0
  269. package/lib/palm.js.map +1 -0
  270. package/lib/palmAtlas.d.ts +79 -0
  271. package/lib/palmAtlas.d.ts.map +1 -0
  272. package/lib/palmAtlas.js +335 -0
  273. package/lib/palmAtlas.js.map +1 -0
  274. package/lib/palmGeometry.d.ts +41 -0
  275. package/lib/palmGeometry.d.ts.map +1 -0
  276. package/lib/palmGeometry.js +309 -0
  277. package/lib/palmGeometry.js.map +1 -0
  278. package/lib/phenology.d.ts +21 -0
  279. package/lib/phenology.d.ts.map +1 -0
  280. package/lib/phenology.js +164 -0
  281. package/lib/phenology.js.map +1 -0
  282. package/lib/random.d.ts +34 -0
  283. package/lib/random.d.ts.map +1 -0
  284. package/lib/random.js +92 -0
  285. package/lib/random.js.map +1 -0
  286. package/lib/scans.d.ts +232 -0
  287. package/lib/scans.d.ts.map +1 -0
  288. package/lib/scans.js +391 -0
  289. package/lib/scans.js.map +1 -0
  290. package/lib/scatter.d.ts +70 -0
  291. package/lib/scatter.d.ts.map +1 -0
  292. package/lib/scatter.js +186 -0
  293. package/lib/scatter.js.map +1 -0
  294. package/lib/species.d.ts +369 -0
  295. package/lib/species.d.ts.map +1 -0
  296. package/lib/species.js +2817 -0
  297. package/lib/species.js.map +1 -0
  298. package/lib/sprays.d.ts +112 -0
  299. package/lib/sprays.d.ts.map +1 -0
  300. package/lib/sprays.js +1137 -0
  301. package/lib/sprays.js.map +1 -0
  302. package/lib/stand.d.ts +52 -0
  303. package/lib/stand.d.ts.map +1 -0
  304. package/lib/stand.js +279 -0
  305. package/lib/stand.js.map +1 -0
  306. package/lib/styles.d.ts +135 -0
  307. package/lib/styles.d.ts.map +1 -0
  308. package/lib/styles.js +79 -0
  309. package/lib/styles.js.map +1 -0
  310. package/lib/tree.d.ts +134 -0
  311. package/lib/tree.d.ts.map +1 -0
  312. package/lib/tree.js +57 -0
  313. package/lib/tree.js.map +1 -0
  314. package/lib/variants.d.ts +157 -0
  315. package/lib/variants.d.ts.map +1 -0
  316. package/lib/variants.js +532 -0
  317. package/lib/variants.js.map +1 -0
  318. package/lib/visibility.d.ts +105 -0
  319. package/lib/visibility.d.ts.map +1 -0
  320. package/lib/visibility.js +242 -0
  321. package/lib/visibility.js.map +1 -0
  322. package/package.json +62 -3
package/README.md CHANGED
@@ -1,3 +1,1542 @@
1
- # Temporary Holding Version
1
+ # Trees
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Trees for three.js on WebGPU, written in TSL: grown from a species' data to
4
+ each tree's own measured size, and drawn in their tens of thousands. It is the
5
+ sibling of [webgpu-grass](https://github.com/jakobholmelund/webgpu-grass), and
6
+ began as the trees of Couch Golf Club, a browser golf game.
7
+
8
+ It is early. It has four looks from the same grown trees: `stylized`,
9
+ crowns laid in dabs of paint, as the game draws them; `painterly`, crowns of
10
+ small crisp leaves lit as a few big soft masses; `sculpted`, crowns of soft
11
+ clay lobes; and `real`, crowns of leaf cards made of the species' own
12
+ scanned leaves, with scanned bark (see *Photographs*).
13
+ WebGPU only (three.js r187, `three/webgpu`).
14
+
15
+ ```
16
+ src/ the package: imports three and nothing else
17
+ assets/ the realistic look's photographs: scanned bark and leaves (CC0, SOURCES.md)
18
+ tools/ scans/ makes assets/ from the downloaded scans
19
+ lab/ the lab: ground, sky, and the package's trees on it; and its gallery
20
+ ```
21
+
22
+ `pnpm test` holds the walls: the package imports only three, the lab
23
+ reaches it only through `src/index.ts`, growing keeps to the size asked
24
+ for, and every tree is fitted to its own numbers.
25
+
26
+ ## The contract
27
+
28
+ ```ts
29
+ const trees = createTrees({
30
+ trees: [{ x, y, z, species: 0, height: 17, crownRadius: 7.5, crownBase: 3.2, trunkRadius: 0.45 }, ...],
31
+ species: STARTER_SPECIES,
32
+ });
33
+ scene.add(trees.object);
34
+ // each frame, before rendering:
35
+ trees.update(renderer, camera, timeSeconds);
36
+ ```
37
+
38
+ - **The renderer should keep depth reversed**
39
+ (`new WebGPURenderer({ reversedDepthBuffer: true })`). Neighbouring
40
+ crowns grow into each other, and their leaves' dabs, all facing the eye,
41
+ can lie closer in depth than an ordinary depth buffer tells apart a few
42
+ dozen metres off: which is in front then changes from frame to frame as
43
+ they sway, and leaves flicker, at every distance and with the eye still.
44
+ Reversed depth tells them apart to a fraction of a millimetre at any
45
+ distance. In the lab's grove, 1609 pixels flickering over a dozen frames
46
+ became 191 (scattered edge pixels), and the near plane no longer matters.
47
+ `update` says so once on the console if it is not.
48
+ - **A tree on the ground** is a place and the four numbers a survey
49
+ measures of it: height, crown radius, the height of its crown's base, its
50
+ trunk's radius (all optional; left out, they are its species'). A yaw and
51
+ a seed may be given; left out, they come from its place. Many trees go in
52
+ packed, ten numbers a tree (`packTrees`, `TREE_FIELDS`).
53
+ - **Where it stands** (alone, at a wood's edge, inside a wood) is worked
54
+ out from the list itself, from each tree's neighbours (see *Where a tree
55
+ stands*). A host that knows better says so, of any tree: `stand` on a
56
+ tree in the list, or `stands` beside a packed list.
57
+ - **A species** is a row of plain data (`species.ts`): how the tree is put
58
+ together (broadleaf, conifer, shrub), its crown's outline, how deep its
59
+ leaves go and how open it is, how it branches, its clumps of leaves, its
60
+ colours and its stiffness. Nothing that draws a tree names a species.
61
+ - **Style** (`trees.style`) is how it is drawn, apart from what it is:
62
+ light in painted bands, how round each clump is lit, the dabs' size,
63
+ light through the leaves. **Detail** (`trees.detail`) says at what size
64
+ in the picture each tier takes over.
65
+ - **Look** (`createTrees({ look: "painterly" })`) is chosen when the trees
66
+ are made, the pieces being different; `style` starts as the look's
67
+ (`LOOK_STYLES[look]`) and can be changed at any time.
68
+ - **Shade on the ground**: `trees.bakeShade(area)` works out how much sun
69
+ reaches the ground past the crowns (as their own leaves and limbs take it:
70
+ see "Light from the crown's own leaves"), and
71
+ `trees.sunAt(xz)` hands it to a host's ground or grass as a TSL node (the
72
+ grass library takes it as `world.sun`).
73
+ - **Photographs** (the realistic look's scanned bark and leaves, in
74
+ `assets/`) are fetched once a page and put in as they come; until then,
75
+ and with `scans: false`, the bark and the sprays are drawn by arithmetic.
76
+ `trees.ready` settles when they are in. A bundler must copy the package's
77
+ `assets/` with it: Vite does, for `new URL(..., import.meta.url)`, unless
78
+ it pre-bundles the package (then exclude it from `optimizeDeps`, or copy
79
+ `assets/` somewhere served and pass `scans: { base: "/where/" }`). Hosts
80
+ may give species photographs of their own (`scans.looks`).
81
+ - **Light, wind and season** (`trees.environment`) are the host's to set, as the
82
+ grass takes them: the sun's direction, the colour of sunlight and of
83
+ shade, the wind's heading and speed; and the day of the year (`day`, 1 on
84
+ the 1st of January, or null), from which a flowering species' bloom is
85
+ worked out (see *Flowers*). `world.sun(xz)` and `world.air(colour,
86
+ at)` let a host's clouds and haze reach the trees. Without `world.air` the
87
+ trees take the scene's fog; with it, only the host's air.
88
+
89
+ ## In a host
90
+
91
+ It is not on a registry yet. Pack it from the workspace and install the
92
+ tarball, alongside the host's own `three` (a peer, r187):
93
+
94
+ ```bash
95
+ pnpm --filter webgpu-trees pack --pack-destination <dir>
96
+ pnpm add <dir>/webgpu-trees-0.0.0.tgz three@^0.187.0
97
+ ```
98
+
99
+ The package holds compiled JavaScript and type declarations (`lib/`) beside
100
+ its `assets/` (about 27 MB of photographs and painted marks, credited in
101
+ `assets/SOURCES.md`). A page fetches only the pictures its species wear.
102
+ A bundler copies all of them into a build, though, because the photographs
103
+ are named with a pattern (`` `../assets/bark/${id}.${map}.avif` ``). The
104
+ smallest working host is [examples/one-tree](../../examples/one-tree), and
105
+ `pnpm consumer:trees` checks it against the packed tarball. Inside the
106
+ workspace, the package resolves to its TypeScript source.
107
+
108
+ ## Styles
109
+
110
+ A look is the pieces a crown is laid with, chosen when the trees are made; a
111
+ style is a row of numbers (`TreeStyle`) saying how they are lit, read each
112
+ frame. Each look starts from its own style (`LOOK_STYLES`: `DEFAULT_STYLE`,
113
+ `PAINTERLY_STYLE`, `SCULPTED_STYLE`, `REAL_STYLE`), and every number keeps
114
+ to a range (`STYLE_RANGES`, `checkStyle`). The host's sun, its tints and the
115
+ wind stay the host's (`trees.environment`); a style turns them, never
116
+ replaces them.
117
+
118
+ | Look | Its crowns | Its light |
119
+ | --- | --- | --- |
120
+ | `stylized` (painted) | brush marks, a few dabs to a clump | the crown's form and each clump's, in flat bands |
121
+ | `painterly` | lumpy clusters of small crisp leaves of the species' kind, hand-painted (`paintedMarks.ts`, *Painted marks*), never longer than `leafSize` metres however big the crown: oval leaves for broadleaves, small diamond leaves for small-leaved trees, hanging lance leaves for willows and eucalyptus, brushes of needles for pines, curved leaflets for palms; a conifer's boughs as sheets of painted sprays (*Boughs*) | a few big lobes, warm yellow-green where lit, cool teal in shade, a rim against the sun |
122
+ | `sculpted` | soft lumpy clay discs, and sprigs of two or three leaves on the tops of its lobes | the lobes as clay balls, each dab a small ball on its lobe |
123
+ | `real` | leaf cards set in the crown, each a spray of the species' leaves; a conifer's boughs as sheets carrying its sprays | as the sun gives it, with light through the leaves |
124
+
125
+ **Lobes.** The painterly and sculpted looks light a crown as a painter does,
126
+ as a handful of masses before any leaf. Each crown's clumps are gathered
127
+ into lobes (`lobes.ts`: k-means, about half the crown's mean radius each,
128
+ seeded from the clumps farthest apart), and every dab is lit, pixel by
129
+ pixel, as the ball of the lobe the eye's ray through it meets first, so
130
+ lobes hide one another as solid masses do and the light runs smoothly over
131
+ all of a lobe's dabs. Lit each by its own lobe instead, the dabs of two
132
+ overlapping lobes interleave into a patchwork. `lobe` says how far a crown
133
+ is lit so (0: as the painted look, each dab one stroke), `bulge` how far
134
+ each dab is its own small ball over it.
135
+
136
+ **Colour.** `warm` turns the sunlit side towards a yellow-green and `cool`
137
+ the shade towards a teal blue-green, each keeping its brightness (a green
138
+ leaf multiplied by a blue light stays green; turned, it goes teal);
139
+ `chroma` makes the colour richer than the species' and `bright` the sunlit
140
+ side brighter beside the shade. `rim` lights a lobe's edge against the sun.
141
+ Mid and far trees are lit the same way over the same lobes, with the
142
+ look's own marks (a cluster of smaller leaves for a gathered dab), so a
143
+ tree keeps its colours as it passes from tier to tier.
144
+
145
+ **Leaf size.** A painterly cluster's leaves are a share of its dab, and a
146
+ big crown's dabs are a metre and more across: drawn so, its leaves were
147
+ the size of a tray beside a golfer. The atlas holds each kind's clusters
148
+ at three densities (`PAINTERLY_DENSITIES`, the leaves smaller and more at
149
+ each), and each dab takes the coarsest whose leaves stay under `leafSize`
150
+ (0.22 m for a broad leaf; a palm's fronds are allowed five times that).
151
+ Nor finer than leaves four pixels across: further off, a leaf's size in
152
+ metres is not seen, and finer leaves were a shimmer of specks over a birch
153
+ or a willow at the fairway; and leaves seven pixels across or fewer are
154
+ drawn softly, their own tone and number eased towards the mean (to a third
155
+ at two pixels), so a far crown is soft painted masses with crisp edges. A
156
+ painterly tree passing between tiers hands its dabs and sheets over piece by
157
+ piece (`pieceShare`), as the realistic look does: handed over pixel by pixel,
158
+ a crown at 60 m was a speckle of sky inside it and lone leaves round it.
159
+ A cluster is a lumpy mass of a few round lobes, darker under its leaves,
160
+ the leaves pointing out from their lobe, so its outline is ragged leaf
161
+ tips all round and no ring of tips pointing out like a star.
162
+
163
+ **Marks.** Until the painted marks come (and with `scans: false`), drawn by
164
+ arithmetic (`marks.ts`), no picture loaded. A painterly leaf is
165
+ an outline about its midrib, folded (one half a little darker), lighter
166
+ to its tip, its own tone, casting a thin shadow on what it lies over;
167
+ green carries a number of each leaf's own, so leaves in the light vary one
168
+ by one. A mark's edge is sharpened over one pixel, so leaves stay crisp
169
+ close to, where a texel covers more than a pixel, and keep their coverage
170
+ far off (see *Far leaves*).
171
+
172
+ **Painted marks.** The painterly look lays its crowns with clusters and
173
+ boughs cut from hand-painted pictures (generated for this project, not
174
+ CC0: `assets/SOURCES.md`), cell for cell where the drawn marks are
175
+ (`assets/marks/`, made offline by `tools/marks/build.mjs` from the pictures
176
+ `tools/marks/recipe.mjs` lists). The shader still colours each leaf from
177
+ its species and the light, so a picture gives only its form: its lightness
178
+ over its own blurred over a leaf and a half (the painter's light on the
179
+ whole clump taken out, the lobes' laid in its place) is the tone, brought
180
+ to the same mean in every cell; its coverage is keyed off its magenta; and
181
+ each painted leaf, found by flooding from the flat insides of the leaves
182
+ up the edges and dark valleys between them, is a number of its own, so
183
+ the light varies leaf by painted leaf. Broadleaves come from three clumps
184
+ of some thirty leaves and, densest, one of a hundred and twenty; birch,
185
+ hawthorn and alder from airy drooping clumps; willow and eucalyptus from
186
+ hanging sprays (kept upright, as a pine's brushes are); a pine's (and a
187
+ spruce's far dabs) from shoots ending in brushes, laid level side by
188
+ side in plates. A finer density is several pictures smaller, set round
189
+ as a clump's lobes are; each dab is turned, mirrored and sized by its
190
+ own number, so no picture repeats the same way. A painted cluster holds
191
+ more and smaller leaves than a drawn one, and the shader is told how much
192
+ smaller (`PAINTED_LEAF_SHARE`), so each dab still takes the coarsest
193
+ density whose leaves keep under `leafSize`, mid dabs too. A conifer's
194
+ sheets are painted boughs turned along their twig, their sprays reaching
195
+ out to either side (another bough's, mirrored, on the far side), the
196
+ sprays painted behind the others left out so air shows between them, the
197
+ underside a shade darker. 1.7 MB of AVIF (4:4:4, no colour matrix: tone,
198
+ number and coverage kept apart); some 0.2 s once a page to make their
199
+ mips. The same views drew within a few percent of the drawn marks' time.
200
+
201
+ **Boughs.** A conifer grown whorl by whorl (spruces, firs, cedars) lays
202
+ its boughs, near and mid, as sheets lying along them, in the painterly and
203
+ the realistic looks (`sheetPieces`). Dabs facing the eye made a fir a stack
204
+ of blocks, and a bough is not a ball of leaves: it is a flat, drooping
205
+ spray, lit on its top and dark beneath. Koerye's foliage-mass study tried
206
+ three ways and found the same: loose leaves gave spiky balls, dense
207
+ clusters looked fragmented and closed blocks cushions, while curved sheets
208
+ held their volume from every side and read as tiered boughs. So each bough
209
+ is a run of overlapping strips on its own wood, from its first clump to
210
+ past its tip, each as wide as the bough's side shoots reach, lifted at its
211
+ foot and drooping to its tip, its edges falling away either side of its
212
+ middle and a little twisted: from the tee a bough hangs its fringe, from
213
+ under it is a bough's shade, and from above its top. A sheet has two
214
+ sides, its top light (needles over a darker body) and its underside dark
215
+ (the body over the needles), the same outline cell for cell; which shows
216
+ is the pixel's to say, and the side lit as itself over its lobe, so
217
+ neighbouring boughs shade as one mass. The sun on a bough's top comes
218
+ through to its underside. Twelve triangles a sheet close to, about 4,300
219
+ a spruce (its dabs were 1,360, its realistic cards 5,450); mid, the same
220
+ boughs in fewer, longer sheets of four, about 480 a spruce. The mid tier
221
+ had been dabs, and a tree passing between the two changed from boughs to
222
+ blots pixel by pixel, a speckle over the whole hand-over. An old pine
223
+ grown as a broadleaf has no whorled boughs, its needles tufts at its
224
+ twigs' ends, and sheets made its crown a palm's fronds: it keeps its
225
+ clusters.
226
+
227
+ A painterly sheet seen aslant had its picture squeezed across its sprays
228
+ into streaks along its bough, and under a cedar the near ones were big
229
+ smeared sheets. So, near, each is turned about its middle line (`aSpine`)
230
+ towards the eye until it faces it at least 0.25 (the cosine), and 0.6
231
+ within three of its half lengths, never more than 63 degrees: a bough seen
232
+ from the tee lies as it lies, its tiers so, and one overhead is never a
233
+ streak. What is still edge-on (under 0.2, or 0.42 close to) goes spray by
234
+ spray, by each painted spray's own number, as its mips thin to their
235
+ hearts; and from five of its half lengths in to one and a half, half its
236
+ sprays go, so close to it breaks into sprays with air between, the rest by
237
+ six tenths of one (a sheet at the eye was a smear). Mid sheets are as they
238
+ were: turned or thinned, a far spruce was a row of spikes.
239
+
240
+ **Light through the leaves.** A thin leaf passes on about as much light as
241
+ it sends back. To an eye looking towards the sun through it, the light is
242
+ bent a little by how the leaf faces and gathers about the sun
243
+ (Barré-Brisebois, GDC 2011: `throughWarp`, `throughPower`), as much as
244
+ `through` says. SeedThree's lesson is that the model alone makes every
245
+ backlit leaf the same lime green: it knows only where the eye, the sun
246
+ and the leaf face, and a crown is not one thickness. So the leaves are as
247
+ thin as the crown lets the sun reach them (Monsi and Saeki, the share of
248
+ sun at the leaf), thicker deep in the crown, and each leaf its own (the
249
+ marks' green is each leaf's number; the realistic sprays carry one too),
250
+ as far as `throughVary` says: the crown's edge glows where little lies
251
+ between, and its heart stays dark. Close to it is worked out pixel by
252
+ pixel, the leaf's facing its lobe's (painterly) or its own (cards); far
253
+ off, once a dab.
254
+
255
+ **Moss.** The wood takes moss where it holds the wet: on what faces up (a
256
+ limb's top), low on the trunk, in the grooves between its buttresses
257
+ (where the surface swells less than round), more on its side away from
258
+ the sun, and never on twigs; `moss` says how much, and a species' bark
259
+ how much it takes (none on a palm, less on pale peeling bark). Painted, it
260
+ is a flat soft green; on furrowed bark, darker and in patches, in the
261
+ furrows first. A few operations a pixel.
262
+
263
+ **Far leaves.** Drawn with alpha to coverage, a far crown thinned away to a
264
+ lace. Each smaller picture (mip) of an atlas, averaged from the one before,
265
+ keeps the alpha's mean but not how much of a mark is over its cut: a
266
+ thin leaf averaged down is a pixel mostly not there, and two overlapping
267
+ leaves of the same soft alpha get the same samples, so a far crown of them
268
+ shows the sky through. The atlases' mips are made here (`mips.ts`), each
269
+ cell's alpha scaled so as much of it lies at or over the cut as at full
270
+ size (Castaño 2010), and the shader sharpens every mark at the cut over a
271
+ pixel: a far leaf covers its pixels as a near one does, and overlapping
272
+ leaves add up. A painterly bough's mips go further, closing towards its
273
+ outline with distance (a needled bough far off is a bough's shape, as a
274
+ painter's far masses are, not a lace of needles).
275
+
276
+ **Cost**, the grove (400 trees) on this Mac at 2800 x 1800, 4x MSAA, the
277
+ least of four runs, graphics card's time for the whole frame: painted 1.8
278
+ ms in the clearing and 1.3 ms from outside, painterly 3.4 and 2.1,
279
+ sculpted 3.5 and 2.1, real 3.0 and 2.3. The same pieces in every look but
280
+ the realistic one; the painterly and sculpted looks' dabs are larger
281
+ (`dabScale` 1.4 and 1.5), which is most of their cost, and their lobe is
282
+ found by a search over the crown's lobes in the vertex shader. A sheet is
283
+ lit by its own lobe, with no search: it faces as its bough does, and the
284
+ search for each of a sheet's twelve vertices was most of what a conifer
285
+ cost.
286
+
287
+ Boughs as sheets, the light through and the far leaves, measured against
288
+ the drawing before them at 1780 x 1868 (the least of two runs each,
289
+ interleaved; this Mac is shared): the grove of 400 spruces, painterly,
290
+ 1.54 to 1.76 ms in the clearing and 2.18 to 2.55 from outside; realistic,
291
+ where sheets replace cards, 1.67 to 1.32 and 2.46 to 1.97. The course's
292
+ 30,000 trees of 30 species, painterly, 0.1 to 0.25 ms more of 3 to 5;
293
+ realistic, 0.1 to 0.5 ms less. Anisotropic filtering is the painterly
294
+ sheets' alone: on the realistic atlas, which every card samples, it cost
295
+ 0.25 ms of the grove for little to see.
296
+
297
+ ## Species
298
+
299
+ `STARTER_SPECIES` are six trees of a temperate course; `MORE_SPECIES` adds
300
+ rows by the regions Couch Golf Club's courses are in, keyed by a short id
301
+ (`MORE_SPECIES.stonePine`); `ALL_SPECIES` is both. A row's size is a typical
302
+ open-grown tree of its kind on a course or in a park there (not a forest
303
+ record), with its source named over the row in `species.ts`; a tree's own
304
+ measured size replaces it. `regions` are from `REGION_ROWS`: california,
305
+ pacific-northwest, great-britain, france, ontario, netherlands, denmark.
306
+
307
+ A row's size is one specimen, and may be retuned to look right. What its
308
+ real trees are documented to be is apart from it: `crownRatio`, crown radius
309
+ over height, and `baseRatio`, crown base over height, each [least, most]
310
+ from drawn up in a stand to open-grown (docs/MORPHOLOGY.md: Tallo's lower
311
+ quartile at 10–18 m for the stand, the open-grown figures and photographed
312
+ outlines for the open), with their sources over each; and `heightRange`,
313
+ [typical, most] in metres, the low end of the height its grown trees commonly
314
+ reach and the most the sources give for the species (every row has one, so a
315
+ host can tell a 27 m tree is not a 20 m palm). A host that tells
316
+ which species a measured tree is matches it against these, so a showpiece
317
+ retuned does not change which trees a course has. Rows no source gives
318
+ proportions for leave them out (gorse and the generic shrub; the California
319
+ fan and queen palms' crown base), and a host has only the specimen's.
320
+
321
+ | Name | Latin | Look | Regions | Height (m) | Crown radius (m) | Crown base (m) |
322
+ | --- | --- | --- | --- | ---: | ---: | ---: |
323
+ | Oak | *Quercus robur* | a broad dome, wider than tall, on crooked limbs | great-britain, france, netherlands, denmark | 17 | 11 | 2.5 |
324
+ | Plane | *Platanus × hispanica* | a big full oval, pale mottled bark | france, great-britain, netherlands, california | 22 | 10 | 3 |
325
+ | Eucalyptus | *Eucalyptus globulus* | an upright, open, irregular crown of hanging bunches on a few ascending pale limbs | california | 26 | 8.5 | 7.5 |
326
+ | Spruce | *Picea abies* | a dark cone, boughs hanging to the ground | denmark, netherlands, ontario | 20 | 5.8 | 1 |
327
+ | Scots pine | *Pinus sylvestris* | a flat lopsided top on a tall orange trunk | great-britain, denmark, netherlands | 19 | 8 | 9 |
328
+ | Shrub | (generic) | a dense mound of small leaves | california, pacific-northwest, great-britain, france, ontario, netherlands, denmark | 2.4 | 1.6 | 0.1 |
329
+ | Beech | *Fagus sylvatica* | a dense dome, smooth grey bark | denmark, great-britain, netherlands, france | 20 | 8 | 2.5 |
330
+ | Silver birch | *Betula pendula* | a narrow open oval of drooping tresses, white bark | great-britain, denmark, netherlands | 15 | 3.5 | 3 |
331
+ | Black alder | *Alnus glutinosa* | a dark cone-to-oval on a leader, by water | denmark, netherlands, france | 15 | 4 | 2.5 |
332
+ | Lombardy poplar | *Populus nigra 'Italica'* | a narrow column | france, netherlands | 22 | 2.5 | 2 |
333
+ | Weeping willow | *Salix × sepulcralis* | a broad mound of hanging curtains, nearly to the ground, yellow-green | france, denmark, netherlands | 11 | 7.5 | 1 |
334
+ | Hawthorn | *Crataegus monogyna* | a small crooked tree, dense and dark | great-britain, denmark, netherlands, france | 6 | 3 | 1.2 |
335
+ | Gorse | *Ulex europaeus* | a dense dark spiny heath shrub | great-britain, denmark, netherlands | 1.6 | 1 | 0.15 |
336
+ | Sitka spruce | *Picea sitchensis* | a big blue-green cone | denmark, pacific-northwest | 28 | 4.5 | 1.5 |
337
+ | Corsican pine | *Pinus nigra* | a dark pine of level whorls, its top blunt | netherlands, denmark, france, great-britain | 18 | 4.5 | 5 |
338
+ | Douglas fir | *Pseudotsuga menziesii* | a tall, somewhat open cone | pacific-northwest, denmark | 30 | 5 | 3 |
339
+ | Western red cedar | *Thuja plicata* | a cone of drooping sprays, red bark | pacific-northwest | 20 | 4.5 | 1 |
340
+ | Monterey cypress | *Hesperocyparis macrocarpa* | a wind-shaped flat top on a few great limbs | california | 18 | 7 | 3 |
341
+ | Monterey pine | *Pinus radiata* | a heavy, lumpy rounded crown going flat, dark green | california | 20 | 7.5 | 4 |
342
+ | Torrey pine | *Pinus torreyana* | an open crooked crown, long grey-green needles | california | 15 | 5.5 | 4 |
343
+ | Aleppo pine | *Pinus halepensis* | an irregular open crown, grey-green | california, france | 15 | 6.5 | 3 |
344
+ | Stone pine | *Pinus pinea* | a flat umbrella of dense cushions on a stem forked into rising limbs | california, france | 15 | 11.5 | 8 |
345
+ | Canary date palm | *Phoenix canariensis* | a big round head of arching fronds on a thick trunk | california | 15 | 5 | 7 |
346
+ | Mexican fan palm | *Washingtonia robusta* | a tall thin pole flared at its foot, a small tight head of fan leaves | california | 22 | 2.2 | 18 |
347
+ | California fan palm | *Washingtonia filifera* | a stout grey column, a head of grey-green fans; in the wild a skirt of dead leaves to the ground | california | 12 | 3 | 7.5 |
348
+ | Queen palm | *Syagrus romanzoffiana* | a smooth grey ringed pole, a few soft plumose fronds arching over | california | 10 | 3.2 | 5.5 |
349
+ | Coast live oak | *Quercus agrifolia* | a low, broad, dark evergreen dome | california | 11 | 8.5 | 1.8 |
350
+ | California sycamore | *Platanus racemosa* | open and crooked, pale bark | california | 18 | 7 | 3.5 |
351
+ | Sugar maple | *Acer saccharum* | a dense oval | ontario | 20 | 6.5 | 3 |
352
+ | Red oak | *Quercus rubra* | a rounded crown on a few big limbs | ontario, denmark, netherlands | 20 | 8 | 3 |
353
+ | Eastern white pine | *Pinus strobus* | tiers of level boughs, soft blue-green | ontario | 22 | 5.5 | 3 |
354
+ | White spruce | *Picea glauca* | a narrow blue-green cone | ontario | 16 | 2.8 | 0.8 |
355
+ | Ash | *Fraxinus excelsior* | a tall airy dome of ascending limbs and pinnate leaves | great-britain, france, netherlands, denmark | 20 | 8 | 3.5 |
356
+ | Sycamore maple | *Acer pseudoplatanus* | a broad dense dome, flaking pale-patched bark | great-britain, france, netherlands, denmark | 20 | 8.5 | 2.5 |
357
+ | White willow | *Salix alba* | a broad upswept crown of silvery grey-green leaves, often leaning | france, netherlands, denmark, great-britain | 18 | 6.5 | 2.5 |
358
+ | European larch | *Larix decidua* | an open light-green cone of drooping boughs with upturned tips | great-britain, denmark | 26 | 5.5 | 3 |
359
+ | Small-leaved lime | *Tilia cordata* | a dense, taller oval dome | great-britain, france, netherlands, denmark | 22 | 6 | 2.5 |
360
+ | Western hemlock | *Tsuga heterophylla* | a narrow dark cone of drooping branch tips | pacific-northwest | 28 | 4.8 | 1.5 |
361
+ | Red alder | *Alnus rubra* | a narrow dome on pale mottled grey bark | pacific-northwest | 20 | 5 | 3 |
362
+ | Norway maple | *Acer platanoides* | a dense round crown of bright green palmate leaves | denmark, france, netherlands | 18 | 7 | 2.5 |
363
+ | Hornbeam | *Carpinus betulus* | a dense oval dome on a fluted steel-grey trunk | great-britain, france, netherlands, denmark | 16 | 6.5 | 2 |
364
+ | Aspen | *Populus tremula* | a narrow open crown on pale grey-green bark | denmark, great-britain, netherlands | 18 | 4.5 | 4.5 |
365
+ | Sea buckthorn | *Hippophae rhamnoides* | a thorny silvery narrow-leaved coastal shrub | netherlands, denmark, great-britain | 3.2 | 2 | 0.15 |
366
+ | Elder | *Sambucus nigra* | a large arching shrub of pinnate leaves | great-britain, france, netherlands, denmark | 4.5 | 2.6 | 0.3 |
367
+ | Scotch broom | *Cytisus scoparius* | a bushy shrub of slender green whippy stems | great-britain, france, netherlands, denmark, pacific-northwest | 1.8 | 1 | 0.1 |
368
+ | Blackthorn | *Prunus spinosa* | a dense dark thorny thicket shrub | great-britain, france, netherlands, denmark | 3.2 | 2 | 0.15 |
369
+
370
+ The oak's, the Scots pine's, the spruce's, the Aleppo pine's and the stone
371
+ pine's proportions (crown reach and base for height) and outlines are
372
+ measured from photographs of open-grown trees (`test/outlines.json`; each
373
+ grows within 12% of its photograph's outline, `test/outline.test.ts`). An
374
+ old pine has given up its leader: the Scots, Torrey, Aleppo, Monterey and
375
+ stone pines are grown as broadleaves, with needles. A stone pine's stem, sinuous
376
+ or leaning a little as it is crooked, forks a third of the way up (`fork`, a share
377
+ of its crown's base, each tree a little higher or lower: `forkSpread`) into two or
378
+ three thick crooked stems (`forkStems` to `forkStemsMost`, each tree its own; the stem's wood
379
+ shared among them by the pipe model, each half or more its thickness), each of which
380
+ divides twice more in V-forks (`forkSplits`), rising and then leaning out further at
381
+ each, their last arms the limbs that reach out under the umbrella: the dark fan of
382
+ limbs under its canopy. A V-fork's two arms share what the crown gives them by the
383
+ light each gathers, neither favoured. Its crown is some three times as wide as deep
384
+ and flat on top (`test/pines.test.ts`); its outline test still reads the Roquebrune
385
+ photograph, whose low left is another tree behind it. Grown narrow in a wood (a crown
386
+ less than a third as wide as deep) its limbs leave its stem one by one, as any tree's.
387
+
388
+ A crown's outline is its `shape`'s, made round (`CROWN_OUTLINES`): widest
389
+ some way up, upright there, curving in above and below. `crownPeak` (0..1)
390
+ says how far up the crown it is widest and `crownRound` how round it is
391
+ above that (the exponent of a superellipse: 1 a cone, 2 an ellipse, 3 or
392
+ more a flat top; Rautiainen et al. 2008 measured 1.35 for Scots pine and
393
+ 1.42 for Norway spruce), over the shape's own; `lobes` (0..1) makes it
394
+ lumpy, bulging out in a few directions and falling back between. A
395
+ broadleaf's `scaffolds` are its great limbs (4, and one more for every
396
+ third of `leader`, if left out), and `shed` (0..1) how readily it drops its
397
+ shaded branches (from `openness` and `branchiness` if left out).
398
+
399
+ A palm (`architecture: "palm"`) is grown as a palm (`palm.ts`; see *Palms*).
400
+ A broadleaf or a shrub that
401
+ weeps (`weep`, 0..1) hangs whips from that share of its outer twigs and of
402
+ the tops of its upper limbs' arches: a short arch out, then straight down to
403
+ as low as the crown's base, leaved all along and over its arch (the willow's
404
+ curtain, the birch's tresses). Past the crown's outline a whip goes no
405
+ further out and turns down the sooner; drawn back in to it, a whip arching
406
+ out of the crown's narrow top turned back on itself, a loop of wire over the
407
+ crown. A crown that weeps half or more (a willow's) has its top clothed: once
408
+ it is thinned and fitted, every piece of wood in its upper half that no
409
+ clump's core lies over gets a whip's spray over it, the highest first, so no
410
+ bare limb stands over its dome of leaves in any variant a course grows
411
+ (`test/weep.test.ts`); the realistic look's sprays there spring from as high
412
+ as their clump is hung (`FixedCards.lift`), not from the wood under it.
413
+
414
+ What the grower cannot do yet, so those rows come as close as their data
415
+ allows: several trunks from one foot (a sycamore's, a coast live oak's). A
416
+ species may lean (`lean`: the trunk leans from its foot and turns upright near its
417
+ crown's base, so the crown stands over its foot; the Torrey pine's, the California sycamore's), and a
418
+ host leans a tree at most 3 degrees besides.
419
+
420
+ ## Palms
421
+
422
+ A palm is a monocot: it does not branch. Its one stem grows from one tip, as
423
+ thick at its top as near its foot (a fan palm's tapers a little and swells at
424
+ its foot, `buttress`), and its crown is its leaves: `whorl` green fronds set
425
+ round that tip one after another by the golden angle (137.5 degrees), each
426
+ standing as its age has it. The pale unopened spear stands upright in the
427
+ middle, the young leaves rise, the mature ones arch out, the old droop, and the
428
+ dead hang against the stem. So a palm is not grown as the other trees are
429
+ (`palm.ts`, beside the grower): each frond is laid out as data the drawing reads
430
+ directly (its rachis, the frame of its leaf along it, its length, width, age
431
+ and colour), and the crown is fitted to the tree's envelope (its height, its
432
+ crown's radius and base, what a ball meets) by how long its fronds are and how
433
+ far they droop together: a crown wider than deep holds its leaves flatter, a
434
+ deep narrow one lets them hang. Its leaves are kept near its kind's size (within
435
+ a fifth of its specimen's, a young palm's a little smaller), whatever head a
436
+ survey hands over: a Mexican fan palm's head measured 1.4 m round had fans a
437
+ third of their size, a feather duster, and one 4.7 m round leaves half as long
438
+ again. A head too narrow for them holds them up, and a skinned fan palm's that
439
+ narrow (under 0.6 of its specimen's reach) is cut hard, its hanging leaves gone,
440
+ as an over-pruned course palm is.
441
+
442
+ - **Leaves** (`palmLeaf`): a feather palm's frond is a ribbon along its
443
+ rachis, folded up in a V (`fold`, a Canary palm's stiff leaflets), a queen
444
+ palm's (`plumose`) a second, drooping rank under it, its leaflets in
445
+ several planes; a fan palm's is a pleated fan at the end of a long stalk,
446
+ folded up along its costa, its segments split past the middle and drooping
447
+ at their tips (`fanDroop`). Their pictures are whole leaves, one atlas for
448
+ all palms (`palmAtlas.ts`): AI-generated photographs for the realistic look,
449
+ painted ones for the others, drawn ones until they come; each picture's
450
+ light and shade over the frond's own colour (its species' green, paler when
451
+ young, going to `deadColor`).
452
+ - **Pruning** (`pruning`, by species, or by tree: `TreeInstance.pruning`, or
453
+ `prunings` beside a packed list): `natural`, every leaf it has, the dead
454
+ hanging under the green (a fan palm's skirt as far down its stem as `skirt`
455
+ says); `skirt`, cut back to a short skirt; `skinned`, the dead and drooping
456
+ leaves cut and its stem cleaned, a collar of boots (old leaf bases) left
457
+ under a fan palm's crown, its leaves' feet down its top 2 m round it (a head
458
+ too shallow for its leaves to hang, less deep than 1.4 of its radius, may
459
+ lose its lowest green ones instead of having them all shortened); `pineapple`, cut back to the leaves above the level,
460
+ its leaf bases trimmed into a ball under the crown. Left out, as courses keep
461
+ them: a Canary palm pineapple cut, the others skinned. Trees kept otherwise
462
+ than their species are their own variants.
463
+ - **Drawn**: near, every frond in twelve pieces and every fan in nineteen
464
+ rays; mid, five and nine; far, two and five, a star of fronds round the
465
+ stem. A fan's blade is turned on its own about its line, so across the crown
466
+ and from below many stand edge-on, its stalk a spoke from the stem. Further
467
+ off (mid, far, and a near fan under about 40 pixels across) a fan is drawn as
468
+ a starburst of a few broad segments in its photograph's colours: its
469
+ photograph mipped down to a few pixels was a disc, and a crown of discs a
470
+ lettuce. A near fan goes over to its starburst whole, between 40 and 22
471
+ pixels, each fan at a size of its own: gone over pixel by pixel, half of a
472
+ fan's pixels its photograph and half its thin starburst, a California fan
473
+ palm's crown from the tee was a speckled lace. A skirt, near, is shingles of dead leaves round the stem, each row
474
+ half over the one below; mid and far, one continuous thatch from under the
475
+ crown to its ragged foot. It is carrot-shaped: its shoulder, tucked under
476
+ the hanging green leaves, flares about as wide as they reach, then it tapers
477
+ steadily to a narrow foot. Its top metre or two is freshly dead, tan to
478
+ ochre; below, weathered pale silvery grey-beige. A skirt cut back short is
479
+ all fresh, a brown tuft under the green. A fan palm's leaves are glossy. The stem wears its bark (a Canary palm's lattice, a fan
480
+ palm's rings), its boots and a pineapple's trimmed bases; where the look
481
+ paints bark flat, their pattern is still drawn faintly. Its leaves' area is
482
+ its fronds' own, which its box of light takes (`GrownTree.leafArea`).
483
+ - **Tiers**: a palm's tier goes by its crown (twice the larger of its width
484
+ and depth), not its height: a 22 m fan palm's stem is a line, and by its
485
+ height it drew its near crown from 200 m off.
486
+ - **Wind**: the stem bends further than a tree's trunk and its crown follows a
487
+ moment late, the bend running up it; the crown tilts as the stem's top does.
488
+ Each frond streams downwind in the gusts, flaps and twists on its own beat
489
+ as its age lets it (a dead one swings freely, a spear hardly moves), and its
490
+ leaflets shimmer.
491
+ - **Cost**, a grove of 400 palms of one kind (graphics card's time for the
492
+ frame, before the palm grower and after): at 1104 x 1868, Canary palms,
493
+ realistic, 0.83 to 0.61 ms in the clearing and 1.15 to 0.97 from outside;
494
+ painterly 0.98 to 0.63 and 0.92 to 0.99. At 3456 x 1894, Mexican fan palms,
495
+ realistic, 1.18-1.37 to 1.23-1.38 ms in the clearing and 1.43-1.60 to
496
+ 1.53-1.60 from outside, with 38 leaves where it had 25, its trees drawn near
497
+ from outside 113 to 13.
498
+ - **The lab** keeps every palm one way (*Palms as kept*, *Natural*, *Skirt*,
499
+ *Skinned*, *Pineapple*; `?prune=`), to judge them by eye.
500
+
501
+ ## Species morphology
502
+
503
+ A tree is known first by its outline, and then, nearer, by how it is put
504
+ together: whether one stem runs to its top, at what angle its limbs leave
505
+ it, how they bend along their length, how its twigs run, where on them its
506
+ leaves are. Two trees of the same outline, one with a spruce's drooping
507
+ boughs that turn up at their tips and one with an oak's crooked limbs run
508
+ out level, are not mistaken for each other a hundred metres off. So each
509
+ species' row says these things too, and the grower grows them.
510
+
511
+ [`docs/MORPHOLOGY.md`](docs/MORPHOLOGY.md) is where the numbers come from:
512
+ for each species its form, branching, foliage, bark and the few traits it is
513
+ known by, every number tagged as read from a source (`[S:...]`, the sources
514
+ and their licences listed at its end), estimated (`[est.]`) or seen in the
515
+ field (`[obs.]`), and a table of what a grower needs. It is our own
516
+ synthesis, with citations; TALLO's measured crowns (Jucker et al. 2022,
517
+ CC BY 4.0) give each species' crown radius for its height in a forest.
518
+
519
+ What a row may say, over its `branchAngle` and `bend` (all left out, a row
520
+ grows as it did):
521
+
522
+ - **`limbAngle`** `[top, base]`: the angle its first-order limbs (a
523
+ broadleaf's great limbs, a conifer's boughs) leave the trunk at, at the top
524
+ of its crown and at its base, in degrees from upright. A Norway spruce's
525
+ top boughs rise and its low ones droop (`[45, 115]`); a white pine's stand
526
+ out at right angles below and rise above; a willow's main branches rise at
527
+ 40 to 45 degrees (Trees and Shrubs Online).
528
+ - **`limbCurve`** and **`limbCurveBack`**: how a limb turns along its length,
529
+ Weber and Penn's curve and curve-back: over its inner half, and over its
530
+ outer. A spruce's J-curved bough droops and turns up at its tip (-30, +50);
531
+ a Torrey pine's runs out level, dips and turns up into its candelabra (-10, +30); a
532
+ willow's rises and arches over (+5, -35); a Monterey cypress's rises,
533
+ elbows and runs level (-50).
534
+ - **`zigzag`**: how far a fine branch turns at each node where its tip died and
535
+ a side bud took the lead (sympodial growth: a plane's, a sycamore's
536
+ twigs, 25 degrees), or none (a maple's, whose terminal bud goes on). Grown
537
+ into the wood after it is smoothed, which would iron a zigzag flat.
538
+ - **`zigzagRun`**: how far a crooked tree's wood runs straight between elbows
539
+ (m): a California sycamore's limbs and branches turn, wander and seek the
540
+ light all at once at each elbow, rather than a little at every internode,
541
+ which drawn as a curve through its nodes was a wavy line hanging in the
542
+ gaps between its pads (`test/crooked.test.ts`: it turns back a fiftieth as
543
+ often a metre, its limbs as crooked).
544
+ - **`phyllotaxis`**: how its side buds are set round a shoot, by the golden
545
+ angle (most trees), opposite and crossed (a maple's: one of each pair
546
+ grown), or in two ranks in the shoot's plane (a beech's flat fans).
547
+ - **`sprayHang`**: how far a conifer's side shoots hang from their bough, from
548
+ a fir's flat spray to a Norway spruce's comb or a cedar's hanging sprays;
549
+ drawn as sheets, its boughs' edges fall in curtains as far again, more low
550
+ down, so a Norway spruce is a closed dark cone and not tiers of lace.
551
+ - **`canopyLift`**: how much of the crown's underside is cleared of leaves,
552
+ a bowl from its rim up into its middle, so its limbs show beneath it: a
553
+ stone pine's umbrella on its bare vase of limbs, a headland cypress's. Only an
554
+ open-grown crown: fitted narrower than 0.8 of its depth it is lifted less,
555
+ and not at all as a column (radius under 0.35 of its depth).
556
+ - **`fork`**, **`forkStems`**, **`forkSplits`**: where a broadleaf's stem divides
557
+ below its crown (a share of the crown's base), into how many stems (2 to 4),
558
+ and how many times each divides again in V-forks before its arms are limbs: a
559
+ stone pine's sinuous stem forked into a few thick crooked stems. Without
560
+ `forkSplits`, each stem is a trunk of its own with its share of the crown
561
+ (below).
562
+ - **`forkShare`**, **`forkSpread`**, **`forkStemsMost`**: the share of its
563
+ trees whose trunk forks, how far one tree's fork strays from `fork` (either
564
+ way, a share of the crown's base: from near the ground to under the crown),
565
+ and the most stems a fork has (`forkStems` the least). Each tree decides
566
+ from its own seed (`formOf`): a parkland oak's forked trunk, a coast live
567
+ oak's or a Monterey cypress's two or three leaning trunks from near the
568
+ ground.
569
+ - **`stemShare`**, **`stemRange`**: the share of its trees that grow as a
570
+ clump of a few stems from one root plate, and how many ([least, most], 2
571
+ to 4): a silver birch's or a black alder's stool, a eucalyptus's regrowth.
572
+ - **`pads`**: how far its leaves gather into flat-topped pads, each branch
573
+ off a great limb keeping only the leaves near its top, with air and bare
574
+ wood under each: a Monterey cypress on a headland, an old Scots pine's
575
+ plates, a Torrey pine's tufts on bare limbs. A small or narrow crown, lit
576
+ through, is in pads 0.9 at most.
577
+ - **`lean`**: how far a tree's trunk leans (degrees), grown so: from its foot,
578
+ holding most of its lean up its bole and turning upright near its crown's
579
+ base (or its fork), its crown grown upright from there, near over its foot,
580
+ each tree its own way (from its seed on a stream of its own, so a lean bends
581
+ the tree it is and grows no other): a Torrey pine's on the bluffs, a
582
+ California sycamore's. A tall bole under a narrow crown leans less (no further
583
+ aside than 0.3 of its crown's radius; a column, under 0.35 of its depth wide,
584
+ not at all), and none in a stand.
585
+ - **`clusters`**: how far its leaves gather into a few bunches hanging at its
586
+ branches' ends, with sky between them: each branch off a great limb keeps
587
+ its leaves only on its last shoots, the bunch bigger and hanging a little
588
+ under them, and a share of its branches bear none, their wood shed back to
589
+ the limb (a blue gum's pendulous clumps of sickle leaves). A small or narrow
590
+ crown, grown in a wood, has none: it is many sprays all through.
591
+ - **`buttress`**: how far its foot spreads into buttresses and flutes, more
592
+ of them and higher (a western red cedar's, a Sitka spruce's).
593
+
594
+ Two things follow from the row without a setting. A conifer that keeps its
595
+ leader and wears needles or scales (a spruce, a fir, a cedar) has a spire:
596
+ its leader clothed in needles all round over its last few metres, finer to
597
+ its tip, its last whorls' boughs short, so its top is a dense point and no
598
+ bare stick; drawn as sheets, round the leader, splayed out and up as a fir's
599
+ top shoots are (one crossed pair, mid). And a pine (`leafKind: "pine"`)
600
+ carries its needles as a pine does, in brushes at its shoots' ends, the
601
+ wood behind them bare, because a pine keeps its needles only on its last
602
+ few years' growth: its sprays are brushes on forked shoots (real), plates
603
+ of upright tufts held level (painterly), never a fir's flat combs, which
604
+ made a pine read as a fir.
605
+
606
+ What draws the eye as wrong first is wood with no leaves where a tree would
607
+ have them: a twig poking out of a conifer's needles. A conifer drawn in
608
+ sheets keeps a twig only where its needles lie close over it, and any twig
609
+ whose end its boughs' sheets still miss is given a sheet of its own along
610
+ it (`test/morphology.test.ts` holds every twig end under its sheets, near and
611
+ mid).
612
+
613
+ `test/morphology.test.ts` holds the species to the reference's numbers that
614
+ a grown tree can be measured for: the sourced ones within what measuring a
615
+ grown tree allows (a spruce's leader to its top and straight; a willow's
616
+ and a stone pine's limb angles; a white pine's boughs square to its stem
617
+ below and rising above; a coast live oak's limbs leaving a trunk of 1.2 to
618
+ 2.4 m and running out level; upper spruce boughs rising and lower ones
619
+ drooping; a plane's twigs zigzagging more than a maple's; every row's crown
620
+ wider for its height than TALLO's forest median, and grown at that median a
621
+ crown of many sprays in its box), and the estimated ones as soft walls,
622
+ with a margin, saying so (each species' limb angles, J-curves, whorls, open
623
+ crown ratios, the cypress's pads, the gorse's mound to the ground, the stone
624
+ pine's bare limbs under its umbrella).
625
+
626
+ ## The lab
627
+
628
+ From the workspace root:
629
+
630
+ ```bash
631
+ pnpm install
632
+ pnpm lab:trees
633
+ ```
634
+
635
+ The lab opens at <http://localhost:5173/lab/>. Drag to turn,
636
+ right-drag to move, the wheel to come nearer. The bar chooses what stands on
637
+ the ground (*One tree*, *Specimen*: one of each, *Grove*: 400, *Wood edge*:
638
+ a wood of some 1,400 trees, their undergrowth among them, seen across open
639
+ ground, *Course*: 30,000 over 2.4 km), the look (*Painted*, *Painterly*, *Sculpted*, *Real*,
640
+ each with its own style), the eye, the hour and the wind; *Envelope* draws each
641
+ tree's measured size over it (its crown's box, outline and ellipsoid, its
642
+ trunk), which is how one sees a drawn tree fills the numbers it was given.
643
+ The rail chooses a species; the inspector changes it (colours and light at
644
+ once, its form by growing it again) or the scene (style, detail, which
645
+ tiers show, how many variants). *Preset* is all of it as JSON; *Measure*
646
+ times the graphics card over fixed views. H puts the panels away, `[` and
647
+ `]` step the scenes. `?scene=`, `?look=`, `?species=`, `?hour=`, `?wind=`, `?day=`, `?eye=`
648
+ and `?fresh` (ignore what the lab kept) set it from the address.
649
+
650
+ ## The gallery
651
+
652
+ `/lab/gallery.html` (*Gallery* on the lab's bar) is where the trees are
653
+ judged by eye, and where one commit's trees are set beside another's. Every
654
+ species, in one look (or every look of one species), from the same five
655
+ views: the **tee** (side-on from 1.6 m, two and a half crown widths off, or
656
+ further if the tree would not fit), the **fairway** (one tree from 60 m),
657
+ **far** (a group of five from 150 m), **under the crown** looking up (at the
658
+ edge of a crown that comes down to the ground), and the **trunk** close, from
659
+ its foot to a little above its first fork. Same sun, wind and moment for
660
+ every cell, the package's own species and seeds: the same commit draws the
661
+ same pixels (`?seed=7`, or by species `?seed=Oak:9,Silver birch:7`, draws
662
+ another set: a forked trunk or a clump where the species has them). Beside
663
+ each species are its botanical name, its regions and the
664
+ links in `lab/REFERENCE.md` (with small copies the browser loads from
665
+ Wikimedia Commons; none is kept here).
666
+
667
+ One renderer off the page draws each cell into a small picture in turn. A
668
+ cell is a piece of a 1080-line, 50 degree screen: the piece the trees fill,
669
+ shrunk to fit the cell, never enlarged beyond the screen's own pixels; the
670
+ trees choose their tier as they would on that screen, and each cell's
671
+ caption says which tier drew them, from how far, at what field of view.
672
+
673
+ *Save set* downloads one contact sheet, named by the commit (and `-dirty`
674
+ when tracked files differ from it), the look, the hour and the wind:
675
+ `trees-9029955-painterly-h9-w4.png`. *Compare* takes two sheets and shows
676
+ them side by side, flickering, or as their difference (with how many pixels
677
+ differ). `?look=` (or `all` with `?one=`), `?species=`, `?region=`, `?kind=`,
678
+ `?views=`, `?hour=`, `?wind=`, `?day=`, `?cell=` (width in pixels), `?screen=` (lines)
679
+ and `?photos=<address>` (a photograph of your own per species,
680
+ `<address><name>.jpg`, from a folder you serve yourself) set it from the
681
+ address.
682
+
683
+ *Reference row* (`?refs=1`) sets each species under the owner's reference
684
+ pictures of it (`lab/references/`: AI-generated, not photographs, credited in
685
+ its `SOURCES.md`; a species with two trees of it, the stone pine, has two
686
+ rows), and draws ours from the views they were taken from, through a phone's
687
+ lens: the **tee** from 25 m at eye height and the **fairway** from 60 m,
688
+ landscape; **straight up** from a step beside the trunk, and the trunk's
689
+ **foot** from 3 m with its lower 2 m in the picture, upright. Their light is
690
+ the pictures' clear morning, the sun low on the left (8:00, mirrored: *Sun
691
+ left*, `?sun=left`, has it for any hour). These cells are drawn at the
692
+ screen's own pixels for their field of view and shrunk into the cell, as a
693
+ screenshot of the game is, so a pine's needles are mipped as a player sees
694
+ them. Only species with pictures are shown; the contact sheet has the
695
+ pictures' rows too, so `__gallery.save({ look: "real", refs: true, species:
696
+ ["Torrey pine"] })` writes a sheet of the pictures over ours.
697
+ `tools/references/build.mjs <folder>` makes the row's pictures (1024 pixels,
698
+ AVIF, 5.3 MB in all) and its `manifest.json` from the owner's originals,
699
+ which stay out of the repository; `test/referenceRow.test.ts` holds the
700
+ manifest to its files and the library's species.
701
+
702
+ *Course sizes* (`?fitted=1`, or `fitted: true` from a script) draws each
703
+ species at the sizes the game's courses give it (`lab/courseSizes.ts`: the
704
+ 10th, 50th and 90th percentiles of height, crown radius and crown base on
705
+ the first holes of Torrey Pines and Walton Heath and all of Riviera's,
706
+ measured in the game; for a species on none of them, a young and a typical
707
+ course tree), and Riviera's five broadleaves at the corners of its spread
708
+ (`cornersOf`: tall and narrow, tall with a low base, tall with a high base,
709
+ short and wide, and shallow),
710
+ under its specimen and its reference pictures, from the tee (25 m), from
711
+ 60 m and from the gallery's own tee (two and a half crown widths off), in
712
+ the reference pictures' light. A wood's species (Walton Heath's Scots pine
713
+ and birch) are drawn at a wood's edge too, their open side to the eye, and
714
+ a single tree the owner saw in the game (a stone pine of 12 m on a crown
715
+ 5.9 m round) has a row of its own.
716
+
717
+ For scripts: `await __gallery.render({ look, views, species, refs })` gives every
718
+ cell as a PNG data URL with the tiers drawn; `await __gallery.sheet({...})`
719
+ the contact sheet; and with the dev server started as
720
+ `GALLERY_OUT=<folder> pnpm dev`, `await __gallery.save({...})` writes the
721
+ sheet into that folder and returns where.
722
+
723
+ ## How a tree grows
724
+
725
+ `growTree(species, size, seed)` grows one tree, the same every time for the
726
+ same arguments, in plain arithmetic (no three), in 1 to 20 ms on this Mac.
727
+
728
+ 0. **Its crown, kept to its top where it is an umbrella pine's.** A stone
729
+ pine's crown (an umbrella's: a flat top, `crownRound` over 3, on limbs
730
+ that divide in V-forks, `forkSplits`) is never deeper than one and a half
731
+ of its radius, or three tenths of its height if that is more, up to 1.8
732
+ of its radius, its stem clean under it (`umbrellaCap`): drawn up in a wood or a planting, its
733
+ crown is "small and confined to the top", and a survey's crown base under
734
+ it is its neighbours' or a few low shoots. Fitted 20 m tall on a crown
735
+ from 3 m, its crown down the whole column was a tower of stacked
736
+ cushions. It keeps the size it was asked for, as a crown its stand has
737
+ lifted does, so the fit leaves its crown at its top.
738
+
739
+ **Its habit at its size** (`age.ts`). A species' row is its specimen, a
740
+ tree old enough to show all it comes to, and most trees a survey hands
741
+ over are smaller or narrower. So a broadleaf's row is taken as its own
742
+ size grows it: how young it is, by its height or its crown's reach beside
743
+ its specimen's, whichever is more (none at 0.8 of it, all at 0.3), fades
744
+ what comes with age: a flat or umbrella top rounds, its pads and its
745
+ blue gum's hanging bunches are fewer, it keeps its leader, its trunk is
746
+ not yet forked (a stone pine's V-forks) nor its underside lifted bare; and
747
+ how much narrower its crown is for its depth than its specimen's rounds a
748
+ flat top too, to a dome at half as wide (docs/MORPHOLOGY.md, *Young, old
749
+ and narrow trees*). A tree at its specimen's size grows exactly as its row
750
+ says; palms, whorled conifers and shrubs do at any size, and a weeping
751
+ tree weeps young.
752
+ 1. **The crown's outline**: the shape's profile (above), turned round the
753
+ trunk, `size.crownRadius` round, from `size.crownBase` to
754
+ `size.height`. Nothing grows out of it.
755
+ 2. **The trunk and its great limbs** (a broadleaf or a shrub). The trunk
756
+ rises bare to the crown's base. Its scaffolds leave it one to each slot
757
+ up the top part of it (a longer part the more it keeps its leader),
758
+ round it by the golden angle, the lowest leaving widest and the highest
759
+ steepest (as Weber and Penn set a tree's first branches): each turns up
760
+ or down by `bend`, arches over by its weight, wanders by `crooked`, and
761
+ reaches out to the outline. The trunk goes on up the crown as its leader,
762
+ all the way if `leader` is 1. A shrub's stems, leaning out from feet
763
+ spread within a third of the crown, are its scaffolds.
764
+
765
+ A tree whose trunk forks, or that grows as a clump, is decided by its own
766
+ seed (`formOf`: its species' `forkShare` and `stemShare`; in a closed wood
767
+ fewer, and those that fork do so higher, its stem drawn up). Its trunk
768
+ rises from one root plate to where its stems part (a clump's a little
769
+ over its root flare; a fork's where its form says, never under its root
770
+ plate nor within a fork's first piece of breast height). There they stand
771
+ side by side, each stepping out to its own side so its outer bark runs on
772
+ from the trunk's, and lean apart, eased in over a few trunk radii (a trunk
773
+ bent harder than its thickness folds over on itself), then turn up: an
774
+ excurrent tree's stems nearly upright, a decurrent one's leaning out to
775
+ some 38 degrees. Each is a tree's stem of its own: its leader rises to the
776
+ middle of its share of the crown, its great limbs (`scaffolds`, shared out)
777
+ leave it round its own side, and its wood keeps to its share (the part of
778
+ the crown nearer its share's middle than another's, by a little): one
779
+ crown, the stems' parts touching, not crowns heaped into a blob. The light
780
+ at a fork is shared by what each stem gathers, neither favoured. Their
781
+ radii: each stem a bole of its own, its area at the fork its share of the
782
+ trunk's (Leonardo, Δ 2), swelling a little into the trunk where it leaves
783
+ it; under breast height the stems' areas there together are the size's
784
+ `trunkRadius` (a clump's basal area), over it the trunk is measured there
785
+ as one stem is. The fit to the size keeps the fork where it grew.
786
+ `stemsAt(tree, y)` gives where its wood crosses a height and how thick:
787
+ at 1 m, a forked tree's stems for a host's colliders.
788
+ 3. **Growing from buds, in the light** (Palubicki et al. 2009, made light),
789
+ eleven cycles of: every bud's light, from how much wood above shades its
790
+ voxel (each node shades a pyramid under it); that light gathered down to
791
+ the foot and handed back up as what to grow with, at each fork more to
792
+ the main axis than to the lateral (Borchert and Honda's model, its
793
+ leaning from `leader`), a scaffold as much as its trunk; each bud growing
794
+ as many internodes as it is given, turned towards the least shadow it
795
+ sees and up or down by `bend` (a shoot keeps some of its last
796
+ internode's turn into the next, so it bends over several and does not
797
+ zigzag), with a lateral bud at every internode by the golden angle at
798
+ `branchAngle`; and every branch that gathers too
799
+ little light for its wood shed (`shed`). So the crown is a shell of lit
800
+ shoots on bare, branching limbs, its inside shed as it shades.
801
+ 4. **Leaves** hang in clumps on the lit shoots near their twigs' ends (the
802
+ deeper the species keeps its leaves, `foliageDepth`, the further back),
803
+ bigger the more light they have, and never more than a fifth of the
804
+ crown's radius round (a crown grown narrow in a wood is many sprays, not
805
+ a few balls on a stick; a column, narrower than 0.35 of its depth, a sixth).
806
+ A crown narrower for its height than its specimen's has its clumps smaller
807
+ by as much (to 0.6 of what its height gives them, at the least): as many of
808
+ its sprays across it as its specimen has, not its specimen's few big ones
809
+ crowded in (a stone pine of 12 m on a crown half its specimen's width was a
810
+ tower of four or five big cushions stacked); but a crown of bunches
811
+ (`clusters`, a blue gum's) keeps its bunches' size, fewer across a narrower
812
+ crown, and keeps them in a narrow crown three quarters as much, with sky
813
+ between them (`CLUMP_BUNCHED`, `CLUSTER_NARROW`): a blue gum 26 m tall on a
814
+ crown 3 to 5 m round is drawn up, not young, an open crown of a few heavy
815
+ ascending limbs hung with bunches; of small sprays all through, it was a mop
816
+ on a pole. A broadleaf's clumps are no more than 0.15 of its crown's depth
817
+ (`CLUMP_OF_DEPTH`; a flat-topped kind's cushions and pads excepted): a blue
818
+ gum's crown 2.6 m deep and 10 m across was one sheet of clumps, a lid. A column's leaves are in pads
819
+ at most 0.4 (`pads`): its sky comes from round it as much as from above,
820
+ and a Scots pine drawn up in a wood kept in its old plates was a pagoda of
821
+ balls up its stem.
822
+ 5. **The wood made good**: where an axis's tip died and the shoot below it
823
+ took the lead, that shoot turned part way back to where the axis ran (a
824
+ twig of such corners is a zigzag); then smoothed (twice, forks held),
825
+ bowed by its weight (thin wood more, `bend` down more), and its straight
826
+ runs joined into single pieces. A tree that weeps then hangs its whips.
827
+ 6. **Conifers** grow whorl by whorl instead: a leader to the top and
828
+ `whorl` boughs to each of `whorlsPerMetre` (closer in a narrow crown,
829
+ for its interwhorl branches), each as long as the outline
830
+ lets it be (some missing, some broken short), with side shoots along
831
+ their leafy parts; then smoothed and bowed. **Palms** grow a head of
832
+ fronds on one stem.
833
+ 7. **Dead twigs dropped**: once crowding clumps are thinned, every twig
834
+ that neither bears a clump, nor lies inside one, nor leads to one is
835
+ shed back to the wood that does. So no twig ends bare, and every clump
836
+ has wood leading to it (`test/borne.test.ts`). Wood that strays out of
837
+ the tree's space is shed too: past its reach, or hanging down below its
838
+ crown's base. A forked trunk's or a clump's stems are trunks all the way
839
+ up their leaders, and a limb that leaves a stem low and rises into the
840
+ crown is kept: shed as strays, a Monterey cypress forked low was a bare
841
+ stump. A crown under 1.5 m round, or under four of its trunk's radii, is
842
+ one stem's (`FORK_ROOM_R`): a blue gum's two stems under a crown 1 m
843
+ round leaned out of it. A V-forked stem's arms reach no further out than
844
+ its crown's inside leaves room for, and rise no higher than into its
845
+ crown, however steep its narrow crown holds them (a stone pine with a
846
+ short crown on a tall stem had grown its limbs above its crown, and no
847
+ leaves). A leaning kind (`lean`, a sycamore's) leans at least half as far
848
+ under a narrow crown, and its forked stems bow as crooked as it is.
849
+ 8. **Fitted to its size**: across so its leaves reach the crown radius, up
850
+ so they reach its height and come down to its crown's base, and drawn in
851
+ to the outline where that moved them out of it. The growing aims at all
852
+ of it, so this is a few percent: up to a tenth across, and more up only
853
+ for a tall narrow crown that did not grow to its top.
854
+ 9. **The wood's thickness** from the pipe model (Shinozaki et al. 1964): a
855
+ branch's cross-section to the 2.4 carries all the twigs beyond it, the
856
+ branches it has shed and the pipes its own length has outlived, so at a
857
+ fork d^Δ = Σ dᵢ^Δ with Δ near 2.1 (measured trees: 1.8 to 2.3, Eloy
858
+ 2011). A bole under a crown that starts above breast height has a taper
859
+ of its own instead: its radius goes as the length of stem above it to
860
+ the 0.6 (between a cone and a paraboloid, as measured boles are), with
861
+ its roots flaring at its foot, at its measured radius at breast height;
862
+ the crown's wood is scaled to meet it where the crown starts. (The pipe
863
+ model alone, reckoned in a small crown's short internodes, swelled a
864
+ long clean bole to many times its top's thickness: a thread under the
865
+ crown.) A species that keeps them (`boleStubs`: birch, oak, alder) has
866
+ dead stubs along a long bole, more just under the crown.
867
+
868
+ `test/structure.test.ts` holds the wood to what measured trees are: every
869
+ species' forks to Leonardo's rule, a broadleaf's great limbs straight
870
+ enough (path over chord) and few, and the Scots pine's and the spruce's
871
+ upper crowns to Rautiainen's exponents.
872
+
873
+ ## How a course's trees are drawn
874
+
875
+ - **A few are grown.** Each species' trees are sorted by where they stand
876
+ (in the open, at a wood's edge, inside a wood: see *Where a tree
877
+ stands*), then into shapes, as many as it takes for every tree to be
878
+ fitted from a variant of nearly its own shape (`VariantOptions.stretch`,
879
+ `FIT_STRETCH`): its crown no more than 1.3 times deeper or shallower for
880
+ its width than its variant's, scaled as a whole no more than 1.3 to the
881
+ 2.5 (1.9), its trunk beside its crown no more than 1.3 cubed (2.2) (and,
882
+ in a wood, its closeness within a quarter). A tree's size counts: its
883
+ habit changes with it, so a 14 m Torrey pine is not a 4 m one's young
884
+ habit stretched. Two shapes at the fewest (`shapes`), twelve at the most
885
+ for each way of standing (`mostShapes`), a palm's two: a palm takes many
886
+ times a broadleaf's time to grow, and its head is its fronds whatever its
887
+ crown's numbers. Each shape is grown once a seed (up to two by default,
888
+ one more for every eight of its trees, `SEED_TREES`; and in a class of
889
+ many shapes about as many trees grown as its fewest shapes would have
890
+ with all their seeds, one a shape at the least: its shapes vary it), at the shape's
891
+ size (see *How a tree grows*), in the light its trees' neighbours leave
892
+ them. Leaves hang in clumps at the twigs, never in the air. A species
893
+ whose trees differ in form at the foot (`forkShare`, `stemShare`) is grown
894
+ from up to three seeds a shape (one for every three of its trees,
895
+ `FORM_TREES`), each seed chosen so the shape's variants, and the shapes,
896
+ are spread over its forms by their shares (`FORM_SEEDS`): a stand of
897
+ twelve shows its forked trunks and clumps among its single stems, not two
898
+ seeds that both came up one stem. `VariantOptions.seed` grows another set
899
+ of the same shapes (the gallery's `?seed=`, by species).
900
+
901
+ Sorted into two shapes by how wide and how high, Riviera's trees (eucalyptus
902
+ 4.7 to 26 m tall on crowns 1 to 5.3 m round, its crown bases 2 to 13.5 m)
903
+ were fitted from variants grown 8 m tall, some stretched six times as far up
904
+ as across. A tree's clumps keep their size as it is stretched (the mean of
905
+ its stretches) while the spaces between them and the wood under them
906
+ stretch, so a Monterey cypress's pads were drawn apart up its crown, each on
907
+ a bare spike, the top of its crown floating over them; a stone pine of 33 m
908
+ was its 12 m variant's cushions stacked into a tower; a blue gum's crown was
909
+ squashed to a thin lid, its limbs pressed into loops. On Riviera's 1st hole
910
+ that is 102 variants where there were 83 (`node tools/cost/course.ts c01`),
911
+ each of its shapes grown about once; the trees' frame costs the same (the
912
+ counter's near tier 0.47 to 0.45 ms), and with the growing and laying made
913
+ faster (the same trees to the bit), making them takes no longer than before:
914
+ `createTrees` for its 1st hole 3.5 to 3.2 s painted, 4.1 to 3.5 s
915
+ realistic; for its 5th, 3.5 to 3.7 s and 4.2 to 3.9 s (this Mac, in the
916
+ browser). `stretch` and `mostShapes` trade the fit against the time.
917
+ - **Every tree is fitted to its own numbers.** Up the tree in two
918
+ stretches (the trunk to its crown's base, the crown to its top), across
919
+ to its crown radius, and the wood thickened to its trunk radius apart
920
+ from where it runs. So a drawn tree fills the space its numbers give,
921
+ which is what a ball hitting it meets. It is then turned, maybe mirrored,
922
+ leant up to 3 degrees and tinted. An edge tree is turned so its open side
923
+ faces its own open ground (give or take 17 degrees), and leans that way.
924
+ - **Four distant modes, selectable per frame (`detail.farMode`)**:
925
+ - `dabs`: the classic 16 gathered dabs and trunk stroke;
926
+ - `impostor`: GPU-baked hemi-octahedral G-buffer impostors (`impostor.ts`: 8×8 views per variant, premultiplied albedo + octahedral normal + depth + sky AO, 3-view simplex blending with depth parallax, dynamically relit across all four looks in a single indirect draw call);
927
+ - `hybrid` (default): 4-tier transition (`near` → `mid` → `far` dabs → `impostor` below `detail.impostorPx`);
928
+ - `splat`: compute-driven `atomicMax` software visibility buffer (`visibility.ts`) resolved with hardware `depthNode` for zero-overdraw sub-pixel distant forests.
929
+ - **GPU Hi-Z occlusion culling (`detail.occlusion`)**: `off`, `canopy` (zero-setup compute splat of dense crown cores into a 256×128 conservative `min` pyramid), or `depth` (downsampling an external scene `DepthTexture` handed to `trees.setDepthTexture`).
930
+ - **Stochastic vertical bark tiling (`detail.stochasticBark`)**: breaks periodic tile seams along tall trunks in the `real` look (live boolean toggle, `true` by default).
931
+ - **Physically based atmosphere (`createAtmosphere`) & biome scatterer (`scatterTrees`, `createGpuScatter`)**: Rayleigh + Mie + ozone Sky-View LUT and height-integrated aerial perspective wired into `world.air`, plus deterministic CPU and WebGPU compute biome scattering. Every SOTA technique can also be toggled or tuned live in the Tree Lab (`Techniques (SOTA)` panel, `Hills` scene, and URL parameters).
932
+ tree in view on the list of the tier its size in the picture calls for:
933
+ near (all its wood, down to the twigs, and three dabs to a clump of
934
+ leaves, one more over any of its twigs they leave out; a clump finer than
935
+ its kind's, a narrow or young crown's, fewer and bigger, by its area, so a
936
+ crown's near dabs follow the crown and not how finely it is divided:
937
+ `GrownTree.clumpShare`, `dabsOf`), mid (its limbs
938
+ and branches, its clumps gathered into at most 56 broad dabs), far (16
939
+ dabs and a stroke for its trunk). A conifer's boughs, near and mid, are
940
+ sheets (see *Boughs*). Each tier is one mesh holding every variant, drawn
941
+ once per variant by an indirect draw for as many trees as are on its
942
+ list: nothing out of view costs a vertex. A tree passing between tiers is
943
+ drawn by both, each in the pixels the other leaves; the realistic look's
944
+ leaves piece by piece instead, each card, dab or sheet growing in or
945
+ shrinking away by a number of its own as the other tier's do the
946
+ opposite (`pieceShare`): the two tiers' leaves do not lie in the same
947
+ places, and handed over pixel by pixel they were a speckle of sky inside
948
+ the crown and of leaves outside it over the whole hand-over.
949
+ - **The wood is drawn as wood**: a tube along a curve through the nodes
950
+ (a cubic through each, running the way the wood runs there), its rings
951
+ at even steps of its turning (9 degrees on limbs, 14 on thinner wood and
952
+ 20 on twigs, close to; 18 and 29 mid), as many-sided as it is thick (16
953
+ round the trunk, 5 round wood just past a twig's 2 cm), on through each
954
+ node into its thickest child, which goes straightest on. Close to, a twig
955
+ is a ribbon turned to the eye, two vertices a ring, as wide as a round
956
+ twig and lit as one (see *What the wood costs*). A limb starts inside its parent and bends out of it,
957
+ flaring where it leaves (its collar); a fork starts back along its
958
+ parent, and the two part as one divides. Where a limb leaves, its
959
+ surface is lit and furrowed as its parent's is, easing to its own: two
960
+ tubes meet in a crease, and lit as one they read as one wood. A trunk
961
+ stands on four to six buttresses, gone by breast height, and every end
962
+ is closed, rounded on thick wood. (`test/wood.test.ts`.)
963
+ - **The realistic look** draws a near tree's clumps as leaf cards set in
964
+ the crown at angles of their own, each spray growing from a twig (its
965
+ foot on one of the clump's twigs or the last of the wood leading to it),
966
+ facing out and up as leaves turn to the light, turned a little to the
967
+ eye so none is seen edge-on; lit as the sun
968
+ lights them, with light through the leaves to an eye looking towards it.
969
+ The sprays are drawn by arithmetic, eight of them (broad, oak, eucalyptus,
970
+ willow, fir, pine, box, a round-leaved shrub): a species says which kind
971
+ its leaves are (`leafKind`). Mid and far trees are the same sprays turned
972
+ to the eye.
973
+ - **Light from the crown's own leaves.** Sunlight reaching a leaf falls off
974
+ as exp(-sum of k dl) over the leaves it crosses (Monsi and Saeki). Each
975
+ grown tree has a small box of cells over it (`light.ts`: 18 x 24 x 18, two
976
+ bytes a cell, some 15 KB a variant, all of them in one 3D texture): how
977
+ thick its leaves and limbs are to the light in each cell, and how much of
978
+ the sky each cell sees past them. The leaves are its clumps, each a ball
979
+ of leaves with leaf area by its cross-section, together the leaf area its
980
+ species' crown carries (a leaf area index of 1.5 to 6.3 over the crown's
981
+ ground, by how open it is); the limbs take the light as cylinders do (not
982
+ the stem, which would shade its own bark). The sky is baked once, swept
983
+ down the box layer by layer along sixteen directions over the sky. Every
984
+ fitted tree reads its variant's box: the vertex shaders carry the point
985
+ back into the variant's frame (the fit undone) and march six steps
986
+ towards the sun, the sun's direction stretched as the crown is, each at a
987
+ place of its own along its step (the piece's own number: no noise from
988
+ frame to frame), from a cell and a half out (the cells blur the leaves a
989
+ metre wide, and a shoot on the sunny side would be in its own blur); the
990
+ sky is one read. So a bough shades the one below, the sun comes through
991
+ the gaps, the outer shoots on the sun's side are lit and the pockets
992
+ inside are not, and the trunk and limbs under a dense crown are in its
993
+ shade. The march follows the sun as it moves; nothing is baked for it.
994
+ A far dab, which stands for a gathered group of clumps, is lit half its
995
+ size out along its facing, as the near leaves it hands over to are. The
996
+ style's `structure` says how far a crown's light is its own leaves' and
997
+ how far its ellipsoid's (a hollow heart, as before; `selfShade` scales
998
+ that one), `density` how thick the leaves are to the light. A dab faces
999
+ as the crown's outside does there, turned towards its own clump's face.
1000
+ The ground's shade (`bakeShade`) marches the same boxes, so a crown's
1001
+ shadow has its gaps.
1002
+ - **Wind from the place and the time.** The tree leans with gusts as they
1003
+ reach it, a tall one later and slower; each limb swings about its foot on
1004
+ its own beat. Nothing is kept from frame to frame.
1005
+
1006
+ On this Mac (Apple, 3200 x 2000, 4x MSAA), 30,000 trees over 2.4 km of 30
1007
+ species cost 2.4 to 3.4 ms of the graphics card's time a frame in the painted
1008
+ look and 4.5 to 7.2 ms in the realistic one, ground and sky included; the
1009
+ cull pass 0.02 ms. `await __treeLab.measure()` in the lab measures it.
1010
+ That was before the near tier drew its twigs, and before its wood was
1011
+ curved: a near tree's wood is now some 25,000 triangles and 14,700
1012
+ vertices on average over the species (9,700 and 9,700 straight, 1,500
1013
+ before the twigs), a mid tree's 1,160 (620). In the lab's grove (400
1014
+ trees, 107 near from the clearing) the wood takes some 0.7 ms of a 2.4 ms
1015
+ frame in the clearing and 0.55 of 1.8 ms from outside, 0.4 and 0.33 ms of
1016
+ 2.15 and 1.5 drawn straight.
1017
+
1018
+ ## Where a tree stands
1019
+
1020
+ A course is mostly woods seen from a fairway, 50 to 200 m off, and a wood
1021
+ is not a row of trees each grown alone. Its edge trees keep long low
1022
+ branches and dense leaves on the side facing the open ground and reach
1023
+ out to the light there, while their side in the wood dies back; inside, a
1024
+ tree keeps a crown only high up, on a tall clean bole, and little sky
1025
+ reaches in. All of it is the light: a tree's sky comes from round it as
1026
+ much as from above, and its neighbours' crowns hide the low sky on their
1027
+ side.
1028
+
1029
+ **Each tree's stand** (`standsOf`, `stand.ts`) is worked out from where the
1030
+ trees stand and how big their crowns are, through a grid of cells hashed by
1031
+ place (some 200 ms for 30,000 trees on this Mac). Round each tree, in
1032
+ sixteen sectors: how much of each its neighbours' crowns fill, as walls of
1033
+ leaves standing past its own crown. A neighbour counts by the angle its
1034
+ crown spans, by how far it reaches over this tree's crown base (a shrub
1035
+ under an oak hides nothing of the oak's sky), by how near it stands (one a
1036
+ tree's height off past the crowns hides little), and one crown hides only
1037
+ seven tenths of what is behind it, so a way is closed as far as the wood is
1038
+ crowns deep. The sixteen are kept as the first two terms of their Fourier
1039
+ series: how closed it is all round (`enclosure`: 0 in the open, about a half
1040
+ at a straight edge, 0.8 and more inside a wood), how much more on one side
1041
+ (`lopsided`) and which way it is most open; and how tall the walls stand
1042
+ and how far off. A host may set any of it, tree by tree.
1043
+
1044
+ **Three kinds of tree are grown from it.** Where even its most open side is
1045
+ mostly closed, a tree is grown as one inside a wood; where one side is closed
1046
+ and another open, as one at an edge; else as one in the open, as it always
1047
+ was (`standingOf`). Each kind is grown for its trees' stand on the whole,
1048
+ its open side along +x, and every tree of it is turned so that side faces
1049
+ its own open ground. Shrubs and palms are grown as in the open wherever
1050
+ they stand; a tree alone, or a park's trees 30 m apart, are grown and lit
1051
+ exactly as before.
1052
+
1053
+ **Grown in the light its neighbours leave it** (`grow.ts`). Of the sky that
1054
+ would reach a place in the crown were the tree alone, the share its stand
1055
+ leaves it (`standShare`): its sky comes through its own crown either way
1056
+ (exp(-k L) over the leafy shell a ray crosses, as the shaders light a
1057
+ crown), and the walls hide what comes in below their tops. So a place on
1058
+ an edge tree's wood side, which had most of its sky from that side, keeps
1059
+ only what comes over or through the rest of the crown, and a place on its
1060
+ open side loses only what reached it through the crown already. Taken for
1061
+ the best lit of the crown, so a sapling in an even shade under a canopy is
1062
+ grown as one in the open. Where it is under half, the crown does not grow at
1063
+ all: its lower branches there died young and were shed (a tree always
1064
+ keeps the top 45% of its height, as foresters find of a dominant tree in a
1065
+ closed stand); and the rest of the crown is shaded by it beside the best
1066
+ lit at the same height, so its buds turn to the open side. An edge tree's
1067
+ great limbs swing out to the open side and those that would end in the
1068
+ dark are never grown; its leader leans out a little; a conifer's boughs on
1069
+ its dark side are shorter, or dead and gone; a weeping tree's whips hang no
1070
+ lower than its crown lives. A crown a wood has lifted is a whole crown of
1071
+ its kind over what is left of the tree, its outline drawn from where it
1072
+ starts to the top and as wide as its own outline or that, never past the
1073
+ crown's ellipsoid (what a ball meets): so a tree inside a wood keeps a full
1074
+ crown, high up, as wide as its neighbours let it be. Its bole keeps dead
1075
+ stubs up to the first living limb, a conifer's too.
1076
+
1077
+ **Lit as it stands** (`engine.ts`, a fifth row of numbers a tree): the
1078
+ walls hide the sky below their tops as seen from each piece of the tree,
1079
+ the way it faces as far as it faces sideways and all round as far as it
1080
+ faces up, never below a fifth of it (light comes down through the canopy's
1081
+ gaps and off the leaves round about); and the sun as far as its ray runs
1082
+ through the walls before it is over their top. So a wood's floor and its
1083
+ trunks are dim, its inside dark from outside, and its edge bright where the
1084
+ sun is on it. A tree whose stand is little (under 0.3 closed on its most
1085
+ closed side) is lit as it always was.
1086
+
1087
+ **Cost.** More is grown: the lab's course of 30,000 trees grows 275 variants
1088
+ for 120 (an edge and an inside kind of most species; inside, one shape
1089
+ fewer), in 4.5 s for 1.7 s in node on this Mac; its stands are worked out in
1090
+ some 0.3 s. Drawing costs no more: a fifth row of numbers a tree, read once a
1091
+ vertex, and a lifted crown has fewer leaves (the course's views and the wood
1092
+ edge's measured the same or less, within what other work on this Mac
1093
+ swings them by).
1094
+
1095
+ `test/stand.test.ts` holds it: a tree alone and the specimens are in the
1096
+ open; a wood's front row stands at its edge, open to the open ground, and
1097
+ its inside is interior; an open stand grows the same tree as none; at an
1098
+ edge a tree keeps its leaves low on the open side and loses the wood
1099
+ side's, inside it is lifted and keeps its top, and wherever it stands it
1100
+ keeps to its box and to its outline or its ellipsoid; an edge tree faces
1101
+ and leans its own way.
1102
+
1103
+ ## Photographs
1104
+
1105
+ The realistic look wears photographs: scanned bark and scanned leaves, CC0
1106
+ from [ambientCG](https://ambientcg.com) and [Poly Haven](https://polyhaven.com),
1107
+ and, where no scan exists, AI-generated pictures (a silver birch's bark, its
1108
+ rugged foot's too, a beech's, a blue gum's rough stocking and smooth streaked
1109
+ stem, a Scots pine's copper upper flakes, a stone pine's plates, a black
1110
+ alder's, a coast live oak's, a weeping willow's, a Lombardy poplar's, a Torrey
1111
+ pine's, a sugar maple's and a red oak's bark, and a Monterey pine's, an Aleppo
1112
+ pine's, a Corsican pine's, an eastern white pine's, a Sitka spruce's, a white
1113
+ spruce's and a Monterey cypress's; a Canary palm's trunk and frond,
1114
+ a blue gum's sickle leaves, a London plane's leaves, a coast live oak's, a
1115
+ hawthorn's, a black alder's, a California sycamore's, a Lombardy poplar's, a
1116
+ silver birch's and a weeping willow's, a gorse's flowering sprigs, a Monterey
1117
+ cypress's sprays and pads, the pines' cushions and clumps, a Torrey pine's, an
1118
+ eastern white pine's and a Corsican pine's shoots, a Sitka spruce's, a white
1119
+ spruce's and a Douglas fir's branch tips; the palms' fans, queen palm frond, dead skirt
1120
+ and pineapple cut, and the painted fronds and fans of the other looks), all
1121
+ credited in `assets/SOURCES.md` with the tool and the prompt each was made with
1122
+ (the generated ones marked so: their owner dedicates them to the public domain, CC0 1.0, as the scans are). A generated bark is pieced
1123
+ into a tile from its own overlap, along the path where its two edges differ
1124
+ least (its streaks first lined up, where it has long ones), and its relief
1125
+ read from its lightness; a generated sheet of leaves is keyed off its magenta,
1126
+ each edge taking the colour of the leaf beside it, so no pink rim is left.
1127
+ `tools/scans/fetch.mjs` downloads the sources, `tools/scans/build.mjs` makes
1128
+ `assets/` from them (`tools/scans/recipe.mjs` lists both, and how each is cut).
1129
+ 20.5 MB of AVIF (4:4:4 for the normal maps, which WebP's halved colour planes
1130
+ spoil). Where the owner gave a picture again at 2048 pixels, that one is used.
1131
+
1132
+ - **Bark** is a set a species wears (`scans.ts` `SCAN_LOOKS`): a tile of
1133
+ 1024 texels of bark, its colour (roughness in alpha) and its relief (normal
1134
+ and height), with the photograph's long-range light evened out so a repeat
1135
+ is not marked. It is wrapped round the wood at its real size (the scan's
1136
+ measured size, or one estimated from its pattern against
1137
+ `docs/MORPHOLOGY.md`, times the species' `barkScale`): seen from two sides
1138
+ square to the wood, each laid up the wood as the bark runs, the two blended
1139
+ by which way the surface faces and by their relief, so there is no seam
1140
+ round a stem and the furrows run up a limb however it leans. Over a stem's
1141
+ root flare and its buttresses it is laid by the length of the surface (not
1142
+ up the centre line, which drew it out in long smears where the foot widens)
1143
+ and round the stem's radius above the flare, so its furrows run on down
1144
+ the flare and spread, and do not cross in chevrons where the two sides
1145
+ meet (`geometry.ts` `flareBark`). Its colour is
1146
+ the scan's, scaled from the set's mean to the species' bark colour (paler up
1147
+ the trunk where the species' is); its relief lights each ridge's sunny side,
1148
+ and the sky's light is less deep in its furrows, where moss gathers first.
1149
+ A species may give way to a second set up its stem, raggedly, in tongues up
1150
+ the furrows: a Scots pine's plates to its copper flakes (which take a colour
1151
+ of their own, not its bark's paled), a blue gum's rough stocking to its
1152
+ smooth streaks, a birch's black
1153
+ foot to its white. The edge runs up and down the furrows in streaks, ragged
1154
+ at two sizes, and a foot's own colour lightens up the stem as it gives way,
1155
+ so a birch's foot is black and rough at the ground and greys into white
1156
+ plates, not a black sock. A birch's white tile has black diamond fissures
1157
+ laid into it by the build (`fissures`), where the picture had none. Twigs
1158
+ stay a twig's dark grey-brown. Only the near tier's wood wears the
1159
+ photographs; further off the bark is drawn as before, in the colours they
1160
+ have close to (a foot's, an upper bark's), so a pine's copper does not go
1161
+ grey-brown as it passes from near to mid.
1162
+ - **Leaves** are a sheet of single leaves a species wears, cut from a scan
1163
+ and stood upright, laid on the species' own twigs at their real size
1164
+ (`sprays.ts`): a row of cards for each species in the trees: three near
1165
+ cards (a twig's end of a few shoots, 0.4 to 0.9 m across), two big cards
1166
+ (a branch's end, a clump wide: a near clump's mass and a conifer's sheets)
1167
+ and two far cards (the mid tier's and the far dabs': the big cards again, or a
1168
+ pine's canopy pictures, `cushionFar`), each one of its two by a number of its own. A card is
1169
+ drawn from its foot: its first row is where its twig comes in, and the
1170
+ shaders lay its first row at its twig's foot (`CARD_V`). An oak's leaves one to a node with a cluster at the tip, a
1171
+ maple's in pairs, a blue gum's few long sickles hanging from the twig's end
1172
+ (its cards hang too, standing upright, their leaves edge to the sky, as a
1173
+ blue gum's do: a card that faced up had no way down along it, and its
1174
+ leaves lay flat; its leaves narrowed to its own, 12 to 30 by 2 to 3 cm, and
1175
+ hung alternately along the shoot, as gathered at its end they lay over one
1176
+ another into an oak's lobed leaf), a willow's and a birch's along hanging
1177
+ whips; a fir's and a cedar's whole scanned sprays. A pine's are its shoots
1178
+ grown as a pine grows them, a whorl of two or three a year, each putting out
1179
+ its own, turning up at their ends, and a tuft of needles only at the end of
1180
+ each, the wood behind it bare (`pineShoots`): a long-needled pine's twig two
1181
+ or three big brushes, a short-needled one's a dozen small ones, as long as
1182
+ its needles (`needleCm`, from `docs/MORPHOLOGY.md`), and its big card a
1183
+ branch of them, a candelabrum with sky between. A tuft is drawn needle by
1184
+ needle, each bundle set in three dimensions (forward near the tip, standing
1185
+ out square and falling back further down) and seen side-on: a starburst,
1186
+ darker at its heart, its needles lying together in spokes so a tuft keeps
1187
+ its spikes when the card is mipped down a few dozen metres off. Its picture
1188
+ as a fan to a shoot made a pine's spray a palmate leaf, and its crown a
1189
+ broad leaf's. A pine's cards are turned about their shoots to the eye (a
1190
+ brush is alike all round), keep a soft fringe of needle tips while a pixel
1191
+ is a few of their texels, and close over their gaps as they are mipped, its
1192
+ big card most (`coverageMips`, a fill a cell). A Canary palm's card a
1193
+ two-metre stretch of its frond, a fan palm's its whole fan. A crown in pads
1194
+ (`pads`) lays its sprays level and facing the sky, in shelves wider than high, so a Monterey cypress is
1195
+ flat-topped tiers and not a heap of balls. The near cards are many small ones (as many to a clump as
1196
+ cover it, at most 36), spread through the clump about its shoots, over two
1197
+ big cards a clump set into it, its mass (three under needles and scales,
1198
+ none under a pine's tufts, whose picture a clump wide was a lump close to,
1199
+ as many tufts to a clump as the pine is dense). A dense species' big card (`openness` under 0.4)
1200
+ has a second branch's leaves behind its own, darker, in their shade: one
1201
+ layer of sprays left gaps a dense crown does not have. Close to, a big card
1202
+ is turned to the eye at least two thirds of the way (seen near edge on, a
1203
+ picture a clump wide was a smear through the crown, its mip chosen by the
1204
+ way it is squeezed most), as a mid tree's cards are, and it gives way to the small sprays over it from
1205
+ five of its half widths off, gone by two and a half, where its texels would
1206
+ be larger than a pixel.
1207
+ The card keeps the drawn sprays' channels (a grey tone
1208
+ from the scan's lightness, lit a little by its own relief; each leaf's own
1209
+ thinness, from the scan's translucency; coverage), so the shaders read
1210
+ either alike and the species' colour still tints them.
1211
+ - **Cost** of the polish above (bunches, pads, curtains, closed big cards,
1212
+ needles, big cards giving way close to): in the lab's grove, 1104 x 1868,
1213
+ the frame took 1.37 to 1.57 ms in the clearing and 1.92 to 2.32 from
1214
+ outside before, 1.25 to 1.28 and 1.70 to 1.72 after (two runs each,
1215
+ interleaved; this Mac is shared): fewer near cards on a pine and on a blue
1216
+ gum's bunches pay for the rest.
1217
+ - **Pines as cushions** (the owner's stone pine references: dense cushions, lit on top
1218
+ and dark beneath, on a flat-topped layer). A pine's tuft is a brush along its
1219
+ shoot's last years (`ScanLook.brush`, in needle lengths: a stone pine's 2, a Monterey
1220
+ pine's 1.8, a Scots pine's 1.6, an Aleppo pine's 1.2), its needles behind the tip's
1221
+ starburst standing forward as a bottle brush's, in a dozen or more bundles (a few big
1222
+ spokes were a palmate leaf a few dozen metres off). Its big card is a branch seen
1223
+ side-on, its shoots rising off it (`pineBranch`): a cushion flat beneath and domed
1224
+ above, wider than high, its wood half a near card's; a pine's mid cards stand up on
1225
+ their twigs (`cardPieces`' `rises`) so the cushions stay cushions, and a dense pine
1226
+ (`openness` under 0.45) has one under its near tufts. Its cards are lit by how high
1227
+ each corner is in its clump (`aTangent.w`): dark at the clump's foot, lighter and
1228
+ yellower at its top. Its light box holds its leaf area times a clumping index of
1229
+ 0.55 (Chen and Black 1992): spread evenly through each clump's ball, it shaded the
1230
+ cushions' sunlit tops. Its near cards spread above their shoots, not under them.
1231
+ - **Which way up a card is.** Thought drawn upside down on their twigs (a triangle card
1232
+ had shown its point down on a pine), a pine's cards had been written bottom row
1233
+ first; its tufts then hung under their shoots, their bare wood stood above them as
1234
+ sticks over the crown, and its big cards' cushions hung under their branches. They
1235
+ were never upside down: three's WebGPU renderer samples a DataTexture's first row at
1236
+ v = 0, as WebGL does (`flipY` is for pictures, not data; checked in the lab with a
1237
+ texture of two rows), the shaders lay v = 0 at a card's foot corner, and every
1238
+ card is drawn from its foot. A triangle on every card, with every twig turned up,
1239
+ stands point up; a willow's hanging whips hang theirs point down. A pine's twigs
1240
+ mostly rise, but not all (a fifth lie sideways, a twentieth point down, under the
1241
+ crown), which is likely what was seen. Now every card is written the one way, first
1242
+ row at the foot (`test/orientation.test.ts`), and no other species needed retuning.
1243
+ - **Pines' cushions** (`ScanLook.cushion`). A stone pine's canopy is many dense cushions of
1244
+ tufts, lit yellow-green on top and near black beneath, with dark creases between
1245
+ them, as photographs show it: built of many small needle cards, it read as a scatter
1246
+ of leafy blobs. A pine with cushions has them on its big cards, one to a card, as
1247
+ game foliage lays its cluster cards: a picture of a cushion (a leaf set of whole
1248
+ pictures, when there are any), or one drawn needle by needle (`"drawn"`,
1249
+ `drawnCushionCard`): a dome as wide as the card on a flat base curling up a little
1250
+ at its ends, puffs on its top and shoulders, packed with the pine's own tufts at
1251
+ their size, each lit as high as it is in its puff and in the dome, darker in the
1252
+ creases where two puffs meet; an open pine's (an Aleppo pine's) a few loose lumps
1253
+ of its own at heights of their own, with air between. Two to a clump near to,
1254
+ 1.45 of its radius from their middle (one to an open pine's clump), and every mid
1255
+ card: each stands upright on its twig, facing out of the crown level
1256
+ (`cardPieces`' `upright`), and the shader turns it to the eye about the vertical,
1257
+ a cylindrical billboard, so its flat base stays level; looked at steeply (from
1258
+ under the crown) it tips over to the eye, a mass overhead and not a card edge on.
1259
+ A far dab of such a pine stands upright too. Its tuft cards are fewer (three tenths
1260
+ of a pine's) and drawn only close to, whole to 9 m and gone by 15 m: a tuft a few
1261
+ pixels across was a broad leaf's blot on the cushions. Its wood thinner than 2 cm
1262
+ is not drawn (it crossed over the cushions as sticks); its limbs are.
1263
+ - **Cushions from photographs.** The owner's pictures (AI-generated, CC0 1.0; `assets/SOURCES.md`),
1264
+ keyed off magenta and kept whole (`tools/scans`): a stone pine's single cushions on its big
1265
+ cards and strips of its canopy, several cushions side by side over crooked branches, on its
1266
+ far cards, its mid cards 2.6 of a clump's radius from their middle so a strip's cushions are
1267
+ a cushion's size; a Monterey pine's dense dark clumps; an Aleppo pine's open grey-green
1268
+ ones, twigs showing; a Scots pine's blue-green ones; a Monterey cypress's flat-topped pads
1269
+ (its whole sprays fewer over them). Each card keeps its picture's own light and shade as
1270
+ its tone, and its warmth (red over blue beside its sheet's mean) in the channel the drawn
1271
+ cards spend on tone again: the shader warms its sunlit top and cools its underside by it
1272
+ (`CUSHION_WARMTH`), and lays only a little of a pine's clump shading over it
1273
+ (`CUSHION_PHOTO_SHADE`), lit from the light box half a card up, at its top, and not its
1274
+ middle, deep in the clump, which darkened a picture already dark beneath. How many to a
1275
+ clump and how big go with how closed the crown is (`closedOf`, openness 0.25 to 0.6,
1276
+ squared): four 2 clump radii from their middle on a stone pine, a Monterey pine or a
1277
+ cypress, about two of 1.4 on a Scots pine, one of 1.1 on an Aleppo pine. Their sizes vary
1278
+ by a third either way and they stand up to half a clump's radius up or down their twigs,
1279
+ so the crown seen from beneath is not rings of plates at one height; tipped over to an eye
1280
+ below, from 20 degrees up, they are drawn up to 1.6 times bigger, closing into a ceiling,
1281
+ and darkened to their undersides. Close overhead they give way to the pine's own tufts from
1282
+ further off than other big cards do (`PINE_BENEATH_FAR`, 2.5 times as far): under a stone pine a
1283
+ player sees its brushes on their reddish branches with sky between, as the owner's reference
1284
+ picture has it, not the cushions' dark undersides, stacked plates. The stone pine wears its own bark too, thick reddish
1285
+ plates between deep fissures (`stonePine`, a tile 1.2 m square). The drawn cushions
1286
+ (`"drawn"`) remain for a pine with no pictures.
1287
+ - **A photograph's tone at the species' colour.** A species' leaf colour is its crown's as it is seen
1288
+ from some way off (`docs/MORPHOLOGY.md`), its own leaves' shade already in it. A card's tone is
1289
+ each leaf's lightness over its sheet's mean, 0.6 on average, and the shader had laid it on at 1.12
1290
+ (as the drawn marks' are), so a photographed crown was 0.67 of its colour before the crown's own
1291
+ shade and the sun were laid over it: the pictures' shade under their leaves counted twice, and the
1292
+ crowns came out darker than the photographs beside them in the gallery. A photographed card's tone
1293
+ is now brought to its species' colour on average (`PHOTO_TONE`, 1/0.6), every realistic crown about
1294
+ half again as bright in linear light; the drawn sprays (`scans: false`) are as they were.
1295
+ - **Pads in layers** (`ScanLook.padThick`). A Monterey cypress's pad picture is a thin shelf, a fifth
1296
+ as high as wide; laid one to a card, an old coastal cypress's thick flat-topped shelves (1–2 m deep,
1297
+ the Lone Cypress's) were thin dark discs floating apart. Each pad card now lays its picture in up to
1298
+ four layers, each a little narrower, higher and to one side, the higher ones behind, a quarter
1299
+ taller than the picture, until the pad is 0.45 as thick as wide: lumpy, lit along each layer's top,
1300
+ dark beneath. Its pads are bigger (`cushionSize`, 2.8 clump radii from their middle, its mid cards
1301
+ as big), so they join each other and the crown into flat-topped masses, and it has as many whole
1302
+ sprays as a crown without pads, a third of them hanging under the pads, so the wood leading into a
1303
+ shelf is clothed near it; and five short sprays more a shelf along the wood leading up into it, over
1304
+ 3.5 m of it (`FixedCards.clothe`). A shelf stands up from its wood, never dropped under it (hung below,
1305
+ its own limb ran on bare above it). Seen from well beneath (tipped more than 0.6 of the way over to the
1306
+ eye), a cushion card is turned its own way about the eye, and a pad's drawn longer up its picture, about
1307
+ as deep as it is wide: their up had been the way out from under the eye, the same for every one
1308
+ overhead, so their wide low pictures lay in rings of stretched bands round the eye. From the tee
1309
+ they stay level bands.
1310
+ - **A Monterey pine in clumps.** Real Monterey pines are dense but lumpy: distinct rounded clumps, sky
1311
+ between them, an irregular outline (the Big Sur reference). Its cushion a clump had been 2.1 of the
1312
+ clump's radius from its middle, its clumps even through the crown 1.4 radii apart: side-on, under 1% of
1313
+ the crown inside its outline showed sky, one heavy mass. Its leaves now gather into bunches at its
1314
+ branches' ends, some branches bare (`clusters` 0.7), it is a little more open (0.35) and lumpier (lobes
1315
+ 0.6), and its cushion is 1.2 radii: some 10% sky inside its outline, the clumps rounded masses apart,
1316
+ its bare lower limbs showing under them (`test/realLook.test.ts`).
1317
+ - **Flowers** (`ScanLook.flowers`, the style's `bloom`). A gorse wears its own sprigs whole (a
1318
+ `sprays` kind, as a cypress's), their yellow pea flowers along their upper half. Its cards keep
1319
+ how far each texel is a flower (yellow or orange: red and green well over blue, red not under
1320
+ green; `flowerOf`) in the channel the drawn cards spend on tone again, each flower's tone against
1321
+ the flowers' mean and each spine's against the spines', and the shader colours a flower in the
1322
+ look's own flower colour (`#f2c230`), lit as the leaf there is (the light on the leaf over the
1323
+ leaf's colour, times the flower's; the air's own light taken off and put back). `bloom` is the
1324
+ share of a bush's sprays in flower, each by its own number: 1 in full flower, 0 out of flower (its
1325
+ flowers gone and its spines left); 0.3 with no day given, a few flowers, not a bush mostly yellow.
1326
+ Given the day of the year (`trees.environment.day`), a species' own year says instead
1327
+ (`ScanLook.flowering`, eased between the days it names and round from December to January, written to
1328
+ the species' rows only when the day changes): common gorse's (`GORSE_FLOWERING`) mainly in flower from
1329
+ January to June, at its height from March to May (0.95 on the 20th of April), a few flowers the rest of
1330
+ the year (0.08 to 0.18; Clements et al. 2001, Tarayre et al. 2007). A host south of the equator passes
1331
+ the day half a year on. The same day also sets the leaves' season (`evalTreeSpeciesPhenology`): spring
1332
+ flush, autumn colour, and deciduous crowns bare from about late October to April. A host that wants the
1333
+ season's flowers on full crowns sets `trees.environment.leafDay = null` (the leaves held in summer
1334
+ leaf, the shade they bake too); a number there sets the leaves' day apart from the flowers'.
1335
+ - **Shoots for tufts** (`ScanLook.tuftPicture`). An eastern white pine's needles are long, soft and
1336
+ fine, in fives; drawn needle by needle as a Scots pine's they were stiff spiky brushes. Its tufts
1337
+ are laid from its own shoot pictures instead, a soft drooping tassel at each shoot's end (the
1338
+ picture three needles long, its brush reaching as far past the shoot as a drawn tuft would). A
1339
+ Corsican pine's from its own shoots too, a stout twig in a brush of long stiff needles (the picture two
1340
+ needles long, `tuftShoot`). A Torrey pine's long stiff grey-green brushes from its own: its picture is
1341
+ mostly brush (`tuftShoot` 1.6), so it is cut where its brush begins (`tuftFrom` 0.3, its bare twig left
1342
+ to the card's own wood) and laid five to a tuft, fanned 0.55 rad apart about the brush's foot
1343
+ (`tuftFan`), each a little longer or shorter, over the pine's own drawn needles, a little longer than
1344
+ them: one flat-laid picture was a narrow tassel, a broad leaf's blot from the tee, and a fan of pictures
1345
+ alone a fan palm's leaf from under the crown; the drawn needles give the brush its edge of needle tips.
1346
+ - **A pine's tufts drawn for each mip** (`pineMip`, `coverageMips`' `drawn`). From the tee a pine read as a
1347
+ broad leaf: averaged down, each needle a quarter of a texel wide was a quarter of an alpha, under the cut, so
1348
+ the mips kept only a tuft's dense heart, and the coverage the mips keep (Castaño) went to filling that heart
1349
+ out into a disc, a broad leaf's blot. Now a pine's needled cards (`needledCards`: its near cards, and its big
1350
+ and far ones unless they are photographs; not a pine whose tufts are one shoot picture each) have their first
1351
+ four mips drawn for themselves: the row drawn again at full size with each needle as wide as that mip's texel
1352
+ and kept by chance as often as it is narrower than that, so a tuft covers about what its needles do but in
1353
+ spokes a texel wide with sky between, then averaged down (Cook et al. 2007, *Stochastic simplification of
1354
+ aggregate detail*: fewer elements, each bigger, the same cover). Their alpha is scaled up to the full-size
1355
+ share where it falls short, never down; past the fourth mip they are averaged on as before. A Torrey pine's
1356
+ fanned shoot pictures, the few big lobes of a palmate leaf a few dozen metres off, are left out of its mips
1357
+ from the second on, its drawn needles half again as many in their place. Each tuft's needles are lit as a
1358
+ brush is from above (`TUFT_UP_LIGHT`): those pointing up lighter, those hanging darker, the inner half of each
1359
+ needle darker (`TUFT_HEART`), a dark heart and lit tips rather than one flat tone. At the third and fourth
1360
+ mips (a near card from the tee) a tuft's outline at the cut is a fifth to a quarter longer for its area than
1361
+ averaged, its cover within a tenth of what it was (Torrey 10.7 to 13.7 at the third, Stone 11.0 to 13.5,
1362
+ Monterey 10.1 to 12.8, Aleppo 14.2 to 16.5; `test/pineMips.test.ts`, `test/silhouette.ts`). No more texture
1363
+ or shader work on the graphics card: the same atlas and mips, only their pictures differ. The page draws each
1364
+ pine's row four times more once its leaves come, some 60 ms a level at 512 texels a card (a quarter of that
1365
+ at 256), a mip at a time between frames.
1366
+ - **A lean** (`TreeSpecies.lean`). A Torrey pine on the bluffs leans (MORPHOLOGY.md 19, the owner's
1367
+ reference): grown leaning 16 degrees its own way from its foot, turning upright near its crown's base, so its
1368
+ crown stands over its foot and keeps to its box, which a ball meets (the grower's `lean`, merged with the
1369
+ California sycamore's: one lean, grown into the trunk).
1370
+ - **Scots and stone pines against their references.** A Scots pine forks at its crown's base into two or three
1371
+ heavy orange sub-leaders in seven trees of ten (MORPHOLOGY.md 5), on a straighter, thicker stem, olive where
1372
+ lit. Its references' crown is flat-topped, the photographed tree's (`test/outlines.json`, a solitary Dutch
1373
+ tree of no stated age) widest just over its crown's base and round-topped, a middle-aged tree's; the outline
1374
+ test holds it to that (9.4% off, 11.7% before), and Rautiainen et al.'s upper-crown shape (t 1.47, measured 1.35), so its top stays round. A stone pine forks lower (two thirds of its crown
1375
+ base) into three thick stems, a trunk 1.4 m through (1.24 before), its crown shallower and its cushions six smaller ones to a
1376
+ clump, a smoother umbrella.
1377
+ - **Where one bark gives way to the next** is laid round the tree's own axis and up its height, eased
1378
+ pixel by pixel: laid round each tube and along it, and eased once a vertex, a forked stem's or a
1379
+ clump's stems took the pattern up afresh where they part, and a sycamore's or a birch's foot bark
1380
+ ended in a line round the top of its root plate.
1381
+ - **The bark's stand-in.** Until the photographs come, the bark's texture is one texel. three builds a
1382
+ texture's sampling into the shader from the texture there when the wood is first drawn, and the stand-in
1383
+ had its defaults, nearest on both sides and clamped: built so, the photographs were read a texel at a time
1384
+ and clamped at the tile's edge wherever the bark ran past it, long vertical streaks up every stem close
1385
+ to. The lab draws before they come and showed it; the gallery waits for `ready`. The stand-in and the
1386
+ sets are now made by one function (`barkLayers`, `test/barkTexture.test.ts`), sampled alike.
1387
+ - **Cost** of the sixth round (the 2048-pixel pictures, the conifers' own bark and shoots, the Monterey pine's clumps,
1388
+ the cypress's clothed limbs, the Torrey pine's fanned brushes): in the lab's grove, 1104 x 1868, the least of two or
1389
+ three runs each, interleaved against main on a shared, busy Mac: the mixed grove 1.38 ms in the clearing and 1.30
1390
+ from outside before, 1.46 and 1.31 after; a grove of Monterey cypresses 1.20 and 1.38 before, 1.45 and 1.34 after
1391
+ (five sprays more a shelf near to); of Monterey pines 0.95 and 1.50 before, 0.87 and 1.11 after (smaller cushions,
1392
+ fewer clumps); of Torrey pines 0.96 and 0.78 before, 0.97 and 0.78 after. The pictures added to the package are
1393
+ 3.6 MB of AVIF (seven bark sets, four shoot sets, and the 2048-pixel pictures a little bigger than the 1024 ones):
1394
+ 20.5 MB of bark and leaves, 22.2 MB with the painted marks.
1395
+ - **Cost** of the fifth batch (pads in layers, the Monterey pine's cushions, gorse's sprigs and flowers, the white
1396
+ pine's shoots, the new bark and leaves): in the lab's grove, 3456 x 2006, the least of two or three runs each,
1397
+ interleaved against main on a shared, busy Mac (graphics card's time for the frame): the mixed grove 4.08 ms in
1398
+ the clearing and 2.77 from outside before, 3.50 and 3.03 after; a grove of Monterey cypresses 3.81 and 3.65 before,
1399
+ 4.14 and 3.32 after (bigger, layered pads and more sprays near to); of Monterey pines 3.22 and 3.03 before, 2.82 and
1400
+ 2.69 after (one cushion a clump, not four); of gorse (all far dabs there) 0.87 and 0.81 before, 0.78 and 0.78
1401
+ after. All within this Mac's noise but perhaps the cypress's clearing, some 0.3 ms. The pictures added to the
1402
+ package are 4.1 MB of AVIF (eight leaf sets and eight bark sets): 16.9 MB in all.
1403
+ - **Cost** of the photographed cushions: in the lab's grove of stone pines only, 3456 x 2006,
1404
+ the frame took 3.48 and 3.28 ms in the clearing and 2.51 and 2.53 from outside before, 4.01
1405
+ and 4.02 and 3.40 and 4.21 after (runs interleaved against the drawn cushions, on a shared,
1406
+ busy Mac): more and bigger cushion cards near to, and mid cards a strip of canopy each, more
1407
+ overdraw. The mixed grove (a Scots pine's clumps in it) 3.36 and 2.89 ms before, 3.40 and
1408
+ 2.42 after. On the graphics card the cards' atlas is seven cards a row (from five); the
1409
+ pictures added to the package are 2.7 MB of AVIF (six leaf sets and a bark set).
1410
+ - **Cost** of the cushion cards (and two big cards a species row): in the lab's grove
1411
+ of stone pines only (`?scene=grove&fill=1`, 400 trees), 3456 x 1892, the frame took
1412
+ 6.24 and 4.51 ms in the clearing and 5.19 and 2.62 from outside before, 3.96 and 3.01
1413
+ and 3.15 and 2.15 after (runs interleaved against the commit before, on a shared,
1414
+ busy Mac): a cushion card a few tufts' cards' worth, and three tenths of the tufts.
1415
+ In the mixed grove (no cushioned pine in it) 4.44 and 3.71 ms before, 4.29 and 3.52
1416
+ after. On the graphics card the cards' atlas is a quarter wider (five cards a row).
1417
+ - **Cost** of the pines as cushions: in the lab's grove, 3456 x 2006, the frame took
1418
+ 3.81 to 3.89 ms in the clearing and 3.39 to 3.50 from outside before, 4.05 to 5.63
1419
+ and 3.68 to 5.14 after (runs interleaved on a shared, busy Mac): more near cards to a
1420
+ dense pine's clump, and a cushion card under them.
1421
+ - **Cost** of the pines' shoots, the hand-over piece by piece and the bark
1422
+ over the flare: in the lab's grove, 1104 x 1868, the frame took 1.29 to
1423
+ 1.34 ms in the clearing and 1.70 to 1.80 from outside before, 1.21 to 1.45
1424
+ and 1.91 to 2.05 after (a mid tree's cards turned to the eye cover more); in
1425
+ the wood edge, from the fairway at 100 m and 60 m, 3.62 and 4.24 ms at the
1426
+ least before, 2.82 and 3.50 after (likely the hand-over: a tree in it no
1427
+ longer draws both tiers whole and throws half away). Runs interleaved on a
1428
+ shared, busy Mac.
1429
+ - **Cost** when the photographs came: in the lab's grove, 1552 x 1868, the frame took 1.80 to 1.92 ms
1430
+ in the clearing and 2.40 to 2.45 from outside, against 1.35 to 1.58 and 1.75 to
1431
+ 1.83 without the photographs (`scans: false`): the near cards about twice
1432
+ as many (four light steps each instead of six), the near wood's bark
1433
+ sampled four times a pixel. On the graphics card: the bark set's layers
1434
+ (1024 square, mipmapped, two textures) about 11 MB each, and the cards 4
1435
+ MB a species row (512 texels a card for up to six species, 256 beyond).
1436
+
1437
+ ## What the trees cost, offline
1438
+
1439
+ `tools/cost/course.ts` counts what a course's trees cost the graphics card
1440
+ from its 1st tee, without drawing or timing anything (the shared graphics
1441
+ card's timings are for agreed windows): the trees the game hands over for a
1442
+ hole, each its species as the game chooses it (read from a worldgolf
1443
+ checkout, `--game`, as its `scripts/tree-mix.mjs` reads a course), planned and
1444
+ grown as `createTrees` grows them, and put through the engine's cull and tiers
1445
+ from the game's bench camera (4 m behind the tee looking at the pin, 48°, a
1446
+ 2880×1800 picture). For each tier: the trees it draws, its cards (dabs),
1447
+ vertices (the dabs', the wood's, the fronds'), and pixels: the dabs' quads
1448
+ clipped to the picture, summed over every layer (overdraw), a tree being
1449
+ handed over split between its two tiers as their pattern splits it.
1450
+ `--lib <checkout>` counts another commit's trees, `--mix-lib <checkout>` holds
1451
+ the mix to another's species:
1452
+
1453
+ ```
1454
+ node tools/cost/course.ts c01 c10 --species
1455
+ node tools/cost/course.ts c01 --lib ../old-checkout --mix-lib .
1456
+ ```
1457
+
1458
+ On Riviera's 1st hole (2026-11-25), whole hole in view: a66c411 as the game
1459
+ had it 7.5k near cards, 876k vertices, 26.2 Mpx; 3afffb6 (finer clumps for
1460
+ the courses' sizes) 14.5k, 1,011k, 28.5 Mpx; fewer dabs to a finer clump
1461
+ 8.2k, 985k, 26.0 Mpx. Near, the wood was most of the vertices (850k of the
1462
+ 985k: every twig, each vertex marching the light box as a dab's does), and
1463
+ the dabs most of the pixels (a near crown's dabs cover it 5 to 15 times);
1464
+ with ribbon twigs and the near wood in bands, 729k (*What the wood costs*).
1465
+ Each tier's line ends with a rough guess at its time (ms, `MS`).
1466
+ `tools/cost/wood.ts c01` breaks a course's near wood down by how thick it is,
1467
+ how far off, how many pixels across, and how much of its own crown lies
1468
+ towards the eye.
1469
+ `test/cost.test.ts` holds a fitted tree's near cards under a bound.
1470
+
1471
+ ### What the wood costs
1472
+
1473
+ Near, the wood was most of a tree's vertices, each marching the box of light
1474
+ as a dab's does: on Riviera's 1st tee (d8bd96b) 641k of the near tier's 677k
1475
+ vertices, 851k of all 985k. Broken down (`tools/cost/wood.ts`): two thirds
1476
+ of it twigs under 2 cm, 46% on the big trees 150 m and more off that are
1477
+ near only by their height, 68% under a pixel across and 21% under the
1478
+ quarter pixel below which the shader shrinks it to nothing (`KEEP_THIN`).
1479
+ None of it lies deep in its crown from every side (marched through its box
1480
+ of light from 26 ways, every piece sees out somewhere, from below if not
1481
+ above), so none is left out for that. So:
1482
+
1483
+ - **A twig is a ribbon.** Wood under 2 cm, near, is a strip of two vertices
1484
+ a ring, turned to the eye in the vertex shader (square to the wood and to
1485
+ the eye), as wide as the four-sided tube it was on average over the ways
1486
+ that was turned (`RIBBON_WIDE`), its normal facing the eye in its middle
1487
+ and half way to its sides at its edges, so it is lit as a round twig. Where
1488
+ a tube thins into a twig it is closed with its tip and the ribbon starts
1489
+ there; a ribbon ends in a point. A twig's rings come every 20 degrees of
1490
+ its turning, not 14 (`TierShape.twig`). A mid tree's wood is still tubes.
1491
+ - **The near wood is in bands by thickness** (`WOOD_BANDS`: 16 mm and up,
1492
+ 6 to 16, under 6, as grown), each variant's triangles laid out thickest
1493
+ first and its vertices in the order they are first used. The cull pass puts
1494
+ each near tree on one more list, its *depth*: the bands whose thickest is a
1495
+ quarter pixel or more across where the tree comes nearest the eye (its
1496
+ middle less its sphere's radius), and the near wood is drawn by one mesh a
1497
+ depth, over the same buffers, each drawing its trees' first bands. Wood
1498
+ thinner than a quarter pixel was already shrunk to nothing, so a band left
1499
+ out was not to be seen: nothing pops.
1500
+
1501
+ Riviera's 1st tee, counted (`tools/cost/course.ts`, d8bd96b to now): near wood
1502
+ 641k to 384k vertices (c03 92k to 67k, c05 1,000k to 685k, c10 844k to
1503
+ 600k); the counter's rough estimate of the trees' time 0.82 to 0.70 ms on
1504
+ c01 (see `MS` in `tools/cost/proxy.ts`: it counts vertices and
1505
+ pixels at what the grove measured a vertex of wood at, nothing of what a
1506
+ shader does with them). A course size's near wood over the fitted species,
1507
+ 331k to 208k vertices (`test/cost.test.ts`). The cost is three near-wood draws
1508
+ a variant where there was one.
1509
+
1510
+ ## Left out, for now
1511
+
1512
+ - The photographs: a birch's dark diamonds are not drawn; the leaves' own colour is used only as lightness (the
1513
+ species gives the hue); the cards are composed on the page's thread, a row
1514
+ of cards a task (a worker would keep a busy page smoother); a set's tile
1515
+ repeats along a tall straight stem.
1516
+
1517
+ - Pines grown as broadleaves (Scots, Monterey, Torrey, Aleppo, stone) keep
1518
+ their clusters and cards: their tufts want sheets of their own, pads
1519
+ along the twigs. A species' kind of sheet is chosen when the trees are
1520
+ made: changing its leaves in the lab needs it grown again.
1521
+
1522
+ - Trees' shadows on each other and on what stands under them (the ground's
1523
+ shade is baked; see above): a tree's light is its own leaves' and its
1524
+ stand's, not a neighbour's crown's in particular.
1525
+ - A tree's light box is its clumps' leaves, blurred about a cell wide: a
1526
+ conifer's sheets and a realistic crown's cards reach past their clumps
1527
+ and are not in it as drawn; the stem is not in it; the sky it sees is
1528
+ baked for the tree as grown, not stretched with its fit.
1529
+ - A fan palm's skirt of dead fronds; multi-stemmed trees (a sycamore's, a
1530
+ live oak's).
1531
+ - In a wood: crowns that press into each other's shapes (each is still its
1532
+ kind's outline, lifted or lopsided), the light that comes in under an
1533
+ edge's crowns to the trees behind it, and the undergrowth, which is the
1534
+ host's to plant (the lab's wood has some).
1535
+ - Phones: WebGPU only.
1536
+
1537
+ ## Licence
1538
+
1539
+ The code is MIT (`LICENSE`). The pictures in `assets/` are all CC0 1.0 Universal (public domain): the
1540
+ scans as ambientCG and Poly Haven publish them, and the AI-generated pictures as their owner dedicates
1541
+ them. `assets/SOURCES.md` lists each one, where it came from, and for a generated one the tool, date and
1542
+ prompt.