Skip to content

Commit 7108db0

Browse files
committed
fix(crimsondesert): auto exposure fixes
(cherry picked from commit 03a1b86)
1 parent f0b54a4 commit 7108db0

2 files changed

Lines changed: 18 additions & 18 deletions

File tree

src/games/crimsondesert/postprocessing/AdaptExposure_0x65CFD284.cs_6_6.hlsl

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -385,8 +385,8 @@ void main(
385385
float _194 = _180 / _193;
386386
// When IMPROVED is on, override the game's per region and ToD controls
387387
// min/max luminance clamps with fixed values, I hope this solves double darkening
388-
float _ae_min_lum = (IMPROVED_AUTO_EXPOSURE == 100) ? AE_MIN_LUM : _param1.z;
389-
float _ae_max_lum = (IMPROVED_AUTO_EXPOSURE == 100) ? AE_MAX_LUM : _param1.w;
388+
float _ae_min_lum = (IMPROVED_AUTO_EXPOSURE == 2) ? AE_MIN_LUM : _param1.z;
389+
float _ae_max_lum = (IMPROVED_AUTO_EXPOSURE == 2) ? AE_MAX_LUM : _param1.w;
390390
float _195 = max(_194, _ae_min_lum);
391391
float _196 = min(_195, _ae_max_lum);
392392
float _197 = sqrt(_192);
@@ -564,7 +564,7 @@ void main(
564564
float _321 = saturate(_320);
565565
float _322 = _321 * _param3.z;
566566
// Sky visibility exposure bias
567-
float _323 = (IMPROVED_AUTO_EXPOSURE == 100) ? 0.0f : (_322 + _param2.z);
567+
float _323 = (IMPROVED_AUTO_EXPOSURE == 2) ? 0.0f : (_322 + _param2.z);
568568
float _324 = max(_smoothed_target_yf, 9.999999747378752e-05f);
569569
float _325 = min(_324, 7.0f);
570570
float _326 = _325 + -0.009999999776482582f;
@@ -587,7 +587,7 @@ void main(
587587
float _343 = _339 - _340;
588588
// Vanilla path (IMPROVED_AUTO_EXPOSURE == 0): keep this sky/occlusion-dependent
589589
// bias term active. Mode 2 zeros it and replaces it with explicit HDR shaping.
590-
float _344 = (IMPROVED_AUTO_EXPOSURE == 100) ? 0.0f : (_343 * _342);
590+
float _344 = (IMPROVED_AUTO_EXPOSURE == 2) ? 0.0f : (_343 * _342);
591591
float _345 = _smoothed_target_yf * 8.0f;
592592
float _346 = log2(_345);
593593
float _347 = _346 - _340;
@@ -598,7 +598,7 @@ void main(
598598

599599
float _350;
600600
[branch]
601-
if (IMPROVED_AUTO_EXPOSURE == 100) {
601+
if (IMPROVED_AUTO_EXPOSURE == 2) {
602602
// --- HDR asymmetric exposure adaptation ---
603603
// We reduce vanilla's adaptation strength via a power curve
604604
// in log space, modulated by sky visibility and scene brightness.
@@ -629,7 +629,7 @@ void main(
629629
if (_353) {
630630
float _357 = __3__39__0__1__g_exposureUAV[1];
631631
[branch]
632-
if (IMPROVED_AUTO_EXPOSURE == 100) {
632+
if (IMPROVED_AUTO_EXPOSURE == 2) {
633633
// Unified log space temporal adaptation becasue Vanilla uses two separate interpolation spaces (1/exp vs linear)
634634
// Causes visible jitter when the target oscillates around the previous value due to histogram noise.
635635
// Log space lerp is symmetric and smooth in both directions.
@@ -705,7 +705,7 @@ void main(
705705
} else {
706706
// Temporal reset (loading screens, menus)
707707
[branch]
708-
if (IMPROVED_AUTO_EXPOSURE == 100) {
708+
if (IMPROVED_AUTO_EXPOSURE == 2) {
709709
// Preserve previous exposure to prevent spikes from garbage
710710
// histogram data during transitions. Temporal adaptation will
711711
// smoothly converge once gameplay resumes.
@@ -800,7 +800,7 @@ void main(
800800
float _425 = _424 * _381;
801801
_427 = _425;
802802
// Apply EV bias for IMPROVED mode (compensates for zeroed _323 push constant correction)
803-
if (IMPROVED_AUTO_EXPOSURE == 100) {
803+
if (IMPROVED_AUTO_EXPOSURE == 2) {
804804
_427 *= exp2(AE_EV_BIAS);
805805
}
806806
}
@@ -859,22 +859,22 @@ void main(
859859
// === RenoDX: Bloom/lens glare stabilisation ===
860860
// Write a low passed exposure into slot 18 (_exposure4.z).
861861
// Histogram-AWB and LensFlareComposite read this instead of the fast
862-
// _exposure0.y when alt auto exposure is toggled.
863-
// This stops vanilla exposure + glare feedback loop that causes bloom shimmer.
864-
//
865-
// Look into maybe doing a further filtering for distance objects?
862+
// exposure state when smoothed AE or PsychoV17 is active.
863+
// This stops the exposure + glare feedback loop that causes shimmer
864+
// and makes foggy interiors flare unpredictably.
866865
[branch]
867-
if (IMPROVED_AUTO_EXPOSURE == 1) {
866+
if ((IMPROVED_AUTO_EXPOSURE == 1) || IMPROVED_AUTO_EXPOSURE == 2) {
868867
float prevSlowExp = __3__39__0__1__g_exposureUAV[18];
869868
float slowSeed = (prevSlowExp > 0.0001f && !isnan(prevSlowExp)) ? prevSlowExp : _427;
870869
float slowTau = 0.05f;
871870
float slowExp = lerp(slowSeed, _427, slowTau);
872871
__3__39__0__1__g_exposureUAV[18] = slowExp;
873872
// Slot 19: filtered target luminance for potential future use
873+
float targetSource = IMPROVED_AUTO_EXPOSURE == 2 ? _psychov17_field_yf : _smoothed_target_yf;
874874
float prevSlowTarget = __3__39__0__1__g_exposureUAV[19];
875875
float targetSeed =
876-
(prevSlowTarget > 0.0001f && !isnan(prevSlowTarget)) ? prevSlowTarget : _smoothed_target_yf;
877-
float slowTarget = lerp(targetSeed, _smoothed_target_yf, 0.08f);
876+
(prevSlowTarget > 0.0001f && !isnan(prevSlowTarget)) ? prevSlowTarget : targetSource;
877+
float slowTarget = lerp(targetSeed, targetSource, 0.08f);
878878
__3__39__0__1__g_exposureUAV[19] = slowTarget;
879879
}
880880

src/games/crimsondesert/postprocessing/Histogram-AWB_0x05A8EA2B.cs_6_6.hlsl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -377,8 +377,8 @@ void main(
377377
// RenoDX: When alt auto exposure is toggled, use the filtered exposure
378378
// from _exposure4.z (slot 18) instead of the fast _exposure0.y to decouple
379379
// glare intensity from jitter.
380-
float _glareExposure = (IMPROVED_AUTO_EXPOSURE == 1) ? max(_exposure4.z, 0.001f) : _exposure0.y;
381-
float _glareExposure2 = (IMPROVED_AUTO_EXPOSURE == 1) ? max(_exposure4.z, 0.001f) : _exposure2.x;
380+
float _glareExposure = (IMPROVED_AUTO_EXPOSURE >= 1) ? max(_exposure4.z, 0.001f) : _exposure0.y;
381+
float _glareExposure2 = (IMPROVED_AUTO_EXPOSURE >= 1) ? max(_exposure4.z, 0.001f) : _exposure2.x;
382382
if (_127) {
383383
float _236 = min(_glareExposure2, 2.0f);
384384
float _237 = max(_236, 0.5f);
@@ -748,7 +748,7 @@ void main(
748748
float _500 = _499 + _398;
749749
// RenoDX: Use slow exposure for glare instance threshold to
750750
// stop shimmering due to jitter
751-
float _glareThresholdExp = (IMPROVED_AUTO_EXPOSURE == 1) ? max(_exposure4.z, 0.001f) : _exposure2.x;
751+
float _glareThresholdExp = (IMPROVED_AUTO_EXPOSURE >= 1) ? max(_exposure4.z, 0.001f) : _exposure2.x;
752752
float _503 = saturate(_glareThresholdExp);
753753
float _504 = _503 * 900.0f;
754754
float _505 = _504 + 100.0f;

0 commit comments

Comments
 (0)