OverviewFilesCommitsIssuesDocsReleasesPeers

dc-terrain commits / dd47dc1

procnodes: take the heightfield GEOMETRY from the grid, or nothing samples it
THE TILES LOADED AND NOTHING READ THEM. 841 tiles packed, 839 resident, 213.6 MiB uploaded to the GPU with a correct elevation range of -4829..5110 -- and the terrain on screen was base noise. _collect_node_data set hblk_n_ from get_tile_size(), which is the node's n_: the SINGLE tile's side, and 0 when only the grid is loaded because set_tile_path() was never called. Same for get_tile_origin() -> ox_/oz_ = 0,0. And `hblk_n_ > 0` is the gate on BOTH: - the four CPU heightfield sample sites, and - the emission that substitutes `pn_terrain_offset = heightmap_gn(x, z)` for the mountain-noise layer. So at 0 the CPU meshed noise, the GLSL emitted the noise branch, and the only symptom was a spawn-height disagreement: `CPU says -409.7 m, GPU expects 165.0 m (575 m apart)`. I added get_grid_info() in the wiring commit and then never used it for the geometry. Now hblk_n_/ox_/oz_/mpp_ come from the grid when there is one, and the log line prints the texel extent and origin so this is visible rather than inferred. ALSO GUARDED: the two OLD single-tile sampler emissions (heightfield_only_, and the generator's own heightfield_path_) now require !hgrid_.active(). They emit custom_data[j*HBLK_N + i], and with HBLK_N now the GRID's texel extent (30,464) that indexes 928M entries into a 55.8M buffer. The node's prelude already emits the PAGED sampler. Built template_release + template_debug. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
dd47dc1db8b95661ec9bd2123211c572934cace6
by plankatron <fleeky@gmail.com> · 2026-09-03T20:07:11.000Z

Changed files (1) +24 -3

src/dc_terrain_generator_procnodes.cpp +24 -3
……@@ -560,9 +560,26 @@ void DCTerrainGeneratorProcNodes::_collect_node_data() {
560560 hgrid_.table = (int)gi.get("table", 0);
561561 hgrid_.mpp = (float)(double)gi.get("mpp", 30.0);
562562 hgrid_.stub = (float)(double)gi.get("stub", 0.0);
563 // ⛔ AND THE GEOMETRY, WHICH IS THE WHOLE POINT.
564 //
565 // hblk_n_/ox_/oz_ were taken from get_tile_size()/get_tile_origin()
566 // above -- the SINGLE tile's, i.e. the node's n_, which is 0 when
567 // only the grid is loaded because set_tile_path() was never called.
568 //
569 // And `hblk_n_ > 0` gates BOTH the four CPU heightfield sites AND
570 // the emission at :1117 that substitutes heightmap_gn(x,z) for the
571 // mountain-noise layer. Left at 0, 213 MiB of tiles upload
572 // successfully and NOTHING EVER SAMPLES THEM: the CPU meshes the
573 // base noise, the GLSL emits the noise branch, and the only symptom
574 // is a CPU/GPU spawn-height disagreement.
575 hblk_n_ = (int)gi.get("side", 0);
576 hblk_ox_ = (float)(double)gi.get("ox", 0.0);
577 hblk_oz_ = (float)(double)gi.get("oz", 0.0);
578 hblk_mpp_ = hgrid_.mpp;
563579 UtilityFunctions::print("[DCTerrainGeneratorProcNodes] tile grid ",
564580 hgrid_.nx, "x", hgrid_.ny, " cells, ", (int)gi.get("tiles", 0),
565 " tiles resident");
581 " tiles resident, ", hblk_n_, " texels/side from (",
582 hblk_ox_, ",", hblk_oz_, ")");
566583 }
567584 }
568585 // ASK THE NODE FOR THE SIDE LENGTH; DO NOT DERIVE IT FROM THE ARRAY.
……@@ -776,7 +793,11 @@ void DCTerrainGeneratorProcNodes::_recompile_glsl() {
776793 // density IS the field. If this does not show the block, nothing downstream
777794 // of it can, and the fault is in getting the bytes to the GPU rather than in
778795 // anything about terrain.
779 if (heightfield_only_ && hblk_n_ > 0) {
796 // NOT over a packed grid: the sampler emitted below is single-tile
797 // addressing, custom_data[j*HBLK_N + i], and with HBLK_N = the grid's texel
798 // extent that indexes 928M entries into a 55.8M buffer. The node's own
799 // prelude already emits the PAGED sampler.
800 if (heightfield_only_ && hblk_n_ > 0 && !hgrid_.active()) {
780801 String hb =
781802 String("const int HBLK_N = ") + itos(hblk_n_) + ";\n"
782803 "const float HBLK_OX = " + String::num(hblk_ox_, 4) + ";\n"
……@@ -899,7 +920,7 @@ void DCTerrainGeneratorProcNodes::_recompile_glsl() {
899920 // as fixed; it was not, and the heightfield_only isolation oracle failed to
900921 // compile on EVERY run -- "Custom shader failed, falling back" -- which is
901922 // what made the map's own GPU/CPU oracle report a 9.1 m disagreement.
902 if (hblk_n_ > 0 && !heightfield_path_.is_empty()) {
923 if (hblk_n_ > 0 && !heightfield_path_.is_empty() && !hgrid_.active()) {
903924 // The sampler alone — HBLK_* consts plus hblk_height_m. Split out because
904925 // the lookdev path needs ONLY this: erosion_wrapper_glsl emits its own
905926 // M_* consts and its own heightmap_gn, and emitting ours as well would be