MCPcopy Create free account
hub / github.com/KhronosGroup/glTF-IBL-Sampler

github.com/KhronosGroup/glTF-IBL-Sampler @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
120 symbols 232 edges 16 files 1 documented · 1% updated 2y ago★ 16810 open issues

Browse by type

Functions 103 Types & classes 17
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

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.

  • Environment HDR image → Cube Map
  • Cube Map → Filtered Cube Map
  • Filtered Cube Map → KTX2 Output File

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).

  • -inputPath: path to panorama image (default) or cube map (if inputIsCubeMap flag ist set)
  • -outCubeMap: output path for filtered cube map (default=outputCubeMap.ktx2)
  • -outLUT: output path for BRDF LUT (default=outputLUT.png)
  • -distribution: NDF to sample (Lambertian, GGX, Charlie)
  • -sampleCount: number of samples used for filtering (default = 1024)
  • -mipLevelCount: number of mip levels of specular cube map. If omitted, an optimal mipmap level is chosen, based on the input panorama's resolution.
  • -cubeMapResolution: resolution of output cube map. If omitted, an optimal resolution is chosen based on the input panorama's resolution.
  • -targetFormat: specify output texture format (R8G8B8A8_UNORM, R16G16B16A16_SFLOAT, R32G32B32A32_SFLOAT)
  • -lodBias: level of detail bias applied to filtering (default = 0)

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

Core symbols most depended-on inside this repo

Shape

Method 94
Class 13
Function 9
Enum 4

Languages

C++100%

Modules by API surface

lib/source/vkHelper.cpp58 symbols
lib/source/vkHelper.h14 symbols
lib/source/ktxImage.cpp10 symbols
lib/source/lib.cpp9 symbols
lib/source/STBImage.h7 symbols
lib/source/STBImage.cpp6 symbols
lib/source/ShaderCompiler.cpp3 symbols
lib/source/ktxImage.h2 symbols
lib/source/format.cpp2 symbols
lib/source/ShaderCompiler.h2 symbols
lib/source/FileHelper.cpp2 symbols
lib/include/GltfIblSampler.h2 symbols

For agents

$ claude mcp add glTF-IBL-Sampler \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page