From a0355c9b897281d0bfea48bec9d490724ecabd96 Mon Sep 17 00:00:00 2001 From: SulfurNitride Date: Sun, 12 Apr 2026 17:54:45 -0500 Subject: Add NIF previewer plugin with Linux-specific fixes Vendored from github.com/Parapets/mo2-preview_nif and adapted for Linux: - BSA texture resolution via MO2 virtual tree with case-insensitive fallback walk (Linux FS is case-sensitive; NIFs reference textures with arbitrary case against files on disk) - Process-wide cached BSA candidate list, keyed by profile path, priority-sorted, filtering disabled mods - Path backslash normalization before loose-file lookup - Polygon offset on SLSF1_Decal-flagged shapes to break z-ties with coincident base meshes (road decals, moss overlays) - Opaque framebuffer via glColorMask alpha lock so alpha-blended shapes can't bleed the dialog background through the preview area - QMouseEvent::globalPosition().toPoint() for Qt6 compatibility Preview dialog behavior (organizercore.cpp): - Switch previewFile and previewFileWithAlternatives from stack-allocated exec() to heap + ApplicationModal + show() + WA_DeleteOnClose. - Parent passed as nullptr so preview lifetime is decoupled from the stack-allocated ModInfoDialog that spawns it. Nested exec() inside the enclosing dialog's exec() was softlocking on close. Co-Authored-By: Claude Opus 4.6 (1M context) --- libs/preview_nif/data/shaders/default.vert | 50 ++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 libs/preview_nif/data/shaders/default.vert (limited to 'libs/preview_nif/data/shaders/default.vert') diff --git a/libs/preview_nif/data/shaders/default.vert b/libs/preview_nif/data/shaders/default.vert new file mode 100644 index 0000000..90cccd3 --- /dev/null +++ b/libs/preview_nif/data/shaders/default.vert @@ -0,0 +1,50 @@ +#version 120 + +uniform mat4 modelViewMatrix; +uniform mat4 mvpMatrix; +uniform mat3 normalMatrix; +uniform vec3 lightDirection; +uniform vec4 ambientColor; +uniform vec4 diffuseColor; + +attribute vec3 position; +attribute vec3 normal; +attribute vec3 tangent; +attribute vec3 bitangent; +attribute vec2 texCoord; +attribute vec4 color; + +varying vec2 TexCoord; +varying vec3 LightDir; +varying vec3 ViewDir; + +varying vec3 N; +varying vec3 t; +varying vec3 b; +varying vec3 v; + +varying vec4 A; +varying vec4 C; +varying vec4 D; + +void main( void ) +{ + gl_Position = mvpMatrix * vec4(position, 1.0); + TexCoord = texCoord; + + N = normalize(normalMatrix * normal); + t = normalize(normalMatrix * tangent); + b = normalize(normalMatrix * bitangent); + v = vec3(modelViewMatrix * vec4(position, 1.0)); + + mat3 tbnMatrix = mat3(b.x, t.x, N.x, + b.y, t.y, N.y, + b.z, t.z, N.z); + + ViewDir = tbnMatrix * -v; + LightDir = tbnMatrix * lightDirection; + + A = ambientColor; + C = color; + D = diffuseColor; +} -- cgit v1.3.1