Skip to content

Commit

Permalink
[PATHFINDER2] Random fixs
Browse files Browse the repository at this point in the history
- Use sdrColor instead of saturate(color)

- Fix date
  • Loading branch information
marat569 committed Nov 12, 2024
1 parent c89f789 commit 7cc36d2
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 12 deletions.
3 changes: 2 additions & 1 deletion src/games/pathfinder2wotr/addon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

#include "../../mods/shader.hpp"
#include "../../mods/swapchain.hpp"
#include "../../utils/date.hpp"
#include "../../utils/settings.hpp"
#include "./shared.h"

Expand Down Expand Up @@ -210,7 +211,7 @@ renodx::utils::settings::Settings settings = {

new renodx::utils::settings::Setting{
.value_type = renodx::utils::settings::SettingValueType::TEXT,
.label = "Version: " + std::string(IsoDate),
.label = std::string("Build: ") + renodx::utils::date::ISO_DATE_TIME,
.section = "About",
.tooltip = std::string(__DATE__),
},
Expand Down
40 changes: 29 additions & 11 deletions src/games/pathfinder2wotr/tonemapper.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ float3 applyUserTonemap(float3 untonemapped, Texture2D lutTexture, SamplerState

outputColor = untonemapped;

// Sample our lut
// Create LUT config
renodx::lut::Config lut_config = renodx::lut::config::Create(
lutSampler,
injectedData.colorGradeLUTStrength,
Expand All @@ -21,7 +21,7 @@ float3 applyUserTonemap(float3 untonemapped, Texture2D lutTexture, SamplerState
// New way of handling vanilla
// Lerp untonemapped with lutcolor, and saturate
if (injectedData.toneMapType == 0.f) {
float3 lutColor = min(1.f, renodx::lut::Sample(lutTexture, lut_config, outputColor));
float3 lutColor = min(1, renodx::lut::Sample(lutTexture, lut_config, outputColor));
outputColor = lerp(outputColor, lutColor, injectedData.colorGradeLUTStrength);
outputColor = saturate(outputColor);
}
Expand Down Expand Up @@ -57,36 +57,54 @@ float3 applyUserTonemap(float3 untonemapped, Texture2D lutTexture, SamplerState
float dicePaperWhite = injectedData.toneMapGameNits / 80.f;
float dicePeakWhite = injectedData.toneMapPeakNits / 80.f;

float sdrColor = DICETonemap(outputColor * dicePaperWhite, dicePaperWhite, DICEconfig) / dicePaperWhite;
outputColor = DICETonemap(outputColor * dicePaperWhite, dicePeakWhite, DICEconfig) / dicePaperWhite;

float3 lutColor = min(1.f, renodx::lut::Sample(lutTexture, lut_config, outputColor));
outputColor = renodx::tonemap::UpgradeToneMap(outputColor, saturate(outputColor), lutColor, 1.f);
float3 lutColor = min(1, renodx::lut::Sample(lutTexture, lut_config, outputColor));
outputColor = renodx::tonemap::UpgradeToneMap(outputColor, sdrColor, lutColor, 1.f);

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

float3 lutColor = min(1.f, renodx::lut::Sample(lutTexture, lut_config, outputColor));
outputColor = renodx::tonemap::UpgradeToneMap(outputColor, saturate(outputColor), lutColor, 1.f);
float3 lutColor = min(1, renodx::lut::Sample(lutTexture, lut_config, outputColor));
outputColor = renodx::tonemap::UpgradeToneMap(outputColor, sdrColor, lutColor, 1.f);

} else if (injectedData.toneMapType == 4.f) { // Frostbite
float frostbitePeak = injectedData.toneMapPeakNits / injectedData.toneMapGameNits;
if (any(outputColor != 0.f)) { // Avoid dividing by zero with frostbite
if (any(outputColor != 0.f)) { // Avoid dividing by zero with frostbite, still artifacts; frostbite is a WIP
float3 sdrColor = renodx::tonemap::frostbite::BT709(outputColor, 1.f);
outputColor = renodx::tonemap::frostbite::BT709(outputColor, frostbitePeak);
float3 lutColor = min(1.f, renodx::lut::Sample(lutTexture, lut_config, outputColor)); // Sample our LUT
outputColor = renodx::tonemap::UpgradeToneMap(outputColor, saturate(outputColor), lutColor, 1.f); // Combine our untonemapped image with the LUT

float3 lutColor = min(1, renodx::lut::Sample(lutTexture, lut_config, outputColor)); // Sample our LUT
outputColor = renodx::tonemap::UpgradeToneMap(outputColor, sdrColor, lutColor, 1.f); // Combine our untonemapped image with the LUT
}

} else if (injectedData.toneMapType == 5.f) { // RenoDRT
float RenoDRTPeak = (injectedData.toneMapPeakNits / injectedData.toneMapGameNits) * 100.f;

// Color, Peak, midgray, midgraynits, exposure, highlights, shadows, contrast, saturation, dechroma, flare, hueCorrectionStrength
float3 sdrColor = renodx::tonemap::renodrt::BT709(outputColor, 100.f, 0.18f, 18.f, 1.f, 1.f, 1.f, 1.f, 1.f, 0.5f, 0.f, 0.f);
outputColor = renodx::tonemap::renodrt::BT709(outputColor, RenoDRTPeak, 0.18f, 18.f, 1.f, 1.f, 1.f, 1.f, 1.f, 0.5f, 0.f, 0.f);

float3 lutColor = min(1.f, renodx::lut::Sample(lutTexture, lut_config, outputColor));
outputColor = renodx::tonemap::UpgradeToneMap(outputColor, saturate(outputColor), lutColor, 1.f);
float3 lutColor = min(1, renodx::lut::Sample(lutTexture, lut_config, outputColor));
outputColor = renodx::tonemap::UpgradeToneMap(outputColor, sdrColor, lutColor, 1.f);
}

// } else if (injectedData.toneMapType == 6.f) { // test
// float RenoDRTPeak = (injectedData.toneMapPeakNits / injectedData.toneMapGameNits) * 100.f;

// // Color, Peak, midgray, midgraynits, exposure, highlights, shadows, contrast, saturation, dechroma, flare, hueCorrectionStrength
// float3 sdrColor = renodx::tonemap::renodrt::BT709(outputColor, 100.f, 0.18f, 18.f, 1.f, 1.f, 1.f, 1.f, 1.f, 0.5f, 0.f, 0.f);
// outputColor = renodx::tonemap::renodrt::BT709(outputColor, RenoDRTPeak, 0.18f, 18.f, 1.f, 1.f, 1.f, 1.f, 1.f, 0.5f, 0.f, 0.f);

// // float3 lutColor = min(1.f, renodx::lut::Sample(lutTexture, lut_config, outputColor));
// float3 lutColor = renodx::lut::Sample(lutTexture, lut_config, outputColor);
// outputColor = renodx::tonemap::UpgradeToneMap(outputColor, sdrColor, lutColor, 1.f);
// // outputColor = lutColor;
// }

if (injectedData.toneMapType != 0) { // UserColorGrading, post-tonemap
outputColor = renodx::color::grade::UserColorGrading(
outputColor,
Expand Down

0 comments on commit 7cc36d2

Please sign in to comment.