Expand description
Clean-room KV6 sprite raycaster for the DDA backend (Substage DDA.8).
Renders KV6 sprites by per-pixel ray casting: for every screen
pixel the sprite covers, transform the camera ray into the sprite’s
local voxel space, 3D-DDA through the KV6, and depth-composite the
first solid voxel against the shared z-buffer. Clean-room (no voxlap
code), the sprite counterpart to the terrain renderer in
crate::dda.
Depth parity. Transforming the ray by the inverse sprite basis
leaves the ray parameter unchanged in world units — a hit at local
parameter t is at world point cam.pos + dir·t — so the
perpendicular depth is t · (dir·forward), exactly the convention
crate::dda writes for terrain. Sprites therefore occlude and are
occluded by DDA terrain correctly.
Shading reads the KV6 voxel’s baked brightness byte (high byte of
the packed colour) via [crate::dda::shade] — the clean-room
brightness model, not voxlap’s dir-LUT reflection shading.
Structs§
- Clip
Flipbook - CPU-side decoded animated voxel clip: every frame’s
SpriteDenseis cached at construction, so per-frame playback is a grid select — not the per-frame voxel-volume decodedraw_sprite_ddapays each call. The CPU counterpart to the GPU flipbook (VCL.2). Build once from aDecodedClip, thendraw_framethe active frame each render. - Sprite
Dense - Dense occupancy + colour grid for one sprite frame, plus its pivot —
the decoded form the per-pixel raycaster marches. Built once from a
Kv6(SpriteDense::from_kv6) or a voxel-clipVoxelFrame(SpriteDense::from_voxel_frame); the latter lets an animated clip cache every frame’s grid up front instead of rebuilding per frame. - Sprite
Shade - Material context for a translucent sprite draw (TV stage): the global
MaterialTableplus this instance’s uniform material id and per-frame alpha multiplier. Passed (asSome) todraw_sprite_dense_shaded/ClipFlipbook::draw_frame_shadedto enable front-to-back accumulate-and-continue compositing;None(or an all-opaque effective material) takes the existing first-hit opaque path byte-for-byte.
Functions§
- draw_
sprite_ dda - Draw one KV6
Spriteinto(fb, zb)by per-pixel ray casting, depth-compositing against whatever the terrain pass already wrote. Returns the number of pixels written. - draw_
sprite_ dda_ shaded - Draw one KV6
Sprite, optionally with a translucent material (TV stage) — thedraw_sprite_dense_shadedcounterpart ofdraw_sprite_dda.shade_ctx == None(or an opaque effective material) renders the sprite opaque, byte-for-byte unchanged. - draw_
sprite_ dense - Draw a pre-decoded
SpriteDenseat a world pose — the generalised core ofdraw_sprite_dda, shared by the KV6 path and animatedClipFlipbookframes.posis the world pivot;s/h/fare the model→world basis columns (local +x/+y/+z);flagshonoursSPRITE_FLAG_INVISIBLE/SPRITE_FLAG_NO_Z. Returns pixels written. - draw_
sprite_ dense_ shaded - Draw a pre-decoded
SpriteDenseat a world pose, optionally with a translucent material (TV stage).shade_ctx: