@@ -777,10 +777,12 @@ static tone_mapping_params_t _calculate_tone_mapping_params(const dt_iop_agx_use
777
777
778
778
const float remaining_y_below_pivot = tone_mapping_params .pivot_y - tone_mapping_params .target_black ;
779
779
const float toe_length_y = remaining_y_below_pivot * user_params -> curve_linear_percent_below_pivot / 100.0f ;
780
- const float dx_linear_below_pivot = toe_length_y / tone_mapping_params .slope ;
780
+ float dx_linear_below_pivot = toe_length_y / tone_mapping_params .slope ;
781
781
// ...and subtract it from pivot_x to get the x coordinate where the linear section joins the toe
782
782
// ... but keep the transition point above x = 0
783
783
tone_mapping_params .toe_transition_x = fmaxf (_epsilon , tone_mapping_params .pivot_x - dx_linear_below_pivot );
784
+ // fix up in case the limitation kicked in
785
+ dx_linear_below_pivot = tone_mapping_params .pivot_x - tone_mapping_params .toe_transition_x ;
784
786
785
787
// from the 'run' pivot_x->toe_transition_x, we calculate the 'rise'
786
788
const float toe_y_below_pivot_y = tone_mapping_params .slope * dx_linear_below_pivot ;
@@ -818,10 +820,11 @@ static tone_mapping_params_t _calculate_tone_mapping_params(const dt_iop_agx_use
818
820
tone_mapping_params .target_white = powf (user_params -> curve_target_display_white_percent / 100.0 , 1.0f / tone_mapping_params .curve_gamma );
819
821
const float remaining_y_above_pivot = tone_mapping_params .target_white - tone_mapping_params .pivot_y ;
820
822
const float shoulder_length_y = remaining_y_above_pivot * user_params -> curve_linear_percent_above_pivot / 100.0f ;
821
- const float dx_linear_above_pivot = shoulder_length_y / tone_mapping_params .slope ;
823
+ float dx_linear_above_pivot = shoulder_length_y / tone_mapping_params .slope ;
822
824
823
825
// don't allow shoulder_transition_x to reach 1
824
826
tone_mapping_params .shoulder_transition_x = fminf (1 - _epsilon , tone_mapping_params .pivot_x + dx_linear_above_pivot );
827
+ dx_linear_above_pivot = tone_mapping_params .pivot_x - tone_mapping_params .shoulder_transition_x ;
825
828
tone_mapping_params .shoulder_transition_y = tone_mapping_params .pivot_y + shoulder_length_y ;
826
829
tone_mapping_params .shoulder_power = user_params -> curve_shoulder_power ;
827
830
0 commit comments