Expand description
Analytic water-surface geometry helpers.
The water is rendered analytically in a fragment shader (no tessellated
surface): a coarse proxy sphere spawns fragments, and the shader
ray-intersects the mathematical sea-level sphere whose radius is computed
here. The level matches the exact radius at which the terrain noise crosses
water_height, so seas/lakes line up with the terrain’s own water coloring.
Mirror of the displacement math in ChunkRealize.slang::displace:
pos = dir * (radius + (h - 0.5) * 2.4 * radius * height_scale). Evaluated
at h = water_height that is the sea-level radius below. The same formula is
used for every builder (noise or custom) so the water level slider means the
same thing everywhere — water_height = 0.5 is the baseline (the noise
midpoint AND the custom h = 0 line), where the sea sits exactly at radius.
Constants§
- HEIGHT_
CENTER_ SCALE - The displacement shader maps a normalized height
hto a centered offset(h - 0.5) * HEIGHT_CENTER_SCALE. Keep in sync withdisplaceinChunkRealize.slang(andChunkTileBake/TileViewer/ScatterPlace). - PROXY_
MARGIN - Radius of the coarse render-proxy sphere: the analytic water radius inflated by a small margin so the proxy’s faceted silhouette always covers the true (smooth) sphere’s silhouette — rays that miss the analytic sphere are discarded in-shader, so the proxy only needs to over-cover, never under.
Functions§
- proxy_
radius - Convenience: proxy sphere radius from the analytic water radius.
- water_
radius - World radius of the analytic sea-level sphere: the terrain surface radius
evaluated at
water_height.water_height = 0.5is the baseline — the noise midpoint / customh = 0line — at which the sea sits exactly atradius. At the shipped defaults (CesBuilder::water_height0.549,CesGPUNoiseExample’sheight_scale0.0585) it sits slightly above, at1.0069 * radius, so terrain pokes through to form seas/lakes wherever the height rises above water. Lowering the level drains the seas; raising it floods low land.