## Is the height field SlopeGradient now supplies in range for the filter?
##
## erosion_node_eval hardcodes peak_height_divisor = 0.6 and
## fade_target = clamp(gn.x / 0.6, -1, 1). erosion_filter.inc warns that a
## caller handing it a field several times larger "saturates the fade target to
## +/-1 everywhere, which is 'every point is a peak' and erases the fade
## approach's whole reason to exist."
##
## ⚠ 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 _init() -> void:
var g := ProcNodeGraph.new()
var grid := g.add_node(MeshGridNode.new())
for i in range(2):
g.get_node(grid).set_input_default(i, 40.0)
g.get_node(grid).set_input_default(2, 300)
g.get_node(grid).set_input_default(3, 300)
var d := g.add_node(DisplaceNode.new())
g.get_node(d).set_input_default(1, 6.06)
g.get_node(d).set_input_default(2, 0.1)
g.get_node(d).set_input_default(3, 1)
g.get_node(d).set_input_default(4, 0.16)
g.get_node(d).set_input_default(5, 2.26)
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()
var v: PackedVector3Array = m.surface_get_arrays(0)[Mesh.ARRAY_VERTEX]
var lo := INF
var hi := -INF
var sat := 0
for p in v:
lo = min(lo, p.y); hi = max(hi, p.y)
if abs(p.y / 2.0) >= 1.0:
sat += 1
print("height field into ErosionNoise: min %.3f max %.3f" % [lo, hi])
print("fade_target = height / 2.0 : min %.3f max %.3f" % [lo / 2.0, hi / 2.0])
print("vertices where |fade_target| >= 1 (clamped): %d / %d (%.1f%%)"
% [sat, v.size(), 100.0 * sat / v.size()])
quit()