Skip to content

Commit

Permalink
[YS10] Cleanup
Browse files Browse the repository at this point in the history
- Cleanup tonemapper.hlsl

- Change default ingame tonemapper to Frostbite
  • Loading branch information
marat569 committed Oct 26, 2024
1 parent fcd4f40 commit d5bd74d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 24 deletions.
4 changes: 2 additions & 2 deletions src/games/ys10/addon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ renodx::utils::settings::Settings settings = {
.key = "toneMapType",
.binding = &shader_injection.toneMapType,
.value_type = renodx::utils::settings::SettingValueType::INTEGER,
.default_value = 2.f,
.default_value = 4.f,
.can_reset = false,
.label = "Tone Mapper",
.section = "Tone Mapping",
.tooltip = "Sets the tone mapper type",
.labels = {"Vanilla", "None", "DICE", "HDR Reinhard", "Frostbite"},
.labels = {"Vanilla", "None", "DICE", "Reinhard+", "Frostbite"},
},
new renodx::utils::settings::Setting{
.key = "toneMapPeakNits",
Expand Down
4 changes: 2 additions & 2 deletions src/games/ys10/final_0xAD51B4B0.ps_5_0.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ void main(
// colorAP1 = max(0, colorAP1); // Clamp to AP1
// r0.rgb = mul(renodx::color::AP1_TO_BT709_MAT, colorAP1); // Clamp to AP1

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 = 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

o0.rgb = r0.rgb;
Expand Down
21 changes: 1 addition & 20 deletions src/games/ys10/tonemapper.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,6 @@
#include "./DICE.hlsl"
#include "./shared.h"

// HDR Baby Reinhard -- Color, peak nits/ game nits for input
float3 fast_reinhard(float3 color, float y_max = 1.f, float y_min = 0.f, float gray_in = 0.18f, float gray_out = 0.18f) {
float x = (y_max * (y_min * gray_out + y_min - gray_out))
/ (gray_in * (gray_out - y_max));
float y = x / y_max;
float z = y_min;
float w = 1 - y_min;

return mad(color, x, z) / mad(color, y, w);
}

float3 applyUserTonemap(float3 untonemapped) {
float3 outputColor;
Expand All @@ -25,14 +15,6 @@ float3 applyUserTonemap(float3 untonemapped) {
outputColor = untonemapped;
}

float vanillaMidGray = 0.18f;
float renoDRTContrast = 1.f;
float renoDRTFlare = 0.f;
float renoDRTShadows = 1.f;
// float renoDRTDechroma = 0.8f;
float renoDRTSaturation = 1.f; //
float renoDRTHighlights = 1.f;

if (injectedData.toneMapType != 0) { // UserColorGrading, pre-tonemap
outputColor.rgb = renodx::color::grade::UserColorGrading(
outputColor.rgb,
Expand All @@ -47,7 +29,6 @@ float3 applyUserTonemap(float3 untonemapped) {

// Start tonemapper if/else
if (injectedData.toneMapType == 2.f) { // DICE

DICESettings DICEconfig = DefaultDICESettings();
DICEconfig.Type = 3;
DICEconfig.ShoulderStart = 0.33f; // Start shoulder
Expand All @@ -59,7 +40,7 @@ float3 applyUserTonemap(float3 untonemapped) {

} else if (injectedData.toneMapType == 3.f) { // baby reinhard
float ReinhardPeak = injectedData.toneMapPeakNits / injectedData.toneMapGameNits;
outputColor.rgb = fast_reinhard(outputColor.rgb, ReinhardPeak);
outputColor.rgb = renodx::tonemap::ReinhardScalable(outputColor.rgb, ReinhardPeak);

} else if (injectedData.toneMapType == 4.f) { // Frostbite
float frostbitePeak = injectedData.toneMapPeakNits / injectedData.toneMapGameNits;
Expand Down

0 comments on commit d5bd74d

Please sign in to comment.