Fry3DX/engine/asset/ksky.h
Nexoniarz f3e8eca87b Fry3DX 0.4: an easy 3D modeller
Shapes with live settings, shape editing, knife and hole tools, drawing
shapes onto other objects, combining objects (add / subtract / overlap),
copies, thickness, painting with stickers and layers, a Layout tab, a
Print tab with checks, packed .fry files with autosave, export to GLB,
glTF, FBX, OBJ, 3MF, STL and PLY, folders in Layers, its own crash
screen, and a website for GitHub Pages in docs/.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NMSrd5oe1GpUD7E6d825KP
2026-10-19 21:18:35 +02:00

25 lines
1.1 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#pragma once
// .ksky: a sky for the renderer, compiled by assetc from an equirectangular .hdr.
// KskyHeader
// `levels` images of width >> k × height >> k RGBM8 pixels (rows top-down), largest first
// Directions are world space (+Z up): u = atan2(d.y, d.x) / 2π + 0.5, v = acos(d.z) / π.
// A pixel's linear radiance is rgb · a · kSkyRange. The sky is normalised so its upper half
// averages 1 (the engine scales it by the map's sky intensity), and the sun is taken out of
// it (the engine draws its own, matching the shadows). Level k is the sky as a surface of
// roughness k / (levels - 1) reflects it (GGX prefiltered), for image-based reflections.
#include <cstdint>
namespace keel {
inline constexpr uint32_t kKskyVersion = 1;
inline constexpr float kSkyRange = 16.0f;
struct KskyHeader {
char magic[4]; // "KSKY"
uint32_t version;
uint32_t width, height, levels;
float sunDir[3]; // towards where the sun was in the photo
float sh[27]; // 9 RGB spherical harmonics of the light it casts: Σ shᵢ·Yᵢ(n) = irradiance / π
};
} // namespace keel