## Emits the vertex heights ErosionNoiseNode actually produces, for the
## end-to-end comparison against ProcNodes_ErosionNoise.
##
## The three layers under this one are checked value-by-value against the C++
## (phacelle, erosion_filter, erosion_node_eval_full). This is the only probe
## that exercises the NODE: the uv derivation from the mesh bounding box, the
## internal gradient-noise fallback, the octave clamp, and the write to pos.y.
##
## Writes [[x, z, y], ...] in Godot's frame. x/z are handed back so the other
## side can normalise to (u, v) in its OWN frame and match on that -- comparing
## by vertex index would silently pass an axis flip, which is exactly the class
## of bug this is looking for.
##
## Usage: godot --headless --path demo --script res://erosion_noise_probe.gd \
## -- <verts_per_side> <size> <out.json>
extends SceneTree
func _init() -> void:
var a := OS.get_cmdline_user_args()
var n := int(a[0])
var size := float(a[1])
var g := ProcNodeGraph.new()
var grid := MeshGridNode.new()
var gi := g.add_node(grid)
g.get_node(gi).set_input_default(0, size) # Size X
g.get_node(gi).set_input_default(1, size) # Size Y
g.get_node(gi).set_input_default(2, n) # Vertices X
g.get_node(gi).set_input_default(3, n) # Vertices Y
var ero := ErosionNoiseNode.new()
var ei := g.add_node(ero)
g.get_node(ei).set_input_default(1, 5.0) # HeightScale
g.get_node(ei).set_input_default(2, 0.16) # ErosionStr
g.get_node(ei).set_input_default(3, 0.6) # SlopePower (dead)
g.get_node(ei).set_input_default(4, 1.0) # CellScale
g.get_node(ei).set_input_default(5, 5) # Octaves
g.get_node(ei).set_input_default(6, 0.5) # Gain
g.connect_sockets(gi, 0, ei, 0)
var host := ProcGeometryNode.new()
host.use_gpu = false # the CPU path is the one being compared
host.set_graph(g)
get_root().add_child(host)
var mesh: ArrayMesh = host.bake_mesh()
if mesh == null or mesh.get_surface_count() == 0:
push_error("no mesh")
quit(1)
return
var arr: Array = mesh.surface_get_arrays(0)
var verts: PackedVector3Array = arr[Mesh.ARRAY_VERTEX]
var out := []
for v in verts:
out.append([v.x, v.z, v.y])
var f := FileAccess.open(a[2], FileAccess.WRITE)
f.store_string(JSON.stringify(out)); f.close()
print("EROSION_NOISE_PROBE wrote ", out.size())
quit()