Skip to content

Commit

Permalink
Merge pull request #38 from marat569/YS10
Browse files Browse the repository at this point in the history
[YS10] Add gamma slider
  • Loading branch information
marat569 authored Oct 26, 2024
2 parents 5d6a510 + f1af73b commit 0e1c925
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 19 deletions.
40 changes: 26 additions & 14 deletions src/games/ys10/addon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,18 @@ renodx::utils::settings::Settings settings = {
.max = 500.f,
},

new renodx::utils::settings::Setting{
.key = "gamma",
.binding = &shader_injection.gamma,
.value_type = renodx::utils::settings::SettingValueType::INTEGER,
.default_value = 1.f,
.can_reset = true,
.label = "Gamma",
.section = "Tone Mapping",
.tooltip = "The game defaults to 2.3 Gamma.",
.labels = {"2.2 Gamma", "2.3 Gamma"},
},

new renodx::utils::settings::Setting{
.key = "colorGradeExposure",
.binding = &shader_injection.colorGradeExposure,
Expand Down Expand Up @@ -177,20 +189,20 @@ BOOL APIENTRY DllMain(HMODULE h_module, DWORD fdw_reason, LPVOID lpv_reserved) {
// });

// 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},
// }});
// 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:
Expand Down
5 changes: 1 addition & 4 deletions src/games/ys10/final_0xAD51B4B0.ps_5_0.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,8 @@ void main(

r0.xyz = tex.SampleLevel(smpl_s, v1.xy, 0).xyz; // Sample game, already in gamma space

// float3 colorAP1 = mul(renodx::color::BT709_TO_AP1_MAT, r0.rgb); // Clamp to AP1
// colorAP1 = max(0, colorAP1); // Clamp to AP1
// r0.rgb = mul(renodx::color::AP1_TO_BT709_MAT, colorAP1); // Clamp to AP1
r0.rgb = injectedData.gamma ? renodx::math::PowSafe(r0.rgb, 2.3f) : renodx::math::PowSafe(r0.rgb, 2.2f); // The game does 2.3 gamma default

r0.rgb = renodx::math::PowSafe(r0.rgb, 2.3f); // The game does 2.3 gamma default
r0.rgb = applyUserTonemap(r0.rgb); // Send our color to tonemapper.hlsl to get processed!
r0.rgb *= injectedData.toneMapGameNits / 80.f; // paper white

Expand Down
1 change: 1 addition & 0 deletions src/games/ys10/shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ struct ShaderInjectData {
float colorGradeShadows;
float colorGradeContrast;
float colorGradeSaturation;
float gamma;
};

#ifndef __cplusplus
Expand Down
2 changes: 1 addition & 1 deletion src/games/ys10/tonemapper.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ float3 applyUserTonemap(float3 untonemapped) {
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
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 0e1c925

Please sign in to comment.