mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-23 07:40:14 +00:00
- 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
104 lines
2.9 KiB
C++
104 lines
2.9 KiB
C++
#pragma once
|
|
|
|
#include <vulkan/vulkan.h>
|
|
#include <vk_mem_alloc.h>
|
|
#include <glm/glm.hpp>
|
|
#include <vector>
|
|
|
|
namespace wowee {
|
|
namespace rendering {
|
|
|
|
class Camera;
|
|
class VkContext;
|
|
|
|
/**
|
|
* @brief Renders lens flare effect when looking at the sun
|
|
*
|
|
* Features:
|
|
* - Multiple flare elements (ghosts) along sun-to-center axis
|
|
* - Sun glow at sun position
|
|
* - Colored flare elements (chromatic aberration simulation)
|
|
* - Intensity based on sun visibility and angle
|
|
* - Additive blending for realistic light artifacts
|
|
*/
|
|
class LensFlare {
|
|
public:
|
|
LensFlare();
|
|
~LensFlare();
|
|
|
|
/**
|
|
* @brief Initialize lens flare system
|
|
* @param ctx Vulkan context
|
|
* @param perFrameLayout Per-frame descriptor set layout (unused, kept for API consistency)
|
|
* @return true if initialization succeeded
|
|
*/
|
|
bool initialize(VkContext* ctx, VkDescriptorSetLayout perFrameLayout);
|
|
|
|
/**
|
|
* @brief Destroy Vulkan resources
|
|
*/
|
|
void shutdown();
|
|
|
|
void recreatePipelines();
|
|
|
|
/**
|
|
* @brief Render lens flare effect
|
|
* @param cmd Command buffer to record into
|
|
* @param camera The camera to render from
|
|
* @param sunPosition World-space sun position
|
|
* @param timeOfDay Current time (0-24 hours)
|
|
*/
|
|
void render(VkCommandBuffer cmd, const Camera& camera, const glm::vec3& sunPosition, float timeOfDay);
|
|
|
|
/**
|
|
* @brief Enable or disable lens flare rendering
|
|
*/
|
|
void setEnabled(bool enabled) { this->enabled = enabled; }
|
|
bool isEnabled() const { return enabled; }
|
|
|
|
/**
|
|
* @brief Set flare intensity multiplier
|
|
*/
|
|
void setIntensity(float intensity);
|
|
float getIntensity() const { return intensityMultiplier; }
|
|
|
|
private:
|
|
struct FlareElement {
|
|
float position; // Position along sun-center axis (-1 to 1, 0 = center)
|
|
float size; // Size in screen space
|
|
glm::vec3 color; // RGB color
|
|
float brightness; // Brightness multiplier
|
|
};
|
|
|
|
struct FlarePushConstants {
|
|
glm::vec2 position; // Screen-space position (-1 to 1)
|
|
float size; // Size in screen space
|
|
float aspectRatio; // Viewport aspect ratio
|
|
glm::vec4 colorBrightness; // RGB color + brightness in w
|
|
};
|
|
|
|
void generateFlareElements();
|
|
float calculateSunVisibility(const Camera& camera, const glm::vec3& sunPosition) const;
|
|
glm::vec2 worldToScreen(const Camera& camera, const glm::vec3& worldPos) const;
|
|
|
|
VkContext* vkCtx = nullptr;
|
|
|
|
VkPipeline pipeline = VK_NULL_HANDLE;
|
|
VkPipelineLayout pipelineLayout = VK_NULL_HANDLE;
|
|
|
|
VkBuffer vertexBuffer = VK_NULL_HANDLE;
|
|
VmaAllocation vertexAlloc = VK_NULL_HANDLE;
|
|
|
|
// Flare elements
|
|
std::vector<FlareElement> flareElements;
|
|
|
|
// Parameters
|
|
bool enabled = true;
|
|
float intensityMultiplier = 1.0f;
|
|
|
|
// Quad vertices for rendering flare sprites
|
|
static constexpr int VERTICES_PER_QUAD = 6;
|
|
};
|
|
|
|
} // namespace rendering
|
|
} // namespace wowee
|