Skip to content

Commit dd73f5b

Browse files
finally, scale and resolution independence
1 parent 3fbe013 commit dd73f5b

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

examples_tests/49.ComputeFFT/main.cpp

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ int main()
190190

191191
IAssetLoader::SAssetLoadParams lp;
192192
auto srcImageBundle = am->getAsset("../../media/colorexr.exr", lp);
193-
auto kerImageBundle = am->getAsset("../../media/kernels/physical_flare_512.exr", lp);
193+
auto kerImageBundle = am->getAsset("../../media/kernels/physical_flare_256.exr", lp);
194194

195195
// get GPU image views
196196
smart_refctd_ptr<IGPUImageView> srcImageView;
@@ -234,8 +234,6 @@ int main()
234234
srcNumChannels = channelCountOverride;
235235
kerNumChannels = channelCountOverride;
236236
assert(srcNumChannels == kerNumChannels); // Just to make sure, because the other case is not handled in this example
237-
238-
const auto srcDim = srcImageView->getCreationParameters().image->getCreationParameters().extent;
239237

240238
// Create Out Image
241239
smart_refctd_ptr<IGPUImage> outImg;
@@ -362,14 +360,21 @@ int main()
362360
);
363361
}();
364362

365-
float bloomScale = 0.125f;
363+
const float bloomRelativeScale = 0.25f;
366364
const auto kerDim = kerImageView->getCreationParameters().image->getCreationParameters().extent;
365+
const auto srcDim = srcImageView->getCreationParameters().image->getCreationParameters().extent;
366+
const float bloomScale = core::min(float(srcDim.width)/float(kerDim.width),float(srcDim.height)/float(kerDim.height))*bloomRelativeScale;
367+
if (bloomScale>1.f)
368+
std::cout << "WARNING: Bloom Kernel will Clip and loose sharpness, increase resolution of bloom kernel!" << std::endl;
367369
const auto marginSrcDim = [srcDim,kerDim,bloomScale]() -> auto
368370
{
369371
auto tmp = srcDim;
370-
tmp.width += core::max(kerDim.width*bloomScale,1u)-1u;
371-
tmp.height += core::max(kerDim.height*bloomScale,1u)-1u;
372-
tmp.depth += core::max(kerDim.depth*bloomScale,1u)-1u;
372+
for (auto i=0u; i<3u; i++)
373+
{
374+
const auto coord = (&kerDim.width)[i];
375+
if (coord>1u)
376+
(&tmp.width)[i] += core::max(coord*bloomScale,1u)-1u;
377+
}
373378
return tmp;
374379
}();
375380
constexpr bool useHalfFloats = true;

0 commit comments

Comments
 (0)