| … | … | @@ -16,7 +16,9 @@ |
| 16 | 16 | // comment still stands. It is a shared math header and nothing more. |
| 17 | 17 | #include "erosion_cpp_shim.h" |
| 18 | 18 | #include "erosion_wrapper_glsl.h" |
| 19 | #include "dc_compute.h" |
| 19 | 20 | #include <godot_cpp/classes/file_access.hpp> |
| 21 | #include <godot_cpp/classes/os.hpp> |
| 20 | 22 | |
| 21 | 23 | namespace godot { |
| 22 | 24 | |
| … | … | @@ -526,6 +528,21 @@ void DCTerrainGeneratorProcNodes::set_graph(const Ref<Resource> &p_graph) { |
| 526 | 528 | // |
| 527 | 529 | // One producer for now, which matches one bound buffer. More than one wants an |
| 528 | 530 | // offset table emitted alongside, which is the same change a grid of tiles needs. |
| 531 | // Read the SAME floats through binding 14 (the atlas image) instead of binding |
| 532 | // 13 (the SSBO). Both hold identical values at identical indices, so this is a |
| 533 | // pure TRANSPORT swap and gate_dc_vs_lookdev must agree to 0.001 m either way. |
| 534 | // |
| 535 | // An ENV VAR rather than a property, deliberately: the point is to run the gate |
| 536 | // BOTH ways over one unchanged scene, and a property would have to be authored |
| 537 | // into the map to be flipped. |
| 538 | // |
| 539 | // HBLK_USE_ATLAS=1 godot4 --path . --script res://scenes/test/... |
| 540 | static bool _use_atlas() { |
| 541 | String v = OS::get_singleton()->get_environment("HBLK_USE_ATLAS"); |
| 542 | return v == "1" || v.to_lower() == "true"; |
| 543 | } |
| 544 | |
| 545 | |
| 529 | 546 | void DCTerrainGeneratorProcNodes::_collect_node_data() { |
| 530 | 547 | if (graph_.is_null()) return; |
| 531 | 548 | Variant nc_var = graph_->call("get_node_count"); |
| … | … | @@ -733,6 +750,8 @@ void DCTerrainGeneratorProcNodes::_recompile_glsl() { |
| 733 | 750 | if (heightfield_only_ && hblk_n_ > 0) { |
| 734 | 751 | String hb = |
| 735 | 752 | String("const int HBLK_N = ") + itos(hblk_n_) + ";\n" |
| 753 | "const int HBLK_ATLAS_W = " + itos(DCCompute::ATLAS_W) + ";\n" |
| 754 | "const bool HBLK_USE_ATLAS = " + String(_use_atlas() ? "true" : "false") + ";\n" |
| 736 | 755 | "const float HBLK_OX = " + String::num(hblk_ox_, 4) + ";\n" |
| 737 | 756 | "const float HBLK_OZ = " + String::num(hblk_oz_, 4) + ";\n" |
| 738 | 757 | "const float HBLK_MPP = " + String::num(hblk_mpp_, 6) + ";\n" |
| … | … | @@ -861,6 +880,8 @@ void DCTerrainGeneratorProcNodes::_recompile_glsl() { |
| 861 | 880 | // that never compiled and a world with no terrain. |
| 862 | 881 | hblk_glsl_sampler = |
| 863 | 882 | String("const int HBLK_N = ") + itos(hblk_n_) + ";\n" |
| 883 | "const int HBLK_ATLAS_W = " + itos(DCCompute::ATLAS_W) + ";\n" |
| 884 | "const bool HBLK_USE_ATLAS = " + String(_use_atlas() ? "true" : "false") + ";\n" |
| 864 | 885 | "const float HBLK_OX = " + String::num(hblk_ox_, 4) + ";\n" |
| 865 | 886 | "const float HBLK_OZ = " + String::num(hblk_oz_, 4) + ";\n" |
| 866 | 887 | "const float HBLK_MPP = " + String::num(hblk_mpp_, 6) + ";\n" |