extends SceneTree
## Does dc-terrain's field agree with the lookdev's?
##
## This is the check that did not exist while every other gate was green, and
## its absence is why "the shader is correct" and "the shader never ran" looked
## the same from here. Everything else either ran OUTSIDE Godot (the standalone
## harness) or ran inside Godot and only inspected GLSL text.
##
## It walks DCTerrain.sample_density down a set of columns and writes the surface
## it finds. gate_dc_vs_lookdev.py then renders the SAME columns with
## erosion_render -- the harness that is itself gated against the parity oracle
## -- and compares. Two independent implementations of the same field, so an
## agreement means something.
##
## It works because ProcNodesBridge::evaluate now reads the heightfield too. It
## could not exist before that: sample_density answered from the fBm world the
## field replaced, and would have "agreed" with nothing.
##
## "$HYPER_TPS_GODOT" --headless --path . --script res://scenes/test/gate_dc_vs_lookdev.gd
const OX := 52800.0
const OZ := 37440.0
const N := 16
const MPP := 120.0
const OUT := "/tmp/dc_surface.txt"
var _m: Node = null
func _init() -> void:
var packed := load("res://scenes/maps/map_dc_diffusion.tscn") as PackedScene
if packed == null:
print("FAIL — map_dc_diffusion.tscn did not load"); quit(2); return
_m = packed.instantiate()
root.add_child(_m)
func _process(_dt: float) -> bool:
var terrain = _m.get_node_or_null("DCTerrain")
if terrain == null:
print("FAIL — no DCTerrain"); quit(1); return true
# PROVE THE GENERATOR IS OURS. If the resource never got assigned, DCTerrain
# silently falls back to its built-in noise -- which is what "I turned
# use_noise off and it changed" was telling us, and nothing downstream of
# that fallback is worth comparing.
var gen = terrain.get("generator")
if gen == null:
print("FAIL — DCTerrain has NO generator; it is drawing built-in noise")
quit(1); return true
print(" generator: ", gen.get_class(), " heightfield: ", gen.get("heightfield_path"))
var f := FileAccess.open(OUT, FileAccess.WRITE)
f.store_line("# x z surface_y (from DCTerrain.sample_density)")
var found := 0
for jz in range(N):
for ix in range(N):
var x := OX + ix * MPP
var z := OZ + jz * MPP
var y: float = _m.call("_surface_y", terrain, x, z)
if y > -999998.0:
found += 1
f.store_line("%.1f %.1f %.4f" % [x, z, y])
f.close()
print(" wrote %s — %d of %d columns had a surface" % [OUT, found, N * N])
if found != N * N:
print("FAIL — some columns have no surface at all")
quit(1); return true
print(" now run: python3 terrain-lookdev/gate_dc_vs_lookdev.py")
quit(0)
return true