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:
+4
-1
@@ -89,7 +89,10 @@ or `src/app`, and on any palette colour this table doesn't list. Values are sRGB
|
||||
|
||||
The terrain shader's sand, marsh, grass, rock and summit colours are shader uniforms
|
||||
and follow the same rules. The sea shader's colours are set from the `SEA_` entries
|
||||
above by `WaterView`.
|
||||
above by `WaterView`. Water goes from `SEA_SHALLOW` to `SEA_DEEP` with its depth and
|
||||
is fully `SEA_DEEP` and opaque by `WaterView.OPEN_DEPTH` (9 m), shallower than the open
|
||||
sea floor, so from the air the sea round the island and past the world's edge is one
|
||||
colour (H16).
|
||||
|
||||
## Weather and light (A6)
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -18,3 +18,11 @@ func test_surface_follows_the_simulation_sea_level() -> void:
|
||||
assert_near(view.surface().position.x, Tuning.WORLD_SIZE_METRES * 0.5, 0.001)
|
||||
assert_eq(view.surface().cast_shadow, GeometryInstance3D.SHADOW_CASTING_SETTING_OFF)
|
||||
view.free()
|
||||
|
||||
|
||||
func test_the_open_sea_colour_is_reached_above_the_sea_floor() -> void:
|
||||
# H6: the floor round the island must not read lighter than the sea past the edge.
|
||||
var view: WaterView = WaterView.new()
|
||||
var open_depth: float = float(view.material().get_shader_parameter("open_depth"))
|
||||
assert_true(open_depth > 0.0 and open_depth < Tuning.ISLAND_SEA_DEPTH)
|
||||
view.free()
|
||||
|
||||
Reference in New Issue
Block a user