mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-02-20 00:04:23 -05:00
Add SkySystem coordinator that follows WoW's actual architecture where skyboxes are authoritative and procedural elements serve as fallbacks. Integrate lighting system across all renderers (terrain, WMO, M2, character) with unified parameters. Sky System: - SkySystem coordinator manages skybox, celestial bodies, stars, clouds, lens flare - Skybox is authoritative (baked stars from M2 models, procedural fallback only) - skyboxHasStars flag gates procedural star rendering (prevents double-star bug) Celestial Bodies (Lore-Accurate): - Two moons: White Lady (30-day cycle, pale white) + Blue Child (27-day cycle, pale blue) - Deterministic moon phases from server gameTime (not deltaTime toys) - Sun positioning driven by LightingManager directionalDir (DBC-sourced) - Camera-locked sky dome (translation ignored, rotation applied) Lighting Integration: - Apply LightingManager params to WMO, M2, character renderers - Unified lighting: directional light, diffuse color, ambient color, fog - Star occlusion by cloud density (70% weight) and fog density (30% weight) Documentation: - Add comprehensive SKY_SYSTEM.md technical guide - Update MEMORY.md with sky system architecture and anti-patterns - Update README.md with WoW-accurate descriptions Critical design decisions: - NO latitude-based star rotation (Azeroth not modeled as spherical planet) - NO always-on procedural stars (skybox authority prevents zone identity loss) - NO universal dual-moon setup (map-specific celestial configurations)
132 lines
3.8 KiB
C++
132 lines
3.8 KiB
C++
#pragma once
|
|
|
|
#include <memory>
|
|
#include <glm/glm.hpp>
|
|
|
|
namespace wowee {
|
|
namespace rendering {
|
|
|
|
class Camera;
|
|
class Skybox;
|
|
class Celestial;
|
|
class StarField;
|
|
class Clouds;
|
|
class LensFlare;
|
|
class LightingManager;
|
|
|
|
/**
|
|
* Sky rendering parameters (extracted from LightingManager)
|
|
*/
|
|
struct SkyParams {
|
|
// Sun/moon positioning
|
|
glm::vec3 directionalDir{0.0f, -1.0f, 0.3f};
|
|
glm::vec3 sunColor{1.0f, 1.0f, 0.9f};
|
|
|
|
// Sky colors (for skybox tinting/blending)
|
|
glm::vec3 skyTopColor{0.5f, 0.7f, 1.0f};
|
|
glm::vec3 skyMiddleColor{0.7f, 0.85f, 1.0f};
|
|
glm::vec3 skyBand1Color{0.9f, 0.95f, 1.0f};
|
|
glm::vec3 skyBand2Color{1.0f, 0.98f, 0.9f};
|
|
|
|
// Atmospheric effects
|
|
float cloudDensity = 0.0f; // 0-1
|
|
float fogDensity = 0.0f; // 0-1
|
|
float horizonGlow = 0.3f; // 0-1
|
|
|
|
// Time
|
|
float timeOfDay = 12.0f; // 0-24 hours
|
|
float gameTime = -1.0f; // Server game time in seconds (-1 = use fallback)
|
|
|
|
// Skybox selection (future: from LightSkybox.dbc)
|
|
uint32_t skyboxModelId = 0;
|
|
bool skyboxHasStars = false; // Does loaded skybox include baked stars?
|
|
};
|
|
|
|
/**
|
|
* Unified sky rendering system
|
|
*
|
|
* Coordinates skybox (authoritative), celestial bodies (sun + 2 moons),
|
|
* and fallback procedural stars. Driven by lighting system data.
|
|
*
|
|
* Architecture:
|
|
* - Skybox is PRIMARY (includes baked stars from M2 models)
|
|
* - Celestial renders sun + White Lady + Blue Child
|
|
* - StarField is DEBUG/FALLBACK only (disabled when skybox has stars)
|
|
*/
|
|
class SkySystem {
|
|
public:
|
|
SkySystem();
|
|
~SkySystem();
|
|
|
|
/**
|
|
* Initialize sky system components
|
|
*/
|
|
bool initialize();
|
|
void shutdown();
|
|
|
|
/**
|
|
* Update sky system (time, moon phases, etc.)
|
|
*/
|
|
void update(float deltaTime);
|
|
|
|
/**
|
|
* Render complete sky
|
|
* @param camera Camera for view/projection
|
|
* @param params Sky parameters from lighting system
|
|
*/
|
|
void render(const Camera& camera, const SkyParams& params);
|
|
|
|
/**
|
|
* Enable/disable procedural stars (DEBUG/FALLBACK)
|
|
* Default: OFF (stars come from skybox)
|
|
*/
|
|
void setProceduralStarsEnabled(bool enabled) { proceduralStarsEnabled_ = enabled; }
|
|
bool isProceduralStarsEnabled() const { return proceduralStarsEnabled_; }
|
|
|
|
/**
|
|
* Enable/disable debug sky mode (forces procedural stars even with skybox)
|
|
*/
|
|
void setDebugSkyMode(bool enabled) { debugSkyMode_ = enabled; }
|
|
bool isDebugSkyMode() const { return debugSkyMode_; }
|
|
|
|
/**
|
|
* Get sun position in world space (for lens flare, shadows, etc.)
|
|
*/
|
|
glm::vec3 getSunPosition(const SkyParams& params) const;
|
|
|
|
/**
|
|
* Enable/disable moon phase cycling
|
|
*/
|
|
void setMoonPhaseCycling(bool enabled);
|
|
|
|
/**
|
|
* Set moon phases manually (0.0-1.0 each)
|
|
*/
|
|
void setWhiteLadyPhase(float phase);
|
|
void setBlueChildPhase(float phase);
|
|
|
|
float getWhiteLadyPhase() const;
|
|
float getBlueChildPhase() const;
|
|
|
|
// Component accessors (for direct control if needed)
|
|
Skybox* getSkybox() const { return skybox_.get(); }
|
|
Celestial* getCelestial() const { return celestial_.get(); }
|
|
StarField* getStarField() const { return starField_.get(); }
|
|
Clouds* getClouds() const { return clouds_.get(); }
|
|
LensFlare* getLensFlare() const { return lensFlare_.get(); }
|
|
|
|
private:
|
|
std::unique_ptr<Skybox> skybox_; // Authoritative sky (gradient now, M2 models later)
|
|
std::unique_ptr<Celestial> celestial_; // Sun + 2 moons
|
|
std::unique_ptr<StarField> starField_; // Fallback procedural stars
|
|
std::unique_ptr<Clouds> clouds_; // Cloud layer
|
|
std::unique_ptr<LensFlare> lensFlare_; // Sun lens flare
|
|
|
|
bool proceduralStarsEnabled_ = false; // Default: OFF (skybox is authoritative)
|
|
bool debugSkyMode_ = false; // Force procedural stars for debugging
|
|
bool initialized_ = false;
|
|
};
|
|
|
|
} // namespace rendering
|
|
} // namespace wowee
|