mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-02 02:43:44 +00:00
fix(ugc): glitter sparkles that move on placed models
Why the glitter never moved: player models (LOT 14) are wrapped in weeblewobble.kfm (RenderComponentWrapper 9845), so the client makes them an LWOSkinnedRenderComponent, whose Run (0x00d6d3d0) updates the scene graph (and so any NiTextureTransformController) only while animation is enabled, and LWOModelBehaviorComponent::EnableAnimation (0x00be2740) turns it off for modelType 2, which every placed property model is. The root flags 0x102 added earlier are only read by the base render component. Nothing in a placed model's .nif can move. What does move: shader classes set globals in their own per-frame Run. Distortion Directional (Ocean) (mapShaders 79, Run 0x010b90c0) slides its texture layers by fixed shares of a tile a second, as the game's own pond ripples (S79__pond_ripplesShape). Glitter bricks now get a sparkle group, S79_GlitterSparkle_Model: their triangles lifted 0.005 off the brick, vertex colors white tinted by the brick, UVs placed per brick, alpha tested (ShaderCommon's alpha test phase, GREATEREQUAL 127), with a stored texture of flat sparkles at alpha 230: one layer's sparkle alone averages under the test, two meeting pass, so sparkles flash and go out as the layers cross. The flecks stay (LEGO-AnimUV, now without the controllers and flags that never ran). The icon and the dashboard's 3D view leave the sparkles out. New settings: shader_glitter_sparkle (79, 0 off), glitter_sparkle_size, glitter_sparkle_amount, glitter_sparkle_tint, glitter_sparkle_brightness; glitter_speed is now how fast sparkles flash (the sparkle tile). Only glitter output changes; non-glitter models are byte-identical. Check in game: reprocess a property with glitter models, then look at them from a few angles and distances, on each graphics quality: - sparkles flash on and off all over the glitter bricks, continuously - no flickering fight between the sparkles and the brick surface - transparent glitter bricks still see-through, flecks still visible - nothing drawn where there is no glitter brick; icons unchanged apart from the flecks Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -174,7 +174,7 @@ async function loadGeneratedModel(url) {
|
||||
// ---- Viewer ----
|
||||
|
||||
const materialCache = new Map();
|
||||
// The glitter colours' moving flecks (window.LDD_GLITTER, the UGC server's glitter settings), updated each frame
|
||||
// The glitter colours' flecks (window.LDD_GLITTER, the UGC server's glitter settings)
|
||||
const glitterMaterials = [];
|
||||
function material(id) {
|
||||
if (!materialCache.has(id)) {
|
||||
@@ -192,9 +192,8 @@ function material(id) {
|
||||
});
|
||||
const glitter = window.LDD_GLITTER;
|
||||
if (glitter && (glitter.colors || []).includes(Number(id))) {
|
||||
// Moving as the game moves its fleck texture: a tile in U in 7 s and in V in 11 s at speed 1
|
||||
const speed = glitter.speed || 0;
|
||||
glitterMaterials.push(addGlitter(created, { coordinates: 'position', tile: glitter.tile || 1.6, flecks: glitter.flecks || 50, scroll: [speed / 7, speed / 11] }));
|
||||
// Still, as the game draws them on a placed model
|
||||
glitterMaterials.push(addGlitter(created, { coordinates: 'position', tile: glitter.tile || 1.6, flecks: glitter.flecks || 50 }));
|
||||
}
|
||||
materialCache.set(id, created);
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ export function shaderOf(manifest, asset, mesh) {
|
||||
|
||||
// NifFile::eShaderLook bits
|
||||
export const SHADER_LOOK = { UNLIT: 1, NO_TEXTURE: 2, NO_VERTEX_COLORS: 4, MATERIAL_COLOR: 8, TWO_LAYERS_BLENDED: 16, TWO_LAYERS_ADDED: 32, REFLECTIVE: 64, BRUSHED: 128, EMISSIVE: 256,
|
||||
GLITTER: 512 };
|
||||
GLITTER: 512, SPARKLE: 1024 };
|
||||
|
||||
/**
|
||||
* Glitter for a three.js material (the UGC server's glitter colors, UgcGlitter): white flecks over the color before
|
||||
|
||||
@@ -123,6 +123,8 @@ export function createNifViewer(container) {
|
||||
let seeThrough = !!mesh.blend && mesh.alpha < 0.99;
|
||||
if (mesh.blend && hasColors) for (let i = 3; i < mesh.colors.length && !seeThrough; i += 4) seeThrough = mesh.colors[i] < 250;
|
||||
const look = mesh.look || 0;
|
||||
// The glitter sparkles (drawn over the glitter bricks) aren't drawn here
|
||||
if (look & SHADER_LOOK.SPARKLE) continue;
|
||||
const metal = metalOf(look);
|
||||
// Glow: the emissive shader's vertex color, unlit (its vertex alpha is the glow, not opacity)
|
||||
const material = look & SHADER_LOOK.EMISSIVE
|
||||
|
||||
Reference in New Issue
Block a user