2026-02-02 12:24:50 -08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
#include <glm/glm.hpp>
|
2026-02-21 19:41:21 -08:00
|
|
|
#include <vulkan/vulkan.h>
|
|
|
|
|
#include <vk_mem_alloc.h>
|
2026-02-02 12:24:50 -08:00
|
|
|
|
|
|
|
|
namespace wowee {
|
|
|
|
|
namespace rendering {
|
|
|
|
|
|
2026-02-21 19:41:21 -08:00
|
|
|
class VkContext;
|
2026-02-22 23:20:13 -08:00
|
|
|
struct SkyParams;
|
2026-02-02 12:24:50 -08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Skybox renderer
|
|
|
|
|
*
|
2026-02-21 21:57:16 -08:00
|
|
|
* Renders an atmospheric sky gradient using a fullscreen triangle.
|
|
|
|
|
* No vertex buffer: 3 vertices cover the entire screen via gl_VertexIndex.
|
|
|
|
|
* World-space ray direction is reconstructed from the inverse view+projection.
|
2026-02-22 23:20:13 -08:00
|
|
|
*
|
|
|
|
|
* Sky colors are driven by DBC data (Light.dbc / LightIntBand.dbc) via SkyParams,
|
|
|
|
|
* with Rayleigh/Mie atmospheric scattering for realistic appearance.
|
2026-02-02 12:24:50 -08:00
|
|
|
*/
|
|
|
|
|
class Skybox {
|
|
|
|
|
public:
|
|
|
|
|
Skybox();
|
|
|
|
|
~Skybox();
|
|
|
|
|
|
2026-02-21 19:41:21 -08:00
|
|
|
bool initialize(VkContext* ctx, VkDescriptorSetLayout perFrameLayout);
|
2026-02-02 12:24:50 -08:00
|
|
|
void shutdown();
|
2026-02-22 02:59:24 -08:00
|
|
|
void recreatePipelines();
|
2026-02-02 12:24:50 -08:00
|
|
|
|
|
|
|
|
/**
|
2026-02-22 23:20:13 -08:00
|
|
|
* Render the skybox using DBC-driven sky colors.
|
2026-02-21 19:41:21 -08:00
|
|
|
* @param cmd Command buffer to record into
|
|
|
|
|
* @param perFrameSet Per-frame descriptor set (set 0, contains camera UBO)
|
2026-02-22 23:20:13 -08:00
|
|
|
* @param params Sky parameters with DBC colors and sun direction
|
2026-02-02 12:24:50 -08:00
|
|
|
*/
|
2026-02-22 23:20:13 -08:00
|
|
|
void render(VkCommandBuffer cmd, VkDescriptorSet perFrameSet, const SkyParams& params);
|
2026-02-02 12:24:50 -08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Enable/disable skybox rendering
|
|
|
|
|
*/
|
|
|
|
|
void setEnabled(bool enabled) { renderingEnabled = enabled; }
|
|
|
|
|
bool isEnabled() const { return renderingEnabled; }
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set time of day (0-24 hours)
|
|
|
|
|
* 0 = midnight, 6 = dawn, 12 = noon, 18 = dusk, 24 = midnight
|
|
|
|
|
*/
|
|
|
|
|
void setTimeOfDay(float time);
|
|
|
|
|
float getTimeOfDay() const { return timeOfDay; }
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Enable/disable time progression
|
|
|
|
|
*/
|
|
|
|
|
void setTimeProgression(bool enabled) { timeProgressionEnabled = enabled; }
|
|
|
|
|
bool isTimeProgressionEnabled() const { return timeProgressionEnabled; }
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Update time progression
|
|
|
|
|
*/
|
|
|
|
|
void update(float deltaTime);
|
|
|
|
|
|
|
|
|
|
private:
|
2026-02-21 19:41:21 -08:00
|
|
|
VkContext* vkCtx = nullptr;
|
|
|
|
|
|
|
|
|
|
VkPipeline pipeline = VK_NULL_HANDLE;
|
|
|
|
|
VkPipelineLayout pipelineLayout = VK_NULL_HANDLE;
|
|
|
|
|
|
2026-02-02 12:24:50 -08:00
|
|
|
float timeOfDay = 12.0f; // Default: noon
|
|
|
|
|
float timeSpeed = 1.0f; // 1.0 = 1 hour per real second
|
|
|
|
|
bool timeProgressionEnabled = false;
|
|
|
|
|
bool renderingEnabled = true;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace rendering
|
|
|
|
|
} // namespace wowee
|