Skip to content

Commit

Permalink
feat(unrealengine): default to HDR10
Browse files Browse the repository at this point in the history
  • Loading branch information
clshortfuse committed Dec 31, 2024
1 parent a3009ab commit 46acc51
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 5 deletions.
26 changes: 23 additions & 3 deletions src/games/unrealengine/addon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ void AddAdvancedSettings() {
.is_global = true,
.is_visible = []() { return settings[0]->GetValue() >= 2; },
};
reshade::get_config_value(nullptr, renodx::utils::settings::global_name.c_str(), ("Upgrade_" + key).c_str(), new_setting->value);
reshade::get_config_value(nullptr, renodx::utils::settings::global_name.c_str(), ("Upgrade_" + key).c_str(), new_setting->value_as_int);
settings.push_back(new_setting);
}

Expand All @@ -653,10 +653,30 @@ void AddAdvancedSettings() {
.is_global = true,
.is_visible = []() { return settings[0]->GetValue() >= 2; },
};
reshade::get_config_value(nullptr, renodx::utils::settings::global_name.c_str(), "Upgrade_SwapChainCompatibility", swapchain_setting->value);
reshade::get_config_value(nullptr, renodx::utils::settings::global_name.c_str(), "Upgrade_SwapChainCompatibility", swapchain_setting->value_as_int);
renodx::mods::swapchain::swapchain_proxy_compatibility_mode = swapchain_setting->GetValue() != 0;
settings.push_back(swapchain_setting);

auto* scrgb_setting = new renodx::utils::settings::Setting{
.key = "Upgrade_UseSCRGB",
.binding = &shader_injection.processingUseSCRGB,
.value_type = renodx::utils::settings::SettingValueType::INTEGER,
.default_value = 0.f,
.label = "Swap Chain Format",
.section = "Resource Upgrades",
.tooltip = "Selects use of HDR10 or scRGB swapchain.",
.labels = {
"HDR10",
"scRGB",
},
.is_global = true,
.is_visible = []() { return settings[0]->GetValue() >= 2; },
};
reshade::get_config_value(nullptr, renodx::utils::settings::global_name.c_str(), "Upgrade_UseSCRGB", scrgb_setting->value_as_int);
shader_injection.processingUseSCRGB = scrgb_setting->GetValue();
renodx::mods::swapchain::SetUseHDR10(scrgb_setting->GetValue() == 0);
settings.push_back(scrgb_setting);

auto* lut_dump_setting = new renodx::utils::settings::Setting{
.key = "DumpLUTShaders",
.binding = &g_dump_shaders,
Expand All @@ -672,7 +692,7 @@ void AddAdvancedSettings() {
.is_global = true,
.is_visible = []() { return settings[0]->GetValue() >= 2; },
};
reshade::get_config_value(nullptr, renodx::utils::settings::global_name.c_str(), "DumpLUTShaders", lut_dump_setting->value);
reshade::get_config_value(nullptr, renodx::utils::settings::global_name.c_str(), "DumpLUTShaders", lut_dump_setting->value_as_int);
g_dump_shaders = lut_dump_setting->GetValue();
settings.push_back(lut_dump_setting);

Expand Down
12 changes: 10 additions & 2 deletions src/games/unrealengine/common.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,17 @@ float3 FinalizeOutput(float3 color) {
color *= injectedData.toneMapUINits;
color = min(color, injectedData.toneMapPeakNits); // Clamp UI or Videos

color = renodx::color::bt709::clamp::BT2020(color);
// Always clamp to BT2020
color = renodx::color::bt2020::from::BT709(color);
color = max(0, color);

if (injectedData.processingUseSCRGB == 1.f) {
color = renodx::color::bt709::from::BT2020(color);
color = color / 80.f;
} else {
color = renodx::color::pq::Encode(color, 1.f);
}

color /= 80.f;
return color;
}

Expand Down
1 change: 1 addition & 0 deletions src/games/unrealengine/shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ struct ShaderInjectData {
float colorGradeBlowout;
float colorGradeFlare;
float colorGradeColorSpace;
float processingUseSCRGB;
};


Expand Down

0 comments on commit 46acc51

Please sign in to comment.