mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-11-01 01:17:13 +00:00
feat(ugc): make models like LU Toolbox does, within CPU and memory budgets
Parity with LU Toolbox's Process Model, Bake Lighting and icon renderer, with its defaults as the settings' defaults: - Colors from its LU palette (UgcPalette: LU colors, LDD colors mapped to the nearest LU one, unknown ones black), transparent bricks at 58.82% opacity, a brick transparent only when all of its materials are. - Color variation: each brick's material gets its HSV value shifted in a 2.224 gamma by up to 5% (times the color's own amount), from a random number of the model, brick and material, so reprocessing gives the same colors in every LOD. Icons get none, and the icon renderer's color corrections. - LODs 0 and 2 with its distance logic, written as NiLODNode/NiRangeLODData like its exports and the game's own brick models, shapes divided at 65535 vertices along the longest side like divide_mesh. - Ambient occlusion like its AO-only bake: 64 rays per vertex, distance 5, after hidden surface removal, transparent bricks neither baked nor occluding, glow colors added. - Icons from its icon scene: 50 mm lens at 53.4/19.5 degrees, sun of 2.5 at 21/50.3 degrees with soft shadows, grey world light with occlusion; LOD 0's hidden surface removal and occlusion are reused for them. - Optional ground plane for hidden surface removal; stats.json per model and the previous version's previews kept for comparing. Budgets, applied live on config reload: max_cpu_percent (workers account their thread CPU time and sleep to stay under it, long renders included), worker_nice, max_memory_mb (jobs are estimated from their brick count and wait until they fit), max_model_bricks and pause_hours. /status and the traffic report show CPU, memory and throttling. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -15,10 +15,22 @@
|
||||
* the finished files. No database, network or CDClient: the main thread gathers the input and stores the result.
|
||||
*/
|
||||
namespace UgcJobs {
|
||||
/**
|
||||
* How models are made. The defaults are LU Toolbox's (Process Model, Bake Lighting and the icon renderer), see the
|
||||
* parity table in docs/UgcServer.md.
|
||||
*/
|
||||
struct Settings {
|
||||
UgcRender::OptimizeOptions optimize;
|
||||
UgcModel::BuildOptions build; // palette, color variation, transparent opacity
|
||||
std::vector<uint32_t> lods{ 0, 2 }; // brickprimitives levels made (LU Toolbox imports LOD 0 and 2; the client has no 3)
|
||||
UgcModel::LodDistances lodDistances;
|
||||
std::string shaderOpaque{ "01" }; // S<shader>_Opaque_...; transparent shapes are always S01
|
||||
UgcRender::OptimizeOptions optimize; // hidden surface removal
|
||||
UgcRender::AoOptions ao; // Bake Lighting (AO Only)
|
||||
UgcRender::IconOptions icon;
|
||||
bool iconCorrectColors{ true }; // the icon renderer's Correct Colors
|
||||
float iconColorVariation{ 0.0f }; // percent; its Apply Color Variation is off
|
||||
UgcRender::IconOptions modularIcon;
|
||||
uint32_t maxBricks{}; // a model with more fails; 0: no limit
|
||||
};
|
||||
|
||||
struct Outcome {
|
||||
@@ -27,6 +39,7 @@ namespace UgcJobs {
|
||||
std::string note; // what was odd but not fatal (missing bricks, ...)
|
||||
UgcStorage::Files files; // name -> bytes, when ok
|
||||
bool aoBaked{};
|
||||
std::string stats; // stats.json: bricks, triangles before and after per LOD, timings
|
||||
};
|
||||
|
||||
// The client's download of `data` (`name` + ".gz" and ".checksum") added to `files`
|
||||
@@ -35,8 +48,15 @@ namespace UgcJobs {
|
||||
// The LXFML of a ugc row's lxfml column (an sd0 stream, or plain LXFML); empty when it can't be read
|
||||
std::string LxfmlFromBlob(const std::string& blob);
|
||||
|
||||
// A player model: the optimized .nif, its icon and its LXFML for download
|
||||
Outcome ProcessModel(const std::string& blob, UgcBricks::BrickLibrary& library, const Settings& settings);
|
||||
// A player model: the optimized .nif, its icon and its LXFML for download, and stats.json. `seed` picks the color
|
||||
// variation's random numbers (the model's id, so making it again gives the same colors).
|
||||
Outcome ProcessModel(const std::string& blob, UgcBricks::BrickLibrary& library, const Settings& settings, uint64_t seed = 0);
|
||||
|
||||
// How many bricks (parts) an LXFML has, counted cheaply (for the memory estimate before a job starts)
|
||||
size_t CountParts(std::string_view lxfml);
|
||||
|
||||
// About how much memory making a model of `parts` bricks takes, in bytes
|
||||
uint64_t EstimateMemory(size_t parts, const Settings& settings);
|
||||
|
||||
struct ModuleInput {
|
||||
uint32_t lot{};
|
||||
|
||||
Reference in New Issue
Block a user