diff --git a/PBR/interface/GLTF_PBR_Renderer.hpp b/PBR/interface/GLTF_PBR_Renderer.hpp index 296886f3..30d3db8b 100644 --- a/PBR/interface/GLTF_PBR_Renderer.hpp +++ b/PBR/interface/GLTF_PBR_Renderer.hpp @@ -95,6 +95,9 @@ class GLTF_PBR_Renderer : public PBR_Renderer /// White point value used by tone mapping float WhitePoint = 3.f; + + /// Highlight color that is applied to the mesh after tone mapping + float4 HighlightColor = float4{0, 0, 0, 0}; }; /// GLTF Model shader resource binding information diff --git a/PBR/src/GLTF_PBR_Renderer.cpp b/PBR/src/GLTF_PBR_Renderer.cpp index 919408ce..421745be 100644 --- a/PBR/src/GLTF_PBR_Renderer.cpp +++ b/PBR/src/GLTF_PBR_Renderer.cpp @@ -404,6 +404,7 @@ void GLTF_PBR_Renderer::Render(IDeviceContext* pCtx, RendererParams.MiddleGray = m_RenderParams.MiddleGray; RendererParams.WhitePoint = m_RenderParams.WhitePoint; RendererParams.IBLScale = m_RenderParams.IBLScale; + RendererParams.HighlightColor = m_RenderParams.HighlightColor; RendererParams.PrefilteredCubeMipLevels = m_Settings.UseIBL ? static_cast(m_pPrefilteredEnvMapSRV->GetTexture()->GetDesc().MipLevels) : 0.f; } diff --git a/Shaders/PBR/private/RenderPBR.psh b/Shaders/PBR/private/RenderPBR.psh index a6a63704..67db3d94 100644 --- a/Shaders/PBR/private/RenderPBR.psh +++ b/Shaders/PBR/private/RenderPBR.psh @@ -255,6 +255,7 @@ void main(in PbrVsOutput VSOut, color += Emissive.rgb * g_PBRAttribs.Material.EmissiveFactor.rgb * g_PBRAttribs.Renderer.EmissionScale; #endif + // Perform tone mapping ToneMappingAttribs TMAttribs; TMAttribs.iToneMappingMode = TONE_MAPPING_MODE_UNCHARTED2; TMAttribs.bAutoExposure = false; @@ -263,6 +264,10 @@ void main(in PbrVsOutput VSOut, TMAttribs.fWhitePoint = g_PBRAttribs.Renderer.WhitePoint; TMAttribs.fLuminanceSaturation = 1.0; color = ToneMap(color, TMAttribs, g_PBRAttribs.Renderer.AverageLogLum); + + // Add highlight color + color = lerp(color, g_PBRAttribs.Renderer.HighlightColor.rgb, g_PBRAttribs.Renderer.HighlightColor.a); + OutColor = float4(color, BaseColor.a); #if ALLOW_DEBUG_VIEW diff --git a/Shaders/PBR/public/PBR_Structures.fxh b/Shaders/PBR/public/PBR_Structures.fxh index 53a26ff3..de53e29d 100644 --- a/Shaders/PBR/public/PBR_Structures.fxh +++ b/Shaders/PBR/public/PBR_Structures.fxh @@ -61,6 +61,7 @@ struct PBRRendererShaderParameters float EmissionScale; float4 WireframeColor; + float4 HighlightColor; uint MeshId; uint Padding0; diff --git a/shaders_inc/PBR_Structures.fxh.h b/shaders_inc/PBR_Structures.fxh.h index bac97966..67658c98 100644 --- a/shaders_inc/PBR_Structures.fxh.h +++ b/shaders_inc/PBR_Structures.fxh.h @@ -61,6 +61,7 @@ " float EmissionScale;\n" "\n" " float4 WireframeColor;\n" +" float4 HighlightColor;\n" "\n" " uint MeshId;\n" " uint Padding0;\n" diff --git a/shaders_inc/RenderPBR.psh.h b/shaders_inc/RenderPBR.psh.h index 4a1e9d99..da1a1561 100644 --- a/shaders_inc/RenderPBR.psh.h +++ b/shaders_inc/RenderPBR.psh.h @@ -255,6 +255,7 @@ " color += Emissive.rgb * g_PBRAttribs.Material.EmissiveFactor.rgb * g_PBRAttribs.Renderer.EmissionScale;\n" "#endif\n" "\n" +" // Perform tone mapping\n" " ToneMappingAttribs TMAttribs;\n" " TMAttribs.iToneMappingMode = TONE_MAPPING_MODE_UNCHARTED2;\n" " TMAttribs.bAutoExposure = false;\n" @@ -263,6 +264,10 @@ " TMAttribs.fWhitePoint = g_PBRAttribs.Renderer.WhitePoint;\n" " TMAttribs.fLuminanceSaturation = 1.0;\n" " color = ToneMap(color, TMAttribs, g_PBRAttribs.Renderer.AverageLogLum);\n" +"\n" +" // Add highlight color\n" +" color = lerp(color, g_PBRAttribs.Renderer.HighlightColor.rgb, g_PBRAttribs.Renderer.HighlightColor.a);\n" +"\n" " OutColor = float4(color, BaseColor.a);\n" "\n" "#if ALLOW_DEBUG_VIEW\n"