H16: The open sea floor reads as fully deep, so the world's edge doesn't show

From the lobby's view a pale square showed round the island: the terrain
grid's edge. The floor inside is 12.4 m down, but the shader's depth curve
only reached about 90% deep there, its view-space depth estimate read 7 to
11 m from the air, and the floor showed through at up to 4% opacity.

The shader now takes the larger of the true vertical depth (from the
world-space ray) and the old estimate, which shallows at a grazing angle
still use; normalises the curve so water WaterView.OPEN_DEPTH (9 m, three
quarters of the sea floor's depth) deep is fully SEA_DEEP; and makes fully
deep water opaque. Re-rendered match_lobby in Forward+ and Compatibility
(no square), and sea_tide_0/3, sea_shore_calm, water_shore, poi_dock and
client_basin (shallows still read as shallow).

Closes #85

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-14 15:08:55 -05:00
co-authored by Claude Opus 5.5
parent 4bc2171b01
commit 00528a197f
4 changed files with 29 additions and 5 deletions
+12 -4
View File
@@ -14,6 +14,10 @@ uniform vec3 deep_colour : source_color = vec3(0.10, 0.22, 0.30);
uniform vec3 foam_colour : source_color = vec3(0.86, 0.88, 0.84);
// Metres of water over which the colour goes from shallow to deep.
uniform float depth_scale = 7.0;
// Water this many metres deep already shows the full open-sea colour and hides the
// floor. It sits under the open sea floor's depth, so the floor round the island and
// the bottomless sea past the world's edge look the same from the air (H6).
uniform float open_depth = 9.0;
// Width of the foam at the waterline, in metres of water thickness.
uniform float foam_width = 0.6;
uniform float ripple_strength = 0.25;
@@ -78,15 +82,19 @@ void fragment() {
vec4 behind = INV_PROJECTION_MATRIX * vec4(SCREEN_UV * 2.0 - 1.0, scene_depth, 1.0);
behind.xyz /= behind.w;
float thickness = max(-behind.z - (-VERTEX.z), 0.0);
// Convert view distance to roughly vertical metres using the view angle.
vertical = thickness * clamp(abs(normalize(VERTEX).y) + 0.25, 0.25, 1.0);
// Convert view distance to roughly vertical metres using the view angle. The
// world-space ray gives the true depth, which the open sea floor needs to read as
// fully deep from the air (H6); the old view-space estimate is kept as a floor, so
// shallows seen at a grazing angle keep their colour.
float steep = abs(normalize(world_position - CAMERA_POSITION_WORLD).y);
vertical = max(thickness * steep, thickness * clamp(abs(normalize(VERTEX).y) + 0.25, 0.25, 1.0));
} else {
vec2 grid = (p / terrain_cell + 0.5) / terrain_samples;
float ground_height = texture(terrain_heights, clamp(grid, vec2(0.0), vec2(1.0))).r;
vertical = max(world_position.y - ground_height, 0.0);
}
float deep = 1.0 - exp(-vertical / depth_scale);
float deep = clamp((1.0 - exp(-vertical / depth_scale)) / (1.0 - exp(-open_depth / depth_scale)), 0.0, 1.0);
vec3 open_water = mix(deep_colour, storm_colour, sea_state);
vec3 water = mix(shallow_colour, open_water, deep);
@@ -118,7 +126,7 @@ void fragment() {
ROUGHNESS = mix(mix(0.12, 0.3, sea_state), 0.6, foam);
METALLIC = 0.0;
SPECULAR = 0.5;
ALPHA = clamp(mix(0.55, 0.96, deep) + foam * 0.3, 0.0, 1.0);
ALPHA = clamp(mix(0.55, 1.0, deep) + foam * 0.3, 0.0, 1.0);
if (!FRONT_FACING) {
// The surface seen from under water: a bright, rippled ceiling of murk.
ALBEDO = mix(murk_colour, shallow_colour, 0.35 + 0.3 * h);
+5
View File
@@ -15,6 +15,10 @@ const SHADER: Shader = preload("res://src/client/water/water.gdshader")
const SIZE: float = 6000.0
## Grid steps across the surface. It is flat, so few are needed.
const SUBDIVISIONS: int = 32
## Water this deep shows the full open-sea colour and hides the floor: three quarters of
## the open sea floor's depth, so the floor round the island and the bottomless sea past
## the world's edge look alike from the air (H6).
const OPEN_DEPTH: float = Tuning.ISLAND_SEA_DEPTH * 0.75
var level: float = 0.0
var sea_state: float = 0.0
@@ -140,6 +144,7 @@ func _build() -> void:
_material.shader = SHADER
_material.set_shader_parameter("shallow_colour", Palette.SEA_SHALLOW)
_material.set_shader_parameter("deep_colour", Palette.SEA_DEEP)
_material.set_shader_parameter("open_depth", OPEN_DEPTH)
_material.set_shader_parameter("storm_colour", Palette.SEA_STORM)
_material.set_shader_parameter("foam_colour", Palette.SEA_FOAM)
_material.set_shader_parameter("murk_colour", Palette.SEA_MURK)