Skip to content

Perspective still images and a render API for watch - #7

Merged
malken21 merged 1 commit into
mainfrom
feature/shots
Nov 10, 2026
Merged

malken21 merged 1 commit into
mainfrom
feature/shots

Conversation

@malken21

Copy link
Copy Markdown
Member

Adds a perspective still-image capability to the renderer, next to the tile pipeline:

  • Camera: ShotCamera / ShotRenderer implement a perspective camera with the same terms as BlueMap's perspective view — target, distance, rotation, angle, vertical fov 75°, its near/far rule, and its effective-target-height rule computed from the world data itself (adjust_height: false opts out). Any image size; translucent sorting follows the view direction.
  • CLI: a shot command writes a PNG plus the camera transform (view/projection matrices, eye, effective target) as JSON.
  • HTTP API: watch --api-port serves POST /v1/render (map name + camera + size → PNG as base64 + transform), GET /v1/maps, GET /v1/health. High-priority requests are served about once a second between tile batches; normal-priority ones a few per step, so batch sequences (for example background-video frames) cannot starve an urgent single shot; identical requests are answered from a short-lived cache; meshes stay cached across frames. The API keeps serving when the tile database is unreachable (tile updates for that map wait). The API is a general renderer capability — overlays and annotations are the caller's job, computed from the returned transform.
  • Block entities: chests (single, double, trapped, ender, copper variants), banners, skulls and heads, and shulker boxes are baked from built-in models mirroring the client's geometry and entity textures; build-data extracts the entity sheets into the texture atlas (existing texture indices unchanged). Sign and bed shapes come from their block models; sign text is not drawn.
  • uvlock: variants with uvlock: true now keep their texture fixed to the world while the model rotates, recomputed from the rotated face direction and element box.

Verification

Measured on a synthetic test world (block entities, uvlock variants, a damaged area) drawn with the same cameras by BlueMap (Paper + BlueMap, browser capture) and by the shot renderer at 1280×720; the renderer's void was composited over black, the capture's void colour:

  • Damage view (distance 70, rotation −0.6, angle 0.75): world-area agreement 94.9%; 88.9% of pixels within ±12 per channel, 97.0% within ±30; mean maximum-channel difference 4.4/255.
  • Close-up view (distance 45, angle 0.9): world-area agreement 93.1%; 80.7% within ±12, 93.6% within ±30; mean difference 8.2/255.

The remaining differences are shading and texture filtering of two independent renderers. Details and request/response formats: docs/render-api.md. Live API check against a running watch: health 204, map list, a high-priority 1280×720 render answered in ~1.5 s end to end (~0.4 s render), a repeated request from cache in ~0.1 s, and a 1920×1080 normal-priority render in ~1.8 s.

Adds a perspective "shot" capability next to the tile renderer:

- ShotCamera / ShotRenderer: a perspective camera with the same terms as
  BlueMap's perspective view (target, distance, rotation, angle, fov 75,
  its near/far rule, and its effective-target-height rule computed from
  the world data), rendering any image size through a perspective
  rasterizer variant. Translucent sorting follows the view direction.
- A `shot` command that writes a PNG plus the camera transform as JSON.
- An HTTP render API served by `watch --api-port`: POST /v1/render with
  a map name, a camera and a size returns the PNG (base64) and the
  transform; GET /v1/maps and /v1/health alongside. High-priority
  requests are served about once a second between tile batches, normal
  ones a few per step, identical requests hit a short-lived cache, and
  the API keeps serving when the tile database is unreachable.
- Block-entity blocks are baked from built-in models mirroring the
  client's geometry and entity textures (chests incl. double and copper
  variants, banners, skulls and heads, shulker boxes); build-data
  extracts the entity sheets into the texture atlas. Sign text is not
  drawn.
- uvlock variants now keep their texture fixed to the world while the
  model rotates, recomputed from the rotated face direction and the
  rotated element box.

docs/render-api.md describes the camera, the API and the measured
equivalence with the BlueMap screenshot path.
@malken21
malken21 merged commit b7a4ce2 into main Nov 10, 2026
2 checks passed
@malken21
malken21 deleted the feature/shots branch November 10, 2026 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant