@@ -16,24 +16,12 @@ public void Generate(PostProcessRenderContext context)
16
16
{
17
17
if ( data == null )
18
18
data = new ComputeBuffer ( k_Bins , sizeof ( uint ) ) ;
19
-
19
+
20
+ var scaleOffsetRes = GetHistogramScaleOffsetRes ( context ) ;
20
21
var compute = context . resources . computeShaders . exposureHistogram ;
21
22
var cmd = context . command ;
22
23
cmd . BeginSample ( "LogHistogram" ) ;
23
24
24
- // Downscale the framebuffer, we don't need an absolute precision to compute the average
25
- // luminance (and it'll make it a tiny bit more stable - bonus side-effect)
26
- var scaleOffsetRes = GetHistogramScaleOffsetRes ( context ) ;
27
-
28
- cmd . GetTemporaryRT ( Uniforms . _AutoExposureCopyTex ,
29
- ( int ) scaleOffsetRes . z ,
30
- ( int ) scaleOffsetRes . w ,
31
- 0 ,
32
- FilterMode . Bilinear ,
33
- context . sourceFormat
34
- ) ;
35
- cmd . BlitFullscreenTriangle ( context . source , Uniforms . _AutoExposureCopyTex ) ;
36
-
37
25
// Clear the buffer on every frame as we use it to accumulate luminance values on each frame
38
26
int kernel = compute . FindKernel ( "KEyeHistogramClear" ) ;
39
27
cmd . SetComputeBufferParam ( compute , kernel , "_HistogramBuffer" , data ) ;
@@ -42,17 +30,14 @@ public void Generate(PostProcessRenderContext context)
42
30
// Get a log histogram
43
31
kernel = compute . FindKernel ( "KEyeHistogram" ) ;
44
32
cmd . SetComputeBufferParam ( compute , kernel , "_HistogramBuffer" , data ) ;
45
- cmd . SetComputeTextureParam ( compute , kernel , "_Source" , Uniforms . _AutoExposureCopyTex ) ;
33
+ cmd . SetComputeTextureParam ( compute , kernel , "_Source" , context . source ) ;
46
34
cmd . SetComputeVectorParam ( compute , "_ScaleOffsetRes" , scaleOffsetRes ) ;
47
35
cmd . DispatchCompute ( compute , kernel ,
48
36
Mathf . CeilToInt ( scaleOffsetRes . z / ( float ) k_ThreadX ) ,
49
37
Mathf . CeilToInt ( scaleOffsetRes . w / ( float ) k_ThreadY ) ,
50
38
1
51
39
) ;
52
40
53
- // Cleanup
54
- cmd . ReleaseTemporaryRT ( Uniforms . _AutoExposureCopyTex ) ;
55
-
56
41
cmd . EndSample ( "LogHistogram" ) ;
57
42
}
58
43
@@ -61,7 +46,7 @@ public Vector4 GetHistogramScaleOffsetRes(PostProcessRenderContext context)
61
46
float diff = rangeMax - rangeMin ;
62
47
float scale = 1f / diff ;
63
48
float offset = - rangeMin * scale ;
64
- return new Vector4 ( scale , offset , Mathf . Floor ( context . width / 2f ) , Mathf . Floor ( context . height / 2f ) ) ;
49
+ return new Vector4 ( scale , offset , context . width , context . height ) ;
65
50
}
66
51
67
52
public void Release ( )
0 commit comments