Skip to content

Commit de2c45c

Browse files
committed
feat(crimsondesert): update slider code, defaults, new blowout
1 parent ab63e4b commit de2c45c

File tree

3 files changed

+56
-23
lines changed

3 files changed

+56
-23
lines changed

src/games/crimsondesert/addon.cpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,9 @@ const std::unordered_map<std::string, float> NEUTRAL_VALUES = {
198198
{"ColorGradeConeResponse", 50.f},
199199
{"ColorGradeContrast", 50.f},
200200
{"ColorGradeSaturation", 50.f},
201+
{"ColorGradeHighlights", 50.f},
202+
{"CustomToneMapMidgrayAdjust", 100.f},
203+
{"LocalLightHueCorrection", 25.f}
201204
};
202205

203206
renodx::mods::shader::CustomShaders custom_shaders = {__ALL_CUSTOM_SHADERS};
@@ -398,7 +401,7 @@ renodx::utils::settings::Settings settings = {
398401
new renodx::utils::settings::Setting{
399402
.key = "ColorGradeHighlights",
400403
.binding = &shader_injection.tone_map_highlights,
401-
.default_value = 50.f,
404+
.default_value = 46.f,
402405
.label = "Highlights",
403406
.section = "Color Grading",
404407
.tint = color_grading,
@@ -410,7 +413,7 @@ renodx::utils::settings::Settings settings = {
410413
new renodx::utils::settings::Setting{
411414
.key = "ColorGradeShadows",
412415
.binding = &shader_injection.tone_map_shadows,
413-
.default_value = 40.f,
416+
.default_value = 50.f,
414417
.label = "Shadows",
415418
.section = "Color Grading",
416419
.tint = color_grading,
@@ -422,19 +425,19 @@ renodx::utils::settings::Settings settings = {
422425
new renodx::utils::settings::Setting{
423426
.key = "ColorGradeContrast",
424427
.binding = &shader_injection.tone_map_contrast,
425-
.default_value = 40.f,
428+
.default_value = 55.f,
426429
.label = "Contrast",
427430
.section = "Color Grading",
428431
.tint = color_grading,
429432
.max = 100.f,
430433
.is_enabled = []() { return RENODX_TONE_MAP_TYPE != 0.f; },
431434
.parse = [](float value) { return value * 0.02f; },
432-
.is_visible = []() { return current_settings_mode >= 1.f && RENODX_TONE_MAP_TYPE != 0.f; },
435+
.is_visible = []() { return current_settings_mode >= 1.f; },
433436
},
434437
new renodx::utils::settings::Setting{
435438
.key = "ColorGradeSaturation",
436439
.binding = &shader_injection.tone_map_saturation,
437-
.default_value = 50.f,
440+
.default_value = 65.f,
438441
.label = "Saturation",
439442
.section = "Color Grading",
440443
.tint = color_grading,
@@ -447,7 +450,7 @@ renodx::utils::settings::Settings settings = {
447450
new renodx::utils::settings::Setting{
448451
.key = "ColorGradeConeResponse",
449452
.binding = &shader_injection.tone_map_cone_response,
450-
.default_value = 65.f,
453+
.default_value = 50.f,
451454
.label = "Cone Response",
452455
.section = "Color Grading",
453456
.tooltip = "Controls the PsychoV cone response shaping.",
@@ -473,7 +476,7 @@ renodx::utils::settings::Settings settings = {
473476
new renodx::utils::settings::Setting{
474477
.key = "ToneMapBlowout",
475478
.binding = &shader_injection.tone_map_blowout,
476-
.default_value = 0.f,
479+
.default_value = 20.f,
477480
.label = "Blowout",
478481
.section = "Color Grading",
479482
.tooltip = "Desaturates the brightest portions of the image, also relative to peak brightness.",
@@ -486,7 +489,7 @@ renodx::utils::settings::Settings settings = {
486489
new renodx::utils::settings::Setting{
487490
.key = "CustomToneMapMidgrayAdjust",
488491
.binding = &shader_injection.custom_tone_map_midgray_adjust,
489-
.default_value = 100.f,
492+
.default_value = 75.f,
490493
.label = "SDR Midgray",
491494
.section = "Color Grading",
492495
.tooltip = "Controls matching mid-gray of the SDR tone mapper. Applies to Vanilla/Custom AE only. 100 = Vanilla, 0 = Neutral.",
@@ -563,7 +566,7 @@ renodx::utils::settings::Settings settings = {
563566
new renodx::utils::settings::Setting{
564567
.key = "LocalLightHueCorrection",
565568
.binding = &shader_injection.local_light_hue_correction,
566-
.default_value = 25.f,
569+
.default_value = 15.f,
567570
.can_reset = true,
568571
.label = "Flame Hue Correction",
569572
.section = "Local Lighting",

src/games/crimsondesert/common.hlsl

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,20 @@ float Highlights(float x, float highlights, float mid_gray) {
9797
}
9898
}
9999

100+
float ContrastSafeShadowBias(float x, float contrast, float mid_gray = 0.18f, float shadow_bias = 0.35f) {
101+
if (contrast == 1.f) return x;
102+
103+
shadow_bias = saturate(shadow_bias);
104+
105+
// Start from the standard contrast curve, then shape its strength like an
106+
// asymmetric S-curve so the toe gets more adjustment than the shoulder.
107+
float contrasted = renodx::color::grade::ContrastSafe(x, contrast, mid_gray);
108+
float shoulder = smoothstep(0.25f, 2.0f, renodx::math::DivideSafe(max(x, 0.f), mid_gray, 0.f));
109+
float effect = lerp(1.f + shadow_bias, 1.f - shadow_bias, shoulder);
110+
111+
return max(0.f, x + (contrasted - x) * effect);
112+
}
113+
100114
float3 ApplyExposureContrastFlareHighlightsShadowsByLuminance(float3 untonemapped, float y, renodx::color::grade::Config config, float mid_gray = 0.18f) {
101115
if (config.exposure == 1.f && config.shadows == 1.f && config.highlights == 1.f && config.contrast == 1.f && config.flare == 0.f) {
102116
return untonemapped;
@@ -249,10 +263,11 @@ float3 CustomPsychoV17Peak(
249263
float yf_target = yf_input;
250264

251265
if (RENODX_TONE_MAP_HIGHLIGHTS != 1.f) {
252-
yf_target = renodx::color::grade::Highlights(yf_target, RENODX_TONE_MAP_HIGHLIGHTS, yf_midgray);
266+
// yf_target = renodx::color::grade::Highlights(yf_target, RENODX_TONE_MAP_HIGHLIGHTS, yf_midgray);
267+
yf_target = Highlights(yf_target, RENODX_TONE_MAP_HIGHLIGHTS, yf_midgray);
253268
}
254269
if (RENODX_TONE_MAP_SHADOWS != 1.f) {
255-
yf_target = renodx::color::grade::Shadows(yf_target, RENODX_TONE_MAP_SHADOWS, yf_midgray);
270+
yf_target = renodx::color::grade::Shadows(yf_target, RENODX_TONE_MAP_SHADOWS, yf_midgray, 1.f);
256271
}
257272
if (RENODX_TONE_MAP_CONTRAST != 1.f) {
258273
yf_target = renodx::color::grade::ContrastSafe(yf_target, RENODX_TONE_MAP_CONTRAST, yf_midgray);
@@ -304,13 +319,29 @@ float3 ProcessTonemap(float3 untonemapped_bt709, float calculated_peak, float mi
304319

305320
mid_gray_scale = lerp(1.f, mid_gray_scale, CUSTOM_TONE_MAP_MIDGRAY_ADJUST);
306321

307-
return CustomPsychoV17AutoExposure(
322+
float3 output_color = CustomPsychoV17AutoExposure(
308323
untonemapped_bt709,
309324
calculated_peak,
310325
mid_gray_scale,
311326
current_average,
312327
target_average,
313328
is_sdr);
329+
330+
if (RENODX_TONE_MAP_BLOWOUT != 0.f) {
331+
float3 availability = 1.f.xxx / (1.f.xxx + (calculated_peak));
332+
availability = lerp(1.f.xxx, availability, RENODX_TONE_MAP_BLOWOUT);
333+
334+
float3 lms_cones = renodx::color::lms::from::BT709(output_color);
335+
float3 current_adaptive_state_lms = renodx::color::lms::from::BT709(target_average);
336+
337+
float input_energy = lms_cones.x + lms_cones.y + lms_cones.z;
338+
float white_y = current_adaptive_state_lms.x + current_adaptive_state_lms.y + current_adaptive_state_lms.z;
339+
float3 white_at_y = current_adaptive_state_lms * (input_energy / white_y);
340+
float3 delta = (lms_cones - white_at_y) * availability;
341+
lms_cones = max(0, white_at_y + delta);
342+
output_color = renodx::color::bt709::from::LMS(lms_cones);
343+
}
344+
return output_color;
314345
}
315346

316347
float3 CustomTonemap(float3 untonemapped_bt709, float mid_gray_scale = 1.f, float current_average = 0.18f, float target_average = 0.18f) {

src/games/crimsondesert/psycho_test17_custom.hlsl

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -600,17 +600,16 @@ float3 psychotm_test17(
600600

601601
float3 lms_cones = lms_graded;
602602

603-
if (bleaching_intensity != 0.f) {
604-
float3 stimulus_trolands = max(current_adaptive_state_lms, 0.f) * 203.f * 4.f;
605-
float3 availability = 1.f.xxx / (1.f.xxx + stimulus_trolands / 20000.f);
606-
availability = lerp(1.f.xxx, availability, bleaching_intensity);
607-
608-
float y = lms_cones.x + lms_cones.y;
609-
float white_y = current_adaptive_state_lms.x + current_adaptive_state_lms.y;
610-
float3 white_at_y = current_adaptive_state_lms * (y / white_y);
611-
float3 delta = (lms_cones - white_at_y) * availability;
612-
lms_cones = white_at_y + delta;
613-
}
603+
// if (bleaching_intensity != 0.f) {
604+
// float3 availability = 1.f.xxx / (1.f.xxx + (peak_value / current_adaptive_state_lms));
605+
// availability = lerp(1.f.xxx, availability, bleaching_intensity);
606+
607+
// float input_energy = lms_cones.x + lms_cones.y + lms_cones.z;
608+
// float white_y = current_adaptive_state_lms.x + current_adaptive_state_lms.y + current_adaptive_state_lms.z;
609+
// float3 white_at_y = current_adaptive_state_lms * (input_energy / white_y);
610+
// float3 delta = (lms_cones - white_at_y) * availability;
611+
// lms_cones = max(0, white_at_y + delta);
612+
// }
614613

615614
// Naka-Rushton is scale-equivariant if input, peak, and anchors are all
616615
// normalized by the same adaptive LMS state, so keep the absolute-LMS form.

0 commit comments

Comments
 (0)