Commit graph

845 commits

Author SHA1 Message Date
Kelsi
9eeb9ce64d Add normal mapping and parallax occlusion mapping for character models
Extends the WMO normal mapping/POM system to character M2 models with
bone-skinned tangents. Auto-generates normal/height maps from diffuse
textures using luminance→height, Sobel→normals (same algorithm as WMO).

- Expand vertex buffer from M2Vertex (48B) to CharVertexGPU (56B) with
  tangent vec4 computed via Lengyel's method in setupModelBuffers()
- Tangents are bone-transformed and Gram-Schmidt orthogonalized in the
  vertex shader, output as TBN for fragment shader consumption
- Fragment shader gains POM ray marching, normal map blending, and LOD
  crossfade via dFdx/dFdy (identical to WMO shader)
- Descriptor set 1 extended with binding 2 for normal/height sampler
- Settings (enable, strength, POM quality) wired from game_screen.cpp
  to both WMO and character renderers via shared UI controls
2026-02-23 01:40:23 -08:00
Kelsi
3c31c43ca6 Enable parallax mapping by default 2026-02-23 01:23:24 -08:00
Kelsi
b12bc1f71e Default normal map strength to 0.8 2026-02-23 01:21:58 -08:00
Kelsi
bec3190b08 Fix POM distortions and add normal map strength slider
POM fixes: use blurred height only for ray march (keep crisp Sobel for
normals), reduce pomScale 0.03→0.012, clamp grazing angle denominator
to 0.15, hard-limit max UV offset, smooth fadeout at steep view angles.

Add Normal Map Strength slider (0.0-2.0) in Video settings for user
control over surface detail intensity. Persisted across sessions.
2026-02-23 01:18:42 -08:00
Kelsi
eaceb58e77 Add normal mapping and parallax occlusion mapping for WMO surfaces
Generate normal+height maps from diffuse textures at load time using
luminance-to-height and Sobel 3x3 filtering. Compute per-vertex tangents
via Lengyel's method for TBN basis construction.

Fragment shader uses screen-space UV derivatives (dFdx/dFdy) for smooth
LOD crossfade and angle-adaptive POM sample counts. Flat textures
naturally produce low height variance, causing POM to self-select off.

Settings: Normal Mapping on by default, POM off by default with
Low/Medium/High quality presets. Persisted across sessions.
2026-02-23 01:10:58 -08:00
Kelsi
1b16bcf71f Add glass pipeline for WMO windows with Fresnel-based transparency
Dedicated Vulkan pipeline with alpha blending AND depth writes so
windows look transparent at oblique angles without see-through artifacts.
Fresnel alpha ranges from 0.4 (grazing) to 0.95 (head-on) with sun
glint, reflections, and silver-lining specular.
2026-02-23 00:43:14 -08:00
Kelsi
fb4ff46fe3 Fix WMO water rendering: correct MLIQ parsing, tile masking, and depth effects
- Fix MLIQ vertex stride: each vertex is 8 bytes (4 flow + 4 height), not 4
- Use MLIQ tile flags to mask out tiles with no liquid (bridges, covered areas)
- Disable wave displacement on WMO water to prevent edge slosh artifacts
- Convert screen-space depth to vertical depth for shoreline foam and water
  transparency, preventing false shoreline effects on occluding geometry
- Add underwater blue fog overlay and scene fog shift (terrain water only)
- Add getNearestWaterHeightAt to avoid false underwater detection from
  elevated WMO water surfaces
- Tint refracted scene toward water color to mask occlusion edge artifacts
- Lower WMO water by 1 unit to match terrain water level
2026-02-23 00:18:32 -08:00
Kelsi
6563eebb60 Enhanced sky atmosphere with DBC-driven colors, sun lighting, and zone weather
- Skybox now uses DBC sky colors (skyTop/skyMiddle/skyBand1/skyBand2) instead
  of hardcoded C++ color curves, with 3-band gradient and Rayleigh/Mie scattering
- Clouds receive sun direction for lit edges, self-shadowing, and silver lining
- Fixed sun quad box artifact with proper edge fade in celestial shader
- Lens flare attenuated by fog, cloud density, and weather intensity
- Replaced garish green/purple lens flare ghosts with warm natural palette
- Added zone-based weather system for single-player mode with per-zone rain/snow
  configuration, probability-based activation, and smooth intensity transitions
- Server SMSG_WEATHER remains authoritative when connected to a server
2026-02-22 23:20:13 -08:00
Kelsi
085fd09b9d Fix water transparency on resize by rebuilding scene history resources
Water scene history textures and 1x pass resources were not recreated on
window resize/fullscreen, causing stale undersized textures that produced
directional transparency artifacts.
2026-02-22 22:42:58 -08:00
Kelsi
03a62526e1 Add player water ripples and separate 1x water pass for MSAA compatibility
Player interaction ripples: vertex shader adds radial damped-sine displacement
centered on player position, fragment shader adds matching normal perturbation
for specular highlights. Player XY packed into shadowParams.zw, ripple strength
into fogParams.w. Separate 1x render pass for water when MSAA is active to
avoid MSAA-induced darkening — water renders after main pass resolves, using
the resolved swapchain image and depth resolve target. Water 1x framebuffers
rebuilt on swapchain recreate (window resize).
2026-02-22 22:34:48 -08:00
Kelsi
67e63653a4 Stabilize Vulkan shadow pipeline diagnostics and compatibility path
- Fix shadow depth image layout transitions by tracking per-frame old/new layouts.
- Update receiver shadow projection to Vulkan clip-depth convention.
- Test inverted shadow compare op path (GREATER_OR_EQUAL).
- Switch shadow compare samplers to NEAREST filtering for broader Vulkan compatibility.
- Expand shadow caster coverage by disabling caster cull filtering in WMO/M2/Character shadow pipelines.
- Keep light-space matrix path on stable character-centered framing.
2026-02-22 10:25:33 -08:00
Kelsi
2c5e0dd313 Fix Vulkan shadow light direction and restore ground-clutter cutout visibility 2026-02-22 09:47:39 -08:00
Kelsi
bd0305f6dd Stabilize Vulkan rendering state for minimap, foliage, and water 2026-02-22 09:34:27 -08:00
Kelsi
8efc1548dc Fix minimap arrow orientation and ground-detail foliage transparency 2026-02-22 08:44:16 -08:00
Kelsi
0631b9f5dc Reduce update-object and inventory update overhead 2026-02-22 08:37:02 -08:00
Kelsi
37888c666d Optimize update-object field mask parsing 2026-02-22 08:30:18 -08:00
Kelsi
3a9bd0d4e5 Fix update-object spline parsing regression 2026-02-22 08:27:17 -08:00
Kelsi
17a2a1f7ef Optimize world socket buffer handling and logging 2026-02-22 08:16:54 -08:00
Kelsi
9c8cd44803 Optimize threading and texture fallback stability 2026-02-22 08:12:08 -08:00
Kelsi
f4d947fab1 Make frame timing logs opt-in 2026-02-22 07:45:49 -08:00
Kelsi
6d55c19987 Stabilize net parsing and reduce texture-cache churn 2026-02-22 07:44:32 -08:00
Kelsi
ae88b226b5 Stabilize streaming memory and parser handling; revert socket recv optimizations 2026-02-22 07:26:54 -08:00
Kelsi
c914295d20 Reduce logging overhead and reuse WMO culling futures 2026-02-22 06:42:15 -08:00
Kelsi
4ea4cb761c Optimize logging and make world packet parser callback-safe 2026-02-22 06:38:41 -08:00
Kelsi
85c8b5d5f4 Optimize logging overhead and character animation threading 2026-02-22 06:32:49 -08:00
Kelsi
9d647e5622 Fix Vulkan shadow shader descriptor set mismatch 2026-02-22 06:28:18 -08:00
Kelsi
57b049fb2a Fix character disappearance from transient Vulkan resource lifetime 2026-02-22 06:21:18 -08:00
Kelsi
7dd1dada5f Work on character rendering and frustrum culling etc 2026-02-22 05:58:45 -08:00
Kelsi
fc5294eb0f Update readme and build instructions docs 2026-02-22 05:09:16 -08:00
Kelsi
e8e859384e Fix minimap MSAA pipeline, defer swapchain recreation, fix player character spawn order
- Add .setMultisample() to minimap display pipeline and recreatePipelines() for MSAA changes
- Defer all swapchain recreation in window.cpp to beginFrame() via markSwapchainDirty()
  to prevent mid-frame render pass destruction crashes on resolution/fullscreen change
- Move spawnPlayerCharacter() call to after loadTestTerrain() where character renderer exists
2026-02-22 03:49:44 -08:00
Kelsi
ebd0084c22 Fix MSAA crash by deferring change to between frames, fix M2 GO orientation
MSAA change was called mid-frame from settings UI, destroying the render pass
and framebuffers while the command buffer was still recording. Now deferred
via pendingMsaaSamples_ flag, applied in beginFrame() before any GPU state.

Also add +180° to M2 game object orientation to fix facing direction.
2026-02-22 03:37:47 -08:00
Kelsi
325254dfcb Port UI icon textures from OpenGL to Vulkan, fix loading screen clear values
Replace all glGenTextures/glTexImage2D calls in UI code with Vulkan texture
uploads via new VkContext::uploadImGuiTexture() helper. This fixes segfaults
from calling OpenGL functions without a GL context (null GLEW function pointers).

- Add uploadImGuiTexture() to VkContext with staging buffer upload pattern
- Convert game_screen, inventory_screen, spellbook_screen, talent_screen
  from GLuint/GL calls to VkDescriptorSet/Vulkan uploads
- Fix loading_screen clearValueCount (was 1, needs 2 or 3 for MSAA)
2026-02-22 03:32:08 -08:00
Kelsi
b1a9d231c7 Fix MSAA 8x crash: clearValueCount must match attachment count
Render pass begin used 2 clear values but MSAA render pass has 3
attachments (MSAA color, depth, resolve). Vulkan requires clear
value count >= attachment count, causing a driver crash at 8x.

Also fix renderYawM2 reference removed in previous commit.
2026-02-22 03:11:21 -08:00
Kelsi
786b35ae0d Remove +90° rotation from M2 game object orientation
M2 game objects don't need the extra 90° yaw offset that was
previously applied — orientation from server is used directly.
2026-02-22 03:07:33 -08:00
Kelsi
fa1867cf2f Fix MSAA 8x crash and eliminate redundant GPU stalls
- Add error handling: revert to 1x if recreateSwapchain fails
- Clamp requested MSAA to device maximum before applying
- Retry MSAA color image allocation without TRANSIENT on failure
- Remove redundant vkDeviceWaitIdle from WMO/M2/Character recreatePipelines
  (caller already waits once, was causing ~13 stalls instead of 1)
2026-02-22 03:05:55 -08:00
Kelsi
e12141a673 Add configurable MSAA anti-aliasing, update auth screen and terrain shader
- MSAA: conditional 2-att (off) vs 3-att (on) render pass with auto-resolve
- MSAA: multisampled color+depth images, query max supported sample count
- MSAA: .setMultisample() on all 25+ main-pass pipelines across 17 renderers
- MSAA: recreatePipelines() on every sub-renderer for runtime MSAA changes
- MSAA: Renderer::setMsaaSamples() orchestrates swapchain+pipeline+ImGui rebuild
- MSAA: Anti-Aliasing combo (Off/2x/4x/8x) in Video settings, persisted
- Update auth screen assets and terrain fragment shader
2026-02-22 02:59:24 -08:00
Kelsi
6d213ad49b Fix M2 game object orientation to use +90° render yaw like characters
M2 game objects (signs, posts) were using orientation - 90° while
characters/NPCs use orientation + 90° for the canonical-to-render yaw
conversion. Both renderers build model matrices identically, so they
need the same offset. The old -90° was calibrated when terrain was
rotated 90°; with correct terrain the signs appeared sideways.
2026-02-22 02:31:16 -08:00
Kelsi
25bd05a631 Add Discord badge to README 2026-02-21 22:09:52 -08:00
Kelsi
b012906887 Add Vulkan Y-flip to projection matrix and ignore node_modules
Negate projection[1][1] to correct for Vulkan's Y-down NDC convention.
Also add node_modules/ to .gitignore to prevent accidental commits.
2026-02-21 22:05:11 -08:00
Kelsi
4fc3689dcc Fix sky and clouds orientation for Z-up world coordinates
Skybox: replace sphere-mesh approach with a fullscreen triangle that
reconstructs the world-space ray direction analytically via inverse
projection/view matrices. Eliminates clip.w=0 degeneracy at the horizon
and correctly maps altitude to dir.z in the Z-up coordinate system.

Clouds: hemisphere mesh was storing altitude in aPos.y (Y-up convention);
the Z-up view matrix projected this sideways, making clouds appear
vertical. Store altitude in aPos.z and update the fragment shader to
read dir.z as altitude and dir.xy as the horizontal UV plane.
2026-02-21 22:04:17 -08:00
Kelsi
69cf39ba02 Activate WMO/char/M2 render loop, purge dead GL block, add underwater overlay
- renderWorld() now calls wmoRenderer, characterRenderer, m2Renderer (+smoke,
  particles) in the correct opaque→transparent order; water moved after all
  opaques; per-subsystem timing active in live path
- Deleted the 310-line #if 0 GL stub block and removed #include <GL/glew.h>
  (last GL reference in renderer.cpp)
- Full-screen overlay pipeline (postprocess.vert + overlay.frag, alpha blend,
  no depth test/write) for underwater tint; lazily initialized, renders a blue
  tint when camera is meaningfully below the water surface; canal vs open-water
  tint colours preserved from original design
- overlay.frag.glsl / overlay.frag.spv added
2026-02-21 22:04:17 -08:00
Kelsi
dea52744a4 Character renderer is fully Vulkan. 2026-02-21 22:04:17 -08:00
Kelsi
83b576e8d9 Vulcan Nightmare
Experimentally bringing up vulcan support
2026-02-21 22:04:17 -08:00
Kelsi
863a786c48 Merge remote-tracking branch 'origin/master' 2026-02-21 22:01:32 -08:00
Kelsi
cfac229fed Include code of conduct 2026-02-21 21:58:07 -08:00
Kelsi Rae Davis
12597294d9 Merge pull request #2 from VPeruS/docker-build
[build] Added configuration to allow building in container
2026-02-21 07:32:56 -08:00
vperus
95f5321833 [build] Added configuration to allow building in container 2026-02-21 17:04:56 +02:00
Kelsi Rae Davis
2d010ffe1a Merge pull request #3 from rursache/fix/extract-mpq-case-check
Fix MPQ detection failing when files are lowercase .mpq
2026-02-21 05:09:52 -08:00
Radu Ursache
ca852345a1 Fix MPQ detection failing when files are lowercase .mpq
The sanity check `ls *.MPQ *.mpq` fails under `set -o pipefail`
when only one case variant exists, because ls exits non-zero for
the unmatched glob pattern and pipefail propagates that failure.

Use `compgen -G` to check each glob pattern independently instead.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-21 15:02:07 +02:00
Kelsi
21f7b0f199 Remove nearest-known displayId model fallback cache for missing creature display mappings - that was weird and I'm done with the horror show 2026-02-21 04:18:14 -08:00