Files
tidewall/test/client/test_water_view.gd
T
claudeandClaude Opus 5.5 00528a197f 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>
2026-11-14 15:08:55 -05:00

29 lines
1.1 KiB
GDScript

extends TestCase
## The client sea from issue W6 follows the simulation's sea level.
func test_surface_follows_the_simulation_sea_level() -> void:
var sim: Simulation = Simulation.new(1, SimGround.flat())
var view: WaterView = WaterView.new()
view.follow(sim)
assert_eq(view.surface().position.y, Tuning.SEA_LEVEL_START)
sim.set_sea_level(8.0)
view.follow(sim)
assert_eq(view.surface().position.y, 8.0)
assert_eq(view.level, 8.0)
# The surface covers the whole world and well past it, so no edge is ever in view.
var mesh: PlaneMesh = view.surface().mesh
assert_true(mesh.size.x >= Tuning.WORLD_SIZE_METRES * 4.0)
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()