Commit Graph
15 Commits
Author SHA1 Message Date
emil28092005 194848d074 fix: physics pause/resume crash — IsAlive checks + safe deletion 2026-06-19 09:44:56 +03:00
emil28092005 74dcc45543 feat: adjustable ambient lighting via ImGui sliders
- SceneUBO expanded: added vec4 ambientColor at offset 400
- UBO size: 448 → 464 bytes
- Fragment shader: ambient from UBO instead of hardcoded constant
- VulkanRenderer: AmbientColor property (default 0.01, 0.01, 0.02)
- ImGui: R/G/B sliders for ambient (0.0-0.5 range)
- Packed at offset 400 after 4 shadowParams (64 bytes at 336)
2026-06-19 09:34:09 +03:00
emil28092005 e3b2cab9f0 feat: fixed 60 FPS render loop + 30 FPS video output
- Main loop: frame limiter at 60 FPS via Thread.Sleep when frame completes
  faster than target (16.67ms). Prevents unnecessary GPU/CPU usage.
- FFmpeg: fixed framerate 60 input, -vf fps=30 downsamples to 30 FPS output
- Removed unused skipFrames variable
- Stable timing for physics + video recording
2026-06-19 09:25:10 +03:00
emil28092005 e813e5e90b fix: force B8G8R8A8_UNORM swapchain — fixes acid video colors
Root cause: driver returned format=58 (A2B10G10R10_PACK32) as fallback
when B8G8R8A8_SRGB wasn't found. 10-bit packed format has different
byte layout → vkCmdCopyImageToBuffer gives garbage when interpreted as
8-bit BGRA → acid colors in video.

Fix:
- QuerySurfaceFormat: try B8G8R8A8_UNORM first (NVIDIA supports it)
- Fallback: B8G8R8A8_SRGB, then first available
- Removed SRGB LUT conversion — UNORM data is already linear
- Raw BGRA bytes go directly to FFmpeg (pixel_format=bgra)
2026-06-19 09:21:26 +03:00
emil28092005 9531b1e9d5 fix: imageCubeArray via core features + SRGB swapchain + LUT color conversion
Three fixes:

1. imageCubeArray: enabled via VkPhysicalDeviceFeatures (core 1.0 feature)
   instead of VkPhysicalDeviceImageCubeArrayFeatures (wrong sType in pNext
   chain was interpreted as VkExternalMemoryImageCreateInfoNV)

2. Swapchain format: reverted to B8G8R8A8_SRGB (was UNORM which driver
   didn't support → fell back to A2B10G10R10 10-bit format=58 → wrong
   pixel layout for capture)

3. Video colors: SRGB→linear conversion via 256-entry LUT in
   ReadCapturedBuffer. SRGB swapchain gives gamma-compressed bytes,
   FFmpeg expects linear. LUT converts each B/G/R channel using
   standard SRGB formula: s<=0.04045 ? s/12.92 : ((s+0.055)/1.055)^2.4

Also: video captures before ImGui (no UI in recording)
2026-06-19 09:17:35 +03:00
emil28092005 d6939e9efa fix: video without UI + correct colors
1. No UI in video: end render pass before ImGui, capture, start new
   render pass with loadOp=LOAD for ImGui, end again. Video captures
   only the 3D scene.

2. Acid colors fixed: swapchain format changed from B8G8R8A8_SRGB to
   B8G8R8A8_UNORM. SRGB format stores gamma-compressed values that
   vkCmdCopyImageToBuffer reads raw — FFmpeg treated them as linear
   causing acid colors. UNORM stores linear values, copy gives linear
   data, FFmpeg bgra→yuv420p conversion is correct.
2026-06-19 09:13:04 +03:00
emil28092005 2daf10b3b1 debug: check if captured frame has non-zero data 2026-06-19 09:09:29 +03:00
emil28092005 277c8aea93 fix: video colors — use BGRA pixel format for FFmpeg, remove swap
Swapchain format is B8G8R8A8_SRGB — vkCmdCopyImageToBuffer gives BGRA
data. Was converting BGRA→RGBA in C# and telling FFmpeg 'rgba' —
but SRGB data needs to stay as-is. Now:
- No BGRA→RGBA swap in ReadCapturedBuffer
- FFmpeg pixel_format=bgra (matches swapchain)
- FFmpeg handles SRGB→yuv420p conversion correctly
2026-06-19 09:07:19 +03:00
emil28092005 b41e64db4a fix: CaptureFrame no longer overwrites CapturedFrame with null
Root cause: CaptureFrame returned null and was assigned to CapturedFrame,
overwriting the data that ReadCapturedBuffer had just set at the start
of the same frame.

Fix: CaptureFrame is now void — only records GPU copy commands.
ReadCapturedBuffer runs at start of next frame (after WaitFrame/fence)
and sets CapturedFrame with actual pixel data.
Program.cs reads CapturedFrame after RenderWorld — now contains data
from the previous frame's GPU copy.
2026-06-19 09:04:03 +03:00
emil28092005 00b6f39201 fix: video recording captures every frame + dynamic FPS for FFmpeg
- Removed skipFrames logic — capture every frame for reliability
- FFmpeg framerate set to actual FPS (capped at 60) instead of hardcoded 30
- Added -vf fps=30 filter to downsample to 30fps in output
- First frame: CapturedFrame is null (no previous capture), skipped naturally
- Second frame onwards: data available from previous frame's GPU copy
2026-06-19 09:01:55 +03:00
emil28092005 ab1a2d05c3 fix: enable imageCubeArray feature + transition all 24 shadow layers
Two validation errors fixed:
1. imageCubeArray feature not enabled → added VkPhysicalDeviceImageCubeArrayFeatures
   to device creation chain (pNext: cubeArray → sync2 → dynamicRendering)
2. Shadow layers 18-23 in UNDEFINED layout → transition ALL 24 layers
   (MaxShadowLights * 6) instead of only numShadowLights * 6
   Descriptor references all 24 layers via CubeArray view
2026-06-19 08:59:22 +03:00
emil28092005 d7b6851217 fix: replace all 0x2000 with 0x1000 in capture barriers
0x2000 = VK_ACCESS_2_HOST_READ_BIT (wrong for GPU transfer)
0x1000 = VK_ACCESS_2_TRANSFER_WRITE_BIT (correct for copy operations)
2026-06-19 08:56:25 +03:00
emil28092005 f8384a8672 fix: ImGui font upload barriers — use correct sync2 access flags
0x2000 was VK_ACCESS_MEMORY_READ_BIT in Vulkan 1.0 but maps to
VK_ACCESS_2_HOST_READ_BIT in sync2. Replaced with 0x1000
(VK_ACCESS_2_TRANSFER_WRITE_BIT) for dst access on transfer layout.
2026-06-19 08:54:54 +03:00
emil28092005 9b80ab7881 fix: video recording — proper layout transitions + deferred buffer read
Three validation errors fixed:
1. vkCmdCopyImageToBuffer inside render pass → moved AFTER vkCmdEndRendering
2. Swapchain images missing TRANSFER_SRC usage → added to swapchain creation
3. Wrong layout transitions → ColorAttachment→TransferSrc→copy→ColorAttachment

Architecture change:
- CaptureFrame now only records commands (returns null)
- ReadCapturedBuffer called at start of NEXT frame (after WaitFrame/fence)
  GPU has finished by then, safe to map memory
- CapturedFrame available 1 frame late (acceptable for video)
- Image transitions: ColorAttachmentOptimal→TransferSrcOptimal→ColorAttachmentOptimal
  (present transition still works because image is back in ColorAttachmentOptimal)
2026-06-19 08:52:41 +03:00
emil28092005 346b422cb0 fix: all lights default to intensity=8 range=15.5 + clipboard logging
- All 3 lights: intensity 8.0, range 15.5 (was 12/8/8, 60/40/40)
- Copy Parameters: also logs to console for debugging
- Clipboard text via ImGui.SetClipboardText (standard API)
2026-06-19 08:44:07 +03:00