feat(dashboard): metal and glow looks in the UGC and zone 3D views

NifFile::ShaderLookFor knows Polished Metal (98), Brushed Steel (99) and
LEGO-Emissive (53). The UGC mesh route sends each mesh's look (from its
multishader tag), and the UGC 3D view draws metal as reflective and glow
unlit. The zone views draw LEGO-Emissive objects going to their vertex
color by its alpha, as the shader does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Aaron Kimbrell
2026-09-28 09:55:00 -05:00
parent b34e8cb254
commit bc9ffeefaf
10 changed files with 130 additions and 21 deletions

View File

@@ -867,6 +867,16 @@ namespace Scenery {
return zone->json;
}
std::vector<uint16_t> MultishaderLooks(const NifFile::Model& model) {
std::vector<uint16_t> looks;
for (const auto& mesh : model.meshes) {
std::optional<int32_t> shader;
if (const auto it = g_ShaderValues.find(mesh.material.shaderTag); it != g_ShaderValues.end()) shader = it->second;
looks.push_back(NifFile::ShaderLookFor(NifFile::MultishaderPart(shader)));
}
return looks;
}
bool ZoneReady(uint32_t zoneId) {
return g_Zones.Ready(zoneId);
}

View File

@@ -3,6 +3,7 @@
#include <cstdint>
#include <optional>
#include <string>
#include <vector>
struct HTTPReply;
struct HTTPContext;
@@ -11,6 +12,10 @@ namespace WorldScene {
struct Object;
}
namespace NifFile {
struct Model;
}
/**
* A zone's scenery for the 3D views, drawn from the game client's files the way the client draws it: every object in
* the zone's scene files (.lvl) with the model of its render component (RenderComponent.render_asset, a .nif or a
@@ -46,6 +51,13 @@ namespace Scenery {
// Whether ZoneJson is built (so answering it is quick)
bool ZoneReady(uint32_t zoneId);
/**
* The eShaderLook bits (NifFile::ShaderLookFor) of each mesh of a multishader model (a player model: RenderComponent
* shader Multishader), from its parts' tags (mapShaders ids, read by Preload); for NifFile::Encode's `looks`.
* Any thread.
*/
std::vector<uint16_t> MultishaderLooks(const NifFile::Model& model);
/**
* The zone's flairs (the grass, flowers and small rocks its terrain file strews over it, models from FlairTable) as a
* manifest in ZoneJson's form, whose models the same mesh and texture routes serve, plus: distance (how far from the

View File

@@ -11,6 +11,7 @@
#include "Database.h"
#include "UgcIconParams.h"
#include "NifFile.h"
#include "Scenery.h"
#include "SettingsCatalog.h"
#include "SettingsHistory.h"
#include "UgcAssemblies.h"
@@ -477,7 +478,7 @@ namespace UgcRoutes {
});
Route(eHTTPMethod::GET, "/api/ugc/mesh/:id", Perm("properties_view"),
"A player model's generated .nif converted for the 3D view (NifFile::Encode, as the scenery meshes). Query: ?lod=0 (most detailed) "
"A player model's generated .nif converted for the 3D view (NifFile::Encode, as the scenery meshes, with each mesh's shader look). Query: ?lod=0 (most detailed) "
"to 3, &version=current|previous, &ao=0 for the mesh before the lighting bake. The header adds triangles and vertices",
[](HTTPReply& reply, const HTTPContext& context) {
const auto id = PathId<LWOOBJID>(context.path, 3);
@@ -495,7 +496,7 @@ namespace UgcRoutes {
if (!model) return JsonError(out, eHTTPStatusCode::UNPROCESSABLE_ENTITY, "The .nif can't be read: " + error);
out.status = eHTTPStatusCode::OK;
out.contentType = eContentType::APPLICATION_OCTET_STREAM;
out.message = NifFile::Encode(*model, std::vector<std::string>(model->meshes.size()));
out.message = NifFile::Encode(*model, std::vector<std::string>(model->meshes.size()), {}, Scenery::MultishaderLooks(*model));
out.headers.push_back("Cache-Control: private, no-cache");
});
});