- 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)
45 lines
1.9 KiB
C++
45 lines
1.9 KiB
C++
#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
|