11 #ifndef hifi_model_Haze_h
12 #define hifi_model_Haze_h
14 #include <glm/glm.hpp>
15 #include <gpu/Resource.h>
17 #include "Transform.h"
18 #include "NumericalConstants.h"
27 static const float INITIAL_HAZE_RANGE;
28 static const float INITIAL_HAZE_HEIGHT;
30 static const float INITIAL_KEY_LIGHT_RANGE;
31 static const float INITIAL_KEY_LIGHT_ALTITUDE;
33 static const float INITIAL_HAZE_BACKGROUND_BLEND;
35 static const glm::vec3 INITIAL_HAZE_COLOR;
37 static const float INITIAL_HAZE_GLARE_ANGLE;
39 static const glm::vec3 INITIAL_HAZE_GLARE_COLOR;
41 static const float INITIAL_HAZE_BASE_REFERENCE;
43 static const float LOG_P_005;
44 static const float LOG_P_05;
50 static inline glm::vec3 convertHazeRangeToHazeRangeFactor(
const glm::vec3 hazeRange) {
52 -LOG_P_005 / hazeRange.x,
53 -LOG_P_005 / hazeRange.y,
54 -LOG_P_005 / hazeRange.z);
58 static inline float convertHazeRangeToHazeRangeFactor(
const float hazeRange) {
return -LOG_P_005 / glm::max(hazeRange, 1.0f); }
60 static inline float convertHazeAltitudeToHazeAltitudeFactor(
const float hazeHeight) {
return -(LOG_P_005 * glm::sign(hazeHeight)) / glm::max(glm::abs(hazeHeight), 1.0f); }
68 static inline float convertGlareAngleToPower(
const float hazeGlareAngle) {
69 const float GLARE_ANGLE_LIMIT = 0.1f;
70 return LOG_P_05 / logf(cosf(RADIANS_PER_DEGREE * glm::max(GLARE_ANGLE_LIMIT, hazeGlareAngle)));
75 void setHazeColor(
const glm::vec3 hazeColor);
76 void setHazeGlareBlend(
const float hazeGlareBlend);
78 void setHazeGlareColor(
const glm::vec3 hazeGlareColor);
79 void setHazeBaseReference(
const float hazeBaseReference);
81 void setHazeActive(
const bool isHazeActive);
82 void setAltitudeBased(
const bool isAltitudeBased);
83 void setHazeAttenuateKeyLight(
const bool isHazeAttenuateKeyLight);
84 void setModulateColorActive(
const bool isModulateColorActive);
85 void setHazeEnableGlare(
const bool isHazeEnableGlare);
87 void setHazeRangeFactor(
const float hazeRange);
88 void setHazeAltitudeFactor(
const float hazeAltitude);
90 void setHazeKeyLightRangeFactor(
const float hazeKeyLightRange);
91 void setHazeKeyLightAltitudeFactor(
const float hazeKeyLightAltitude);
93 void setHazeBackgroundBlend(
const float hazeBackgroundBlend);
95 using UniformBufferView = gpu::BufferView;
96 UniformBufferView getHazeParametersBuffer()
const {
return _hazeParametersBuffer; }
102 glm::vec3 hazeColor { INITIAL_HAZE_COLOR };
103 float hazeGlareBlend { convertGlareAngleToPower(INITIAL_HAZE_GLARE_ANGLE) };
105 glm::vec3 hazeGlareColor { INITIAL_HAZE_GLARE_COLOR };
106 float hazeBaseReference { INITIAL_HAZE_BASE_REFERENCE };
108 glm::vec3 colorModulationFactor;
115 #if defined(__clang__)
116 __attribute__((unused))
121 float hazeBackgroundBlend { INITIAL_HAZE_BACKGROUND_BLEND };
123 float hazeRangeFactor { convertHazeRangeToHazeRangeFactor(INITIAL_HAZE_RANGE) };
124 float hazeHeightFactor { convertHazeAltitudeToHazeAltitudeFactor(INITIAL_HAZE_HEIGHT) };
125 float hazeKeyLightRangeFactor { convertHazeRangeToHazeRangeFactor(INITIAL_KEY_LIGHT_RANGE) };
127 float hazeKeyLightAltitudeFactor { convertHazeAltitudeToHazeAltitudeFactor(INITIAL_KEY_LIGHT_ALTITUDE) };
132 UniformBufferView _hazeParametersBuffer {
nullptr };
135 using HazePointer = std::shared_ptr<Haze>;