feat(render3d): terrain_lake_carve - a height map may carry its own lake bed

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-16 15:27:21 +03:00
parent 6dfdee75e2
commit fa6c422f9b
5 changed files with 16 additions and 2 deletions

View file

@ -10,6 +10,7 @@ uniform float u_dem_base; // the elevation that becomes y = 0
uniform vec2 u_origin; // world x/z of the map's centre
uniform vec4 u_lake; // a lake: centre x/z, half extents (zero = none)
uniform float u_lake_level; // its surface height; the model records the surface, the bed is carved below it
uniform float u_lake_carve; // 0: the height map carries its own bed (terrain_lake_carve)
uniform float u_sea_level; // the sea the coast falls into (terrain_sea); the lake's level unless set
uniform vec4 u_isle; // an island: centre x/z, radius (or rim margin), falloff width
uniform float u_isle_mode; // 0 none, 1 radial (terrain_island), 2 inward from the survey's edge (terrain_coast)
@ -50,7 +51,7 @@ void main() {
float raw = demRaw(v_uv) * (u_dem_max - u_dem_min) + u_dem_min - u_dem_base;
// the survey carries its own relief at this resolution; only the foot track is added
h -= 0.25 * smoothstep(6.0, 1.5, pathDist(xz));
if (u_lake.z > 0.0) {
if (u_lake.z > 0.0 && u_lake_carve > 0.5) {
// the elevation model samples the water surface as flat ground: inside the lake's
// outline sink it into a bed, deepest in the middle, with a gentle gravel ramp at the shore
vec2 q = (xz - u_lake.xy) / u_lake.zw;

View file

@ -157,7 +157,8 @@ U 4be7acd9 frag u_dem_base 776 float 1 0
U 4be7acd9 frag u_origin 784 vec2 1 0
U 4be7acd9 frag u_lake 800 vec4 1 0
U 4be7acd9 frag u_lake_level 816 float 1 0
U 4be7acd9 frag u_sea_level 820 float 1 0
U 4be7acd9 frag u_lake_carve 820 float 1 0
U 4be7acd9 frag u_sea_level 824 float 1 0
U 4be7acd9 frag u_isle 832 vec4 1 0
U 4be7acd9 frag u_isle_mode 848 float 1 0
U 4be7acd9 frag u_dem_blur 852 float 1 0