Skip to content

Commit

Permalink
Add hdr cvar, tweak bloom accordingly
Browse files Browse the repository at this point in the history
  • Loading branch information
vs-shirokii committed Dec 18, 2023
1 parent 8d46ab9 commit db961cd
Showing 1 changed file with 40 additions and 12 deletions.
52 changes: 40 additions & 12 deletions src/common/rendering/rt/rt_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ namespace cvar
RT_CVAR( rt_classic_white, 3.f, "white point for classic renderer" )

RT_CVAR( rt_vsync, false, "vertical synchronization to prevent tearing" )
RT_CVAR( rt_hdr, false, "enable HDR output for display" )

RT_CVAR( rt_renderscale, 0.f, "[0.2, 1.0] resolution scale")
RT_CVAR( rt_upscale_dlss, 0, "0 - off, 1 - quality, 2 - balanced, 3 - perf, 4 - ultra perf, 5 - DLSS with rt_renderscale, 6 - DLAA" )
Expand Down Expand Up @@ -128,7 +129,8 @@ namespace cvar
RT_CVAR( rt_light_s, 1000.f, "intensity of lights defined by a map")
RT_CVAR( rt_light_radius, 0.02f, "default radius for original lights (in meters)")

RT_CVAR( rt_flsh, 800.f, "flashlight intensity")
RT_CVAR( rt_flsh, false, "flashlight enable")
RT_CVAR( rt_flsh_intensity, 800.f, "flashlight intensity")
RT_CVAR( rt_flsh_radius, 0.02f, "flashlight source disk radius in meters")
RT_CVAR( rt_flsh_angle, 20.f, "flashlight width in degrees")
RT_CVAR( rt_flsh_r, -0.2f, "flashlight position offset - right (in meteres)")
Expand Down Expand Up @@ -160,11 +162,11 @@ namespace cvar
RT_CVAR( rt_water_wavestren, 3.f, "normal map strength for water" )

RT_CVAR( rt_bloom, true, "enable bloom" )
RT_CVAR( rt_bloom_intensity, 1.f, "bloom intensity" )
RT_CVAR( rt_bloom_threshold, 4.f, "bloom threshold" )
RT_CVAR( rt_bloom_emis_mult, 9.f, "bloom multiplier for emissive" )
RT_CVAR( rt_bloom_dirt, 0.8f, "lens dirt intensity" )
RT_CVAR( rt_bloom_dirt_enable, true, "lens dirt enable" )
RT_CVAR( rt_bloom_scale, 1.f, "multiplier for a calculated bloom" )
RT_CVAR( rt_bloom_ev, 6.f, "EV offset for bloom calculation input" )
RT_CVAR( rt_bloom_threshold, 16.f, "brightness threshold for bloom calculation input" )
RT_CVAR( rt_bloom_dirt, true, "lens dirt enable" )
RT_CVAR( rt_bloom_dirt_scale, 0.8f, "lens dirt multiplier" )

RT_CVAR( rt_ef_crt, false, "CRT-monitor filter" )
RT_CVAR( rt_ef_chraber, 0.15f, "chromatic aberration intensity" )
Expand Down Expand Up @@ -2088,6 +2090,22 @@ bool RT_IgnoreUserInput()
//
//

#ifdef WIN32
#include "shellapi.h"
void RT_AskUserToEnableHDRInSettings()
{
if( MessageBoxA( nullptr,
"Please ensure that HDR is enabled in \'Display\' settings.\n"
"Otherwise the results will be skewed.\n\n"
"Open \'Display\' settings?",
"Enable HDR in Display settings",
MB_YESNO | MB_ICONEXCLAMATION ) == IDYES )
{
ShellExecuteA( nullptr, "open", "ms-settings:display", nullptr, nullptr, SW_SHOWNORMAL );
}
}
#endif

void RTFrameBuffer::RT_BeginFrame()
{
m_state->RT_BeginFrame();
Expand All @@ -2098,8 +2116,18 @@ void RTFrameBuffer::RT_BeginFrame()
.pMapName = RT_GetMapName(),
.ignoreExternalGeometry = false,
.vsync = cvar::rt_vsync,
.hdr = cvar::rt_hdr,
};

#ifdef WIN32
static bool g_askedToEnable = false;
if( info.hdr && !g_askedToEnable )
{
g_askedToEnable = true;
RT_AskUserToEnableHDRInSettings();
}
#endif

RgResult r = rt.rgStartFrame( &info );
RG_CHECK( r );
}
Expand Down Expand Up @@ -2171,12 +2199,12 @@ void RTFrameBuffer::RT_DrawFrame()
};

auto bloom_params = RgDrawFrameBloomParams{
.sType = RG_STRUCTURE_TYPE_DRAW_FRAME_BLOOM_PARAMS,
.pNext = &texture_params,
.bloomIntensity = cvar::rt_bloom ? 0.06f * cvar ::rt_bloom_intensity : 0.f,
.inputThreshold = cvar::rt_bloom_threshold,
.bloomEmissionMultiplier = cvar::rt_bloom_emis_mult,
.lensDirtIntensity = cvar::rt_bloom_dirt_enable ? cvar::rt_bloom_dirt : 0.f,
.sType = RG_STRUCTURE_TYPE_DRAW_FRAME_BLOOM_PARAMS,
.pNext = &texture_params,
.inputEV = cvar::rt_bloom_ev,
.inputThreshold = cvar::rt_bloom_threshold,
.bloomIntensity = cvar::rt_bloom ? cvar ::rt_bloom_scale : 0.f,
.lensDirtIntensity = cvar::rt_bloom_dirt ? cvar::rt_bloom_dirt_scale : 0.f,
};

auto illum_params = RgDrawFrameIlluminationParams{
Expand Down

0 comments on commit db961cd

Please sign in to comment.