OverviewFilesCommitsIssuesDocsReleasesPeers

dc-terrain commits / ca60568

erosion: a real on/off toggle, from the terrain panel
The filter is an ENHANCEMENT over the heightmap displacement, so it has to be possible to look at the heightmap alone. It is a checkbox rather than a strength of zero because it is structural: skipping the ErosionNoise node takes the whole noise library with it, since nothing left in a heightfield graph mentions noise. map_dc_diffusion's emitted density shader goes 60,627 -> 5,639 bytes. Strength 0 would look similar and cost the same octave loop. proc-nodes compile_to_glsl_function takes skip_types (node TYPES to leave out) dc-terrain erosion_enabled property; passes ["ErosionNoise"] when false hyper-tps a checkbox in the terrain panel, shown only when the target has the property; the map sets it from EROSION_ENABLED at setup Verified: off compiles (59,536 bytes of SPIR-V, control rejects a broken body), on is byte-identical to the pre-session baseline, spawn surface 165.0 m either way. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
ca605680ca4fb2c7a512d3a1a7e28dd276100a2e
by plankatron <fleeky@gmail.com> · 2026-09-02T02:35:30.000Z

Changed files (2) +34 -1

src/dc_terrain_generator_procnodes.cpp +18 -1
……@@ -21,6 +21,9 @@
2121namespace godot {
2222
2323void DCTerrainGeneratorProcNodes::_bind_methods() {
24 ClassDB::bind_method(D_METHOD("set_erosion_enabled", "value"), &DCTerrainGeneratorProcNodes::set_erosion_enabled);
25 ClassDB::bind_method(D_METHOD("get_erosion_enabled"), &DCTerrainGeneratorProcNodes::get_erosion_enabled);
26 ADD_PROPERTY(PropertyInfo(Variant::BOOL, "erosion_enabled"), "set_erosion_enabled", "get_erosion_enabled");
2427 ClassDB::bind_method(D_METHOD("set_mountain_scale", "value"), &DCTerrainGeneratorProcNodes::set_mountain_scale);
2528 ClassDB::bind_method(D_METHOD("get_mountain_scale"), &DCTerrainGeneratorProcNodes::get_mountain_scale);
2629 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "mountain_scale"), "set_mountain_scale", "get_mountain_scale");
……@@ -380,6 +383,13 @@ void DCTerrainGeneratorProcNodes::set_lookdev_wrapper(bool p_val) {
380383 emit_changed();
381384}
382385
386void DCTerrainGeneratorProcNodes::set_erosion_enabled(bool p_val) {
387 if (erosion_enabled_ == p_val) return;
388 erosion_enabled_ = p_val;
389 _recompile_glsl();
390 emit_changed();
391}
392
383393void DCTerrainGeneratorProcNodes::set_terrain_height(float p_height) {
384394 if (terrain_height_ == p_height) return;
385395 terrain_height_ = p_height;
……@@ -659,7 +669,14 @@ void DCTerrainGeneratorProcNodes::_recompile_glsl() {
659669
660670 // Cross-extension call with octave clamping enabled.
661671 // proc-nodes will emit min(N, pn_max_octaves) for all integer (octave) params.
662 Variant glsl_var = graph_->call("compile_to_glsl_function", "proc_density", true);
672 // SKIP THE EROSION NODE when the toggle is off. Not in the graph's emission
673 // means not in the shader at all: no filter, and no noise library either,
674 // because nothing left in a heightfield graph mentions noise.
675 PackedStringArray skip;
676 if (!erosion_enabled_) {
677 skip.push_back("ErosionNoise");
678 }
679 Variant glsl_var = graph_->call("compile_to_glsl_function", "proc_density", true, skip);
663680 if (glsl_var.get_type() != Variant::STRING) {
664681 UtilityFunctions::push_warning("DCTerrainGeneratorProcNodes: compile_to_glsl_function returned non-string");
665682 return;
src/dc_terrain_generator_procnodes.h +16 -0
……@@ -175,6 +175,20 @@ class DCTerrainGeneratorProcNodes : public DCTerrainGenerator {
175175 // That is what relief_scale/relief_floor were bolted on to fake.
176176 bool height_space_sqrt_ = false;
177177
178 // EROSION ON OR OFF — a real toggle, not a strength of zero.
179 //
180 // The heightmap IS the terrain: the Heightfield node samples the baked tile
181 // and displaces the surface to it, which is a complete map by itself. The
182 // erosion filter runs on a finer grid than the model's 30/90 m and
183 // synthesises the detail below its resolution. Turning it off must not move
184 // the ground, only remove that detail.
185 //
186 // False skips the ErosionNoise node when emitting, and because nothing else
187 // in a heightfield graph mentions noise, the whole noise library goes with
188 // it -- 60 KB of shader down to 5.6 KB. Strength 0 would cost the same
189 // octave loop and leave the library in place.
190 bool erosion_enabled_ = true;
191
178192 // ── Layer and filter parameters ───────────────────────────────────────
179193 float mountain_scale_ = 1.0f;
180194 float mountain_height_ = 0.5f;
……@@ -279,6 +293,8 @@ public:
279293 void set_heightfield_path(const String &p_path);
280294 String get_heightfield_path() const { return heightfield_path_; }
281295 void set_heightfield_only(bool p_val);
296 void set_erosion_enabled(bool p_val);
297 bool get_erosion_enabled() const { return erosion_enabled_; }
282298
283299 void set_mountain_scale(float p_val);
284300 float get_mountain_scale() const { return mountain_scale_; }