Skip to content

armgit / 67.js

Public Imported from GitHub
0

3D engine that AI agents drive

Document mirrorLevels 2 for terrain near water with its measured cost (part of #316)

Nguyen Xuan An1e1df3935ec8
diff --git a/changes/316-terrain-default.md b/changes/316-terrain-default.md
new file mode 100644
index 00000000..5b6a299e
--- /dev/null
+++ b/changes/316-terrain-default.md
@@ -0,0 +1 @@
+- docs/terrain.md recommends `createTerrain({ mirrorLevels: 2 })` for terrain near water and gives its cost: about 22 MB more mesh data and 80% more build time on a 900 m terrain, for a mirror frame at +25% instead of +40% over reflection off (part of #316). The default stays 0, because the terrain has no way to know about water.
diff --git a/docs/terrain.md b/docs/terrain.md
index 7288f6ac..632e86bf 100644
--- a/docs/terrain.md
+++ b/docs/terrain.md
@@ -90,6 +90,10 @@ Memory: three `TEXTURE_2D_ARRAY`s on units 11 to 13 (sRGB colour, normal, roughn
In a recipe, the same ground is the `terrain` geometry (`size`, `resolution`, `seed`, `amplitude`, `holes`): see [agent-scene](agent-scene.md).
+## Terrain near water
+
+`createTerrain({ mirrorLevels: 2 })` builds two extra coarse meshes for each chunk that only the water reflection draws (`attachWaterReflection` hides them from every other draw). Set it for terrain that a reflecting surface will mirror; it stays 0 otherwise because the terrain knows nothing of the water, which a scene adds afterwards. Measured on a 900 m terrain at resolution 128 with 8 by 8 chunks: it adds about 22 MB of mesh data (the finest level is 61 MB) and raises the build time from about 410 ms to 740 ms (median of 5). In return the mirror frame of the water benchmark (960 by 540, RTX 3060, median of 240 samples) costs +25% over reflection off instead of +40%.
+
## Heightfield from rasters
`67js/addons/heightfield` builds a mesh from georeferenced rasters (heights, a mask, a photo) when `createTerrain` does not fit, such as a shoreline cut from a sea mask. A raster is `{ values, width, height, box: { x_min, x_max, y_min, y_max } }`, pixel centres on the box, row 0 at the north edge.