Skip to content

Commit

Permalink
feat(unrealengine): expose more options
Browse files Browse the repository at this point in the history
  • Loading branch information
clshortfuse committed Jan 5, 2025
1 parent 231584c commit c35e97b
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 25 deletions.
52 changes: 45 additions & 7 deletions src/games/unrealengine/addon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,14 +206,14 @@ renodx::utils::settings::Settings settings = {

},
new renodx::utils::settings::Setting{
.key = "ToneMapPerChannel",
.key = "ToneMapScaling",
.binding = &shader_injection.toneMapPerChannel,
.value_type = renodx::utils::settings::SettingValueType::INTEGER,
.default_value = 0.f,
.label = "Per Channel",
.label = "Scaling",
.section = "Tone Mapping",
.tooltip = "Applies tonemapping per-channel instead of by luminance",
.labels = {"Off", "On"},
.tooltip = "Luminance scales colors consistently while per-channel saturates and blows out sooner",
.labels = {"Luminance", "Per Channel"},
.is_enabled = []() { return shader_injection.toneMapType == 1; },
.is_visible = []() { return settings[0]->GetValue() >= 1; },
},
Expand Down Expand Up @@ -270,18 +270,31 @@ renodx::utils::settings::Settings settings = {
.is_enabled = []() { return shader_injection.toneMapType == 1; },
.parse = [](float value) { return value * 0.02f; },
},

new renodx::utils::settings::Setting{
.key = "ColorGradeBlowout",
.key = "ColorGradeHighlightSaturation",
.binding = &shader_injection.colorGradeBlowout,
.default_value = 50.f,
.label = "Blowout",
.label = "Highlight Saturation",
.section = "Color Grading",
.tooltip = "Controls highlight desaturation due to overexposure.",
.tooltip = "Adds or removes highlight color.",
.max = 100.f,
.is_enabled = []() { return shader_injection.toneMapType == 1; },
.parse = [](float value) { return (value * 0.02f) - 1.f; },
.is_visible = []() { return settings[0]->GetValue() >= 1; },
},
new renodx::utils::settings::Setting{
.key = "ColorGradeBlowout",
.binding = &shader_injection.colorGradeDechroma,
.default_value = 0.f,
.label = "Blowout",
.section = "Color Grading",
.tooltip = "Adds highlight desaturation due to overexposure.",
.max = 100.f,
.is_enabled = []() { return shader_injection.toneMapType == 1; },
.parse = [](float value) { return (value * 0.02f); },
.is_visible = []() { return settings[0]->GetValue() >= 1; },
},
new renodx::utils::settings::Setting{
.key = "ColorGradeFlare",
.binding = &shader_injection.colorGradeFlare,
Expand All @@ -293,6 +306,31 @@ renodx::utils::settings::Settings settings = {
.is_enabled = []() { return shader_injection.toneMapType == 1; },
.parse = [](float value) { return value * 0.02f; },
},
new renodx::utils::settings::Setting{
.key = "ColorGradeRestorationMethod",
.binding = &shader_injection.colorGradeRestorationMethod,
.value_type = renodx::utils::settings::SettingValueType::INTEGER,
.default_value = 0.f,
.label = "Grading Application",
.section = "Color Grading",
.tooltip = "Chooses method to apply grading for HDR.",
.labels = {"Luminance", "Per Channel"},
.is_enabled = []() { return shader_injection.toneMapType == 1; },
.is_visible = []() { return settings[0]->GetValue() >= 1; },
},
new renodx::utils::settings::Setting{
.key = "ColorGradeStrength",
.binding = &shader_injection.colorGradeStrength,
.value_type = renodx::utils::settings::SettingValueType::FLOAT,
.default_value = 100.f,
.label = "Grading Strength",
.section = "Color Grading",
.tooltip = "Chooses strength of original color grading.",
.max = 100.f,
.is_enabled = []() { return shader_injection.toneMapType == 1; },
.parse = [](float value) { return value * 0.01f; },
.is_visible = []() { return settings[0]->GetValue() >= 1; },
},
new renodx::utils::settings::Setting{
.key = "ColorGradeColorSpace",
.binding = &shader_injection.colorGradeColorSpace,
Expand Down
37 changes: 20 additions & 17 deletions src/games/unrealengine/common.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ float3 ToneMap(float3 bt709) {
config.reno_drt_highlights = 1.0f;
config.reno_drt_shadows = 1.0f;
config.reno_drt_contrast = 1.0f;
config.reno_drt_saturation = 1.05f;
config.reno_drt_dechroma = 0;
config.reno_drt_saturation = 1.0f;
config.reno_drt_dechroma = injectedData.colorGradeDechroma;
config.reno_drt_blowout = injectedData.colorGradeBlowout;
config.reno_drt_flare = 0.10f * pow(injectedData.colorGradeFlare, 10.f);
config.reno_drt_working_color_space = 2u;
Expand All @@ -178,21 +178,24 @@ float3 ToneMap(float3 bt709) {
float3 UpgradeToneMapAP1(float3 untonemapped_ap1, float3 tonemapped_bt709) {
float3 untonemapped_bt709 = renodx::color::bt709::from::AP1(untonemapped_ap1);

float3 neutral_sdr_color = RenoDRTSmoothClamp(untonemapped_bt709);

float3 untonemapped_graded;
if (injectedData.toneMapPerChannel == 1) {
untonemapped_graded = UpgradeToneMapPerChannel(
untonemapped_bt709,
neutral_sdr_color,
tonemapped_bt709,
1);
} else {
untonemapped_graded = UpgradeToneMapByLuminance(
untonemapped_bt709,
neutral_sdr_color,
tonemapped_bt709,
1);
float3 untonemapped_graded = untonemapped_bt709;
if (injectedData.colorGradeStrength != 0) {
float3 neutral_sdr_color = RenoDRTSmoothClamp(untonemapped_bt709);

if (injectedData.colorGradeRestorationMethod == 1) {
untonemapped_graded = UpgradeToneMapPerChannel(
untonemapped_bt709,
neutral_sdr_color,
tonemapped_bt709,
1);
} else {
untonemapped_graded = UpgradeToneMapByLuminance(
untonemapped_bt709,
neutral_sdr_color,
tonemapped_bt709,
1);
}
untonemapped_graded = lerp(untonemapped_bt709, untonemapped_graded, injectedData.colorGradeStrength);
}
return ToneMap(untonemapped_graded);
}
Expand Down
5 changes: 4 additions & 1 deletion src/games/unrealengine/shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,19 @@ struct ShaderInjectData {
float toneMapGammaCorrection;
float toneMapHueCorrectionMethod;
float toneMapHueCorrection;
float toneMapPerChannel;
float toneMapHueProcessor;
float toneMapPerChannel;
float colorGradeExposure;
float colorGradeHighlights;
float colorGradeShadows;
float colorGradeContrast;
float colorGradeSaturation;
float colorGradeDechroma;
float colorGradeBlowout;
float colorGradeFlare;
float colorGradeColorSpace;
float colorGradeRestorationMethod;
float colorGradeStrength;
float processingUseSCRGB;
};

Expand Down

0 comments on commit c35e97b

Please sign in to comment.