@@ -60,9 +60,9 @@ RWTexture2D<float4> Dest : register(u0);
6060
6161// =====================================================================================================
6262// GENERATED by scripts/export_hlsl.py, do not edit by hand. Networks in half precision (min16float). Packed form (per-lane mads on column weights).
63- // sharpener commit e48176f
64- // Natural (Model 0): runs/Natural-D10/seed1_best.pt (low_p 4) (strength x 0.75), seed 1, step 10000, val loss 0.06060
65- // Crisp (Model 1): runs/Crisp-D10-p50/seed0_best.pt (hc 2) (low_p 4), seed 0, step 10000, val loss 0.06466
63+ // sharpener commit 5a02ec0
64+ // Natural (Model 0): runs/Natural-D10/seed1_best.pt (hm 16) ( low_p 4) (strength x 0.75), seed 1, step 10000, val loss 0.06060
65+ // Crisp (Model 1): runs/Crisp-D10-p50/seed0_best.pt (hc 2) (hm 16) ( low_p 4), seed 0, step 10000, val loss 0.06466
6666// Model config: {"slope": 0.2, "eps": 0.0001, "flat_t": 0.01, "ratio_t": 0.05, "luma": [0.2125999927520752, 0.7152000069618225, 0.0722000002861023]}; hidden / K: Natural 12 / 0.15, Crisp 12 / 0.15
6767// Windows (network input + mean / clamp + flat test): Natural 25 / 13, Crisp 25 / 13 taps (9 = 3x3, 13 = 3x3 + the four at distance 2)
6868// =====================================================================================================
@@ -83,6 +83,9 @@ float LowP() { return (Model == 1) ? kLowP1 : kLowP0; }
8383static const float kHighContrast0 = 0.0 ; // Natural: residual / (1 + (range / mean / hc) ** 2), 0 = off
8484static const float kHighContrast1 = 2.0 ; // Crisp
8585float HighContrast () { return (Model == 1 ) ? kHighContrast1 : kHighContrast0; }
86+ static const float kHighContrastMin0 = 16.0 ; // Natural: residual / (1 + ((mean - min) / min / hm) ** 2), 0 = off
87+ static const float kHighContrastMin1 = 16.0 ; // Crisp
88+ float HighContrastMin () { return (Model == 1 ) ? kHighContrastMin1 : kHighContrastMin0; }
8689
8790bool ClampLowRel () { return true ; } // undershoot limited to K x min
8891static const float kClampK = 0.150000006 ;
@@ -942,6 +945,14 @@ void CSMain(uint3 DTid : SV_DispatchThreadID, uint3 GTid : SV_GroupThreadID, uin
942945 float hq = (mx - mn) * inv / HighContrast ();
943946 r /= 1.0 + hq * hq;
944947 }
948+ // HighContrastMin() > 0: the same against the darkest neighbour, 1 / (1 + ((mean - min) / min / hm) ** 2). Unbounded, so
949+ // it also holds next to 1e5 x HDR lamps, where range / mean saturates at ~2-3; the mean (all taps) because it scales
950+ // the residual, while the bounds taps can miss a lamp two pixels away
951+ if (HighContrastMin () > 0.0 )
952+ {
953+ float hq = max (mean - mn, 0.0 ) / max (mn, kEps) / HighContrastMin ();
954+ r /= 1.0 + hq * hq;
955+ }
945956 float lumaOut = lumaC + r * mean * (intensity * StrengthScale ()); // per-model scale: the slider top = the model's best point
946957
947958 // Clamp to the neighbourhood range, overshoot K per model (0: none beyond the [min, max])
0 commit comments