Skip to content

Commit d4aa499

Browse files
GLTF Viewer: use sRGB textures
1 parent 1010fbc commit d4aa499

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

Samples/GLTFViewer/src/GLTFViewer.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -338,12 +338,8 @@ void GLTFViewer::CreateGLTFResourceCache()
338338
m_pResourceMgr = GLTF::ResourceManager::Create(m_pDevice, ResourceMgrCI);
339339

340340
m_CacheUseInfo.pResourceMgr = m_pResourceMgr;
341-
342-
m_CacheUseInfo.BaseColorFormat = TEX_FORMAT_RGBA8_UNORM;
343-
m_CacheUseInfo.PhysicalDescFormat = TEX_FORMAT_RGBA8_UNORM;
344-
m_CacheUseInfo.NormalFormat = TEX_FORMAT_RGBA8_UNORM;
345-
m_CacheUseInfo.OcclusionFormat = TEX_FORMAT_RGBA8_UNORM;
346-
m_CacheUseInfo.EmissiveFormat = TEX_FORMAT_RGBA8_UNORM;
341+
// GLTF loader uses typeless format for texture atlases to allow UNORM and SRGB usage.
342+
m_CacheUseInfo.SetAtlasFormats(TEX_FORMAT_RGBA8_TYPELESS);
347343
}
348344

349345
static RefCntAutoPtr<ITextureView> CreateWhiteFurnaceEnvMap(IRenderDevice* pDevice)
@@ -552,6 +548,12 @@ void GLTFViewer::CreateGLTFRenderer()
552548
RendererCI.pMaterialAttribsCB = m_GLTFRenderer ? m_GLTFRenderer->GetPBRMaterialAttribsCB() : nullptr;
553549
RendererCI.pJointsBuffer = m_GLTFRenderer ? m_GLTFRenderer->GetJointsBuffer() : nullptr;
554550

551+
// Using TEX_COLOR_CONVERSION_MODE_NONE requires creating sRGB views, which is not supported
552+
// when TextureSubresourceViews feature is not available.
553+
RendererCI.TexColorConversionMode = m_pDevice->GetDeviceInfo().Features.TextureSubresourceViews ?
554+
GLTF_PBR_Renderer::CreateInfo::TEX_COLOR_CONVERSION_MODE_NONE :
555+
GLTF_PBR_Renderer::CreateInfo::TEX_COLOR_CONVERSION_MODE_SRGB_TO_LINEAR;
556+
555557
m_GLTFRenderer = std::make_unique<GLTF_PBR_Renderer>(m_pDevice, nullptr, m_pImmediateContext, RendererCI);
556558

557559
if (m_bUseResourceCache)

0 commit comments

Comments
 (0)