11 #ifndef hifi_render_utils_BloomStage_h
12 #define hifi_render_utils_BloomStage_h
14 #include <graphics/Stage.h>
16 #include <unordered_map>
17 #include <render/IndexedContainer.h>
18 #include <render/Stage.h>
20 #include <render/Forward.h>
21 #include <render/DrawTask.h>
22 #include <graphics/Bloom.h>
25 class BloomStage :
public render::Stage {
27 static std::string _stageName;
28 static const std::string& getName() {
return _stageName; }
30 using Index = render::indexed_container::Index;
31 static const Index INVALID_INDEX;
32 static bool isIndexInvalid(Index index) {
return index == INVALID_INDEX; }
34 using BloomPointer = graphics::BloomPointer;
35 using Blooms = render::indexed_container::IndexedPointerVector<graphics::Bloom>;
36 using BloomMap = std::unordered_map<BloomPointer, Index>;
38 using BloomIndices = std::vector<Index>;
40 Index findBloom(
const BloomPointer& bloom)
const;
41 Index addBloom(
const BloomPointer& bloom);
43 BloomPointer removeBloom(Index index);
45 bool checkBloomId(Index index)
const {
return _blooms.checkIndex(index); }
47 Index getNumBlooms()
const {
return _blooms.getNumElements(); }
48 Index getNumFreeBlooms()
const {
return _blooms.getNumFreeIndices(); }
49 Index getNumAllocatedBlooms()
const {
return _blooms.getNumAllocatedIndices(); }
51 BloomPointer getBloom(Index bloomId)
const {
52 return _blooms.get(bloomId);
62 void clear() { _blooms.clear(); }
64 void pushBloom(BloomStage::Index index) { _blooms.emplace_back(index); }
66 BloomStage::BloomIndices _blooms;
68 using FramePointer = std::shared_ptr<Frame>;
72 using BloomStagePointer = std::shared_ptr<BloomStage>;
74 class BloomStageSetup {
76 using JobModel = render::Job::Model<BloomStageSetup>;
79 void run(
const render::RenderContextPointer& renderContext);
84 class FetchBloomConfig :
public render::Job::Config {
86 Q_PROPERTY(
float bloomIntensity MEMBER bloomIntensity WRITE setBloomIntensity NOTIFY dirty);
87 Q_PROPERTY(
float bloomThreshold MEMBER bloomThreshold WRITE setBloomThreshold NOTIFY dirty);
88 Q_PROPERTY(
float bloomSize MEMBER bloomSize WRITE setBloomSize NOTIFY dirty);
91 FetchBloomConfig() : render::Job::Config() {}
93 float bloomIntensity { graphics::Bloom::INITIAL_BLOOM_INTENSITY };
94 float bloomThreshold { graphics::Bloom::INITIAL_BLOOM_THRESHOLD };
95 float bloomSize { graphics::Bloom::INITIAL_BLOOM_SIZE };
98 void setBloomIntensity(
const float value) { bloomIntensity = value; emit dirty(); }
99 void setBloomThreshold(
const float value) { bloomThreshold = value; emit dirty(); }
100 void setBloomSize(
const float value) { bloomSize = value; emit dirty(); }