Skip to content

Commit

Permalink
Fixed the sudden darkening of the screen: #26
Browse files Browse the repository at this point in the history
  • Loading branch information
apanteleev committed Jul 2, 2019
1 parent 3d6dae9 commit 871dc77
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/refresh/vkpt/shader/tone_mapping_curve.comp
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ void main()
// the two methods.
// Our histogram is already normalized, so do a prefix sum over the histogram bins:
const float histogram_cdf = computePrefixSum(original_hist, linear_idx);
const float histogram_cdf_prev = histogram_cdf - original_hist;

// Compute the average log luminance over the range of the histogram from
// tm_low_percentile% to tm_high_percentile%:
Expand All @@ -161,7 +162,13 @@ void main()
float weight_sum = 0.0;
float bin_sum = 0.0;

if((lower_limit <= histogram_cdf) && (histogram_cdf <= upper_limit))
// See if the CDF for this bin, as a range between the current bin and previous
// bin CDFs, intersects with the histogram percentile limits.
// Can't treat the CDF as a point value because then a scene that has very
// uniform brightness might have most of its luminance within a single bin,
// and that single bin will just skip over the percentile limits,
// and no bins will be considered for the auto exposure value.
if((lower_limit <= histogram_cdf) && (histogram_cdf_prev <= upper_limit))
{
weight_sum = bin_log_luminance * original_hist;
bin_sum = original_hist;
Expand Down

0 comments on commit 871dc77

Please sign in to comment.