VisuTwin Canvas
C++ 3D Engine — Metal Backend
Loading...
Searching...
No Matches
renderPassDepthAwareBlur.cpp
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2025-2026 Arnis Lektauers
3//
4//
6
9#include "scene/camera.h"
10
11namespace visutwin::canvas
12{
13 RenderPassDepthAwareBlur::RenderPassDepthAwareBlur(const std::shared_ptr<GraphicsDevice>& device,
14 Texture* sourceTexture, CameraComponent* cameraComponent, const bool horizontal)
15 : RenderPassShaderQuad(device), _sourceTexture(sourceTexture),
16 _cameraComponent(cameraComponent), _horizontal(horizontal)
17 {
18 }
19
21 {
22 const auto gd = device();
23 if (!gd || !_sourceTexture || !_cameraComponent || !_cameraComponent->camera()) {
24 return;
25 }
26
27 Texture* depthTexture = gd->sceneDepthMap();
28 if (!depthTexture) {
29 return;
30 }
31
32 const auto rt = renderTarget();
33 if (!rt || !rt->colorBuffer()) {
34 return;
35 }
36
37 const auto* camera = _cameraComponent->camera();
38
40 params.sourceTexture = _sourceTexture;
41 params.depthTexture = depthTexture;
42 params.filterSize = 8;
43 params.sourceInvResolutionX = 1.0f / static_cast<float>(rt->colorBuffer()->width());
44 params.sourceInvResolutionY = 1.0f / static_cast<float>(rt->colorBuffer()->height());
45 params.cameraNear = camera->nearClip();
46 params.cameraFar = camera->farClip();
47
48 gd->executeDepthAwareBlurPass(params, _horizontal);
49 }
50}
RenderPassDepthAwareBlur(const std::shared_ptr< GraphicsDevice > &device, Texture *sourceTexture, CameraComponent *cameraComponent, bool horizontal)
std::shared_ptr< RenderTarget > renderTarget() const
Definition renderPass.h:98
std::shared_ptr< GraphicsDevice > device() const
Definition renderPass.h:124
RenderPassShaderQuad(const std::shared_ptr< GraphicsDevice > &device)
GPU texture resource supporting 2D, cubemap, volume, and array formats with mipmap management.
Definition texture.h:57