11 #ifndef hifi_render_utils_HazeStage_h
12 #define hifi_render_utils_HazeStage_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/Haze.h>
25 class HazeStage :
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 HazePointer = graphics::HazePointer;
35 using Hazes = render::indexed_container::IndexedPointerVector<graphics::Haze>;
36 using HazeMap = std::unordered_map<HazePointer, Index>;
38 using HazeIndices = std::vector<Index>;
40 Index findHaze(
const HazePointer& haze)
const;
41 Index addHaze(
const HazePointer& haze);
43 HazePointer removeHaze(Index index);
45 bool checkHazeId(Index index)
const {
return _hazes.checkIndex(index); }
47 Index getNumHazes()
const {
return _hazes.getNumElements(); }
48 Index getNumFreeHazes()
const {
return _hazes.getNumFreeIndices(); }
49 Index getNumAllocatedHazes()
const {
return _hazes.getNumAllocatedIndices(); }
51 HazePointer getHaze(Index hazeId)
const {
52 return _hazes.get(hazeId);
62 void clear() { _hazes.clear(); }
64 void pushHaze(HazeStage::Index index) { _hazes.emplace_back(index); }
66 HazeStage::HazeIndices _hazes;
68 using FramePointer = std::shared_ptr<Frame>;
72 using HazeStagePointer = std::shared_ptr<HazeStage>;
74 class HazeStageSetup {
76 using JobModel = render::Job::Model<HazeStageSetup>;
79 void run(
const render::RenderContextPointer& renderContext);
84 class FetchHazeConfig :
public render::Job::Config {
87 Q_PROPERTY(glm::vec3 hazeColor MEMBER hazeColor WRITE setHazeColor NOTIFY dirty);
88 Q_PROPERTY(
float hazeGlareAngle MEMBER hazeGlareAngle WRITE setHazeGlareAngle NOTIFY dirty);
90 Q_PROPERTY(glm::vec3 hazeGlareColor MEMBER hazeGlareColor WRITE setHazeGlareColor NOTIFY dirty);
91 Q_PROPERTY(
float hazeBaseReference MEMBER hazeBaseReference WRITE setHazeBaseReference NOTIFY dirty);
93 Q_PROPERTY(
bool isHazeActive MEMBER isHazeActive WRITE setHazeActive NOTIFY dirty);
94 Q_PROPERTY(
bool isAltitudeBased MEMBER isAltitudeBased WRITE setAltitudeBased NOTIFY dirty);
95 Q_PROPERTY(
bool isHazeAttenuateKeyLight MEMBER isHazeAttenuateKeyLight WRITE setHazeAttenuateKeyLight NOTIFY dirty);
96 Q_PROPERTY(
bool isModulateColorActive MEMBER isModulateColorActive WRITE setModulateColorActive NOTIFY dirty);
97 Q_PROPERTY(
bool isHazeEnableGlare MEMBER isHazeEnableGlare WRITE setHazeEnableGlare NOTIFY dirty);
99 Q_PROPERTY(
float hazeRange MEMBER hazeRange WRITE setHazeRange NOTIFY dirty);
100 Q_PROPERTY(
float hazeHeight MEMBER hazeHeight WRITE setHazeAltitude NOTIFY dirty);
102 Q_PROPERTY(
float hazeKeyLightRange MEMBER hazeKeyLightRange WRITE setHazeKeyLightRange NOTIFY dirty);
103 Q_PROPERTY(
float hazeKeyLightAltitude MEMBER hazeKeyLightAltitude WRITE setHazeKeyLightAltitude NOTIFY dirty);
105 Q_PROPERTY(
float hazeBackgroundBlend MEMBER hazeBackgroundBlend WRITE setHazeBackgroundBlend NOTIFY dirty);
108 FetchHazeConfig() : render::Job::Config() {}
110 glm::vec3 hazeColor{ graphics::Haze::INITIAL_HAZE_COLOR };
111 float hazeGlareAngle{ graphics::Haze::INITIAL_HAZE_GLARE_ANGLE };
113 glm::vec3 hazeGlareColor{ graphics::Haze::INITIAL_HAZE_GLARE_COLOR };
114 float hazeBaseReference{ graphics::Haze::INITIAL_HAZE_BASE_REFERENCE };
116 bool isHazeActive{
false };
117 bool isAltitudeBased{
false };
118 bool isHazeAttenuateKeyLight{
false };
119 bool isModulateColorActive{
false };
120 bool isHazeEnableGlare{
false };
122 float hazeRange{ graphics::Haze::INITIAL_HAZE_RANGE };
123 float hazeHeight{ graphics::Haze::INITIAL_HAZE_HEIGHT };
125 float hazeKeyLightRange{ graphics::Haze::INITIAL_KEY_LIGHT_RANGE };
126 float hazeKeyLightAltitude{ graphics::Haze::INITIAL_KEY_LIGHT_ALTITUDE };
128 float hazeBackgroundBlend{ graphics::Haze::INITIAL_HAZE_BACKGROUND_BLEND };
131 void setHazeColor(
const glm::vec3 value) { hazeColor = value; emit dirty(); }
132 void setHazeGlareAngle(
const float value) { hazeGlareAngle = value; emit dirty(); }
134 void setHazeGlareColor(
const glm::vec3 value) { hazeGlareColor = value; emit dirty(); }
135 void setHazeBaseReference(
const float value) { hazeBaseReference = value; ; emit dirty(); }
137 void setHazeActive(
const bool active) { isHazeActive = active; emit dirty(); }
138 void setAltitudeBased(
const bool active) { isAltitudeBased = active; emit dirty(); }
139 void setHazeAttenuateKeyLight(
const bool active) { isHazeAttenuateKeyLight = active; emit dirty(); }
140 void setModulateColorActive(
const bool active) { isModulateColorActive = active; emit dirty(); }
141 void setHazeEnableGlare(
const bool active) { isHazeEnableGlare = active; emit dirty(); }
143 void setHazeRange(
const float value) { hazeRange = value; emit dirty(); }
144 void setHazeAltitude(
const float value) { hazeHeight = value; emit dirty(); }
146 void setHazeKeyLightRange(
const float value) { hazeKeyLightRange = value; emit dirty(); }
147 void setHazeKeyLightAltitude(
const float value) { hazeKeyLightAltitude = value; emit dirty(); }
149 void setHazeBackgroundBlend(
const float value) { hazeBackgroundBlend = value; ; emit dirty(); }