Skip to content

Commit

Permalink
PBR Renderer: check R32F support for irradiance cube map
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMostDiligent committed May 7, 2024
1 parent 525ee5e commit 97ac15b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
1 change: 0 additions & 1 deletion PBR/interface/PBR_Renderer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,6 @@ class PBR_Renderer
RefCntAutoPtr<ITextureView> m_pDefaultNormalMapSRV;
RefCntAutoPtr<ITextureView> m_pDefaultPhysDescSRV;

static constexpr TEXTURE_FORMAT IrradianceCubeFmt = TEX_FORMAT_RGBA32_FLOAT;
static constexpr TEXTURE_FORMAT PrefilteredEnvMapFmt = TEX_FORMAT_RGBA16_FLOAT;
static constexpr Uint32 IrradianceCubeDim = 64;
static constexpr Uint32 PrefilteredEnvMapDim = 256;
Expand Down
13 changes: 12 additions & 1 deletion PBR/src/PBR_Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,17 @@ PBR_Renderer::PBR_Renderer(IRenderDevice* pDevice,
{
PrecomputeBRDF(pCtx, m_Settings.NumBRDFSamples);

TEXTURE_FORMAT IrradianceCubeFmt = TEX_FORMAT_RGBA32_FLOAT;
if (!m_Device.GetTextureFormatInfo(IrradianceCubeFmt))
{
IrradianceCubeFmt = TEX_FORMAT_RGBA16_FLOAT;
if (!m_Device.GetTextureFormatInfo(IrradianceCubeFmt))
{
LOG_WARNING_MESSAGE("This device supports neither RGBA32_FLOAT nor RGBA16_FLOAT formats. Using RGBA8 as fallback for irradiance cube map, so expect artifacts in IBL.");
IrradianceCubeFmt = TEX_FORMAT_RGBA8_UNORM;
}
}

TextureDesc TexDesc;
TexDesc.Name = "Irradiance cube map for PBR renderer";
TexDesc.Type = RESOURCE_DIM_TEX_CUBE;
Expand Down Expand Up @@ -526,7 +537,7 @@ void PBR_Renderer::PrecomputeCubemaps(IDeviceContext* pCtx,
PSODesc.PipelineType = PIPELINE_TYPE_GRAPHICS;

GraphicsPipeline.NumRenderTargets = 1;
GraphicsPipeline.RTVFormats[0] = IrradianceCubeFmt;
GraphicsPipeline.RTVFormats[0] = m_pIrradianceCubeSRV->GetDesc().Format;
GraphicsPipeline.PrimitiveTopology = PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP;
GraphicsPipeline.RasterizerDesc.CullMode = CULL_MODE_NONE;
GraphicsPipeline.DepthStencilDesc.DepthEnable = False;
Expand Down

0 comments on commit 97ac15b

Please sign in to comment.