@threenative/terrain 0.1.9 → 0.1.12

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 (243) hide show
  1. package/README.md +40 -59
  2. package/THIRD_PARTY_NOTICES.md +2 -1
  3. package/dist/bake-DJ5cxg0C.d.ts +82 -0
  4. package/dist/editor/index.d.ts +4 -4
  5. package/dist/editor/index.js +130 -128
  6. package/dist/editor/server.d.ts +2 -2
  7. package/dist/editor/server.js +38 -35
  8. package/dist/editor/worker.d.ts +1 -1
  9. package/dist/editor/worker.js +101 -101
  10. package/dist/export.d.ts +1 -1
  11. package/dist/index.d.ts +156 -273
  12. package/dist/index.js +562 -378
  13. package/dist/kit-world.d.ts +107 -0
  14. package/dist/kit-world.js +5134 -0
  15. package/dist/kit.d.ts +21 -4
  16. package/dist/kit.js +337 -223
  17. package/dist/mcp/cook-child.js +1963 -1543
  18. package/dist/mcp/server.js +716 -429
  19. package/dist/prop-package-Dwz0EWoB.d.ts +141 -0
  20. package/dist/{server-B5RdvEAC.d.ts → server-LnFwY8sr.d.ts} +1 -1
  21. package/dist/starter.d.ts +1142 -7
  22. package/dist/starter.js +2102 -120
  23. package/dist/{terrain-CAEaW0mQ.d.ts → terrain-DYCyAOCJ.d.ts} +1 -1
  24. package/dist/three.d.ts +1 -1
  25. package/dist/three.js +1 -1
  26. package/dist/{types-BpH00qsx.d.ts → types-kpI0C4hW.d.ts} +1 -1
  27. package/dist/{world-package-B8QgHjAQ.d.ts → world-package-DqJC3-Nn.d.ts} +2 -2
  28. package/docs/authoring/editor.md +73 -0
  29. package/docs/authoring/new-environment.md +97 -0
  30. package/docs/authoring/recipes.md +97 -0
  31. package/docs/authoring/world-export.md +66 -0
  32. package/package.json +24 -8
  33. package/starter/alpine/README.md +22 -12
  34. package/starter/alpine/bake.mjs +14 -1
  35. package/starter/alpine/biome.data.json +187 -25
  36. package/starter/alpine/heightmap.r16 +0 -0
  37. package/starter/alpine/playerRig.ts +89 -0
  38. package/starter/alpine/recipe.json +169 -15
  39. package/starter/alpine/render/bakedFile.ts +17 -0
  40. package/starter/alpine/render/benchmark.ts +77 -0
  41. package/starter/alpine/render/biomeData.ts +14 -0
  42. package/starter/alpine/render/biomes.ts +687 -0
  43. package/starter/alpine/render/ground/cover.ts +565 -0
  44. package/starter/alpine/render/ground/horizon.ts +219 -0
  45. package/starter/alpine/render/ground/palette.d.ts +1 -0
  46. package/starter/alpine/render/ground/palette.js +11 -0
  47. package/starter/alpine/render/ground/scatter.ts +104 -0
  48. package/starter/alpine/render/ground/terrain.ts +1860 -0
  49. package/starter/alpine/render/kitAssets.ts +28 -0
  50. package/starter/alpine/render/loading.ts +354 -0
  51. package/starter/alpine/render/lookKnobs.ts +37 -0
  52. package/starter/alpine/render/orbitCamera.ts +155 -0
  53. package/starter/alpine/render/props/farForest.ts +94 -0
  54. package/starter/alpine/render/props/pack.ts +1114 -0
  55. package/starter/alpine/render/props/prepared.ts +225 -0
  56. package/starter/alpine/render/props/propMaterials.ts +1239 -0
  57. package/starter/alpine/render/props/propProgress.ts +2 -0
  58. package/starter/alpine/render/props/propWorld.ts +105 -0
  59. package/starter/alpine/render/props/props.ts +633 -0
  60. package/starter/alpine/render/props/spruce.ts +440 -0
  61. package/starter/alpine/render/sky/atmosphere.ts +329 -0
  62. package/starter/alpine/render/sky/sky.ts +382 -0
  63. package/starter/alpine/render/texturePreparation.ts +135 -0
  64. package/starter/alpine/render/water/river.ts +1132 -0
  65. package/starter/alpine/render/worldNames.ts +6 -0
  66. package/starter/alpine/scene.ts +715 -0
  67. package/starter/alpine/sceneProps.ts +561 -0
  68. package/starter/alpine/sceneState.ts +33 -0
  69. package/starter/alpine/world/terrainAssets.ts +145 -0
  70. package/starter/alpine/world/walkBand.ts +47 -0
  71. package/starter/alpine/world/water.ts +74 -0
  72. package/starter/alpine/worlds.ts +13 -0
  73. package/starter/arbor/wind.ts +84 -0
  74. package/starter/coastal/README.md +26 -25
  75. package/starter/coastal/assets.json +10 -0
  76. package/starter/coastal/bake.mjs +14 -1
  77. package/starter/coastal/biome.data.json +18 -3
  78. package/starter/coastal/playerRig.ts +89 -0
  79. package/starter/coastal/recipe.json +220 -18
  80. package/starter/coastal/render/bakedFile.ts +17 -0
  81. package/starter/coastal/render/benchmark.ts +81 -0
  82. package/starter/coastal/render/biomeData.ts +14 -0
  83. package/starter/coastal/render/biomes.ts +678 -0
  84. package/starter/coastal/render/ground/cover.ts +565 -0
  85. package/starter/coastal/render/ground/horizon.ts +219 -0
  86. package/starter/coastal/render/ground/palette.d.ts +1 -0
  87. package/starter/coastal/render/ground/palette.js +11 -0
  88. package/starter/coastal/render/ground/scatter.ts +104 -0
  89. package/starter/coastal/render/ground/terrain.ts +1829 -0
  90. package/starter/coastal/render/kitAssets.ts +28 -0
  91. package/starter/coastal/render/loading.ts +354 -0
  92. package/starter/coastal/render/lookKnobs.ts +37 -0
  93. package/starter/coastal/render/orbitCamera.ts +155 -0
  94. package/starter/coastal/render/props/farForest.ts +94 -0
  95. package/starter/coastal/render/props/pack.ts +1109 -0
  96. package/starter/coastal/render/props/prepared.ts +225 -0
  97. package/starter/coastal/render/props/propMaterials.ts +1239 -0
  98. package/starter/coastal/render/props/propProgress.ts +2 -0
  99. package/starter/coastal/render/props/propWorld.ts +105 -0
  100. package/starter/coastal/render/props/props.ts +633 -0
  101. package/starter/coastal/render/props/spruce.ts +440 -0
  102. package/starter/coastal/render/sky/atmosphere.ts +329 -0
  103. package/starter/coastal/render/sky/sky.ts +382 -0
  104. package/starter/coastal/render/texturePreparation.ts +135 -0
  105. package/starter/coastal/render/water/ocean.ts +284 -0
  106. package/starter/coastal/render/water/river.ts +1132 -0
  107. package/starter/coastal/render/worldNames.ts +6 -0
  108. package/starter/coastal/scene.ts +740 -0
  109. package/starter/coastal/sceneProps.ts +559 -0
  110. package/starter/coastal/sceneState.ts +33 -0
  111. package/starter/coastal/world/terrainAssets.ts +151 -0
  112. package/starter/coastal/world/walkBand.ts +47 -0
  113. package/starter/coastal/world/water.ts +74 -0
  114. package/starter/coastal/worlds.ts +13 -0
  115. package/starter/desert/README.md +51 -23
  116. package/starter/desert/bake-flora.mjs +142 -0
  117. package/starter/desert/bake-rocks.mjs +291 -0
  118. package/starter/desert/bake.mjs +14 -1
  119. package/starter/desert/biome.data.json +24 -12
  120. package/starter/desert/playerRig.ts +89 -0
  121. package/starter/desert/recipe.json +63 -16
  122. package/starter/desert/render/bakedFile.ts +17 -0
  123. package/starter/desert/render/benchmark.ts +79 -0
  124. package/starter/desert/render/biomeData.ts +14 -0
  125. package/starter/desert/render/biomes.ts +660 -0
  126. package/starter/desert/render/ground/cover.ts +565 -0
  127. package/starter/desert/render/ground/debris.ts +136 -0
  128. package/starter/desert/render/ground/horizon.ts +219 -0
  129. package/starter/desert/render/ground/palette.d.ts +1 -0
  130. package/starter/desert/render/ground/palette.js +11 -0
  131. package/starter/desert/render/ground/scatter.ts +104 -0
  132. package/starter/desert/render/ground/terrain.ts +1854 -0
  133. package/starter/desert/render/kitAssets.ts +28 -0
  134. package/starter/desert/render/loading.ts +354 -0
  135. package/starter/desert/render/lookKnobs.ts +37 -0
  136. package/starter/desert/render/orbitCamera.ts +155 -0
  137. package/starter/desert/render/props/farForest.ts +96 -0
  138. package/starter/desert/render/props/formations.ts +630 -0
  139. package/starter/desert/render/props/pack.ts +1195 -0
  140. package/starter/desert/render/props/prepared.ts +225 -0
  141. package/starter/desert/render/props/propMaterials.ts +1255 -0
  142. package/starter/desert/render/props/propProgress.ts +2 -0
  143. package/starter/desert/render/props/propWorld.ts +105 -0
  144. package/starter/desert/render/props/props.ts +624 -0
  145. package/starter/desert/render/props/spruce.ts +440 -0
  146. package/starter/desert/render/sand.ts +581 -0
  147. package/starter/desert/render/sky/atmosphere.ts +329 -0
  148. package/starter/desert/render/sky/sky.ts +382 -0
  149. package/starter/desert/render/texturePreparation.ts +135 -0
  150. package/starter/desert/render/water/river.ts +1132 -0
  151. package/starter/desert/render/worldNames.ts +6 -0
  152. package/starter/desert/scene.ts +748 -0
  153. package/starter/desert/sceneProps.ts +562 -0
  154. package/starter/desert/sceneState.ts +33 -0
  155. package/starter/desert/world/terrainAssets.ts +162 -0
  156. package/starter/desert/world/walkBand.ts +47 -0
  157. package/starter/desert/world/water.ts +74 -0
  158. package/starter/desert/worlds.ts +13 -0
  159. package/starter/forest/README.md +59 -116
  160. package/starter/forest/assets.json +14 -14
  161. package/starter/forest/bake.mjs +26 -4
  162. package/starter/forest/playerRig.ts +89 -0
  163. package/starter/forest/recipe.json +233 -43
  164. package/starter/forest/render/bakedFile.ts +17 -0
  165. package/starter/forest/render/benchmark.ts +77 -0
  166. package/starter/forest/render/biomeData.ts +14 -0
  167. package/starter/forest/render/biomes.ts +637 -0
  168. package/starter/forest/render/ground/cover.ts +565 -0
  169. package/starter/forest/render/ground/horizon.ts +219 -0
  170. package/starter/forest/render/ground/palette.d.ts +1 -0
  171. package/starter/forest/render/ground/palette.js +11 -0
  172. package/starter/forest/render/ground/scatter.ts +104 -0
  173. package/starter/forest/render/ground/terrain.ts +1796 -0
  174. package/starter/forest/render/kitAssets.ts +28 -0
  175. package/starter/forest/render/loading.ts +354 -0
  176. package/starter/forest/render/lookKnobs.ts +37 -0
  177. package/starter/forest/render/orbitCamera.ts +155 -0
  178. package/starter/forest/render/props/farForest.ts +94 -0
  179. package/starter/forest/render/props/pack.ts +1078 -0
  180. package/starter/forest/render/props/prepared.ts +226 -0
  181. package/starter/forest/render/props/propMaterials.ts +1247 -0
  182. package/starter/forest/render/props/propProgress.ts +2 -0
  183. package/starter/forest/render/props/propWorld.ts +105 -0
  184. package/starter/forest/render/props/props.ts +624 -0
  185. package/starter/forest/render/props/spruce.ts +440 -0
  186. package/starter/forest/render/sky/atmosphere.ts +329 -0
  187. package/starter/forest/render/sky/sky.ts +382 -0
  188. package/starter/forest/render/texturePreparation.ts +135 -0
  189. package/starter/forest/render/water/river.ts +1132 -0
  190. package/starter/forest/render/worldNames.ts +6 -0
  191. package/starter/forest/scene.ts +715 -0
  192. package/starter/forest/sceneProps.ts +559 -0
  193. package/starter/forest/sceneState.ts +33 -0
  194. package/starter/forest/surface.json +2 -2
  195. package/starter/forest/world/terrainAssets.ts +158 -0
  196. package/starter/forest/world/walkBand.ts +47 -0
  197. package/starter/forest/world/water.ts +74 -0
  198. package/starter/forest/worlds.ts +13 -0
  199. package/starter/tundra/README.md +35 -14
  200. package/starter/tundra/bake.mjs +14 -1
  201. package/starter/tundra/biome.data.json +6 -6
  202. package/starter/tundra/playerRig.ts +89 -0
  203. package/starter/tundra/recipe.json +111 -110
  204. package/starter/tundra/render/bakedFile.ts +17 -0
  205. package/starter/tundra/render/benchmark.ts +79 -0
  206. package/starter/tundra/render/biomeData.ts +14 -0
  207. package/starter/tundra/render/biomes.ts +714 -0
  208. package/starter/tundra/render/ground/cover.ts +565 -0
  209. package/starter/tundra/render/ground/horizon.ts +219 -0
  210. package/starter/tundra/render/ground/palette.d.ts +1 -0
  211. package/starter/tundra/render/ground/palette.js +11 -0
  212. package/starter/tundra/render/ground/scatter.ts +104 -0
  213. package/starter/tundra/render/ground/terrain.ts +1874 -0
  214. package/starter/tundra/render/kitAssets.ts +28 -0
  215. package/starter/tundra/render/loading.ts +354 -0
  216. package/starter/tundra/render/lookKnobs.ts +37 -0
  217. package/starter/tundra/render/orbitCamera.ts +155 -0
  218. package/starter/tundra/render/props/farForest.ts +96 -0
  219. package/starter/tundra/render/props/pack.ts +1088 -0
  220. package/starter/tundra/render/props/prepared.ts +225 -0
  221. package/starter/tundra/render/props/propMaterials.ts +1247 -0
  222. package/starter/tundra/render/props/propProgress.ts +2 -0
  223. package/starter/tundra/render/props/propWorld.ts +105 -0
  224. package/starter/tundra/render/props/props.ts +624 -0
  225. package/starter/tundra/render/props/spruce.ts +440 -0
  226. package/starter/tundra/render/sky/atmosphere.ts +329 -0
  227. package/starter/tundra/render/sky/sky.ts +382 -0
  228. package/starter/tundra/render/texturePreparation.ts +135 -0
  229. package/starter/tundra/render/water/river.ts +1132 -0
  230. package/starter/tundra/render/worldNames.ts +6 -0
  231. package/starter/tundra/scene.ts +715 -0
  232. package/starter/tundra/sceneProps.ts +559 -0
  233. package/starter/tundra/sceneState.ts +33 -0
  234. package/starter/tundra/world/terrainAssets.ts +159 -0
  235. package/starter/tundra/world/walkBand.ts +47 -0
  236. package/starter/tundra/world/water.ts +74 -0
  237. package/starter/tundra/worlds.ts +13 -0
  238. package/starter-assets.json +4 -4
  239. package/starter-credits.json +901 -15
  240. package/AGENT_GUIDE.md +0 -209
  241. package/starter/forest/sky.ts +0 -38
  242. package/starter/forest/water.ts +0 -257
  243. package/starter/forest/world.ts +0 -182
@@ -0,0 +1,637 @@
1
+ import { measureBands } from "@threenative/terrain";
2
+ import { ACESFilmicToneMapping, type Texture, type ToneMapping } from "three";
3
+ /** Game-owned biome choices; all five worlds share the same rendering and collision paths. */
4
+ import {
5
+ abs,
6
+ dot,
7
+ float,
8
+ mix,
9
+ mx_fractal_noise_float,
10
+ mx_noise_float,
11
+ mx_worley_noise_vec2,
12
+ normalWorldGeometry,
13
+ positionWorld,
14
+ rotateUV,
15
+ smoothstep,
16
+ texture,
17
+ vec2,
18
+ vec3,
19
+ vec4,
20
+ } from "three/tsl";
21
+ import type { Node } from "three/webgpu";
22
+ import { GROUND_MAPS, type IGroundMaps, type LayerKey } from "../world/terrainAssets.js";
23
+ import type { WORLD_NAMES } from "./worldNames.js";
24
+ import { WORLD } from "./worldNames.js";
25
+
26
+ export type WorldName = (typeof WORLD_NAMES)[number];
27
+ type RGB = readonly [number, number, number];
28
+
29
+ /** Where a pinned vista camera looks, from the player it tracks. */
30
+ export interface IVistaAim {
31
+ /** Metres along x and z from the player that the camera looks at. */
32
+ readonly at: readonly [number, number];
33
+ /** Metres above the player's feet, or null to look level with the world's own water. */
34
+ readonly rise: number | null;
35
+ }
36
+
37
+ type HeightBand =
38
+ | "alpine"
39
+ | "rock"
40
+ | "treeline"
41
+ | "cap"
42
+ | "desertRock"
43
+ | "alpineRock"
44
+ | "alpineHollow";
45
+ type HeightBands = Readonly<Record<HeightBand, readonly [number, number]>>;
46
+
47
+ export interface IBiome {
48
+ readonly world: WorldName;
49
+ readonly grassTint: RGB;
50
+ readonly stoneTint: RGB;
51
+ /** Prop-only tint; terrain rock keeps its own grading. */
52
+ readonly propStoneTint?: RGB;
53
+ readonly snowTint: RGB;
54
+ readonly distantStone: RGB;
55
+ readonly snowFractions: readonly [number, number, number];
56
+ readonly heightFractions: HeightBands;
57
+ /**
58
+ * Metres the fractions scale by, when they are heights above the floor rather than shares of this
59
+ * ground's own walkable range: a treeline does not climb because a cooked square is hillier.
60
+ */
61
+ readonly bandSpan?: number;
62
+ readonly maps: Record<LayerKey, IGroundMaps>;
63
+ readonly horizon: "mountain" | "alpine" | "mesa" | "plain";
64
+ readonly sun: {
65
+ readonly color: number;
66
+ readonly intensity: number;
67
+ readonly direction: RGB;
68
+ readonly shadowRadius: number;
69
+ };
70
+ readonly sky: {
71
+ turbidity: number;
72
+ rayleigh: number;
73
+ mieCoefficient: number;
74
+ mieDirectionalG: number;
75
+ };
76
+ readonly fill: { readonly sky: number; readonly ground: number; readonly intensity: number };
77
+ readonly haze: {
78
+ readonly color: number;
79
+ readonly density: number;
80
+ readonly valleyDensity: number;
81
+ readonly height: number;
82
+ readonly sunScatter: number;
83
+ };
84
+ readonly atmosphere: {
85
+ readonly rayleigh: RGB;
86
+ readonly mie: number;
87
+ readonly radiance: number;
88
+ readonly distanceScale: number;
89
+ readonly horizonFade: readonly [number, number];
90
+ /**
91
+ * Alpine air past the playable valley: exponential height fog (UE's two-term
92
+ * `ExponentialHeightFog`) in place of the local haze tint, and `distanceScale` in place of the
93
+ * valley's, blended in over `reach` metres so the valley keeps its clear air. A ridge above the
94
+ * layers stays clear and a valley under them fills with mist. Each term is an extinction per
95
+ * metre at `height` that falls by e every `scale` metres up; `start` is the clear foreground in
96
+ * metres. Absent, the world keeps the distance-squared haze everywhere.
97
+ */
98
+ readonly heightFog?: {
99
+ readonly reach: readonly [number, number];
100
+ readonly distanceScale: number;
101
+ readonly start: number;
102
+ readonly terms: readonly {
103
+ readonly density: number;
104
+ readonly height: number;
105
+ readonly scale: number;
106
+ }[];
107
+ };
108
+ /**
109
+ * Mist between the stands of a wood: a third exponential layer (same integral as `heightFog`,
110
+ * UE 5.8.3: Engine/Shaders/Private/HeightFogCommon.ush:207-214) that starts `start` metres from
111
+ * the eye and lies on the valley floor, so each stand behind the next is a little paler and the
112
+ * low sun glows in the air. `maxOpacity` is UE's `FogMaxOpacity`: a far stand keeps its shape.
113
+ * `color` is the mist in shade. Absent, the foreground air is clear.
114
+ */
115
+ readonly groundMist?: {
116
+ readonly color: number;
117
+ readonly start: number;
118
+ readonly maxOpacity: number;
119
+ readonly term: { readonly density: number; readonly height: number; readonly scale: number };
120
+ };
121
+ };
122
+ readonly skyRadiance: number;
123
+ readonly saturation: number;
124
+ readonly skySaturation: number;
125
+ readonly exposure: number;
126
+ /** The tone curve this world was graded under. */
127
+ readonly toneMapping: ToneMapping;
128
+ /** The ground is graded from the bake's own photographed turf, not from measured layers. */
129
+ readonly lawnGround: boolean;
130
+ /** Bare bedded rock and dirt: the ground keeps its beds and carries no snow. */
131
+ readonly mesaGround: boolean;
132
+ /** Moss and lichen mats lie over the ground, from the polygon field. */
133
+ readonly mossGround: boolean;
134
+ /** Rock walls read the crest projection and hold snow in their own bands. */
135
+ readonly crestRock: boolean;
136
+ /** Metres a hollow lifts the snowline probe: a sheltered shelf keeps its snow. */
137
+ readonly snowHollowLift: number;
138
+ /** Steepness, 0..1, the snow starts to shed at. */
139
+ readonly snowShedFrom: number;
140
+ /** Snow comes from this look's own weight graph rather than from the crest snow cover. */
141
+ readonly localSnow: boolean;
142
+ /** The turf fades to a distant cover colour, and loses its relief, with distance. */
143
+ readonly crestTurf: boolean;
144
+ /** The meadow here is an olive field of blades, mixed into the lawn by the open ground. */
145
+ readonly oliveMeadow: boolean;
146
+ /** The rock carries bedded mesa bands: the desert's own projection and varnish. */
147
+ readonly mesaRock: boolean;
148
+ /** Loose sand on the ground ripples, and the ripples flatten where the sand is wet. */
149
+ readonly sandRipples: boolean;
150
+ /** The open meadow past the square's edge belongs to this look. */
151
+ readonly openMeadow: boolean;
152
+ /** The ground under a closed stand: needle litter, bare earth and its shade. */
153
+ readonly woodedGround: boolean;
154
+ /** A shore's ground: dry soil patches between the sand banks. */
155
+ readonly shoreGround: boolean;
156
+ /** The far backdrop keeps the survey's own look instead of the crest's spruce stands. */
157
+ readonly surveyedBackdrop: boolean;
158
+ /** The backdrop shades from this look's unfiltered survey collar. */
159
+ readonly surveyCollar: boolean;
160
+ /** The terrain mesh casts shadows: a massif casts onto its own valley. */
161
+ readonly terrainCastsShadow: boolean;
162
+ /** Metres the ground's own masks extend past the playable square; zero for no collar. */
163
+ readonly groundCollarMeters: number;
164
+ /** The collar carries the distant rock tilt; a mat plain keeps its resident normals. */
165
+ readonly continuationTilt: boolean;
166
+ /** How far a stone's albedo is pulled to grey. */
167
+ readonly stoneGrey: number;
168
+ /** How far distant stone fades to the massif's own tone. */
169
+ readonly distantStoneShare: number;
170
+ /**
171
+ * Share of a stone's height the ground snap sinks it by once its footprint's four points have also
172
+ * been snapped, so a boulder settles into a slope instead of hanging on one contact; null for a
173
+ * stone snapped at its centre only.
174
+ */
175
+ readonly stoneSinkShare: number | null;
176
+ /** How many prepared stone scans this look's props use; a second fills the pack's primitive slot. */
177
+ readonly stoneScans: number;
178
+ /** The tone a ground's distant stone fades to, where it differs from the stone's own. */
179
+ readonly groundDistantStone?: RGB;
180
+ /** A stone's base takes the ground's own contact band. */
181
+ readonly stoneGroundBand: boolean;
182
+ /** That contact band draws the crest rockface rather than the look's own rock. */
183
+ readonly contactRockface: boolean;
184
+ /** Stone draws its shadow from the sun-facing side, so an intersection shows no lit strip. */
185
+ readonly stoneFrontFace: boolean;
186
+ /** The look's stone is dry CC0 scans, without the meadow's moss. */
187
+ readonly dryStones: boolean;
188
+ /** The look's stone carries snow. */
189
+ readonly stoneSnow: boolean;
190
+ /** The tint this look gives a blade of ground cover. */
191
+ readonly propGrassTint: RGB;
192
+ /** How much moss a stone wears over its own albedo, 0..1. */
193
+ readonly stoneMoss: number;
194
+ /** The moss a stone wears, where it wears any. */
195
+ readonly stoneMossTint: RGB;
196
+ /** The flat snow a snowed stone mixes in where it is not crest-mapped. */
197
+ readonly stoneSnowTint: RGB;
198
+ /** The tint this look gives an imported crown. */
199
+ readonly canopyTint: RGB;
200
+ /** The tint this look gives an imported blade or frond. */
201
+ readonly bladeTint: RGB;
202
+ /**
203
+ * The value of every blade, frond and mat against the crowns above them: a sward photographed in
204
+ * midday sun draws brighter than the wood it grows in. Petals keep their photograph. Absent, 1.
205
+ */
206
+ readonly swardTint?: RGB;
207
+ /**
208
+ * Multiplies the open turf the sward grows from. A short blade covers a part of its ground, so a
209
+ * turf several times brighter than the blade draws the blades as black hair on a yellow lawn
210
+ * (measured 4.45 times in the forest's low sun). Absent, the turf keeps its photograph.
211
+ */
212
+ readonly turfTint?: RGB;
213
+ /**
214
+ * The sun's shadow is drawn to a window around the eye, and the far forest casts none, so a tree
215
+ * past either draws fully sunlit beside crowns that stand in each other's shade. This is the mean
216
+ * stand shade such a tree takes at a sun on the horizon (`standShaded`); it fades to none as the
217
+ * sun climbs. Absent, those trees draw unshaded.
218
+ */
219
+ readonly standShade?: RGB;
220
+ /**
221
+ * The share of ambient and sky-image light a plant keeps where the baked canopy closes over it.
222
+ * In the open it sees the whole sky; under a closed wood it sees a few gaps, and at the full value
223
+ * a fern in deep shade glows lime beside ground that takes no sky image at all. Absent, 1.
224
+ */
225
+ readonly understoreySkyLight?: number;
226
+ /** The tint this look gives an imported cutout in its own grading. */
227
+ readonly cutoutTint: RGB;
228
+ /** The tint this look gives an imported stone in its own grading. */
229
+ readonly stoneSectionTint: RGB;
230
+ /** Inner-crown shade, 0..1: how dark the middle of a crown draws. */
231
+ readonly canopyInnerShade: number;
232
+ /** A crown's inner shade runs linear from the geometry's own weight, not squared. */
233
+ readonly canopyLinearInner: boolean;
234
+ /** The crown's inner ambient occlusion: at the trunk, and at the needle tips. */
235
+ readonly canopyAmbientOcclusion: readonly [number, number];
236
+ /** The look's crowns and blades are shaded by its own needle path, not as imported PBR. */
237
+ readonly woodCanopy: boolean;
238
+ /** A crown's normal comes from its own geometry where the art carries no normal map. */
239
+ readonly crownGeometryNormals: boolean;
240
+ /** The look's crowns keep the authored alpha cutoff rather than a constant one. */
241
+ readonly authoredAlphaTest: boolean;
242
+ /** The scale a crown's own emissive takes, where this look lifts it less than the shared one. */
243
+ readonly canopyEmissiveScale: number | null;
244
+ /** The look's ground cover is a low mat: no photographic relief, a stricter cutoff, dark roots. */
245
+ readonly mats: boolean;
246
+ /** The look's mountains are pinned crags, 24 m on their longest axis. */
247
+ readonly pinnedCrags: boolean;
248
+ /** The look's bush is the small scrub model, not the temperate thicket. */
249
+ readonly scrubBush: boolean;
250
+ /** The look's blades go straw, and its dunes go straw with height. */
251
+ readonly strawBlades: boolean;
252
+ /** Metres the game's own sapling art stands at in this biome; null for the art's own height. */
253
+ readonly saplingHeight: number | null;
254
+ /** The look's river mirrors the ponds beside it, not only the sky. */
255
+ readonly riverMirrorsPonds: boolean;
256
+ /** The pinned camera a vista is framed from; null where the player's own camera follows them. */
257
+ readonly vistaAim: IVistaAim | null;
258
+ readonly clouds: number;
259
+ /** Virtual shadow map size, texels: finer where a distant ridge casts onto a valley. */
260
+ readonly shadowMapSize: number;
261
+ /** A single texel of normal bias, which ties a contact to the shadow resolution. */
262
+ readonly tightShadowContacts: boolean;
263
+ /** Per-level refresh step where a shadow page is crossed slowly, else null for the default. */
264
+ readonly shadowRefreshStep: readonly [number, number] | null;
265
+ /** Temporal anti-aliasing on this look's still passes. */
266
+ readonly temporalAA: boolean;
267
+ /** This look carries the water-proof diagnostic arm. */
268
+ readonly waterProof: boolean;
269
+ }
270
+
271
+ const temperate: IBiome = {
272
+ world: "forest",
273
+ grassTint: [0.43, 0.76, 0.38],
274
+ // The meadow's rock grading, which is the only reader of this look's ground tint: a lawn's stones
275
+ // are graded by the ground, and its props carry `propStoneTint` instead. This is the tone the
276
+ // lawn's stones were graded to before the split named it: `[0.48, 0.44, 0.39]` stood here and
277
+ // never reached a pixel, because both readers gated `stoneTint` behind `otherBiome`.
278
+ stoneTint: [0.44, 0.46, 0.42],
279
+ snowTint: [1, 1, 1],
280
+ distantStone: [0.115, 0.105, 0.088],
281
+ // Snow and caps belong to the surveyed horizon, beyond the resident height range.
282
+ snowFractions: [3.6, 4.8, 0.22],
283
+ heightFractions: {
284
+ alpine: [0.95, 1.65],
285
+ rock: [0.35, 1.8],
286
+ // The generated backdrop rises to 848 m over a 41 m walkable range. Spruce climbs to about
287
+ // 260-400 m (its 70th-80th height percentile) and snow holds only on the peaks' gentle ground
288
+ // above 570-690 m (93rd-97th). At 227-315 m the snow lay across every saddle as a white band.
289
+ treeline: [6.5, 10],
290
+ cap: [14, 17],
291
+ desertRock: [0.18, 0.48],
292
+ alpineRock: [0.06, 0.14],
293
+ alpineHollow: [0.05, 0.12],
294
+ },
295
+ maps: GROUND_MAPS,
296
+ horizon: "mountain",
297
+ sun: { color: 0xffe3b5, intensity: 5.8, direction: [-180, 145, 80], shadowRadius: 1.7 },
298
+ sky: { turbidity: 2, rayleigh: 3, mieCoefficient: 0.003, mieDirectionalG: 0.82 },
299
+ fill: { sky: 0xa8c8e8, ground: 0x464937, intensity: 0.72 },
300
+ haze: {
301
+ color: 0x8ca8ba,
302
+ density: 0.0011,
303
+ valleyDensity: 0.000006,
304
+ height: 120,
305
+ sunScatter: 0.32,
306
+ },
307
+ atmosphere: {
308
+ rayleigh: [0.005802, 0.013558, 0.0331],
309
+ mie: 0.004,
310
+ radiance: 1.4,
311
+ distanceScale: 1.5,
312
+ // The generated backdrop's rim stands at 2.36 km (`horizon.json`), up to 3.7 km from the vista
313
+ // eye, so the fade only rounds off its corners; at [1800, 3300] it swapped the far ridges for sky.
314
+ horizonFade: [3400, 4800],
315
+ // UE 5.8.3 exponential height fog, two terms (Engine/Shaders/Private/HeightFogCommon.ush:207-214,
316
+ // :309-311): a broad haze and a thin valley mist under the 71 m vista eye.
317
+ heightFog: {
318
+ // The lake (0.25-0.6 km from the vista eye) and the far stands (to 0.8 km) keep the valley's
319
+ // air; the judge held them to BEFORE within 2/255. The massif starts at 1.1 km.
320
+ reach: [900, 1300],
321
+ // UE's `AerialPespectiveViewDistanceScale` (SkyAtmosphereComponent.cpp:131, default 1): the
322
+ // 2.4 km backdrop takes the blue of a range twice as far away, as the goal frame does.
323
+ distanceScale: 4,
324
+ start: 150,
325
+ terms: [
326
+ { density: 0.0002, height: 0, scale: 200 },
327
+ { density: 0.0015, height: 15, scale: 35 },
328
+ ],
329
+ },
330
+ },
331
+ skyRadiance: 0.27,
332
+ saturation: 1,
333
+ skySaturation: 1,
334
+ // +0.45 EV with TRAA (opaque foliage no longer averages with soil and sky), then +0.68 EV once the
335
+ // sky image lost its baked sun: that disc had been 44% of the meadow's light.
336
+ exposure: 2 ** 0.87,
337
+ toneMapping: ACESFilmicToneMapping,
338
+ lawnGround: true,
339
+ mesaGround: false,
340
+ mossGround: false,
341
+ crestRock: false,
342
+ snowHollowLift: 5,
343
+ snowShedFrom: 0.04,
344
+ localSnow: false,
345
+ crestTurf: false,
346
+ oliveMeadow: false,
347
+ mesaRock: false,
348
+ sandRipples: false,
349
+ openMeadow: false,
350
+ woodedGround: false,
351
+ shoreGround: false,
352
+ surveyedBackdrop: false,
353
+ surveyCollar: false,
354
+ terrainCastsShadow: false,
355
+ groundCollarMeters: 0,
356
+ continuationTilt: true,
357
+ stoneGrey: 0.35,
358
+ distantStoneShare: 0.65,
359
+ stoneSinkShare: 0.12,
360
+ stoneScans: 1,
361
+ stoneGroundBand: true,
362
+ contactRockface: false,
363
+ stoneFrontFace: false,
364
+ dryStones: false,
365
+ stoneSnow: false,
366
+ propGrassTint: [0.86, 0.92, 0.6],
367
+ stoneMoss: 0.38,
368
+ stoneMossTint: [0.045, 0.078, 0.019],
369
+ stoneSnowTint: [0.84, 0.87, 0.91],
370
+ canopyTint: [0.6, 0.78, 0.34],
371
+ bladeTint: [0.6, 0.78, 0.45],
372
+ cutoutTint: [0.72, 0.8, 0.55],
373
+ stoneSectionTint: [0.7, 0.78, 0.61],
374
+ canopyInnerShade: 0.6,
375
+ canopyLinearInner: false,
376
+ canopyAmbientOcclusion: [0.35, 1],
377
+ woodCanopy: false,
378
+ crownGeometryNormals: false,
379
+ authoredAlphaTest: false,
380
+ canopyEmissiveScale: null,
381
+ mats: false,
382
+ pinnedCrags: false,
383
+ scrubBush: false,
384
+ strawBlades: false,
385
+ saplingHeight: null,
386
+ riverMirrorsPonds: false,
387
+ vistaAim: null,
388
+ clouds: 0.76,
389
+ shadowMapSize: 2048,
390
+ tightShadowContacts: false,
391
+ shadowRefreshStep: null,
392
+ temporalAA: true,
393
+ waterProof: false,
394
+ };
395
+
396
+ /** The wood itself: the temperate base with its stand rules on. The other four looks are not woods. */
397
+ const forest: IBiome = {
398
+ ...temperate,
399
+ heightFractions: {
400
+ ...temperate.heightFractions,
401
+ // The backdrop rises to about 1100 m over a 41 m walkable range, its near massif a surveyed
402
+ // mountain on 300-500 m of foothills (PRD-866). Spruce climbs to 450-575 m, about half the
403
+ // relief as on a real range, so the massif's lower slopes are wooded (owner reference
404
+ // 2026-11-09: "mountains with forested lower slopes"); snow holds above 700-860 m. At 227-315 m
405
+ // the snow lay across every saddle as a white band.
406
+ treeline: [11, 14],
407
+ cap: [17, 21],
408
+ },
409
+ // The pinned valley's own span: a cooked world (`STRATA_WORLD`) keeps these bands in metres above
410
+ // its floor, so its treeline and snow sit where this forest's do.
411
+ bandSpan: 41,
412
+ oliveMeadow: true,
413
+ openMeadow: true,
414
+ woodedGround: true,
415
+ surveyCollar: true,
416
+ contactRockface: true,
417
+ woodCanopy: true,
418
+ crownGeometryNormals: true,
419
+ authoredAlphaTest: true,
420
+ // The wood stands in a low warm sun, 20 degrees up: the owner's reference frame (2026-11-09) is a
421
+ // spruce wood an hour before sunset, with deep shade inside the stands and warm patches on the
422
+ // floor. Less sky fill keeps that shade deep. The other temperate worlds keep the midday sun.
423
+ sun: { ...temperate.sun, color: 0xffb878, intensity: 8, direction: [180, 72, 80] },
424
+ fill: { ...temperate.fill, intensity: 0.55 },
425
+ // The ground plants sit a third darker and cooler, at the crowns' value (owner, 2026-11-09:
426
+ // "ground vegetation still too brighty compared to the forest").
427
+ swardTint: [0.64, 0.72, 0.66],
428
+ // Brings the sunlit turf to about twice its blades' value and to their green.
429
+ turfTint: [0.3, 0.44, 0.32],
430
+ // Measured at the overview, 20 degree sun: square crowns over far crowns, linear, per channel.
431
+ standShade: [0.13, 0.25, 0.51],
432
+ // A fern under a closed crown keeps a third of the sky; the open meadow keeps all of it.
433
+ understoreySkyLight: 0.3,
434
+ // The meadow's own distant stone tone: a lawn fades to a paler rock than its props do.
435
+ groundDistantStone: [0.16, 0.17, 0.155],
436
+ // Clearer alpine air under the low evening sun (owner, 2026-11-09): at a distance scale of 4 and
437
+ // 0.0002/m the massif washed to a flat lilac sheet; 2.5 and 0.00012/m keep its ridges apart and
438
+ // its snow white, and the thin valley mist still lies against its foot.
439
+ atmosphere: {
440
+ ...temperate.atmosphere,
441
+ heightFog: {
442
+ reach: [900, 1300],
443
+ distanceScale: 2.5,
444
+ start: 150,
445
+ terms: [
446
+ { density: 0.00012, height: 0, scale: 200 },
447
+ { density: 0.0015, height: 15, scale: 35 },
448
+ ],
449
+ },
450
+ // Evening mist on the valley floor (the wood stands at 13-30 m): a stand 60 m off is about a
451
+ // seventh mist, one 150 m off a third, and the layer thins by e every 15 m up, so a view from above the crowns stays clear.
452
+ groundMist: {
453
+ color: 0x6c8590,
454
+ start: 10,
455
+ maxOpacity: 0.36,
456
+ term: { density: 0.0035, height: 14, scale: 15 },
457
+ },
458
+ },
459
+ };
460
+
461
+ export const BIOMES: Record<WorldName, IBiome> = {
462
+ [WORLD]: forest,
463
+ };
464
+
465
+ export interface IWorldBiome extends IBiome {
466
+ readonly elevationRange: readonly [number, number];
467
+ readonly heightBands: HeightBands;
468
+ readonly snowBand: readonly [number, number];
469
+ }
470
+
471
+ /** Resolve game-owned fractions once against this world's actual samples (`measureBands` owns the arithmetic). */
472
+ export function measureBiome(biome: IBiome, heights: readonly number[]): IWorldBiome {
473
+ const rows = [
474
+ ...Object.entries(biome.heightFractions).map(([layer, [from, to]]) => ({ layer, from, to })),
475
+ { layer: "snow", from: biome.snowFractions[0], to: biome.snowFractions[1] },
476
+ ];
477
+ // The ground's own range, measured (and validated) whatever span the bands scale by.
478
+ const ground = measureBands(rows, heights);
479
+ const floor = ground.elevationRange[0];
480
+ const measured =
481
+ biome.bandSpan === undefined ? ground : measureBands(rows, [floor, floor + biome.bandSpan]);
482
+ return {
483
+ ...biome,
484
+ elevationRange: ground.elevationRange,
485
+ heightBands: measured.bands as HeightBands,
486
+ // The snow row above is always passed, so measureBands always returns its band.
487
+ snowBand: measured.snowBand as readonly [number, number],
488
+ };
489
+ }
490
+
491
+ /** A flat world has no elevation transition; never emit equal-edge smoothstep. */
492
+ export function elevationBand(
493
+ biome: IWorldBiome,
494
+ band: readonly [number, number],
495
+ height: Node<"float"> = positionWorld.y,
496
+ ): Node<"float"> {
497
+ return biome.elevationRange[0] === biome.elevationRange[1]
498
+ ? float(0)
499
+ : smoothstep(band[0], band[1], height);
500
+ }
501
+
502
+ /** Local ground rules; slope keeps steep faces bare and noise breaks the snow's contour line. */
503
+ export function biomeWeights(
504
+ biome: IWorldBiome,
505
+ steep: Node<"float">,
506
+ hollow: Node<"float">,
507
+ breakup: Node<"float">,
508
+ ): Partial<Record<LayerKey, Node<"float">>> {
509
+ if (biome.lawnGround) return {};
510
+ const drift = mx_fractal_noise_float(positionWorld.mul(0.033), 3);
511
+ const stone = smoothstep(0.1, 0.29, steep.add(breakup.mul(0.04)));
512
+ if (biome.mesaGround)
513
+ return {
514
+ dirt: smoothstep(0.14, 0.65, hollow).mul(0.7),
515
+ moss: float(0),
516
+ sand: float(0),
517
+ rock: stone
518
+ .max(elevationBand(biome, biome.heightBands.desertRock).mul(0.48))
519
+ .mul(float(1).sub(smoothstep(0.12, 0.5, hollow).mul(0.35))),
520
+ snow: float(0),
521
+ };
522
+ // Wind-scoured convex/exposed faces shed snow; sheltered shelves keep it.
523
+ const exposure = normalWorldGeometry.x.mul(0.65).add(normalWorldGeometry.z.mul(0.4)).max(0);
524
+ const retention = elevationBand(
525
+ biome,
526
+ biome.snowBand,
527
+ positionWorld.y.add(hollow.max(0).mul(biome.snowHollowLift)),
528
+ ).mul(
529
+ float(1)
530
+ .sub(smoothstep(biome.snowShedFrom, biome.snowFractions[2], steep))
531
+ .mul(float(1).sub(exposure.mul(0.28))),
532
+ );
533
+ // A narrow retention threshold leaves wind-shaped shelves and sharp scour edges.
534
+ const snow = smoothstep(0.36, 0.42, retention.add(hollow.max(0).mul(0.08)));
535
+ const cells = mx_worley_noise_vec2(
536
+ vec3(positionWorld.x, 0, positionWorld.z).mul(0.13).add(drift.mul(0.35)),
537
+ );
538
+ const polygon = smoothstep(0.025, 0.11, cells.y.sub(cells.x));
539
+ const mats = smoothstep(
540
+ 0.47,
541
+ 0.77,
542
+ float(0.52)
543
+ .add(positionWorld.x.mul(0.343).add(positionWorld.z.mul(0.1566)).sin().mul(0.27))
544
+ .add(positionWorld.z.mul(0.3741).sub(positionWorld.x.mul(0.1666)).add(1.3).sin().mul(0.24))
545
+ .add(positionWorld.x.mul(0.6958).add(positionWorld.z.mul(0.5307)).sin().mul(0.12)),
546
+ );
547
+ return {
548
+ dirt: biome.mossGround
549
+ ? smoothstep(0.08, 0.5, hollow)
550
+ .mul(0.28)
551
+ .max(polygon.oneMinus().mul(0.3))
552
+ .mul(mats.oneMinus())
553
+ : smoothstep(0.08, 0.5, hollow).mul(0.55),
554
+ moss: biome.mossGround
555
+ ? mats
556
+ .mul(smoothstep(-0.2, 0.22, drift).mul(0.85).add(0.15))
557
+ .mul(snow.oneMinus())
558
+ .mul(mix(0.72, 0.98, polygon))
559
+ : float(0),
560
+ rock: biome.crestRock
561
+ ? stone
562
+ .max(0.8)
563
+ .max(elevationBand(biome, biome.heightBands.alpineRock).mul(0.58))
564
+ .max(
565
+ smoothstep(0.12, 0.5, hollow)
566
+ .mul(elevationBand(biome, biome.heightBands.alpineHollow))
567
+ .mul(0.45),
568
+ )
569
+ .mul(float(1).sub(smoothstep(0.08, 0.4, hollow).mul(0.4)))
570
+ : stone,
571
+ snow: biome.localSnow ? snow : alpineSnowCover(biome, hollow),
572
+ };
573
+ }
574
+
575
+ /** One world-space RockFace003 projection on both the massif and its protruding ribs. */
576
+ export function alpineRockTap(source: Texture, plane: Node<"vec2">, relief = false): Node<"vec4"> {
577
+ const tap = (scale: number, angle: number, offset: Node<"vec2">) => {
578
+ const sampled = texture(source, rotateUV(plane.div(scale), float(angle), vec2(0)).add(offset));
579
+ if (!relief) return sampled;
580
+ const tangent = rotateUV(sampled.xy.mul(2).sub(1), float(-angle), vec2(0));
581
+ return vec4(tangent, sampled.z.mul(2).sub(1), 1);
582
+ };
583
+ const patch = smoothstep(-0.35, 0.35, mx_noise_float(positionWorld.mul(0.025)));
584
+ return mix(tap(8, 0.17, vec2(0)), tap(32, -0.21, vec2(0.37, 0.61)), patch.mul(0.3).add(0.2));
585
+ }
586
+
587
+ export function alpineRockAlbedo(source: Texture): Node<"vec3"> {
588
+ const axis = abs(normalWorldGeometry).pow(4);
589
+ const share = axis.div(axis.x.add(axis.y).add(axis.z));
590
+ return share.x
591
+ .mul(alpineRockTap(source, positionWorld.zy).rgb)
592
+ .add(share.y.mul(alpineRockTap(source, positionWorld.xz).rgb))
593
+ .add(share.z.mul(alpineRockTap(source, positionWorld.xy).rgb));
594
+ }
595
+
596
+ export function alpineRockColor(sample: Node<"vec3">): Node<"vec3"> {
597
+ const grey = dot(sample, vec3(0.2126, 0.7152, 0.0722));
598
+ return mix(sample, vec3(grey), 0.25).mul(vec3(0.86, 0.88, 0.9));
599
+ }
600
+
601
+ /** Snow respects world elevation and upward faces, including tilted instanced scans. */
602
+ export function alpineSnowCover(
603
+ biome: IWorldBiome,
604
+ hollow: Node<"float"> = float(0),
605
+ ): Node<"float"> {
606
+ const exposure = normalWorldGeometry.x.mul(0.65).add(normalWorldGeometry.z.mul(0.4)).max(0);
607
+ const retention = elevationBand(
608
+ biome,
609
+ biome.snowBand,
610
+ positionWorld.y.add(hollow.max(0).mul(110)),
611
+ )
612
+ .mul(smoothstep(0.35, 0.72, normalWorldGeometry.y))
613
+ .mul(float(1).sub(exposure.mul(0.28)))
614
+ .mul(float(1).sub(hollow.min(0).negate().mul(0.65)));
615
+ return smoothstep(0.36, 0.42, retention);
616
+ }
617
+
618
+ /** Thin sediment beds have varying thickness; varnish runs down, not around, a wall. */
619
+ export function desertRockColor(sample: Node<"vec3">): Node<"vec3"> {
620
+ const grain = dot(sample, vec3(0.2126, 0.7152, 0.0722));
621
+ const warp = mx_fractal_noise_float(positionWorld.mul(vec3(0.012, 0.003, 0.012)), 3).mul(5);
622
+ const height = positionWorld.y.add(warp);
623
+ const beds = mx_noise_float(vec3(0, height.mul(1.55), 0));
624
+ const fine = height.mul(4.1).add(beds.mul(2.8)).sin().mul(0.05);
625
+ const ledge = smoothstep(0.38, 0.62, mx_noise_float(vec3(0, height.mul(0.19), 0))).mul(0.18);
626
+ const varnish = smoothstep(
627
+ -0.18,
628
+ 0.28,
629
+ mx_fractal_noise_float(positionWorld.mul(vec3(0.42, 0.004, 0.42)), 3),
630
+ )
631
+ .mul(normalWorldGeometry.y.abs().oneMinus())
632
+ .mul(0.4);
633
+ return vec3(1.52, 0.9, 0.5)
634
+ .mul(grain)
635
+ .mul(beds.mul(0.24).add(fine).add(1).sub(ledge))
636
+ .mul(mix(vec3(1), vec3(0.55, 0.48, 0.42), varnish));
637
+ }