render3d: the fog wall culls on the CPU - nothing past it costs a draw, a vertex or a caster
cam_sphere_visible refuses a sphere wholly past the wall (terrain patches, scatter cells, stream
chunks, grass tiles, water), actors past it are skipped for draws, casters and outlines, the grass
reach and the streams' generate-and-gather reach end at it, and the card shadows cast only from
the wall's share of a layer (fog_casters.ludic, rebuilt every 4 m). r3d_beyond_fog is exported for
the game to skip animating what will not be drawn. Render-only: no query of the ground or the world
changes, and off is the old frame (0 pixels over 8 against 160ce96, twice per side).
Draws per frame at the overlook: 2757 off, 1104 at 175 m, 484 at 30 m.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
b9f9cb8495
commit
2ce2d997be
9 changed files with 88 additions and 11 deletions
|
|
@ -32,6 +32,12 @@ property Layer {
|
|||
imp_buf: int = 0,
|
||||
sh_buf: int = 0, # every instance, for shadow casting (no cull, no LOD split)
|
||||
n_sh: int = 0,
|
||||
fog_buf: int = 0, # the casters inside the fog wall (fog_casters.ludic)
|
||||
fog_n: int = 0,
|
||||
fog_src: int = -1,
|
||||
fog_wall: float = 0.0,
|
||||
fog_x: float = 0.0,
|
||||
fog_z: float = 0.0,
|
||||
n_far: int = 0,
|
||||
scratch: floats,
|
||||
last_cam: floats,
|
||||
|
|
@ -261,6 +267,7 @@ function layer_new(render3d_st: mut Render3dState, model: Model, cap: int, folia
|
|||
l.buf = gpu_buffer_new(render3d_st)
|
||||
l.imp_buf = gpu_buffer_new(render3d_st)
|
||||
l.sh_buf = gpu_buffer_new(render3d_st)
|
||||
l.fog_buf = gpu_buffer_new(render3d_st)
|
||||
l.rough = 1.0
|
||||
for i in 0 .. len(model.prims) { scatter_attach(render3d_st, model.prims[i].mesh, l.buf) }
|
||||
push(render3d_st.sc_layers, l)
|
||||
|
|
@ -983,8 +990,11 @@ function layer_draw_shadow(render3d_st: mut Render3dState, l: Layer, light_vp: f
|
|||
u_v3(render3d_st, gpu_uniform(render3d_st, p, "u_face_dir"), render3d_st.sun_dir)
|
||||
u_v3(render3d_st, gpu_uniform(render3d_st, p, "u_cam_pos"), render3d_st.cam_pos)
|
||||
gpu_cull(render3d_st, false)
|
||||
scatter_attach(render3d_st, render3d_st.sc_card, l.sh_buf)
|
||||
mesh_draw_instanced(render3d_st, render3d_st.sc_card, l.n_sh)
|
||||
let buf = fog_casters(render3d_st, l)
|
||||
let n = fog_casters_n(render3d_st, l)
|
||||
if n == 0 { return }
|
||||
scatter_attach(render3d_st, render3d_st.sc_card, buf)
|
||||
mesh_draw_instanced(render3d_st, render3d_st.sc_card, n)
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1196,6 +1206,7 @@ function scatter_clear_all(render3d_st: mut Render3dState) -> void {
|
|||
if l.buf != 0 { gpu_buffer_free(render3d_st, l.buf) }
|
||||
if l.imp_buf != 0 { gpu_buffer_free(render3d_st, l.imp_buf) }
|
||||
if l.sh_buf != 0 { gpu_buffer_free(render3d_st, l.sh_buf) }
|
||||
if l.fog_buf != 0 { gpu_buffer_free(render3d_st, l.fog_buf) }
|
||||
if l.lod_buf != null { for k in 0 .. l.n_lods { gpu_buffer_free(render3d_st, l.lod_buf[k]) } }
|
||||
if l.inst != null { free(l.inst) }
|
||||
if l.scratch != null { free(l.scratch) }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue