Skip to content

Commit

Permalink
feat(dbzspark): Add renodrt as a display tonemap option
Browse files Browse the repository at this point in the history
  • Loading branch information
MohannedElfatih authored and clshortfuse committed Dec 5, 2024
1 parent e75547d commit bf3493e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 26 deletions.
18 changes: 2 additions & 16 deletions src/games/dbzspark/addon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,7 @@
#include "../../utils/settings.hpp"
#include "./shared.h"

#include <embed/0x2569985B.h> // LUT
#include <embed/0x31FE4421.h> // LUT
#include <embed/0x36E3A438.h> // LUT
#include <embed/0x4156562D.h> // Final
#include <embed/0x4F06C1AD.h> // Output
#include <embed/0x8C20620E.h> // Output
#include <embed/0x9A3DADB2.h> // Output
#include <embed/0xC2A711CC.h> // LUT
#include <embed/0xE2C936EB.h> // LUT
#include <embed/0xF554DE7A.h> // Output

#include <embed/0x5975CAFA.h> // ColorCorrect
#include <embed/0x753DE2A9.h> // ColorCorrect
#include <embed/0xAB3F1A02.h> // ColorCorrect
#include <embed/0xD80F99B3.h> // ColorCorrect
#include <embed/shaders.h>

namespace {

Expand Down Expand Up @@ -79,7 +65,7 @@ renodx::utils::settings::Settings settings = {
.label = "Display Tone Mapper",
.section = "Tone Mapping",
.tooltip = "Sets an additional tonemapper run to map to peak",
.labels = {"Off", "DICE", "Reinhard"},
.labels = {"Off", "DICE", "renoDRT"},
},
new renodx::utils::settings::Setting{
.key = "toneMapPeakNits",
Expand Down
8 changes: 4 additions & 4 deletions src/games/dbzspark/shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ cbuffer injectedBuffer : register(b0, space50) {
ShaderInjectData injectedData : packoffset(c0);
}
/* static const ShaderInjectData injectedData = {
3.f, // toneMapType
1.f, // toneMapDisplay
500.f, // toneMapPeakNits
150.f, // toneMapGameNits
2.f, // toneMapType
2.f, // toneMapDisplay
800.f, // toneMapPeakNits
160.f, // toneMapGameNits
120.f, // toneMapUINits
1.f, // toneMapGammaCorrection
1.f, // colorGradeExposure
Expand Down
12 changes: 6 additions & 6 deletions src/games/dbzspark/tonemapper.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ renodx::tonemap::Config getCommonConfig() {
///
/// @param lutInputColor The color input that needs to be tonemapped.
/// @return The tonemapped color compressed to the SDR range, ensuring that it can be applied to SDR color grading with `UpgradeToneMap`.
float3 renoDRTSmoothClamp(float3 untonemapped) {
float3 renoDRTSmoothClamp(float3 untonemapped, bool sdr = true) {
renodx::tonemap::renodrt::Config renodrt_config = renodx::tonemap::renodrt::config::Create();
renodrt_config.nits_peak = 100.f;
renodrt_config.nits_peak = sdr ? 100.f : injectedData.toneMapPeakNits;
renodrt_config.mid_gray_value = 0.18f;
renodrt_config.mid_gray_nits = 18.f;
renodrt_config.exposure = 1.f;
Expand All @@ -59,8 +59,6 @@ float3 renoDRTSmoothClamp(float3 untonemapped) {

float3 renoDRTColor = renodx::tonemap::renodrt::BT709(untonemapped, renodrt_config);
renoDRTColor = lerp(untonemapped, renoDRTColor, saturate(renodx::color::y::from::BT709(untonemapped) / renodrt_config.mid_gray_value));
// renoDRTColor = renodx::tonemap::UpgradeToneMap(untonemapped, saturate(untonemapped), renoDRTColor, saturate(renodx::color::y::from::BT709(untonemapped) / renodrt_config.mid_gray_value));
// renoDRTColor = renodx::tonemap::UpgradeToneMap(untonemapped, saturate(untonemapped), renoDRTColor, 1.f);

return renoDRTColor;
}
Expand Down Expand Up @@ -118,7 +116,7 @@ float3 displayTonemap(float3 color) {
Not sure if that's correct though */
const float dicePaperWhite = injectedData.toneMapGameNits;
const float dicePeakWhite = peak;
const float highlightsShoulderStart = 0.25; // Low shoulders cuz game is too bright overall, with sharp highlights
const float highlightsShoulderStart = 0.05; // Low shoulders cuz game is too bright overall, with sharp highlights
const float frostReinPeak = peak / injectedData.toneMapGameNits;

// Tonemap adjustments from color correctors
Expand All @@ -129,9 +127,11 @@ float3 displayTonemap(float3 color) {

color.rgb = DICETonemap(color.rgb * dicePaperWhite, dicePeakWhite, config) / dicePaperWhite;
} else if (tonemapper == 2.f) {
color.rgb = renodx::tonemap::ReinhardScalable(color.rgb, frostReinPeak);
color.rgb = renoDRTSmoothClamp(color, false);
} else if (tonemapper == 3.f) {
color.rgb = renodx::tonemap::frostbite::BT709(color.rgb, frostReinPeak);
} else if (tonemapper == 4.f) {
color.rgb = renodx::tonemap::ReinhardScalable(color.rgb, frostReinPeak);
}

return color;
Expand Down

0 comments on commit bf3493e

Please sign in to comment.