XeGTAO Documentation

repository·master·Indexed 21 days ago

https://github.com/gametechdev/xegtao

An open-source, MIT-licensed DirectX/HLSL implementation of Ground Truth Ambient Occlusion (GTAO). It provides a radiometrically-correct screen-space ambient occlusion effect for modern PC GPUs, featuring integrated spatial denoising, support for bent normals, and a three-pass compute pipeline (PrefilterDepths, MainPass, and Denoise). Requires DirectX 12 (Shader Model 6_3) and Windows 10+.

Tokens
15.8K
Snippets
48
Records
95
Agent score
75%

What's inside XeGTAO

  1. Overview of DirectXTex library capabilities

    master

    DirectXTex is a shared source library for texture content processing. It is primarily used for reading and writing DDS files and performing operations such as:

    • Resizing and mip-map generation
    • Format conversion
    • Block compression (BC) for Direct3D runtime texture resources
    • Height-map to normal-map conversion

    The library utilizes the Windows Image Component (WIC) APIs and includes built-in readers/writers for .TGA and .HDR formats. It also supports WIC-based bitmap formats including BMP, JPEG, PNG, TIFF, and HD Photo.

  2. Overview of Open Asset Import Library (assimp)

    master
    Assimp is a library designed to import and export various 3D model formats. It loads different file formats into a single, shared in-memory format, making it easier to handle diverse 3D assets in a single application. Beyond simple importing, it provides mesh post-processing tools to generate missing render data such as normals, tangent spaces, and triangulation.
  3. XeGTAO performance and features

    master

    XeGTAO is a DirectX/HLSL implementation of the GTAO algorithm, providing a radiometrically-correct ambient occlusion term.

    Key Features

    • Directional GTAO: Supports computing a directional component (bent normals / cones). Adding this component increases the cost by approximately 25%.
    • Denoising: Includes an integrated spatial denoising filter.
    • Temporal Accumulation: Designed to leverage TAA (Temporal Anti-Aliasing) for higher detail and better radiometric correctness.

    Performance Benchmarks (Approximate)

    • High Quality (Full Resolution):
      • 3840x2160 on RTX 3070: ~1.4ms
      • 1920x1080 on RTX 2060: ~0.56ms
      • 1920x1080 on 11th Gen Intel Core i7-1195G7 (Integrated): ~2.39ms
    • Low Quality: A faster, lower-quality preset is also available.

    Requirements

    • API: DirectX 12 (Shader Model 6_3).
    • Platform: Windows 10+.
  4. Use RAII-style wrappers via imgui_scoped

    master

    The imgui_scoped header provides experimental RAII-style (Resource Acquisition Is Initialization) wrappers for common Dear ImGui functions. These wrappers are intended to manage the lifecycle of ImGui state (like pushing/popping styles or IDs) automatically using C++ scope rules.

    Note: This is an experimental feature and is not currently in the main Dear ImGui repository. It is based on pull request #2197 and discussed in issue #2096 of the official repository.

  5. Configure Near-field Bounding and Falloff

    master

    XeGTAO attenuates the effect from distant samples based on two primary settings:

    • Effect radius: The near-field occlusion radius.
    • Falloff range: The range over which the effect is attenuated.

    Unlike the original GTAO paper, XeGTAO interpolates the sample horizon angle towards the hemisphere horizon (computed as $\text{cos}(\text{normal_angle} \pm \pi/2)$) rather than towards -1. This makes the attenuation function independent of the projected normal vector, preventing haloing or detail loss under certain view angles.

  6. The meshoptimizer optimization pipeline

    master

    When optimizing a mesh, the order of operations is critical for achieving the best results. You should feed your mesh through the following pipeline in this specific order:

    1. Indexing (Remove redundant vertices and generate an index buffer)
    2. Vertex cache optimization (Reorder triangles for GPU cache efficiency)
    3. Overdraw optimization (Reorder triangles to minimize pixel shader overdraw)
    4. Vertex fetch optimization (Reorder vertex buffer for memory locality)
    5. Vertex quantization (Reduce attribute precision to save bandwidth)
    6. Vertex/index buffer compression (Optional final step)
  7. Configure XeGTAO Denoising and TAA integration

    master

    XeGTAO uses a 5x5 depth-aware spatial denoising filter. It does not implement its own temporal reprojection; instead, it relies on the host engine's Temporal Anti-Aliasing (TAA) for the temporal component.

    To leverage temporal stability, you should enable temporal noise in your pipeline. This allows TAA to smooth the AO, but you must ensure temporal variance remains low enough so TAA does not mischaracterize the noise as scene features. If TAA is unavailable, the effect relies solely on the 5x5 spatial denoiser.

  8. Merge icon fonts into a main font

    master

    To use icons in ImGui, merge an icon font into your existing font stack using ImFontConfig::MergeMode = true. This allows you to refer to icons directly in your strings.

    Note: The character ranges array must remain in scope for the duration of font usage because AddFont* functions use it lazily and do not copy it.

    // Load a first font
    io.Fonts->AddFontDefault();
    
    // Define ranges (must stay in scope)
    static const ImWchar icons_ranges[] = { 0xf000, 0xf3ff, 0 };
    
    ImFontConfig config;
    config.MergeMode = true;
    
    // Merge DroidSans
    io.Fonts->AddFontFromFileTTF("DroidSans.ttf", 18.0f, &config, io.Fonts->GetGlyphRangesJapanese());
    
    // Merge FontAwesome icons
    io.Fonts->AddFontFromFileTTF("fontawesome-webfont.ttf", 18.0f, &config, icons_ranges);
  9. Handle UTF-8 encoding and codepoint remapping

    master

    All strings in ImGui must use UTF-8 encoding.

    • C++11: Use the u8"string" syntax for UTF-8 literals.
    • Legacy C++: Convert strings to UTF-8 manually or load text from files already saved in UTF-8.
    • Remapping: You can use font->AddRemapChar() to map local codepage characters to Unicode codepoints, though this can cause issues for international users editing source code.