24 _cameraComponent(cameraComponent), _blurEnabled(blurEnabled)
28 _ssaoRenderTarget = createSsaoRenderTarget(
"SsaoFinalTexture", _ssaoTexture);
30 auto options = std::make_shared<RenderPassOptions>();
31 options->resizeSource = std::shared_ptr<Texture>(_sourceTexture, [](
Texture*) {});
32 init(_ssaoRenderTarget, options);
35 const Color clearWhite(1.0f, 1.0f, 1.0f, 1.0f);
40 _blurTempRenderTarget = createSsaoRenderTarget(
"SsaoTempTexture", _blurTempTexture);
43 _blurPassH = std::make_shared<RenderPassDepthAwareBlur>(
44 device, _ssaoTexture.get(), _cameraComponent,
true);
45 auto blurHOptions = std::make_shared<RenderPassOptions>();
46 blurHOptions->resizeSource = _ssaoTexture;
47 _blurPassH->init(_blurTempRenderTarget, blurHOptions);
48 const Color clearBlack(0.0f, 0.0f, 0.0f, 0.0f);
49 _blurPassH->setClearColor(&clearBlack);
53 _blurPassV = std::make_shared<RenderPassDepthAwareBlur>(
54 device, _blurTempTexture.get(), _cameraComponent,
false);
55 auto blurVOptions = std::make_shared<RenderPassOptions>();
56 blurVOptions->resizeSource = _ssaoTexture;
57 _blurPassV->init(_ssaoRenderTarget, blurVOptions);
58 _blurPassV->setClearColor(&clearBlack);
92 if (!gd || !_cameraComponent || !_cameraComponent->camera()) {
97 Texture* depthTexture = gd->sceneDepthMap();
102 const auto* camera = _cameraComponent->camera();
104 if (!rt || !rt->colorBuffer()) {
108 const auto width =
static_cast<float>(rt->colorBuffer()->width());
109 const auto height =
static_cast<float>(rt->colorBuffer()->height());
111 if (width <= 0.0f || height <= 0.0f) {
116 const float aspect = width / height;
117 const float spiralTurns = 10.0f;
118 const float step = (1.0f / (
static_cast<float>(
sampleCount) - 0.5f)) * spiralTurns * 2.0f *
PI;
121 const float bias = 0.001f;
122 const float peak = 0.1f * effectiveRadius;
124 const float projectionScale = 0.5f * (_sourceTexture ?
static_cast<float>(_sourceTexture->height()) : height);
130 _blueNoiseValue =
static_cast<float>(std::rand()) /
static_cast<float>(RAND_MAX);
132 _blueNoiseValue = 0.0f;
147 params.
peak2 = peak * peak;
155 gd->executeSsaoPass(params);
GPU texture resource supporting 2D, cubemap, volume, and array formats with mipmap management.