forks/DiligentFX / gltf-multiview GLTF_PBR_Renderer

Tree @gltf-multiview (Download .tar.gz)

Physially-Based GLTF Renderer

A physially-based GLTF2.0 renderer with image-based lighting.

The renderer uses the reference GLTF2.0 lighting model.

Khronos GLTF viewer Diligent Engine

The implementation is based on GLTF sample viewer from Khronos Group and Vulkan-glTF-PBR project by Sascha Willems.

Using the renderer

To initialize the renderer, populate GLTF_PBR_Renderer::CreateInfo structure and create an instance of GLTF_PBR_Renderer class:

auto BackBufferFmt  = m_pSwapChain->GetDesc().ColorBufferFormat;
auto DepthBufferFmt = m_pSwapChain->GetDesc().DepthBufferFormat;
GLTF_PBR_Renderer::CreateInfo RendererCI;
RendererCI.RTVFmt         = BackBufferFmt;
RendererCI.DSVFmt         = DepthBufferFmt;
RendererCI.AllowDebugView = true;
RendererCI.UseIBL         = true;
RendererCI.FrontCCW       = true;
m_GLTFRenderer.reset(new GLTF_PBR_Renderer(m_pDevice, m_pImmediateContext, RendererCI));

Note that the front face is set to counter-clockwise because in GLTF, y axis points down and we need to invert it, which will reverse the winding order.

The renderer generates all required look-up tables at run-time. For image-based lighting, it pre-computes irradiance cube map for diffuse component and pre-filtered environment map for specular component:

RefCntAutoPtr<ITexture> EnvironmentMap;
CreateTextureFromFile("textures/papermill.ktx", TextureLoadInfo{"Environment map"}, m_pDevice, &EnvironmentMap);
m_EnvironmentMapSRV = EnvironmentMap->GetDefaultView(TEXTURE_VIEW_SHADER_RESOURCE);
m_GLTFRenderer->PrecomputeCubemaps(m_pDevice, m_pImmediateContext, m_EnvironmentMapSRV);

The renderer itself does not implement any loading functionality. Use Asset Loader to load GLTF models. When model is loaded, it is important to call InitializeResourceBindings() method to let the renderer initialize internal shader resource binding objects:

m_Model.reset(new GLTF::Model(m_pDevice, m_pImmediateContext, Path));
m_GLTFRenderer->InitializeResourceBindings(*m_Model, m_CameraAttribsCB, m_LightAttribsCB);

To render the model, prepare GLTF_PBR_Renderer::RenderInfo structure and call Render() method:

m_GLTFRenderer->Render(m_pImmediateContext, *m_Model, m_RenderParams);

For more details, see GLTFViewer.cpp.


GLTF Sampler Viewer


GLTF2.0 Format Specification

History of GLTF_PBR_Renderer @gltf-multiview git clone