Compare commits
No commits in common. "a12bcbbcadea8d75105e9378570af82ca0a7b0b7" and "5813ee3b5a8ac54aecfbc67bbcf5acc7ff5b2fc1" have entirely different histories.
a12bcbbcad
...
5813ee3b5a
|
|
@ -53,59 +53,6 @@ export function roomVantage(env, region, opts = {}) {
|
||||||
return mostOpenCell(distanceToWall(tiles, env.width, env.height), env.width, region.cells);
|
return mostOpenCell(distanceToWall(tiles, env.width, env.height), env.width, region.cells);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Per-(room, facing) camera cell, chosen so the faced geometry reads
|
|
||||||
// UNAMBIGUOUSLY in the depth map. The room-wide most-open vantage stands far
|
|
||||||
// from everything: the faced wall lands near max-view (≈ black), and the
|
|
||||||
// diffusion model decorates that ambiguity with hallucinated doors — while a
|
|
||||||
// real opening renders off-center because the camera isn't aligned with the
|
|
||||||
// gap. Instead:
|
|
||||||
// open ahead → stand in a cell whose straight-ahead ray ESCAPES the room
|
|
||||||
// through the gap, a comfortable 2–7 cells back: the passage
|
|
||||||
// you'd walk through is centered and clearly deep.
|
|
||||||
// wall ahead → stand ~3 cells from the wall: it renders mid-bright and
|
|
||||||
// solid, leaving the model nothing to invent.
|
|
||||||
export function directedVantage(env, region, dirName, opts = {}) {
|
|
||||||
const { tiles } = getStage(env, opts.stage);
|
|
||||||
const w = env.width, h = env.height;
|
|
||||||
const dist = distanceToWall(tiles, w, h);
|
|
||||||
const [dx, dy] = DIRS[dirName];
|
|
||||||
const cellSet = new Set(region.cells.map(([x, y]) => x + ',' + y));
|
|
||||||
const [cx, cy] = centroidOf(region.cells);
|
|
||||||
|
|
||||||
let best = null, bestScore = Infinity, anyEscape = false;
|
|
||||||
const cand = [];
|
|
||||||
for (const [x, y] of region.cells) {
|
|
||||||
let px = x, py = y, run = 0, escaped = false;
|
|
||||||
for (let s = 0; s < 24; s++) {
|
|
||||||
px += dx; py += dy;
|
|
||||||
if (px < 0 || py < 0 || px >= w || py >= h) break;
|
|
||||||
if (blocks(tiles[py][px])) break;
|
|
||||||
run++;
|
|
||||||
if (!cellSet.has(px + ',' + py)) escaped = true; // ray left the room through a gap
|
|
||||||
}
|
|
||||||
if (escaped) anyEscape = true;
|
|
||||||
cand.push({ x, y, run, escaped });
|
|
||||||
}
|
|
||||||
for (const c of cand) {
|
|
||||||
if (anyEscape && !c.escaped) continue; // when a gap is sightable, only gap-aligned cells qualify
|
|
||||||
const clearance = dist[c.y * w + c.x];
|
|
||||||
// Sweet bands: gaps read best 2–7 cells out; a blank wall at ~2.
|
|
||||||
const band = anyEscape
|
|
||||||
? (c.run < 2 ? (2 - c.run) * 6 : c.run > 7 ? (c.run - 7) * 2 : 0)
|
|
||||||
: Math.abs(c.run - 2) * 3; // closed: stand close — a bright dominant slab leaves no room for phantom doors
|
|
||||||
const hug = clearance <= 1 ? 5 : 0; // don't press against a side wall
|
|
||||||
// Open: center on the gap. Closed: deliberately stand OFF the room's
|
|
||||||
// perpendicular axis — a symmetric stage begs the model to paint a
|
|
||||||
// centered focal door; an off-axis dead-end corner doesn't.
|
|
||||||
const perp = dirName === 'N' || dirName === 'S' ? c.x - cx : c.y - cy;
|
|
||||||
const cen = ((c.x - cx) ** 2 + (c.y - cy) ** 2) * 0.05;
|
|
||||||
const offAxis = anyEscape ? 0 : (Math.abs(perp) < 1.5 ? 4 : 0);
|
|
||||||
const score = band + hug + (anyEscape ? cen : offAxis + cen * 0.4);
|
|
||||||
if (score < bestScore) { bestScore = score; best = [c.x, c.y]; }
|
|
||||||
}
|
|
||||||
return best ?? mostOpenCell(dist, w, region.cells);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Default demo vantage: the most-open cell of the largest room (or, failing that,
|
// Default demo vantage: the most-open cell of the largest room (or, failing that,
|
||||||
// the most open floor cell anywhere).
|
// the most open floor cell anywhere).
|
||||||
export function vantage(env, opts = {}) {
|
export function vantage(env, opts = {}) {
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
import init, { generate, default_config_json } from './pkg/reikhelm_wasm.js';
|
import init, { generate, default_config_json } from './pkg/reikhelm_wasm.js';
|
||||||
import { renderMap, getStage, THEMES } from './render.js';
|
import { renderMap, getStage, THEMES } from './render.js';
|
||||||
import { downloadDepth, exportDepthDataURL, exportDepthToServer } from './depth.js';
|
import { downloadDepth, exportDepthDataURL, exportDepthToServer } from './depth.js';
|
||||||
import { exportFPVDataURL, exportFPVToServer, vantage, directedVantage } from './fpv.js';
|
import { exportFPVDataURL, exportFPVToServer, vantage } from './fpv.js';
|
||||||
import { dungeonManifest } from './explore.js';
|
import { dungeonManifest } from './explore.js';
|
||||||
|
|
||||||
const canvas = document.getElementById('view');
|
const canvas = document.getElementById('view');
|
||||||
|
|
@ -241,10 +241,7 @@ window.reikhelm = {
|
||||||
const sd = state.env.seed;
|
const sd = state.env.seed;
|
||||||
for (const r of m.rooms) {
|
for (const r of m.rooms) {
|
||||||
for (const dir of ['N', 'E', 'S', 'W']) {
|
for (const dir of ['N', 'E', 'S', 'W']) {
|
||||||
// Per-direction camera: gap-aligned when the way is open, near-wall
|
await exportFPVToServer(state.env, `atlas/${sd}/_work/r${r.id}_${dir}_depth.png`, { at: r.vantage, dir });
|
||||||
// when it's closed — so the depth map can't be misread by the model.
|
|
||||||
const at = directedVantage(state.env, state.env.regions[r.id], dir);
|
|
||||||
await exportFPVToServer(state.env, `atlas/${sd}/_work/r${r.id}_${dir}_depth.png`, { at, dir });
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await this.saveJSON(`atlas/${sd}/manifest.json`, m);
|
await this.saveJSON(`atlas/${sd}/manifest.json`, m);
|
||||||
|
|
|
||||||
|
|
@ -56,11 +56,7 @@ DEFAULT_BODY = THEME_BODY["stone"]
|
||||||
# These reinforce the depth (a deep recess vs a near wall straight ahead) so the
|
# These reinforce the depth (a deep recess vs a near wall straight ahead) so the
|
||||||
# model paints a passage only where one actually exists — killing phantom doors.
|
# model paints a passage only where one actually exists — killing phantom doors.
|
||||||
AHEAD_OPEN = "a dark arched passage leads onward into shadow ahead"
|
AHEAD_OPEN = "a dark arched passage leads onward into shadow ahead"
|
||||||
# cfg 1.0 makes negatives inert, so the closed case is carried by emphatic
|
AHEAD_WALL = "a solid carved stone wall closes the way ahead"
|
||||||
# positive description — themes like the vault say "locked", which otherwise
|
|
||||||
# summons phantom doors on blank walls.
|
|
||||||
AHEAD_WALL = ("the way ahead ends at a blank unbroken wall of carved stone blocks, "
|
|
||||||
"sealed solid masonry with no door and no opening, a dead end")
|
|
||||||
NEGATIVE = ("person, people, human, figure, character, hands, fingers, hand, arm, arms, "
|
NEGATIVE = ("person, people, human, figure, character, hands, fingers, hand, arm, arms, "
|
||||||
"holding weapon, sword, feet, legs, body, silhouette, UI, HUD, text, watermark, modern")
|
"holding weapon, sword, feet, legs, body, silhouette, UI, HUD, text, watermark, modern")
|
||||||
|
|
||||||
|
|
@ -128,18 +124,13 @@ def main():
|
||||||
theme = room.get("theme")
|
theme = room.get("theme")
|
||||||
is_open = bool(room.get("open", {}).get(d, False))
|
is_open = bool(room.get("open", {}).get(d, False))
|
||||||
prompt = prompt_for(theme, is_open)
|
prompt = prompt_for(theme, is_open)
|
||||||
strength = a.strength
|
|
||||||
# Walls render under their own FIXED seed: the open-frame seed's
|
|
||||||
# favorite composition is a centered doorway — exactly what a closed
|
|
||||||
# wall must not grow. One class, one seed → style stays coherent.
|
|
||||||
render_seed = a.render_seed if is_open else a.render_seed + 13
|
|
||||||
prefix = f"r{rid}_{d}_{RUN}" # per-run unique; avoids ComfyUI prefix-counter collisions on re-bake
|
prefix = f"r{rid}_{d}_{RUN}" # per-run unique; avoids ComfyUI prefix-counter collisions on re-bake
|
||||||
frame = os.path.join(atlas, f"r{rid}_{d}.png")
|
frame = os.path.join(atlas, f"r{rid}_{d}.png")
|
||||||
tag = f"[{i}/{len(depths)}] r{rid} {d} {theme or '?'}{'·open' if is_open else '·wall'}"
|
tag = f"[{i}/{len(depths)}] r{rid} {d} {theme or '?'}{'·open' if is_open else '·wall'}"
|
||||||
|
|
||||||
if not run(["python3", COMFY, "zrender", a.url, "--depth", depth,
|
if not run(["python3", COMFY, "zrender", a.url, "--depth", depth,
|
||||||
"--width", str(a.width), "--height", str(a.height),
|
"--width", str(a.width), "--height", str(a.height),
|
||||||
"--strength", str(strength), "--seed", str(render_seed),
|
"--strength", str(a.strength), "--seed", str(a.render_seed),
|
||||||
"--prompt", prompt, "--negative", NEGATIVE,
|
"--prompt", prompt, "--negative", NEGATIVE,
|
||||||
"--prefix", prefix, "--wait", "300"]):
|
"--prefix", prefix, "--wait", "300"]):
|
||||||
print(f" {tag} RENDER FAILED"); continue
|
print(f" {tag} RENDER FAILED"); continue
|
||||||
|
|
@ -150,8 +141,7 @@ def main():
|
||||||
render = renders[0]
|
render = renders[0]
|
||||||
|
|
||||||
if not run([VENV_PY, PIXELATE, render, "--palette", PALETTE,
|
if not run([VENV_PY, PIXELATE, render, "--palette", PALETTE,
|
||||||
"--size", a.size, "--preview-scale", "0", "--overshoot", "6",
|
"--size", a.size, "--preview-scale", "0", "--out", frame]):
|
||||||
"--out", frame]):
|
|
||||||
print(f" {tag} DITHER FAILED"); continue
|
print(f" {tag} DITHER FAILED"); continue
|
||||||
|
|
||||||
os.remove(render) # keep the depth, drop the big intermediate render
|
os.remove(render) # keep the depth, drop the big intermediate render
|
||||||
|
|
|
||||||
|
Before Width: | Height: | Size: 97 KiB After Width: | Height: | Size: 72 KiB |
|
Before Width: | Height: | Size: 97 KiB After Width: | Height: | Size: 74 KiB |
|
Before Width: | Height: | Size: 100 KiB After Width: | Height: | Size: 74 KiB |
|
Before Width: | Height: | Size: 70 KiB After Width: | Height: | Size: 75 KiB |
|
Before Width: | Height: | Size: 82 KiB After Width: | Height: | Size: 64 KiB |
|
Before Width: | Height: | Size: 86 KiB After Width: | Height: | Size: 68 KiB |
|
Before Width: | Height: | Size: 92 KiB After Width: | Height: | Size: 66 KiB |
|
Before Width: | Height: | Size: 63 KiB After Width: | Height: | Size: 64 KiB |
|
Before Width: | Height: | Size: 91 KiB After Width: | Height: | Size: 75 KiB |
|
Before Width: | Height: | Size: 96 KiB After Width: | Height: | Size: 79 KiB |
|
Before Width: | Height: | Size: 89 KiB After Width: | Height: | Size: 75 KiB |
|
Before Width: | Height: | Size: 96 KiB After Width: | Height: | Size: 77 KiB |
|
Before Width: | Height: | Size: 87 KiB After Width: | Height: | Size: 64 KiB |
|
Before Width: | Height: | Size: 87 KiB After Width: | Height: | Size: 68 KiB |
|
Before Width: | Height: | Size: 89 KiB After Width: | Height: | Size: 66 KiB |
|
Before Width: | Height: | Size: 88 KiB After Width: | Height: | Size: 68 KiB |
|
Before Width: | Height: | Size: 96 KiB After Width: | Height: | Size: 78 KiB |
|
Before Width: | Height: | Size: 73 KiB After Width: | Height: | Size: 73 KiB |
|
Before Width: | Height: | Size: 89 KiB After Width: | Height: | Size: 70 KiB |
|
Before Width: | Height: | Size: 104 KiB After Width: | Height: | Size: 85 KiB |
|
Before Width: | Height: | Size: 86 KiB After Width: | Height: | Size: 51 KiB |
|
Before Width: | Height: | Size: 89 KiB After Width: | Height: | Size: 71 KiB |
|
Before Width: | Height: | Size: 86 KiB After Width: | Height: | Size: 67 KiB |
|
Before Width: | Height: | Size: 87 KiB After Width: | Height: | Size: 56 KiB |
|
Before Width: | Height: | Size: 97 KiB After Width: | Height: | Size: 69 KiB |
|
Before Width: | Height: | Size: 97 KiB After Width: | Height: | Size: 73 KiB |
|
Before Width: | Height: | Size: 90 KiB After Width: | Height: | Size: 69 KiB |
|
Before Width: | Height: | Size: 94 KiB After Width: | Height: | Size: 69 KiB |
|
Before Width: | Height: | Size: 105 KiB After Width: | Height: | Size: 61 KiB |
|
Before Width: | Height: | Size: 92 KiB After Width: | Height: | Size: 77 KiB |
|
Before Width: | Height: | Size: 90 KiB After Width: | Height: | Size: 76 KiB |
|
Before Width: | Height: | Size: 94 KiB After Width: | Height: | Size: 74 KiB |
|
Before Width: | Height: | Size: 90 KiB After Width: | Height: | Size: 76 KiB |
|
Before Width: | Height: | Size: 89 KiB After Width: | Height: | Size: 56 KiB |
|
Before Width: | Height: | Size: 93 KiB After Width: | Height: | Size: 72 KiB |
|
Before Width: | Height: | Size: 90 KiB After Width: | Height: | Size: 74 KiB |
|
Before Width: | Height: | Size: 94 KiB After Width: | Height: | Size: 81 KiB |
|
Before Width: | Height: | Size: 98 KiB After Width: | Height: | Size: 76 KiB |
|
Before Width: | Height: | Size: 96 KiB After Width: | Height: | Size: 80 KiB |
|
Before Width: | Height: | Size: 106 KiB After Width: | Height: | Size: 80 KiB |
|
Before Width: | Height: | Size: 95 KiB After Width: | Height: | Size: 74 KiB |
|
Before Width: | Height: | Size: 94 KiB After Width: | Height: | Size: 82 KiB |
|
Before Width: | Height: | Size: 96 KiB After Width: | Height: | Size: 74 KiB |
|
Before Width: | Height: | Size: 101 KiB After Width: | Height: | Size: 81 KiB |
|
Before Width: | Height: | Size: 101 KiB After Width: | Height: | Size: 81 KiB |
|
Before Width: | Height: | Size: 98 KiB After Width: | Height: | Size: 72 KiB |
|
Before Width: | Height: | Size: 93 KiB After Width: | Height: | Size: 71 KiB |
|
Before Width: | Height: | Size: 117 KiB After Width: | Height: | Size: 81 KiB |
|
Before Width: | Height: | Size: 88 KiB After Width: | Height: | Size: 68 KiB |
|
Before Width: | Height: | Size: 87 KiB After Width: | Height: | Size: 68 KiB |
|
Before Width: | Height: | Size: 87 KiB After Width: | Height: | Size: 68 KiB |
|
Before Width: | Height: | Size: 92 KiB After Width: | Height: | Size: 64 KiB |
|
Before Width: | Height: | Size: 90 KiB After Width: | Height: | Size: 78 KiB |
|
Before Width: | Height: | Size: 92 KiB After Width: | Height: | Size: 72 KiB |
|
Before Width: | Height: | Size: 91 KiB After Width: | Height: | Size: 80 KiB |
|
Before Width: | Height: | Size: 94 KiB After Width: | Height: | Size: 56 KiB |
|
Before Width: | Height: | Size: 102 KiB After Width: | Height: | Size: 76 KiB |
|
Before Width: | Height: | Size: 98 KiB After Width: | Height: | Size: 77 KiB |
|
Before Width: | Height: | Size: 92 KiB After Width: | Height: | Size: 74 KiB |
|
Before Width: | Height: | Size: 98 KiB After Width: | Height: | Size: 74 KiB |
|
Before Width: | Height: | Size: 93 KiB After Width: | Height: | Size: 73 KiB |
|
Before Width: | Height: | Size: 87 KiB After Width: | Height: | Size: 67 KiB |
|
Before Width: | Height: | Size: 86 KiB After Width: | Height: | Size: 69 KiB |
|
Before Width: | Height: | Size: 93 KiB After Width: | Height: | Size: 76 KiB |
|
Before Width: | Height: | Size: 94 KiB After Width: | Height: | Size: 75 KiB |
|
Before Width: | Height: | Size: 99 KiB After Width: | Height: | Size: 76 KiB |
|
Before Width: | Height: | Size: 102 KiB After Width: | Height: | Size: 81 KiB |
|
Before Width: | Height: | Size: 117 KiB After Width: | Height: | Size: 81 KiB |
|
Before Width: | Height: | Size: 91 KiB After Width: | Height: | Size: 70 KiB |
|
Before Width: | Height: | Size: 100 KiB After Width: | Height: | Size: 81 KiB |
|
Before Width: | Height: | Size: 102 KiB After Width: | Height: | Size: 79 KiB |
|
Before Width: | Height: | Size: 94 KiB After Width: | Height: | Size: 70 KiB |
|
Before Width: | Height: | Size: 108 KiB After Width: | Height: | Size: 79 KiB |
|
Before Width: | Height: | Size: 100 KiB After Width: | Height: | Size: 81 KiB |
|
Before Width: | Height: | Size: 102 KiB After Width: | Height: | Size: 72 KiB |
|
Before Width: | Height: | Size: 90 KiB After Width: | Height: | Size: 70 KiB |
|
Before Width: | Height: | Size: 87 KiB After Width: | Height: | Size: 68 KiB |
|
Before Width: | Height: | Size: 91 KiB After Width: | Height: | Size: 62 KiB |
|
Before Width: | Height: | Size: 88 KiB After Width: | Height: | Size: 65 KiB |
|
Before Width: | Height: | Size: 92 KiB After Width: | Height: | Size: 66 KiB |
|
Before Width: | Height: | Size: 98 KiB After Width: | Height: | Size: 80 KiB |
|
Before Width: | Height: | Size: 98 KiB After Width: | Height: | Size: 72 KiB |
|
Before Width: | Height: | Size: 98 KiB After Width: | Height: | Size: 74 KiB |
|
Before Width: | Height: | Size: 103 KiB After Width: | Height: | Size: 79 KiB |
|
Before Width: | Height: | Size: 98 KiB After Width: | Height: | Size: 79 KiB |
|
Before Width: | Height: | Size: 98 KiB After Width: | Height: | Size: 73 KiB |
|
Before Width: | Height: | Size: 81 KiB After Width: | Height: | Size: 73 KiB |
|
Before Width: | Height: | Size: 98 KiB After Width: | Height: | Size: 74 KiB |
|
Before Width: | Height: | Size: 90 KiB After Width: | Height: | Size: 74 KiB |
|
Before Width: | Height: | Size: 91 KiB After Width: | Height: | Size: 75 KiB |
|
Before Width: | Height: | Size: 97 KiB After Width: | Height: | Size: 75 KiB |
|
Before Width: | Height: | Size: 90 KiB After Width: | Height: | Size: 75 KiB |
|
Before Width: | Height: | Size: 92 KiB After Width: | Height: | Size: 78 KiB |
|
Before Width: | Height: | Size: 99 KiB After Width: | Height: | Size: 78 KiB |
|
Before Width: | Height: | Size: 103 KiB After Width: | Height: | Size: 78 KiB |
|
Before Width: | Height: | Size: 92 KiB After Width: | Height: | Size: 78 KiB |
|
Before Width: | Height: | Size: 92 KiB After Width: | Height: | Size: 75 KiB |