render3d: the height field and photograph on the CPU as tiles read from a file (off until the game asks)
terrain_tiles_to(dir, key) before a map is made: once made, its heights, photograph and baked normals are written tile by tile (64 m, TT_TEX) to <dir>/<key>.tiles - fresh every time, header last, so no other generator's or a torn file is ever read - and the whole copies go. Every read goes through the tile: resident, else read from the file there and then into a 2048-tile clock, so terrain_height, terrain_height_smooth, terrain_ortho* and terrain_chunk_heights answer exactly what the whole copy did (R3D_TT_CHECK: worst 0.0 m over 4000 points) whatever is resident - two machines and the boot's placements agree to the bit. terrain_chunk_heights takes render3d_st mut for it. terrain_height_near(read-only): the tile if it is in, else a coarse 2048^2 level (worst 0.91 m), never the file - for line checks that must not take render3d_st mut. terrain_texel() is the texel size, terrain_tiles_prefetch(x, z, r, budget) reads ahead, and a frame that reads more than 8 tiles says so once. R3D_TERRAIN_TILES=<dir> turns it on for a run. At the overlook with MallocLargeCache=0: 1731 MB off, 1658 MB on; 192 MB written in ~200 ms; the frame unchanged (0 pixels over 8). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
c5e58d14ea
commit
5b3cfac48e
8 changed files with 385 additions and 15 deletions
|
|
@ -99,7 +99,7 @@ function water_reflection_pass(render3d_st: mut Render3dState) -> void {
|
|||
function water_reflect_visible(render3d_st: mut Render3dState) -> bool {
|
||||
if render3d_st.wb_primary < 0 { return false }
|
||||
if render3d_st.wb_refl_always < 0 { render3d_st.wb_refl_always = 0; if r3d_env_has(render3d_st, "R3D_REFL_ALWAYS") { render3d_st.wb_refl_always = 1 } }
|
||||
if render3d_st.wb_refl_always == 1 or render3d_st.ter_heights == null { return true }
|
||||
if render3d_st.wb_refl_always == 1 or not ter_present(render3d_st) { return true }
|
||||
if render3d_st.wb_ncells < 0 { let t0 = gl_now_us(); water_cells_build(render3d_st); render3d_st.wb_build_us = gl_now_us() - t0 }
|
||||
if render3d_st.wb_dbg < 0 { render3d_st.wb_dbg = 0; if r3d_env_has(render3d_st, "R3D_REFL_DBG") { render3d_st.wb_dbg = 1 } }
|
||||
if render3d_st.wb_dbg == 1 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue