forked from phenom/healer-man
Update Healer Man server
This commit is contained in:
1 parent
6114a2295f
commit
69809f7228
593 files changed
+903643
-40774
No files matched your search
@@ -14,6 +14,9 @@ import { NodeIO } from "@gltf-transform/core";
|
||||
import { BufferAttribute, BufferGeometry, Matrix4, Quaternion, Vector3 } from "three";
|
||||
import { MeshBVH } from "three-mesh-bvh";
|
||||
import { bakeNavigationFromCollisionAssets } from "../dungeon-pipeline/recast-bake.mjs";
|
||||
import { environmentOptimizationArguments } from "./lib/environment-optimization.mjs";
|
||||
import { applyNativeMaterialSemantics } from "./lib/native-material-semantics.mjs";
|
||||
import { applyRunewakerVisualUvAdaptationsToFile } from "./lib/rom-visual-uv-adaptations-file.mjs";
|
||||
|
||||
const scriptDirectory = path.dirname(fileURLToPath(import.meta.url));
|
||||
const projectRoot = path.resolve(scriptDirectory, "../..");
|
||||
@@ -68,8 +71,8 @@ const gltfTransform = path.join(
|
||||
const ktx2Compressor = path.join(
|
||||
projectRoot,
|
||||
"scripts",
|
||||
"asset-pipeline",
|
||||
"compress-ktx2.mjs",
|
||||
"runewaker-pipeline",
|
||||
"compress-environment-textures.mjs",
|
||||
);
|
||||
const khronosValidator = path.join(
|
||||
projectRoot,
|
||||
@@ -173,6 +176,10 @@ async function prepareTextures() {
|
||||
path.join(rawDirectory, "export-report.json"),
|
||||
path.join(preparedDirectory, "export-report.json"),
|
||||
);
|
||||
const sourceReportFile = path.join(preparedDirectory, "export-report.json");
|
||||
const sourceReport = JSON.parse(await readFile(sourceReportFile, "utf8"));
|
||||
sourceReport.sourceResourceSha256 = await sha256(path.join(resourceRoot, recipe.source.model));
|
||||
await writeFile(sourceReportFile, JSON.stringify(sourceReport, null, 2) + "\n", "utf8");
|
||||
const sourceMtl = await readFile(path.join(rawDirectory, "scene.mtl"), "utf8");
|
||||
const preparedMtl = sourceMtl.replace(/^(map_Kd\s+.+)\.dds\s*$/gim, "$1.png");
|
||||
await writeFile(path.join(preparedDirectory, "scene.mtl"), preparedMtl, "utf8");
|
||||
@@ -206,29 +213,22 @@ async function convertEnvironment() {
|
||||
async function optimizeVisual() {
|
||||
const source = path.join(convertedDirectory, `${slug}-visual.glb`);
|
||||
const output = path.join(convertedDirectory, `${slug}-visual.optimized.glb`);
|
||||
const nativeMaterialSemantics = await applyNativeMaterialSemantics(source);
|
||||
const visualUvAdaptations = await applyRunewakerVisualUvAdaptationsToFile(source, {
|
||||
dungeonId: slug,
|
||||
policyIds: recipe.visualUvAdaptationPolicies ?? [],
|
||||
sourceReport: recipe.visualUvAdaptationPolicies?.length
|
||||
? JSON.parse(await readFile(path.join(preparedDirectory, "export-report.json"), "utf8"))
|
||||
: undefined,
|
||||
});
|
||||
await run(
|
||||
process.execPath,
|
||||
[
|
||||
gltfTransform,
|
||||
"optimize",
|
||||
source,
|
||||
output,
|
||||
"--compress",
|
||||
"meshopt",
|
||||
"--meshopt-level",
|
||||
"high",
|
||||
"--instance",
|
||||
"true",
|
||||
"--instance-min",
|
||||
"3",
|
||||
"--texture-size",
|
||||
"2048",
|
||||
],
|
||||
[gltfTransform, ...environmentOptimizationArguments(source, output)],
|
||||
"optimize the visual GLB with HealerMan's standard settings",
|
||||
);
|
||||
await run(
|
||||
process.execPath,
|
||||
[ktx2Compressor, output, "--concurrency", "1", "--jobs", "2"],
|
||||
[ktx2Compressor, output, "--concurrency", "1", "--jobs", "2", "--report", path.join(convertedDirectory, "texture-quality-report.json")],
|
||||
"compress the visual textures with KTX2",
|
||||
);
|
||||
await writeFile(
|
||||
@@ -238,12 +238,20 @@ async function optimizeVisual() {
|
||||
dungeonId: slug,
|
||||
status: "review-required",
|
||||
source: { file: path.basename(source), size: (await stat(source)).size },
|
||||
optimized: { file: path.basename(output), size: (await stat(output)).size },
|
||||
optimized: {
|
||||
file: path.basename(output),
|
||||
size: (await stat(output)).size,
|
||||
checksum: await sha256(output),
|
||||
},
|
||||
compression: "meshopt+ktx2",
|
||||
commands: [
|
||||
"gltf-transform optimize --compress meshopt --meshopt-level high --instance true --instance-min 3 --texture-size 2048",
|
||||
"node scripts/asset-pipeline/compress-ktx2.mjs <optimized.glb> --concurrency 1 --jobs 2",
|
||||
"node scripts/runewaker-pipeline/lib/native-material-semantics.mjs <converted.glb> (before optimization)",
|
||||
"gltf-transform optimize --compress meshopt --meshopt-level high --instance true --instance-min 3 --simplify false --texture-compress false",
|
||||
"node scripts/runewaker-pipeline/compress-environment-textures.mjs <optimized.glb> --concurrency 1 --jobs 2",
|
||||
],
|
||||
textureQuality: JSON.parse(await readFile(path.join(convertedDirectory, "texture-quality-report.json"), "utf8")),
|
||||
nativeMaterialSemantics,
|
||||
visualUvAdaptations,
|
||||
}, null, 2)}\n`,
|
||||
"utf8",
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user