- Himmel: 4k-HDRI von Poly Haven (CC0, tools/assets/hdri.mjs) statt Sky-Shader. Kuppel zeigt das Foto ab 12°, darunter weiches Band und Dunst in Nebelfarbe; Umgebungslicht und Spiegelungen per PMREM; Sonne aus dem Bild gekappt und als Licht übernommen (77°, Stärke 2,5) - Schatten: CSM mit vier Stufen (25/100/350/1000 m, je 2048²), Schutznetz für beleuchtete Materialien, Normal-Bias 1,5 Texel je Stufe gegen Streifen auf doppelseitigen Materialien (Figur, Autos) - Startfigur wirft Schatten, Palmen und Laternen empfangen Schatten, Wasser als ruhige See - Debug-Panel: Sonne, Himmelslicht, Himmelshelligkeit; Namensnennung um das HDRI ergänzt Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
21 lines
1.2 KiB
JavaScript
21 lines
1.2 KiB
JavaScript
// Lädt das HDRI "Nowhere Road" (Poly Haven, CC0) in 4k als Radiance-.hdr nach public/textures/.
|
|
// Dasselbe Bild wie das 84-MB-EXR von Poly Haven, als RGBE aber nur ein Drittel so groß und ohne
|
|
// eigenen Encoder — src/world/sky.js macht daraus Himmel, Umgebungslicht und Sonne.
|
|
import { createHash } from "node:crypto";
|
|
import { mkdir, writeFile } from "node:fs/promises";
|
|
|
|
const UA = { "User-Agent": "leonida-assets/0.1 (local hobby project)" };
|
|
const SLUG = "nowhere_road";
|
|
const RESOLUTION = "4k";
|
|
|
|
const files = await (await fetch(`https://api.polyhaven.com/files/${SLUG}`, { headers: UA })).json();
|
|
const entry = files.hdri?.[RESOLUTION]?.hdr;
|
|
if (!entry) throw new Error(`${SLUG}: kein ${RESOLUTION}-HDR bei Poly Haven`);
|
|
const buf = Buffer.from(await (await fetch(entry.url, { headers: UA })).arrayBuffer());
|
|
// Ein abgebrochener Download ergäbe ein halbes Panorama, das HDRLoader trotzdem still lädt.
|
|
const md5 = createHash("md5").update(buf).digest("hex");
|
|
if (md5 !== entry.md5) throw new Error(`${SLUG}: MD5 ${md5} statt ${entry.md5}`);
|
|
await mkdir("public/textures", { recursive: true });
|
|
await writeFile(`public/textures/${SLUG}_${RESOLUTION}.hdr`, buf);
|
|
console.log(`${SLUG}_${RESOLUTION}.hdr ${(buf.length / 1e6).toFixed(1)} MB`);
|