KhronosGroup / glTF-IBL-Sampler

Sampler to create the glTF sample environments
Apache License 2.0
131 stars 18 forks source link

glTF IBL Sampler

Introduction

This project pre-filters an environment High Dynamic Range (HDR) panorama image and stores diffuse and specular parts in cube maps respectively. Considering different material characteristics, the specular part consists of several mip-map levels corresponding to different roughness values of the modeled material. The final basis compression into a KTX2 file ensures small file sizes while maintaining reasonable image quality.

Algorithm references:

Workflow

The individual transformations can be executed separately in the library, enabling the use of a cube map as input in future releases.

This separation of shader passes ensures both, flexibility and extensibility. The pre-filtering will use the algorithms noted in the glTF Sample Environments repository.

Workflow

Building

The project provides a cmake file to generate respective build files.

Third Party Requirements:

CMake option IBLSAMPLER_EXPORT_SHADERS can be used to automatically copy the shader folder to the executable folder when generating the project files. By default, shaders will be loaded from their source location in lib/shaders.

The glTF-IBL-Sampler consists of two projects: lib (shared library) and cli (executable).

Usage

The CLI takes an environment HDR image as input. The filtered specular and diffuse cube maps can be stored as KTX1 or KTX2 (with basis compression).

Example

.\cli.exe -inputPath ..\cubemap_in.hdr -outCubeMap ..\..\specular_out.ktx2 -distribution GGX -sampleCount 1024 -targetFormat R16G16B16A16_SFLOAT
.\cli.exe -inputPath ..\cubemap_in.hdr -outCubeMap ..\diffuse_out.ktx2 -distribution Lambertian -sampleCount 1024 -targetFormat R16G16B16A16_SFLOAT