Skip to content

Commit

Permalink
[YS10] Clamp frostbite to AP1
Browse files Browse the repository at this point in the history
- Fix NaNs on 0,0,0
  • Loading branch information
marat569 committed Oct 26, 2024
1 parent d5bd74d commit f2e658b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
16 changes: 16 additions & 0 deletions src/games/ys10/addon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,22 @@ BOOL APIENTRY DllMain(HMODULE h_module, DWORD fdw_reason, LPVOID lpv_reserved) {
// .new_format = reshade::api::format::r16g16b16a16_float,
// });

// R11G11B10
// renodx::mods::swapchain::swap_chain_upgrade_targets.push_back({.old_format = reshade::api::format::r11g11b10_float,
// .new_format = reshade::api::format::r16g16b16a16_float,
// .ignore_size = true,
// .view_upgrades = {
// {{reshade::api::resource_usage::shader_resource,
// reshade::api::format::r11g11b10_float},
// reshade::api::format::r16g16b16a16_float},
// {{reshade::api::resource_usage::unordered_access,
// reshade::api::format::r11g11b10_float},
// reshade::api::format::r16g16b16a16_float},
// {{reshade::api::resource_usage::render_target,
// reshade::api::format::r11g11b10_float},
// reshade::api::format::r16g16b16a16_float},
// }});

break;
case DLL_PROCESS_DETACH:
reshade::unregister_addon(h_module);
Expand Down
3 changes: 2 additions & 1 deletion src/games/ys10/tonemapper.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "./DICE.hlsl"
#include "./shared.h"


float3 applyUserTonemap(float3 untonemapped) {
float3 outputColor;

Expand Down Expand Up @@ -45,6 +44,8 @@ float3 applyUserTonemap(float3 untonemapped) {
} else if (injectedData.toneMapType == 4.f) { // Frostbite
float frostbitePeak = injectedData.toneMapPeakNits / injectedData.toneMapGameNits;
outputColor = renodx::tonemap::frostbite::BT709(outputColor, frostbitePeak);

outputColor = renodx::color::bt709::clamp::AP1(outputColor); // Clamp frostbite to AP1 to avoid invalid colors
}

if (injectedData.toneMapType != 0) { // UserColorGrading, post-tonemap
Expand Down

0 comments on commit f2e658b

Please sign in to comment.