Skip to content

Commit

Permalink
feat(ff7remake): add reinhard based hdr video, add highlight saturation
Browse files Browse the repository at this point in the history
  • Loading branch information
clshortfuse committed Feb 1, 2025
1 parent 219dbff commit 91afafb
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 12 deletions.
25 changes: 18 additions & 7 deletions src/games/ff7remake/addon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,26 +185,37 @@ renodx::utils::settings::Settings settings = {
.max = 100.f,
.parse = [](float value) { return value * 0.02f; },
},
new renodx::utils::settings::Setting{
.key = "ColorGradeHighlightSaturation",
.binding = &RENODX_TONE_MAP_HIGHLIGHT_SATURATION,
.default_value = 50.f,
.label = "Highlight Saturation",
.section = "Color Grading",
.tooltip = "Adds or removes highlight color.",
.max = 100.f,
.is_enabled = []() { return RENODX_TONE_MAP_TYPE >= 1; },
.parse = [](float value) { return value * 0.02f; },
.is_visible = []() { return settings[0]->GetValue() >= 1; },
},
new renodx::utils::settings::Setting{
.key = "ColorGradeBlowout",
.binding = &RENODX_TONE_MAP_BLOWOUT,
.default_value = 50.f,
.default_value = 0.f,
.label = "Blowout",
.section = "Color Grading",
.tooltip = "Controls highlight desaturation due to overexposure.",
.max = 100.f,
.is_enabled = []() { return shader_injection.tone_map_type == 3; },
.parse = [](float value) { return value * 0.02f - 1.f; },
.parse = [](float value) { return value * 0.01f; },
},
new renodx::utils::settings::Setting{
.key = "ColorGradeFlare",
.binding = &RENODX_TONE_MAP_FLARE,
.default_value = 50.f,
.label = "Flare",
.section = "Color Grading",
.tooltip = "Flare/Glare",
.tooltip = "Flare/Glare Compensation",
.max = 100.f,
.is_enabled = []() { return shader_injection.tone_map_type == 3; },
.is_enabled = []() { return RENODX_TONE_MAP_TYPE == 3; },
.parse = [](float value) { return value * 0.02f; },
},
new renodx::utils::settings::Setting{
Expand Down Expand Up @@ -262,11 +273,11 @@ renodx::utils::settings::Settings settings = {
.key = "FXHDRVideos",
.binding = &CUSTOM_HDR_VIDEOS,
.value_type = renodx::utils::settings::SettingValueType::INTEGER,
.default_value = 0.f,
.default_value = 2.f,
.label = "HDR Videos",
.section = "Effects",
.tooltip = "Uses modified BT.2446a to inverse tonemap SDR videos",
.labels = {"Off", "On"},
.labels = {"Off", "BT.2446a", "RenoDRT"},
},
new renodx::utils::settings::Setting{
.value_type = renodx::utils::settings::SettingValueType::BUTTON,
Expand Down
6 changes: 3 additions & 3 deletions src/games/ff7remake/common.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ float3 ToneMap(float3 color, float2 position) {
config.reno_drt_shadows = 1.0f;
config.reno_drt_contrast = 1.1f;
config.reno_drt_saturation = 1.0f;
config.reno_drt_dechroma = 0; // 0.80f; // 0.80f
config.reno_drt_blowout = RENODX_TONE_MAP_BLOWOUT;
config.reno_drt_flare = 0.10 * RENODX_TONE_MAP_FLARE;
config.reno_drt_blowout = -1.f * (RENODX_TONE_MAP_HIGHLIGHT_SATURATION - 1.f);
config.reno_drt_dechroma = RENODX_TONE_MAP_BLOWOUT;
config.reno_drt_flare = 0.10f * pow(RENODX_TONE_MAP_FLARE, 10.f);
config.reno_drt_working_color_space = 2u;
config.reno_drt_per_channel = RENODX_TONE_MAP_PER_CHANNEL != 0;

Expand Down
35 changes: 33 additions & 2 deletions src/games/ff7remake/output_0xD950DA01.ps_5_1.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -276,15 +276,46 @@ void main(
r4.xyz = renodx::color::gamma::Encode(r4.xyz);
r4.xyz = renodx::draw::UpscaleVideoPass(r4.xyz);
r4.xyz = renodx::color::gamma::DecodeSafe(r4.xyz);
} else if (CUSTOM_HDR_VIDEOS == 2.f) {
float y = renodx::color::y::from::BT709(r4.xyz);
float untonemapped_y = renodx::tonemap::inverse::Reinhard(y);
float3 untonemapped = r4.xyz * renodx::math::DivideSafe(untonemapped_y, y, 0);
renodx::tonemap::renodrt::Config hdr_video_config = renodx::tonemap::renodrt::config::Create();
float peak = RENODX_PEAK_WHITE_NITS / RENODX_DIFFUSE_WHITE_NITS;
hdr_video_config.nits_peak = peak * 100.f;
hdr_video_config.mid_gray_value = 0.18f;
hdr_video_config.mid_gray_nits = 18.f;
hdr_video_config.exposure = 1.0f;
hdr_video_config.contrast = 1.0f;
hdr_video_config.saturation = 1.1f;
hdr_video_config.highlights = 1.0f;
hdr_video_config.shadows = 1.0f;

hdr_video_config.blowout = -0.01f;
hdr_video_config.dechroma = 0;
hdr_video_config.flare = 0;

hdr_video_config.tone_map_method = renodx::tonemap::renodrt::config::tone_map_method::REINHARD;
hdr_video_config.hue_correction_type = renodx::tonemap::renodrt::config::hue_correction_type::CUSTOM;
hdr_video_config.hue_correction_source = r4.xyz;
hdr_video_config.per_channel = false;
hdr_video_config.working_color_space = 2u;
hdr_video_config.clamp_peak = 2u;
hdr_video_config.clamp_color_space = -1.f;
r4.xyz = renodx::tonemap::renodrt::BT709(untonemapped, hdr_video_config);
}

if (RENODX_SWAP_CHAIN_CUSTOM_COLOR_SPACE == renodx::draw::COLOR_SPACE_CUSTOM_BT709D93) {
r4.xyz = renodx::color::bt709::from::BT709D93(r4.xyz);
}

r5.x = dot(float3(0.627403915, 0.329282999, 0.0433131009), r4.xyz);
r5.y = dot(float3(0.0690973029, 0.919540584, 0.0113623003), r4.xyz);
r5.z = dot(float3(0.0163914002, 0.0880132988, 0.895595312), r4.xyz);

r3.yzw = float3(250, 250, 250) * r5.xyz;
// r3.yzw = float3(250, 250, 250) * r5.xyz;

r3.yzw = RENODX_GRAPHICS_WHITE_NITS * r5.xyz;
r3.yzw = RENODX_DIFFUSE_WHITE_NITS * r5.xyz;
}

// T5 = video
Expand Down

0 comments on commit 91afafb

Please sign in to comment.