Overte C++ Documentation
BloomEffect.h
1 //
2 // BloomEffect.h
3 // render-utils/src/
4 //
5 // Created by Olivier Prat on 09/25/17.
6 // Copyright 2017 High Fidelity, Inc.
7 //
8 // Distributed under the Apache License, Version 2.0.
9 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
10 //
11 
12 #ifndef hifi_render_utils_BloomEffect_h
13 #define hifi_render_utils_BloomEffect_h
14 
15 #include <render/Engine.h>
16 
17 #include "BloomStage.h"
18 
19 #include "DeferredFrameTransform.h"
20 #include "LightingModel.h"
21 
22 class BloomConfig : public render::Task::Config {
23  Q_OBJECT
24 };
25 
26 class BloomThresholdConfig : public render::Job::Config {
27  Q_OBJECT
28 };
29 
30 class BloomThreshold {
31 public:
32  using Inputs = render::VaryingSet4<DeferredFrameTransformPointer, gpu::FramebufferPointer, BloomStage::FramePointer, LightingModelPointer>;
33  using Outputs = render::VaryingSet3<gpu::FramebufferPointer, float, graphics::BloomPointer>;
34  using Config = BloomThresholdConfig;
35  using JobModel = render::Job::ModelIO<BloomThreshold, Inputs, Outputs, Config>;
36 
37  BloomThreshold(unsigned int downsamplingFactor);
38 
39  void configure(const Config& config);
40  void run(const render::RenderContextPointer& renderContext, const Inputs& inputs, Outputs& outputs);
41 
42 private:
43 
44 #include "BloomThreshold.shared.slh"
45 
46  gpu::FramebufferPointer _outputBuffer;
47  gpu::PipelinePointer _pipeline;
48  gpu::StructBuffer<Parameters> _parameters;
49 };
50 
51 
52 class BloomApplyConfig : public render::Job::Config {
53  Q_OBJECT
54 };
55 
56 class BloomApply {
57 public:
58  using Inputs = render::VaryingSet5<gpu::FramebufferPointer, gpu::FramebufferPointer, gpu::FramebufferPointer, gpu::FramebufferPointer, graphics::BloomPointer>;
59  using Config = BloomApplyConfig;
60  using JobModel = render::Job::ModelI<BloomApply, Inputs, Config>;
61 
62  BloomApply();
63 
64  void configure(const Config& config);
65  void run(const render::RenderContextPointer& renderContext, const Inputs& inputs);
66 
67 private:
68 
69 #include "BloomApply.shared.slh"
70 
71  gpu::PipelinePointer _pipeline;
72  gpu::StructBuffer<Parameters> _parameters;
73 };
74 
75 class BloomDraw {
76 public:
77  using Inputs = render::VaryingSet2<gpu::FramebufferPointer, gpu::FramebufferPointer>;
78  using JobModel = render::Job::ModelI<BloomDraw, Inputs>;
79 
80  BloomDraw() {}
81 
82  void run(const render::RenderContextPointer& renderContext, const Inputs& inputs);
83 
84 private:
85 
86  gpu::PipelinePointer _pipeline;
87 };
88 
89 class DebugBloomConfig : public render::Job::Config {
90  Q_OBJECT
91  Q_PROPERTY(int mode READ getMode WRITE setMode NOTIFY dirty)
92 
93 public:
94 
95  enum Mode {
96  OFF = 0,
97  MODE_LEVEL0,
98  MODE_LEVEL1,
99  MODE_LEVEL2,
100  MODE_ALL_LEVELS,
101 
102  MODE_COUNT
103  };
104 
105  DebugBloomConfig() : render::Job::Config(false) {}
106 
107  void setMode(int mode);
108  int getMode() const { return _mode; }
109 
110  int _mode{ MODE_ALL_LEVELS };
111 
112 signals:
113  void dirty();
114 };
115 
116 class DebugBloom {
117 public:
118  using Inputs = render::VaryingSet5<gpu::FramebufferPointer, gpu::FramebufferPointer, gpu::FramebufferPointer, gpu::FramebufferPointer, gpu::FramebufferPointer>;
119  using Config = DebugBloomConfig;
120  using JobModel = render::Job::ModelI<DebugBloom, Inputs, Config>;
121 
122  DebugBloom();
123 
124  void configure(const Config& config);
125  void run(const render::RenderContextPointer& renderContext, const Inputs& inputs);
126 
127 private:
128  gpu::PipelinePointer _pipeline;
129  gpu::BufferPointer _params;
130  DebugBloomConfig::Mode _mode;
131 };
132 
133 class BloomEffect {
134 public:
135  using Inputs = render::VaryingSet4<DeferredFrameTransformPointer, gpu::FramebufferPointer, BloomStage::FramePointer, LightingModelPointer>;
136  using Config = BloomConfig;
137  using JobModel = render::Task::ModelI<BloomEffect, Inputs, Config>;
138 
139  BloomEffect();
140 
141  void configure(const Config& config);
142  void build(JobModel& task, const render::Varying& inputs, render::Varying& outputs);
143 
144 };
145 
146 #endif // hifi_render_utils_BloomEffect_h