12 #ifndef hifi_model_Haze_h
13 #define hifi_model_Haze_h
15 #include <glm/glm.hpp>
16 #include <gpu/Resource.h>
18 #include "Transform.h"
19 #include "NumericalConstants.h"
28 static const float INITIAL_HAZE_RANGE;
29 static const float INITIAL_HAZE_HEIGHT;
31 static const float INITIAL_KEY_LIGHT_RANGE;
32 static const float INITIAL_KEY_LIGHT_ALTITUDE;
34 static const float INITIAL_HAZE_BACKGROUND_BLEND;
36 static const glm::vec3 INITIAL_HAZE_COLOR;
38 static const float INITIAL_HAZE_GLARE_ANGLE;
40 static const glm::vec3 INITIAL_HAZE_GLARE_COLOR;
42 static const float INITIAL_HAZE_BASE_REFERENCE;
44 static const float LOG_P_005;
45 static const float LOG_P_05;
51 static inline glm::vec3 convertHazeRangeToHazeRangeFactor(
const glm::vec3 hazeRange) {
53 -LOG_P_005 / hazeRange.x,
54 -LOG_P_005 / hazeRange.y,
55 -LOG_P_005 / hazeRange.z);
59 static inline float convertHazeRangeToHazeRangeFactor(
const float hazeRange) {
return -LOG_P_005 / glm::max(hazeRange, 1.0f); }
61 static inline float convertHazeAltitudeToHazeAltitudeFactor(
const float hazeHeight) {
return -(LOG_P_005 * glm::sign(hazeHeight)) / glm::max(glm::abs(hazeHeight), 1.0f); }
69 static inline float convertGlareAngleToPower(
const float hazeGlareAngle) {
70 const float GLARE_ANGLE_LIMIT = 0.1f;
71 return LOG_P_05 / logf(cosf(RADIANS_PER_DEGREE * glm::max(GLARE_ANGLE_LIMIT, hazeGlareAngle)));
76 void setHazeColor(
const glm::vec3 hazeColor);
77 void setHazeGlareBlend(
const float hazeGlareBlend);
79 void setHazeGlareColor(
const glm::vec3 hazeGlareColor);
80 void setHazeBaseReference(
const float hazeBaseReference);
82 void setHazeActive(
const bool isHazeActive);
83 void setAltitudeBased(
const bool isAltitudeBased);
84 void setHazeAttenuateKeyLight(
const bool isHazeAttenuateKeyLight);
85 void setModulateColorActive(
const bool isModulateColorActive);
86 void setHazeEnableGlare(
const bool isHazeEnableGlare);
88 void setHazeRangeFactor(
const float hazeRange);
89 void setHazeAltitudeFactor(
const float hazeAltitude);
91 void setHazeKeyLightRangeFactor(
const float hazeKeyLightRange);
92 void setHazeKeyLightAltitudeFactor(
const float hazeKeyLightAltitude);
94 void setHazeBackgroundBlend(
const float hazeBackgroundBlend);
96 using UniformBufferView = gpu::BufferView;
97 UniformBufferView getHazeParametersBuffer()
const {
return _hazeParametersBuffer; }
99 bool isActive()
const;
105 glm::vec3 hazeColor { INITIAL_HAZE_COLOR };
106 float hazeGlareBlend { convertGlareAngleToPower(INITIAL_HAZE_GLARE_ANGLE) };
108 glm::vec3 hazeGlareColor { INITIAL_HAZE_GLARE_COLOR };
109 float hazeBaseReference { INITIAL_HAZE_BASE_REFERENCE };
111 glm::vec3 colorModulationFactor;
118 #if defined(__clang__)
119 __attribute__((unused))
124 float hazeBackgroundBlend { INITIAL_HAZE_BACKGROUND_BLEND };
126 float hazeRangeFactor { convertHazeRangeToHazeRangeFactor(INITIAL_HAZE_RANGE) };
127 float hazeHeightFactor { convertHazeAltitudeToHazeAltitudeFactor(INITIAL_HAZE_HEIGHT) };
128 float hazeKeyLightRangeFactor { convertHazeRangeToHazeRangeFactor(INITIAL_KEY_LIGHT_RANGE) };
130 float hazeKeyLightAltitudeFactor { convertHazeAltitudeToHazeAltitudeFactor(INITIAL_KEY_LIGHT_ALTITUDE) };
135 UniformBufferView _hazeParametersBuffer {
nullptr };
138 using HazePointer = std::shared_ptr<Haze>;