Toast Engine
Loading...
Searching...
No Matches
hdr_image.cpp File Reference
#include "hdr_image.hpp"
#include <stb_image.h>
#include <toast/log.hpp>
#include <tracy/Tracy.hpp>
Include dependency graph for hdr_image.cpp:

Functions

auto assets::decodeHdr (std::span< const uint8_t > bytes) -> HdrImage
 Decodes a Radiance .hdr image held in memory.

Detailed Description

Author
dario
Date
07/08/2026
Note
Carries STB_IMAGE_IMPLEMENTATION, so it is excluded from the unity build and the PCH in engine/CMakeLists.txt - same treatment as vma.cpp. An implementation macro landing in a shared translation unit defines the whole library into whatever else happened to be batched with it

Function Documentation

◆ decodeHdr()

auto assets::decodeHdr ( std::span< const uint8_t > bytes) -> HdrImage
nodiscard

Decodes a Radiance .hdr image held in memory.

Radiance is the format essentially every free environment library ships, and it decodes to linear radiance directly - no transfer function to undo and no exposure baked in, which is exactly what an environment map has to be. It is read here rather than converted to KTX2 at import: toktx only ingests PNG, so a KTX2 route would need the library driven directly, and a format this simple does not earn that

Parameters
bytesWhole file contents
Returns
a decoded image, or one where valid() is false if bytes is not a readable HDR