pinhole camera ray map like vanilla (vertical fov 70, horizontal from aspect, pixel centres, no roll) instead of yaw/pitch corner rotation that squashed photos vertically by cos 35, shared buildRayMap in test tools, camera projection test scenes

This commit is contained in:
MineTec committed 2026-11-04 17:07:19 +01:00
1 parent 88bae41a03
commit 6660ebe557
5 files changed
+77 -112

No files matched your search

+40 -1
View File
@@ -136,6 +136,15 @@ public class PPTest extends JavaPlugin {
scenes.put("frames_side", new Scene("frames_side", this::frames, -1.5, 3.2, -1.0, 4.5, 2.6, 3.6));
scenes.put("frames_dirs_ne", new Scene("frames_dirs_ne", this::framesDirs, 16, 7.5, -4, 8, 4, 3.5));
scenes.put("frames_dirs_sw", new Scene("frames_dirs_sw", this::framesDirs, 0, 1.2, 10, 8, 4, 3.5));
// Camera projection (pinhole, vertical FOV 70): frontal checkerboard wall / item-frame map (squares must be
// square, same size everywhere), ceiling straight up, floor straight down at yaw 30, oblique wall with
// stripes (edges must stay straight, the vertical stripe through the view centre vertical). *_sq = 384x384.
scenes.put("cam_checker_sq", new Scene("cam_checker_sq", this::camChecker, 5.5, 5.5, 1, 5.5, 5.5, 6));
scenes.put("cam_checker", new Scene("cam_checker", this::camChecker, 5.5, 5.5, 1, 5.5, 5.5, 6));
scenes.put("cam_frame_sq", new Scene("cam_frame_sq", this::camFrame, 5.5, 5.5, 3, 5.5, 5.5, 6));
scenes.put("cam_up_sq", new Scene("cam_up_sq", this::camChecker, 5.5, 6, 0.5, 5.5, 11, 0.5));
scenes.put("cam_down_sq", new Scene("cam_down_sq", this::camChecker, 5.5, 4, 0.5, 5.4995, 0, 0.500866));
scenes.put("cam_oblique", new Scene("cam_oblique", this::camStripes, 2, 11, 1.5, 5.5, 5.5, 6));
// Performance (entity BVH): a 15x18 animal farm (270 mobs, randomizeData=false, fixed body yaw) and 300
// item displays from a seeded RNG -> deterministic, pixel-diffable; the render time is logged.
scenes.put("perf_farm", new Scene("perf_farm", this::perfFarm, -6, 9, -13, 4, 0, 0));
@@ -274,7 +283,7 @@ public class PPTest extends JavaPlugin {
Location eye = o.clone().add(sc.camX, sc.camY, sc.camZ);
Vector look = o.clone().add(sc.lookX, sc.lookY, sc.lookZ).toVector().subtract(eye.toVector());
eye.setDirection(look);
RenderJob job = r.prepare(eye, sc.name.startsWith("proj_") || sc.name.startsWith("rf_") || sc.name.startsWith("frames") ? new Resolution(960, 640) : new Resolution(480, 320), null);
RenderJob job = r.prepare(eye, sc.name.endsWith("_sq") ? new Resolution(384, 384) : sc.name.startsWith("proj_") || sc.name.startsWith("rf_") || sc.name.startsWith("frames") ? new Resolution(960, 640) : new Resolution(480, 320), null);
if (sc.name.equals("dbg")) {
try {
java.lang.reflect.Field f = DefaultScreenRenderer.class.getDeclaredField("objectBaker");
@@ -1253,6 +1262,36 @@ public class PPTest extends JavaPlugin {
}
}
/** Black/white concrete checkerboard: wall z=6 (x -6..17, y 0..11), ceiling y=11 and floor y=-1. */
private void camChecker(Location o) {
for (int a = -6; a < 18; a++)
for (int b = 0; b < 12; b++) {
Material m = ((a + b) & 1) == 0 ? Material.WHITE_CONCRETE : Material.BLACK_CONCRETE;
w.getBlockAt(o.getBlockX() + a, o.getBlockY() + b, o.getBlockZ() + 6).setType(m, false);
}
for (int a = -6; a < 18; a++)
for (int c = -12; c < 6; c++) {
Material m = ((a + c) & 1) == 0 ? Material.WHITE_CONCRETE : Material.BLACK_CONCRETE;
w.getBlockAt(o.getBlockX() + a, o.getBlockY() + 11, o.getBlockZ() + c).setType(m, false);
w.getBlockAt(o.getBlockX() + a, o.getBlockY() - 1, o.getBlockZ() + c).setType(m, false);
}
}
/** Black wall z=6 with one item frame (synthetic map, 1x1 block) facing north at cell (5,5,5). */
private void camFrame(Location o) {
for (int a = -6; a < 18; a++)
for (int b = 0; b < 12; b++) w.getBlockAt(o.getBlockX() + a, o.getBlockY() + b, o.getBlockZ() + 6).setType(Material.BLACK_CONCRETE, false);
frame(o, 5, 5, 5, BlockFace.NORTH, false, synthMap(), 0, true);
}
/** Black wall z=6 with a white vertical stripe (x=5) and a white horizontal stripe (y=5). */
private void camStripes(Location o) {
for (int a = -6; a < 18; a++)
for (int b = 0; b < 12; b++)
w.getBlockAt(o.getBlockX() + a, o.getBlockY() + b, o.getBlockZ() + 6)
.setType(a == 5 || b == 5 ? Material.WHITE_CONCRETE : Material.BLACK_CONCRETE, false);
}
private ItemFrame frame(Location o, int x, int y, int z, BlockFace face, boolean glow, ItemStack item, int rot, boolean visible) {
Location l = o.clone().add(x + 0.5, y + 0.5, z + 0.5);
Class<? extends ItemFrame> c = glow ? GlowItemFrame.class : ItemFrame.class;