render.project (API level 31) returns where a world point lands on the
screen, in GUI pixels, through the camera the last drawn frame used:
the player's own view or a mod's set-main-view camera, the bob and the
spin included, at most a frame behind. None for a point behind the
camera, and with no world or drawn frame yet; a point off the screen
still projects past its edges, for the caller to clip.
The game copies the frame's eye and view-projection into the mod
snapshot after a world frame is drawn, and clears it when another world
is entered, so a stale camera never projects into the new one. The
projection is camera-relative, as the world's geometry is drawn, with
the renderer's own f32 precision far from the origin.
For AirDef's world overlay: square markers over visible targets while
a key is held, on top of normal gameplay. The UI test guest calls the
new function so the sandbox checks the level-31 contract.
Co-Authored-By: Kimi Code <noreply@moonshot.ai>
mod_model_geometry baked every model twice a frame (current + HD motion):
collect_seeded, two atlas hash lookups and a normal derivation per face, a
full-atlas special-material scan, and a linear material search per quad.
Resolve the faces once per pack generation instead (MeshCache keyed by
BlockStateId, generation = the pack's Arc<RenderAssets>, ptr_eq): sprite
rect, model-space quad/normal, emission and the quad's special material.
A frame only transforms and lights the retained faces; the normal matrix
is built once per instance, and the motion pass (#124) re-transforms the
same faces for previous positions instead of a second bake. Vertices are
bit-identical to the old path (unit test over the transform/glow/light
matrix). Reload (apply_staged_pack) and world unload (clear_entities,
leave_server) drop the cache; the generation guard catches any pack swap.
stats/bench expose mod_models counters (frames/models/quads/motion_quads/
vertex_bytes/motion_bytes/mesh_builds/atlas_scans); span mod_models inside
entity_geometry. Measured on M5/Metal 2560x1440 HD, Polygon raid scene
(14 batteries + 3 waves, ~135 models/frame): entity_geometry CPU
5.71 -> 1.57 ms avg (p95 8.7 -> 2.2), prepare phase 23.5 -> 7.05 ms;
static scene pixel-identical at converged LOD. Upload bytes unchanged;
GPU instancing is the next stage of #126 direction A.
Co-Authored-By: Kimi Code <noreply@moonshot.ai>
Compose NGX and HDR Vulkan device creation, retain one SDK per device and a context per output size, and evaluate DLSS with existing motion/depth/jitter. Bracket NGX with explicit display-linear color conversion and ordered command buffers. Native TAA/TAAU remains the fallback; Windows compile check passes, runtime acceptance still requires RTX.
Co-Authored-By: Kimi Code <noreply@moonshot.ai>
Keep each mod model's last rendered world transform and emit a separate previous-position vertex stream. A depth-read-only motion pass overwrites camera-only vectors with exact previous-frame object motion and matching alpha cutouts. Add HORIZON_HD_DEBUG_MOTION for visual verification.
Co-Authored-By: Kimi Code <noreply@moonshot.ai>
The near colour-shadow pass leaves leaves out of depth while the far cascade includes them. Blend both filters over six blocks and fade tint on the same curve so the boundary no longer reads as a circle around the camera.
Co-Authored-By: Kimi Code <noreply@moonshot.ai>
Add an RG16F current-to-previous render-pixel target to the HD G-buffer. Terrain and entities write previous drawn-camera projections; TAA/TAAU use matching opaque vectors and retain the depth fallback elsewhere. Object-local previous transforms and vendor SDK evaluation remain separate phases.
Co-Authored-By: Kimi Code <noreply@moonshot.ai>
Uploads staged every buffer write through wgpu's StagingBelt, which gives a
write larger than its chunk a buffer of exactly that size, keeps it for good
and only reuses it for writes that fit. The entity batch outgrows the 1 MiB
chunk with a few hundred mobs and grows a little each tick while more appear,
so every tick took a new buffer: about 1 GB more per hundred mobs past ~750,
never given back, until the game was killed (upstream #2826).
Writes larger than the chunk now take a power-of-two slice and copy only
their bytes, so the buffers the belt keeps are reused: one per doubling.
Backport of horizon-rust/horizon@f7b77fbc88,
whose file moved from crates/horizon-client-render/src/gfx/upload.rs to
crates/horizon-client/src/gfx/upload.rs. Takes its growth test
(growing_large_writes_reuse_the_belt_buffers) and the kept_buffers helper as
written. Fork issue: #130.
Co-Authored-By: Kimi Code <noreply@moonshot.cn>
A camera shown only as the screen's own view was never prepared: the note
required a non-empty picture list. Two runs picking the same local id both
claimed the screen's frame, though only the first one's camera was drawn
from it. The client now notes whether the frame was a world frame and the
(run, camera id) the screen's world was drawn from, so the main-view
milestone belongs to the run whose selection the screen used, and a title
or loading frame reports the path off without erasing earlier milestones.
A world transition clears the submission, the main-view selection and the
milestones: another world's cameras are not drawn. A camera given to
set-main-view drops its picture target, so its milestone starts over until
a frame is drawn from it. prepared stays a host-side encoding milestone,
not target registration, not a GPU fence, not a visible pixel.
Also gate the client's note on the `mods` feature: without it the default
horizon-client build did not compile.
Verified: horizon-mods 37 unit, 44 sandbox (1 ignored; real Wasmtime
guests, the two-run test shows each id 7 follows only its own pictures and
selection) and 4 api_reference; client checks and build with and without
`mods`; gfx lib tests.
Co-Authored-By: Kimi Code <noreply@moonshot.cn>
API 30 adds render.camera-status: availability, the last noted frame's
mod-camera picture path, the calling run's accepted set-views submission
for this world generation, and per-camera prepared flags. A camera is
prepared when the renderer encoded its picture into the texture target
in a real frame of this generation, or a world frame rendered from it as
the set-main-view selection: a host-side encoding milestone, not target
registration, not a GPU fence, not a visible pixel. An empty set-views
clears the request; a resubmission, world transition or mod reload waits
for a new frame. The renderer reports the pictures it drew each frame;
the game notes the frame after a successful render. Verified with two
real Wasmtime guests sharing local camera id 7: each run's readiness
follows only its own submission and main-view choice, and a world
transition resets both.
Co-Authored-By: Kimi Code <noreply@moonshot.cn>
The writer removed its video, raw sound and log only when a take was
cancelled, so an encoder error or a non-zero ffmpeg exit left them in the
films folder. A failed take now removes exactly the files it wrote; the
log's last lines move into the error, since the log itself goes.
The encoder always writes <name>.video.mp4, and <name>.mp4 appears only
after a successful mux or rename. A failed, cancelled or no-audio take
therefore cannot overwrite or delete a film of an earlier export with the
same name. The writer's entry point takes the ffmpeg and its arguments so
a test can drive a failing encoder.
Co-Authored-By: Kimi Code <noreply@moonshot.ai>
Preserve AirDef replay lighting and acoustic commands while retaining upstream shadow and HDR fixes. Give the two entity shadow shaders distinct entry points.
Co-Authored-By: Codex <noreply@openai.com>