ands/lightmapper logo

ands/lightmapper

Free

A C/C++ single-file library for drop-in lightmap baking. Just use your existing OpenGL renderer to bounce light!

FreeFree tier
Type
Open Source

About ands/lightmapper

Lightmapper is a C/C++ single-file header library for baking lightmaps using an existing OpenGL renderer. It enables drop-in integration for precomputing ambient occlusion and global illumination for static scene geometry. The library supports multiple bounces of indirect light, any light shapes and emissive surfaces, and hierarchical selective interpolation to accelerate baking. It includes APIs for setting geometry, rendering hemicubes, and postprocessing lightmap images (dilate, power, save TGA). The provided example application demonstrates ambient occlusion baking and works on Windows/Linux/macOS.

Key Features

Single-file header library (lightmapper.h) with easy #define implementation
Uses existing OpenGL renderer for lightmap baking
Supports multiple bounces for global illumination
Hierarchical selective interpolation for faster baking
Hemicube rendering with adjustable resolution/quality
Supports any light shapes and emissive surfaces
Built-in lightmap image postprocessing: dilate, power, gamma correction, TGA export
Example application included with CMake build

Pros & Cons

Pros
  • Drop-in integration: just include one header and define implementation
  • Leverages existing OpenGL drawing code, minimizing setup
  • Supports multiple bounces for realistic indirect lighting
  • Scalable quality via hemicube resolution and interpolation settings
  • Cross-platform (Windows/Linux/macOS) with example application
  • Free and open-source (MIT license implied by GitHub repo)
Cons
  • Requires a working OpenGL renderer; no standalone compute mode
  • Only for static geometry; dynamic objects not supported
  • Needs pre-existing lightmap UVs and an atlas tool (e.g., xatlas)
  • Baking is CPU-based via hemicube rendering; can be slow for high resolutions
  • Limited to the features in a single-header library; no advanced denoising or caching
  • Documentation is minimal beyond the README and example code

Best For

Baking ambient occlusion for static 3D scenesPrecomputing global illumination for game environmentsLightmap generation for real-time rendering enginesOffline lighting calculations for architectural visualizationRapid prototyping of light baking in OpenGL projects

FAQ

How do I integrate Lightmapper into my project?
Add '#define LIGHTMAPPER_IMPLEMENTATION' before including 'lightmapper.h' in one source file. Then use the provided API (lmCreate, lmBegin, lmEnd, etc.) as shown in the example.
Does Lightmapper support dynamic lighting or moving objects?
No, Lightmapper is designed for static scene geometry only. It precomputes lightmaps that remain fixed until recomputed.
What are the dependencies?
The library itself requires only a C/C++ compiler and OpenGL. The example application additionally uses GLFW and GLEW (via git submodules).
Can I use custom light shapes?
Yes, any light shape can be used as long as you draw it with its corresponding emissive color during the baking passes.
How do I prepare my geometry for lightmapping?
You need to generate lightmap UV coordinates using external tools like 'thekla_atlas', 'xatlas', or 'uvatlas'. Then pass the mesh data with lightmap UVs to lmSetGeometry.