Skip to content

Commit

Permalink
feat(unrealengine): don't clamp negatives
Browse files Browse the repository at this point in the history
  • Loading branch information
clshortfuse committed Dec 30, 2024
1 parent 96a64e4 commit ad2a263
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
9 changes: 3 additions & 6 deletions src/games/unrealengine/common.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ float3 PostToneMapScale(float3 color) {
color = renodx::color::srgb::EncodeSafe(color);
}

// bg-sRGB should be clamped between -0.53f and 1.68f
// https://www.itu.int/dms_pub/itu-r/opb/rep/R-REP-BT.2380-2-2018-PDF-E.pdf
// Just clamp negative or else peak is limited
color = max(-0.53f, color);

return color;
}

Expand Down Expand Up @@ -111,6 +106,8 @@ float3 RenoDRTSmoothClamp(float3 untonemapped) {
renodrt_config.hue_correction_strength = 0.f;
renodrt_config.working_color_space = 0u;

// renodrt_config.tone_map_method = renodx::tonemap::renodrt::config::tone_map_method::REINHARD;

return renodx::tonemap::renodrt::BT709(untonemapped, renodrt_config);
}

Expand All @@ -134,7 +131,7 @@ float3 ToneMap(float3 bt709) {
config.reno_drt_saturation = 1.05f;
config.reno_drt_dechroma = 0;
config.reno_drt_blowout = injectedData.colorGradeBlowout;
config.reno_drt_flare = 0.10f * injectedData.colorGradeFlare;
config.reno_drt_flare = 0.10f * pow(injectedData.colorGradeFlare, 10.f);
config.reno_drt_working_color_space = 2u;
config.reno_drt_per_channel = injectedData.toneMapPerChannel != 0;

Expand Down
20 changes: 13 additions & 7 deletions src/mods/swapchain.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -952,8 +952,6 @@ static void OnInitResource(
return;
}

if (initial_data != nullptr) return;

auto& private_data = device->get_private_data<DeviceData>();
const std::unique_lock lock(private_data.mutex);

Expand All @@ -972,15 +970,18 @@ static void OnInitResource(
return;
}

bool changed = false;
std::stringstream s;
s << "mods::swapchain::OnInitResource(tracking ";
s << reinterpret_cast<void*>(resource.handle);
s << ", flags: " << std::hex << static_cast<uint32_t>(desc.flags) << std::dec;
s << ", state: " << std::hex << static_cast<uint32_t>(initial_state) << std::dec;
s << ", width: " << desc.texture.width;
s << ", height: " << desc.texture.height;
s << ", initial_data: " << (initial_data == nullptr ? "false" : "true");
s << ", format: " << desc.texture.format;
if (private_data.applied_target != nullptr) {
changed = true;
if (private_data.applied_target->resource_tag != -1) {
renodx::utils::resource::SetResourceTag(device, resource, private_data.applied_target->resource_tag);
}
Expand Down Expand Up @@ -1073,6 +1074,7 @@ static void OnInitResource(
reshade::log::message(reshade::log::level::debug, s.str().c_str());
}
}
changed = true;
s << ", flagged: true";
} else {
// Nothing to do
Expand All @@ -1082,12 +1084,16 @@ static void OnInitResource(
s << ")";

#ifdef DEBUG_LEVEL_1
reshade::log::message(
desc.texture.format == reshade::api::format::unknown
? reshade::log::level::warning
: reshade::log::level::info,
s.str().c_str());
changed = true;
#endif

if (changed) {
reshade::log::message(
desc.texture.format == reshade::api::format::unknown
? reshade::log::level::warning
: reshade::log::level::info,
s.str().c_str());
}
}

static void OnDestroyResource(reshade::api::device* device, reshade::api::resource resource) {
Expand Down

0 comments on commit ad2a263

Please sign in to comment.