Skip to content
This repository was archived by the owner on Nov 30, 2020. It is now read-only.

Commit cb0cfb6

Browse files
committed
Faster auto exposure (~4x)
1 parent 96f0e14 commit cb0cfb6

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

PostProcessing/Shaders/Builtins/ExposureHistogram.hlsl

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ float FindMaxHistogramValue(StructuredBuffer<uint> buffer)
2929
{
3030
uint maxValue = 0u;
3131

32+
UNITY_UNROLL
3233
for (uint i = 0; i < HISTOGRAM_BINS; i++)
3334
{
3435
uint h = buffer[i];
@@ -63,19 +64,19 @@ float GetAverageLuminance(StructuredBuffer<uint> buffer, float4 params, float ma
6364
uint i;
6465
float totalSum = 0.0;
6566

66-
UNITY_LOOP
67-
for (i = 0; i < HISTOGRAM_BINS; i++)
68-
totalSum += GetBinValue(buffer, i, maxHistogramValue);
67+
UNITY_UNROLL
68+
for (i = 0; i < HISTOGRAM_BINS; i++)
69+
totalSum += GetBinValue(buffer, i, maxHistogramValue);
6970

7071
// Skip darker and lighter parts of the histogram to stabilize the auto exposure
7172
// x: filtered sum
7273
// y: accumulator
7374
// zw: fractions
7475
float4 filter = float4(0.0, 0.0, totalSum * params.xy);
7576

76-
UNITY_LOOP
77-
for (i = 0; i < HISTOGRAM_BINS; i++)
78-
FilterLuminance(buffer, i, maxHistogramValue, scaleOffset, filter);
77+
UNITY_UNROLL
78+
for (i = 0; i < HISTOGRAM_BINS; i++)
79+
FilterLuminance(buffer, i, maxHistogramValue, scaleOffset, filter);
7980

8081
// Clamp to user brightness range
8182
return clamp(filter.x / max(filter.y, EPSILON), params.z, params.w);

0 commit comments

Comments
 (0)