@@ -87,18 +87,19 @@ public override void Render(PostProcessRenderContext context)
87
87
// Apply auto exposure adjustment in the prefiltering pass
88
88
sheet . properties . SetTexture ( ShaderIDs . AutoExposureTex , context . autoExposureTexture ) ;
89
89
90
- // Determine the iteration count
91
- float logh = Mathf . Log ( context . height , 2f ) + Mathf . Min ( settings . diffusion . value , 10f ) - 10f ;
92
- int logh_i = Mathf . FloorToInt ( logh ) ;
93
- int iterations = Mathf . Clamp ( logh_i , 1 , k_MaxPyramidSize ) ;
94
- float sampleScale = 0.5f + logh - logh_i ;
95
- sheet . properties . SetFloat ( ShaderIDs . SampleScale , sampleScale ) ;
96
-
97
90
// Do bloom on a half-res buffer, full-res doesn't bring much and kills performances on
98
91
// fillrate limited platforms
99
92
int tw = context . width / 2 ;
100
93
int th = context . height / 2 ;
101
94
95
+ // Determine the iteration count
96
+ int s = Mathf . Max ( tw , th ) ;
97
+ float logs = Mathf . Log ( s , 2f ) + Mathf . Min ( settings . diffusion . value , 10f ) - 10f ;
98
+ int logs_i = Mathf . FloorToInt ( logs ) ;
99
+ int iterations = Mathf . Clamp ( logs_i , 1 , k_MaxPyramidSize ) ;
100
+ float sampleScale = 0.5f + logs - logs_i ;
101
+ sheet . properties . SetFloat ( ShaderIDs . SampleScale , sampleScale ) ;
102
+
102
103
// Prefiltering parameters
103
104
float lthresh = Mathf . GammaToLinearSpace ( settings . threshold . value ) ;
104
105
float knee = lthresh * settings . softKnee . value + 1e-5f ;
@@ -122,7 +123,8 @@ public override void Render(PostProcessRenderContext context)
122
123
cmd . BlitFullscreenTriangle ( last , mipDown , sheet , pass ) ;
123
124
124
125
last = mipDown ;
125
- tw /= 2 ; th /= 2 ;
126
+ tw = Mathf . Max ( tw / 2 , 1 ) ;
127
+ th = Mathf . Max ( th / 2 , 1 ) ;
126
128
}
127
129
128
130
// Upsample
0 commit comments