Sprite sheets, atlases, game UI, time of day, weather presets, headless captures

- BillboardInstance: per-instance uv sub-rect, feet anchor, turn, dithered alpha, flash;
  BillboardBatch::sharedTexture; Texture createEmpty/update/cellUV/cellAnchor/nearest
- SpriteAtlas: fixed-cell runtime atlas with gutters
- hd2d::ui: Octopath-style panels, fonts (Cinzel, EB Garamond), dialogue box with
  typewriter + portraits + choices, menus, nameplates, toasts, ImGui theme
- DayCycle (dawn/day/dusk/night keyframes, sun + moon arcs), Weather overcast/mist/
  lightning, night-aware presets, stars and moon in the sky
- Hidden-window offscreen captures (Window visible=false, Renderer output FBO,
  OffscreenTarget); --screenshot never opens a window
- Camera::worldToScreen; CMake usable via add_subdirectory (HD2D_BUILD_DEMO,
  HD2D_ENGINE_ASSET_DIR)
This commit is contained in:
Gabrieal Jimmy
2026-10-02 15:05:23 -05:00
parent 16c03afd16
commit 83a1f16806
44 changed files with 2835 additions and 226 deletions

View File

@@ -0,0 +1,44 @@
#pragma once
#include "hd2d/Weather.h"
#include <glm/glm.hpp>
#include <vector>
namespace hd2d {
// Time of day: turns an hour into a complete clear-weather WeatherLook by
// smoothly interpolating tweakable keyframes, and moves the directional
// light along a sun arc by day and a moon arc by night (so shadows always
// work). Feed the result to Weather::setClearLook() every frame; the hour is
// usually driven externally (e.g. by a game server).
class DayCycle {
public:
struct Keyframe {
float hour; // [0, 24)
const char* name; // for tuning UIs
WeatherLook look; // sunAzimuth / sunElevation / daylight are ignored (computed from the hour)
};
DayCycle(); // default keys: late night, dawn, morning, noon, afternoon, dusk, night
WeatherLook look(float hour) const; // any hour, wraps to [0, 24)
float daylight(float hour) const; // 0 night .. 1 day (sun height above the horizon)
float night(float hour) const; // 0 day .. 1 night (stars + moon visibility)
// Direction of the directional light: x = azimuth, y = elevation
// (radians, see Sun); the sun between sunrise and sunset, else the moon.
glm::vec2 lightAngles(float hour) const;
bool moonUp(float hour) const;
std::vector<Keyframe> keys; // sorted by hour; interpolation wraps around midnight
float sunrise = 5.0f, sunset = 19.0f;
float sunAzimuth = -0.6f; // azimuth at solar noon
float sunSweep = 2.6f; // azimuth travelled from sunrise to sunset
float sunMaxElevation = 1.05f;
float moonAzimuth = 0.45f; // azimuth at the middle of the night
float moonSweep = 1.6f;
float moonMaxElevation = 0.62f;
float horizonFade = 0.12f; // light elevation (radians) over which it fades in
float minElevation = 0.05f; // light never goes lower (keeps shadows stable)
};
} // namespace hd2d