## Control: is Displace itself dead, or is something downstream discarding it?
## Builds Grid -> Displace with NO ErosionNoise and perturbs Strength.
##
## ⚠ RUNNING GODOT DIRECTLY REWRITES project.godot. The editor strips every
## comment and drops any setting that equals its default -- it ate the 30-line
## Jolt block and `screen_space_roughness_limiter/enabled` during this script's
## own development. scripts/dev-editor.sh restores it; a bare `godot --headless
## --path .` does not. Check `git status project.godot` after running this
## locally. CI is unaffected: it runs in a throwaway git-archive extraction.
extends SceneTree
func _bake(strength: float) -> PackedVector3Array:
var g := ProcNodeGraph.new()
var grid := g.add_node(MeshGridNode.new())
g.get_node(grid).set_input_default(0, 40.0)
g.get_node(grid).set_input_default(1, 40.0)
g.get_node(grid).set_input_default(2, 100)
g.get_node(grid).set_input_default(3, 100)
var d := g.add_node(DisplaceNode.new())
g.get_node(d).set_input_default(1, strength)
g.connect_sockets(grid, 0, d, 0)
var host := ProcGeometryNode.new()
host.use_gpu = false
host.set_graph(g)
get_root().add_child(host)
var m: ArrayMesh = host.bake_mesh()
if m == null or m.get_surface_count() == 0:
return PackedVector3Array()
return m.surface_get_arrays(0)[Mesh.ARRAY_VERTEX]
func _md(a, b) -> float:
if a.size() != b.size() or a.is_empty():
return -1.0
var x := 0.0
for i in range(a.size()):
x = max(x, (a[i] - b[i]).length())
return x
func _init() -> void:
var s6 := _bake(6.06) # the value terrain.tres carries
print("CONTROL Displace 6.06 vs 6.06 : %.6f" % _md(s6, _bake(6.06)))
print("Grid->Displace ONLY, 6.06 vs 30: %.6f" % _md(s6, _bake(30.0)))
print("Grid->Displace ONLY, 6.06 vs 0: %.6f" % _md(s6, _bake(0.0)))
quit()