extends SceneTree
## Compile-probe for shaders/terrain_noise.gdshaderinc.
##
## MUST RUN WITH A DISPLAY. Godot compiles shaders on the rendering server, so
## --headless loads the resource without ever compiling it: a headless "pass"
## here cannot fail and therefore proves nothing (dc_erosion_color.gdshader
## carries the same warning). This puts the material on a real mesh in a real
## viewport so the compiler actually runs.
##
## DISPLAY=:0 "$HYPER_TPS_GODOT" --path . --rendering-driver vulkan \
## --script res://scenes/test/shader_probe.gd
var _frames := 0
var probe_path := "res://shaders/terrain_noise_probe.gdshader"
func _initialize() -> void:
var a := OS.get_cmdline_user_args()
for i in range(a.size() - 1):
if a[i] == "--shader": probe_path = a[i + 1]
print("PROBE: " + probe_path)
var mi := MeshInstance3D.new()
mi.mesh = BoxMesh.new()
var mat := ShaderMaterial.new()
mat.shader = load(probe_path)
mi.material_override = mat
root.add_child(mi)
var cam := Camera3D.new()
cam.position = Vector3(0, 0, 3)
root.add_child(cam)
print("PROBE: mesh + material in tree, compiling...")
func _process(_d: float) -> bool:
_frames += 1
if _frames > 30:
print("PROBE: survived 30 frames — shader COMPILED")
quit(0)
return true
return false