@@ -223,9 +223,10 @@ nbl_glsl_ext_FFT_Parameters_t nbl_glsl_ext_FFT_getParameters()
223
223
#include <nbl/builtin/glsl/math/complex.glsl>
224
224
nbl_glsl_complex nbl_glsl_ext_FFT_getPaddedData(in ivec3 coordinate, in uint channel)
225
225
{
226
- ivec2 inputImageSize = textureSize(inputImage,0);
227
- vec2 normalizedCoords = (vec2(coordinate.xy)+vec2(0.5f))/(vec2(inputImageSize)*pc.kernelScale);
228
- vec4 texelValue = textureLod(inputImage, normalizedCoords+vec2(0.5-0.5/pc.kernelScale), -log2(pc.kernelScale));
226
+ const ivec2 inputImageSize = textureSize(inputImage,0);
227
+ const ivec2 halfInputImageSize = inputImageSize>>1;
228
+ const vec2 relativeCoords = vec2(coordinate.xy-halfInputImageSize)/pc.kernelScale;
229
+ const vec4 texelValue = textureLod(inputImage,(relativeCoords+vec2(0.5))/vec2(inputImageSize)+vec2(0.5),-log2(pc.kernelScale));
229
230
return nbl_glsl_complex(texelValue[channel], 0.0f);
230
231
}
231
232
#define _NBL_GLSL_EXT_FFT_GET_PADDED_DATA_DEFINED_
@@ -269,7 +270,8 @@ layout(set=0, binding=3, rg32f) uniform image2D NormalizedKernel[3];
269
270
270
271
layout(push_constant) uniform PushConstants
271
272
{
272
- uvec4 strides;
273
+ uvec3 strides;
274
+ float bloomIntensity;
273
275
uvec4 bitreverse_shift;
274
276
} pc;
275
277
@@ -288,6 +290,8 @@ void main()
288
290
const uvec2 coord = bitfieldReverse(gl_GlobalInvocationID.xy)>>pc.bitreverse_shift.xy;
289
291
const nbl_glsl_complex shift = nbl_glsl_expImaginary(-nbl_glsl_PI*float(coord.x+coord.y));
290
292
value = nbl_glsl_complex_mul(value,shift)/power;
293
+ const float bloomIntensity = 0.95;
294
+ value = value*bloomIntensity+nbl_glsl_complex(1.0-bloomIntensity,0.0);
291
295
imageStore(NormalizedKernel[gl_WorkGroupID.z],ivec2(coord),vec4(value,0.0,0.0));
292
296
}
293
297
)===" ));
@@ -446,6 +450,10 @@ uvec3 nbl_glsl_ext_FFT_Parameters_t_getDimensions()
446
450
{
447
451
return uvec3(pc.data.imageWidth,pc.data.imageHeight,1u);
448
452
}
453
+ uint nbl_glsl_ext_FFT_Parameters_t_getLog2FFTSize()
454
+ {
455
+ return CommonPushConstants_getPassLog2FFTSize(0);
456
+ }
449
457
bool nbl_glsl_ext_FFT_Parameters_t_getIsInverse()
450
458
{
451
459
return false;
@@ -459,7 +467,7 @@ uint nbl_glsl_ext_FFT_Parameters_t_getDirection()
459
467
460
468
void nbl_glsl_ext_FFT_setData(in uvec3 coordinate, in uint channel, in nbl_glsl_complex complex_value)
461
469
{
462
- const uint index = ((channel<<nbl_glsl_ext_FFT_Parameters_t_getLog2FFTSize( ))+coordinate.x)*pc.data.imageHeight+coordinate.y;
470
+ const uint index = ((channel<<CommonPushConstants_getPassLog2FFTSize(0 ))+coordinate.x)*pc.data.imageHeight+coordinate.y;
463
471
outSpectrum[index] = complex_value;
464
472
}
465
473
#define _NBL_GLSL_EXT_FFT_SET_DATA_DEFINED_
@@ -559,7 +567,11 @@ layout(binding=4) uniform sampler2D NormalizedKernel[3];
559
567
560
568
uvec3 nbl_glsl_ext_FFT_Parameters_t_getDimensions()
561
569
{
562
- return uvec3(0x1u<<nbl_glsl_ext_FFT_Parameters_t_getLog2FFTSize(),pc.data.imageHeight,1u);
570
+ return uvec3(0x1u<<CommonPushConstants_getPassLog2FFTSize(0),pc.data.imageHeight,1u);
571
+ }
572
+ uint nbl_glsl_ext_FFT_Parameters_t_getLog2FFTSize()
573
+ {
574
+ return CommonPushConstants_getPassLog2FFTSize(1);
563
575
}
564
576
bool nbl_glsl_ext_FFT_Parameters_t_getIsInverse()
565
577
{
@@ -576,7 +588,7 @@ nbl_glsl_complex nbl_glsl_ext_FFT_getPaddedData(ivec3 coordinate, in uint channe
576
588
#define _NBL_GLSL_EXT_FFT_GET_PADDED_DATA_DEFINED_
577
589
void nbl_glsl_ext_FFT_setData(in uvec3 coordinate, in uint channel, in nbl_glsl_complex complex_value)
578
590
{
579
- const uint index = ((channel<<nbl_glsl_ext_FFT_Parameters_t_getLog2FFTSize( ))+coordinate.x)*pc.data.imageHeight+coordinate.y;
591
+ const uint index = ((channel<<CommonPushConstants_getPassLog2FFTSize(0 ))+coordinate.x)*pc.data.imageHeight+coordinate.y;
580
592
spectrum[index] = complex_value;
581
593
}
582
594
#define _NBL_GLSL_EXT_FFT_SET_DATA_DEFINED_
@@ -642,7 +654,7 @@ nbl_glsl_complex nbl_glsl_ext_FFT_getPaddedData(ivec3 coordinate, in uint channe
642
654
{
643
655
if (!nbl_glsl_ext_FFT_wrap_coord(coordinate))
644
656
return nbl_glsl_complex(0.f,0.f);
645
- const uint index = ((channel<<nbl_glsl_ext_FFT_Parameters_t_getLog2FFTSize( ))+coordinate.x)*pc.data.imageHeight+coordinate.y;
657
+ const uint index = ((channel<<CommonPushConstants_getPassLog2FFTSize(0 ))+coordinate.x)*pc.data.imageHeight+coordinate.y;
646
658
return spectrum[index];
647
659
}
648
660
)===" ));
@@ -680,7 +692,11 @@ nbl_glsl_complex nbl_glsl_ext_FFT_getPaddedData(ivec3 coordinate, in uint channe
680
692
681
693
uvec3 nbl_glsl_ext_FFT_Parameters_t_getDimensions()
682
694
{
683
- return uvec3(0x1u<<nbl_glsl_ext_FFT_Parameters_t_getLog2FFTSize(),pc.data.imageHeight,1u);
695
+ return uvec3(0x1u<<CommonPushConstants_getPassLog2FFTSize(0),pc.data.imageHeight,1u);
696
+ }
697
+ uint nbl_glsl_ext_FFT_Parameters_t_getLog2FFTSize()
698
+ {
699
+ return CommonPushConstants_getPassLog2FFTSize(0);
684
700
}
685
701
bool nbl_glsl_ext_FFT_Parameters_t_getIsInverse()
686
702
{
@@ -772,7 +788,7 @@ nbl_glsl_complex nbl_glsl_ext_FFT_getPaddedData(ivec3 coordinate, in uint channe
772
788
{
773
789
if (!nbl_glsl_ext_FFT_wrap_coord(coordinate))
774
790
return nbl_glsl_complex(0.f,0.f);
775
- const uint index = ((channel<<nbl_glsl_ext_FFT_Parameters_t_getLog2FFTSize( ))+coordinate.x)*pc.data.imageHeight+coordinate.y;
791
+ const uint index = ((channel<<CommonPushConstants_getPassLog2FFTSize(0 ))+coordinate.x)*pc.data.imageHeight+coordinate.y;
776
792
return inSpectrum[index];
777
793
}
778
794
)===" ));
@@ -1018,9 +1034,9 @@ nbl_glsl_complex nbl_glsl_ext_FFT_getPaddedData(ivec3 coordinate, in uint channe
1018
1034
}
1019
1035
1020
1036
const auto & kerDim = outParam.kernel ->getCreationParameters ().extent ;
1021
- const float bloomScale = core::min (float (extent.width )/ float (kerDim.width ),float (extent.height )/ float (kerDim.height ))*bloomScaleBundle[i].value ();
1037
+ const float bloomScale = core::min (float (extent.width ) / float (kerDim.width ), float (extent.height ) / float (kerDim.height ))* bloomScaleBundle[i].value ();
1022
1038
if (bloomScale>1 .f )
1023
- os::Printer::log (imageIDString + " Bloom Kernel will Clip and loose sharpness, increase resolution of bloom kernel!" , ELL_WARNING);
1039
+ os::Printer::log (imageIDString + " Bloom Kernel loose sharpness, increase resolution of bloom kernel!" , ELL_WARNING);
1024
1040
const auto marginSrcDim = [extent,kerDim,bloomScale]() -> auto
1025
1041
{
1026
1042
auto tmp = extent;
@@ -1170,12 +1186,13 @@ nbl_glsl_complex nbl_glsl_ext_FFT_getPaddedData(ivec3 coordinate, in uint channe
1170
1186
{
1171
1187
shaderConstants.imageWidth = param.width ;
1172
1188
shaderConstants.imageHeight = param.height ;
1173
- assert (intensityBufferOffset%IntensityValuesSize==0u );
1174
1189
1190
+ assert (intensityBufferOffset%IntensityValuesSize==0u );
1175
1191
shaderConstants.intensityBufferDWORDOffset = intensityBufferOffset/IntensityValuesSize;
1176
1192
shaderConstants.denoiserExposureBias = denoiserExposureBiasBundle[i].value ();
1177
1193
1178
- shaderConstants.flags = 0b11u ; // (autoexposureOn<<1)|beforeDenoise
1194
+ assert (param.fftPushConstants [0 ].getLog2FFTSize ()==param.fftPushConstants [2 ].getLog2FFTSize ());
1195
+ shaderConstants.flags = (param.fftPushConstants [1 ].getLog2FFTSize ()<<7u )|(param.fftPushConstants [0 ].getLog2FFTSize ()<<2u )|0b11u ; // (autoexposureOn<<1)|beforeDenoise
1179
1196
switch (tonemapperBundle[i].first )
1180
1197
{
1181
1198
case DTEA_TONEMAPPER_REINHARD:
@@ -1216,7 +1233,7 @@ nbl_glsl_complex nbl_glsl_ext_FFT_getPaddedData(ivec3 coordinate, in uint channe
1216
1233
if (core::isnan (key))
1217
1234
{
1218
1235
shaderConstants.tonemapperParams [0 ] = 0.18 ;
1219
- shaderConstants.flags &= 0b01u ; // ~(autoexposureOn<<1)
1236
+ shaderConstants.flags &= ~ 0b10u ; // ~(autoexposureOn<<1)
1220
1237
}
1221
1238
else
1222
1239
shaderConstants.tonemapperParams [0 ] = key;
@@ -1532,7 +1549,7 @@ nbl_glsl_complex nbl_glsl_ext_FFT_getPaddedData(ivec3 coordinate, in uint channe
1532
1549
// compute post-processing
1533
1550
{
1534
1551
// let the shaders know we're in the second phase now
1535
- shaderConstants.flags &= 0b10u ;
1552
+ shaderConstants.flags &= ~ 0b01u ;
1536
1553
driver->pushConstants (sharedPipelineLayout.get (), video::IGPUSpecializedShader::ESS_COMPUTE, offsetof (CommonPushConstants,flags), sizeof (uint32_t ), &shaderConstants.flags );
1537
1554
// Bloom
1538
1555
uint32_t workgroupCounts[2 ] = { (param.width +kComputeWGSize -1u )/kComputeWGSize ,param.height };
0 commit comments