Detailed 32 px imp sprite and finer world pixel rows (540, 1080)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Richard ZinkandClaude Opus 5.5 committed 2026-11-07 20:41:29 +01:00
1 parent 10af85fd95
commit 928c34e78b
7 files changed
+121 -18

No files matched your search

+10 -3
View File
@@ -1561,7 +1561,9 @@ impl R3d {
}
}
// sprites as billboards
if let Some(mesh) = self.billboards(g, gfx, cam, t) {
// the world's pixel rows (detailed sprites only where they get enough pixels)
let world_rows = pix.map_or(screen_height() * screen_dpi_scale(), |(_, th, _)| th as f32);
if let Some(mesh) = self.billboards(g, gfx, cam, t, world_rows) {
draw_mesh(&mesh);
}
// solid unlit objects (default material, depth tested)
@@ -1636,7 +1638,7 @@ impl R3d {
self.draw_2d(g, gfx, cam, &m, t);
}
fn billboards(&self, g: &Game, gfx: &Gfx, cam: &Cam, t: f32) -> Option<Mesh> {
fn billboards(&self, g: &Game, gfx: &Gfx, cam: &Cam, t: f32, world_rows: f32) -> Option<Mesh> {
let (_, r, _) = cam.basis();
let toward = cam.eye_dir();
let amb = |x: f32, z: f32| {
@@ -1656,6 +1658,9 @@ impl R3d {
let mut mb = MB::new();
let sw = SPRITE_TEX_W;
let sh = SPRITE_TEX_H;
// screen pixels per tile: a sprite's cell (1.2 sizes high) shows a detailed sprite when
// every texel of it gets nearly a pixel; fewer pixels would only turn it into noise
let px_per_tile = world_rows / cam.view_h().max(0.1);
for e in &g.ents {
if !e.alive || e.held || unit_hidden(g, e) {
continue;
@@ -1754,7 +1759,9 @@ impl R3d {
lunge = 0.0;
}
let white = e.flash > 0.07;
let src = Gfx::sprite_cell_view(e.kind, white, e.level, if e.captive != 0 { 0 } else { view });
let v = if e.captive != 0 { 0 } else { view };
let detailed = w * 1.2 * px_per_tile >= crate::gfx::ACELL as f32 * 0.85;
let src = detailed.then(|| Gfx::hd_cell_view(e.kind, white, e.level, v)).flatten().unwrap_or_else(|| Gfx::sprite_cell_view(e.kind, white, e.level, v));
let (mut u0, v0) = (src.x / sw, src.y / sh);
let (mut u1, v1) = ((src.x + src.w) / sw, (src.y + src.h) / sh);
if mirror {