VisuTwin Canvas
C++ 3D Engine — Metal Backend
Loading...
Searching...
No Matches
renderPassBloom.h
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2025-2026 Arnis Lektauers
3//
4//
5#pragma once
6
7#include <algorithm>
8#include <vector>
9
11
12namespace visutwin::canvas
13{
15 {
16 public:
17 RenderPassBloom(const std::shared_ptr<GraphicsDevice>& device, Texture* sourceTexture, PixelFormat format);
18 ~RenderPassBloom() = default;
19
20 void frameUpdate() const override;
21 void onDisable() override;
22
23 Texture* bloomTexture() const { return _bloomTexture; }
24 void setBlurLevel(const int value) { _blurLevel = std::max(value, 1); }
25
26 private:
27 void destroyRenderTargets(int startIndex = 0);
28 void destroyRenderPasses();
29 std::shared_ptr<RenderTarget> createRenderTarget(int index, std::shared_ptr<Texture>& outTexture) const;
30 void createRenderTargets(int count);
31 int calcMipLevels(uint32_t width, uint32_t height, int minSize) const;
32 void createRenderPasses(int numPasses);
33
34 Texture* _sourceTexture = nullptr;
36 int _blurLevel = 16;
37 std::shared_ptr<RenderTarget> _bloomRenderTarget;
38 Texture* _bloomTexture = nullptr;
39 std::vector<std::shared_ptr<RenderTarget>> _renderTargets;
40
41 // Textures must outlive the RenderTargets that reference them (RenderTarget
42 // stores only a raw Texture*). We keep them alive here.
43 std::shared_ptr<Texture> _bloomColorTexture;
44 std::vector<std::shared_ptr<Texture>> _ownedTextures;
45 };
46}
void setBlurLevel(const int value)
RenderPassBloom(const std::shared_ptr< GraphicsDevice > &device, Texture *sourceTexture, PixelFormat format)
std::shared_ptr< GraphicsDevice > device() const
Definition renderPass.h:124
RenderPass(const std::shared_ptr< GraphicsDevice > &device)
Definition renderPass.h:66
GPU texture resource supporting 2D, cubemap, volume, and array formats with mipmap management.
Definition texture.h:57