mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-07-31 01:41:14 -04:00
Re-apply the multiplicative brightness overlay (scene*br, no white washout) and stop it compounding through water refraction. Water refraction samples a scene-history image captured from the final swapchain, which has the display brightness baked in; re-applying brightness on the water each frame fed back through that temporal capture and blew out (a multiply diverges where the old white-lerp converged). Pass the brightness factor to the water shader and divide it back out of the refraction sample, so refraction sees the un-brightened scene and the display still gets a true multiply. This also fixes the latent darkening feedback (water creeping to black). No pass restructuring; localized to the overlay + water shader.
89 lines
3.2 KiB
C++
89 lines
3.2 KiB
C++
#pragma once
|
|
|
|
#include <glm/vec3.hpp>
|
|
#include <glm/vec4.hpp>
|
|
#include <glm/mat4x4.hpp>
|
|
#include <vulkan/vulkan.h>
|
|
#include <vk_mem_alloc.h>
|
|
#include <functional>
|
|
#include <optional>
|
|
|
|
namespace wowee {
|
|
namespace rendering {
|
|
|
|
class VkContext;
|
|
|
|
/// Manages selection circle and fullscreen overlay Vulkan pipelines.
|
|
/// Extracted from Renderer to isolate overlay rendering resources.
|
|
class OverlaySystem {
|
|
public:
|
|
/// Height query callable: returns floor height at (x, y) or (x, y, probeZ).
|
|
using HeightQuery2D = std::function<std::optional<float>(float x, float y)>;
|
|
using HeightQuery3D = std::function<std::optional<float>(float x, float y, float probeZ)>;
|
|
|
|
explicit OverlaySystem(VkContext* ctx);
|
|
~OverlaySystem();
|
|
|
|
OverlaySystem(const OverlaySystem&) = delete;
|
|
OverlaySystem& operator=(const OverlaySystem&) = delete;
|
|
|
|
// Selection circle
|
|
void setSelectionCircle(const glm::vec3& pos, float radius, const glm::vec3& color);
|
|
void clearSelectionCircle();
|
|
void renderSelectionCircle(const glm::mat4& view, const glm::mat4& projection,
|
|
VkCommandBuffer cmd,
|
|
HeightQuery2D terrainHeight,
|
|
HeightQuery3D wmoHeight,
|
|
HeightQuery3D m2Height);
|
|
|
|
// Fullscreen color overlay (underwater tint, etc.)
|
|
void renderOverlay(const glm::vec4& color, VkCommandBuffer cmd);
|
|
|
|
// Fullscreen multiplicative brightness scale (scene.rgb *= scale). Uses a
|
|
// dst-color blend so brightness > 1 truly scales luminance instead of
|
|
// lerping toward white (which washed everything out). scale > 1 only.
|
|
void renderBrightnessScale(float scale, VkCommandBuffer cmd);
|
|
|
|
/// Destroy all Vulkan resources (called before VkContext teardown).
|
|
void cleanup();
|
|
|
|
/// Recreate pipelines after swapchain resize / MSAA change.
|
|
void recreatePipelines();
|
|
|
|
private:
|
|
void initSelectionCircle();
|
|
void initOverlayPipeline();
|
|
void initBrightnessPipeline();
|
|
|
|
VkContext* vkCtx_ = nullptr;
|
|
|
|
// Selection circle resources
|
|
VkPipeline selCirclePipeline_ = VK_NULL_HANDLE;
|
|
VkPipelineLayout selCirclePipelineLayout_ = VK_NULL_HANDLE;
|
|
::VkBuffer selCircleVertBuf_ = VK_NULL_HANDLE;
|
|
VmaAllocation selCircleVertAlloc_ = VK_NULL_HANDLE;
|
|
::VkBuffer selCircleIdxBuf_ = VK_NULL_HANDLE;
|
|
VmaAllocation selCircleIdxAlloc_ = VK_NULL_HANDLE;
|
|
int selCircleVertCount_ = 0;
|
|
glm::vec3 selCirclePos_{0.0f};
|
|
glm::vec3 selCircleColor_{1.0f, 0.0f, 0.0f};
|
|
float selCircleRadius_ = 1.5f;
|
|
bool selCircleVisible_ = false;
|
|
|
|
// Floor-snap cache: the terrain/WMO/M2 floor queries are collision
|
|
// raycasts, so reuse the result while the target stands still. Refreshed
|
|
// periodically in case world geometry streams in around the target.
|
|
glm::vec3 selCircleFloorCachePos_{0.0f};
|
|
float selCircleFloorCacheZ_ = 0.0f;
|
|
int selCircleFloorCacheAge_ = -1; // -1 = invalid; counts frames since query
|
|
|
|
// Fullscreen overlay resources
|
|
VkPipeline overlayPipeline_ = VK_NULL_HANDLE;
|
|
VkPipelineLayout overlayPipelineLayout_ = VK_NULL_HANDLE;
|
|
// Multiplicative brightness pipeline (shares overlayPipelineLayout_).
|
|
VkPipeline brightnessPipeline_ = VK_NULL_HANDLE;
|
|
};
|
|
|
|
} // namespace rendering
|
|
} // namespace wowee
|