From b820f397fcba7488cb316d9f6d7ef9a1c6ba8cf7 Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Thu, 26 Oct 2017 08:39:22 -0700 Subject: [PATCH 01/12] Fix zero-divide. --- libraries/model/src/model/Haze.h | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/libraries/model/src/model/Haze.h b/libraries/model/src/model/Haze.h index fe606bf083..29eedcd372 100644 --- a/libraries/model/src/model/Haze.h +++ b/libraries/model/src/model/Haze.h @@ -30,10 +30,25 @@ namespace model { -LOG_P_005 / hazeRange_m.z); } - inline float convertHazeRangeToHazeRangeFactor(const float hazeRange_m) { return (-LOG_P_005 / hazeRange_m); } + + inline float convertHazeRangeToHazeRangeFactor(const float hazeRange_m) { + // limit range to no less than 1.0 metres + if (hazeRange_m < 1.0f) { + return -LOG_P_005; + } + else { + return -LOG_P_005 / hazeRange_m; + } + } inline float convertHazeAltitudeToHazeAltitudeFactor(const float hazeAltitude_m) { - return -LOG_P_005 / hazeAltitude_m; + // limit altitude to no less than 1.0 metres + if (hazeAltitude_m < 1.0) { + return -LOG_P_005; + } + else { + return -LOG_P_005 / hazeAltitude_m; + } } // Derivation (s is the proportion of sun blend, a is the angle at which the blend is 50%, solve for m = 0.5 From c5c996f18677dc598e3b4c94d56ff0bf7c9b9446 Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Thu, 26 Oct 2017 09:21:38 -0700 Subject: [PATCH 02/12] Cleanup. --- libraries/model/src/model/Haze.h | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/libraries/model/src/model/Haze.h b/libraries/model/src/model/Haze.h index 29eedcd372..2ffdd2333b 100644 --- a/libraries/model/src/model/Haze.h +++ b/libraries/model/src/model/Haze.h @@ -16,8 +16,8 @@ #include "NumericalConstants.h" namespace model { - const float LOG_P_005 = (float)log(0.05); - const float LOG_P_05 = (float)log(0.5); + const float LOG_P_005 = logf(0.05f); + const float LOG_P_05 = logf(0.5f); // Derivation (d is distance, b is haze coefficient, f is attenuation, solve for f = 0.05 // f = exp(-d * b) @@ -30,26 +30,10 @@ namespace model { -LOG_P_005 / hazeRange_m.z); } + // limit range and altitude to no less than 1.0 metres + inline float convertHazeRangeToHazeRangeFactor(const float hazeRange_m) { return -LOG_P_005 / glm::max(hazeRange_m, 1.0f); } - inline float convertHazeRangeToHazeRangeFactor(const float hazeRange_m) { - // limit range to no less than 1.0 metres - if (hazeRange_m < 1.0f) { - return -LOG_P_005; - } - else { - return -LOG_P_005 / hazeRange_m; - } - } - - inline float convertHazeAltitudeToHazeAltitudeFactor(const float hazeAltitude_m) { - // limit altitude to no less than 1.0 metres - if (hazeAltitude_m < 1.0) { - return -LOG_P_005; - } - else { - return -LOG_P_005 / hazeAltitude_m; - } - } + inline float convertHazeAltitudeToHazeAltitudeFactor(const float hazeAltitude_m) { return -LOG_P_005 / glm::max(hazeAltitude_m, 1.0f); } // Derivation (s is the proportion of sun blend, a is the angle at which the blend is 50%, solve for m = 0.5 // s = dot(lookAngle, sunAngle) = cos(a) @@ -57,7 +41,7 @@ namespace model { // log(m) = p * log(s) // p = log(m) / log(s) inline float convertDirectionalLightAngleToPower(const float directionalLightAngle) { - return LOG_P_05 / (float)log(cos(RADIANS_PER_DEGREE * directionalLightAngle)); + return LOG_P_05 / logf(cosf(RADIANS_PER_DEGREE * directionalLightAngle)); } const glm::vec3 initialHazeColor{ 0.5f, 0.6f, 0.7f }; From 66c31caf4b17a970a6b47419a4d7abf1318126bb Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Fri, 27 Oct 2017 09:08:58 -0700 Subject: [PATCH 03/12] Refactoring of the haze --- .../src/RenderableZoneEntityItem.cpp | 6 +- libraries/entities/CMakeLists.txt | 2 +- libraries/entities/src/HazePropertyGroup.cpp | 13 ---- libraries/entities/src/HazePropertyGroup.h | 33 +++------ libraries/entities/src/ZoneEntityItem.h | 19 ++--- libraries/model/src/model/Haze.cpp | 42 +++++------ libraries/model/src/model/Haze.h | 65 +++-------------- libraries/model/src/model/HazeInit.h | 69 +++++++++++++++++++ .../render-utils/src/DeferredGlobalLight.slh | 10 +-- .../src/DeferredLightingEffect.cpp | 4 +- libraries/render-utils/src/DrawHaze.cpp | 34 ++++----- libraries/render-utils/src/DrawHaze.h | 68 +++++++++--------- libraries/render-utils/src/Haze.slf | 20 +++--- libraries/render-utils/src/Haze.slh | 14 ++-- libraries/render-utils/src/HazeStage.cpp | 10 +-- libraries/render-utils/src/HazeStage.h | 44 ++++++------ scripts/system/html/entityProperties.html | 16 ++--- scripts/system/html/js/entityProperties.js | 28 ++++---- 18 files changed, 249 insertions(+), 248 deletions(-) create mode 100644 libraries/model/src/model/HazeInit.h diff --git a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp index 0235f1b7a3..877e245006 100644 --- a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp @@ -346,15 +346,15 @@ void ZoneEntityRenderer::updateHazeFromEntity(const TypedEntityPointer& entity) xColor hazeColor = _hazeProperties.getHazeColor(); haze->setHazeColor(glm::vec3(hazeColor.red / 255.0, hazeColor.green / 255.0, hazeColor.blue / 255.0)); xColor hazeGlareColor = _hazeProperties.getHazeGlareColor(); - haze->setDirectionalLightColor(glm::vec3(hazeGlareColor.red / 255.0, hazeGlareColor.green / 255.0, hazeGlareColor.blue / 255.0)); + haze->setHazeGlareColor(glm::vec3(hazeGlareColor.red / 255.0, hazeGlareColor.green / 255.0, hazeGlareColor.blue / 255.0)); haze->setHazeEnableGlare(_hazeProperties.getHazeEnableGlare()); - haze->setDirectionalLightBlend(model::convertDirectionalLightAngleToPower(_hazeProperties.getHazeGlareAngle())); + haze->setHazeGlareBlend(model::convertGlareAngleToPower(_hazeProperties.getHazeGlareAngle())); float hazeAltitude = _hazeProperties.getHazeCeiling() - _hazeProperties.getHazeBaseRef(); haze->setHazeAltitudeFactor(model::convertHazeAltitudeToHazeAltitudeFactor(hazeAltitude)); haze->setHazeBaseReference(_hazeProperties.getHazeBaseRef()); - haze->setHazeBackgroundBlendValue(_hazeProperties.getHazeBackgroundBlend()); + haze->setHazeBackgroundBlend(_hazeProperties.getHazeBackgroundBlend()); haze->setHazeAttenuateKeyLight(_hazeProperties.getHazeAttenuateKeyLight()); haze->setHazeKeyLightRangeFactor(model::convertHazeRangeToHazeRangeFactor(_hazeProperties.getHazeKeyLightRange())); diff --git a/libraries/entities/CMakeLists.txt b/libraries/entities/CMakeLists.txt index 322d69da16..c23740654e 100644 --- a/libraries/entities/CMakeLists.txt +++ b/libraries/entities/CMakeLists.txt @@ -1,4 +1,4 @@ set(TARGET_NAME entities) setup_hifi_library(Network Script) include_directories(SYSTEM "${OPENSSL_INCLUDE_DIR}") -link_hifi_libraries(shared networking octree avatars) +link_hifi_libraries(shared networking octree avatars model) diff --git a/libraries/entities/src/HazePropertyGroup.cpp b/libraries/entities/src/HazePropertyGroup.cpp index 996d2e0cd3..3cc3e69960 100644 --- a/libraries/entities/src/HazePropertyGroup.cpp +++ b/libraries/entities/src/HazePropertyGroup.cpp @@ -15,19 +15,6 @@ #include "EntityItemProperties.h" #include "EntityItemPropertiesMacros.h" -const float HazePropertyGroup::DEFAULT_HAZE_RANGE{ 1000.0f }; -const xColor HazePropertyGroup::DEFAULT_HAZE_COLOR{ 128, 154, 179 }; // Bluish -const xColor HazePropertyGroup::DEFAULT_HAZE_GLARE_COLOR{ 255, 229, 179 }; // Yellowish -const float HazePropertyGroup::DEFAULT_HAZE_GLARE_ANGLE{ 20.0 }; - -const float HazePropertyGroup::DEFAULT_HAZE_CEILING{ 200.0f }; -const float HazePropertyGroup::DEFAULT_HAZE_BASE_REF{ 0.0f }; - -const float HazePropertyGroup::DEFAULT_HAZE_BACKGROUND_BLEND{ 0.0f }; - -const float HazePropertyGroup::DEFAULT_HAZE_KEYLIGHT_RANGE{ 1000.0 }; -const float HazePropertyGroup::DEFAULT_HAZE_KEYLIGHT_ALTITUDE{ 200.0f }; - void HazePropertyGroup::copyToScriptValue(const EntityPropertyFlags& desiredProperties, QScriptValue& properties, QScriptEngine* engine, bool skipDefaults, EntityItemProperties& defaultEntityProperties) const { COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_RANGE, Haze, haze, HazeRange, hazeRange); COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_COLOR, Haze, haze, HazeColor, hazeColor); diff --git a/libraries/entities/src/HazePropertyGroup.h b/libraries/entities/src/HazePropertyGroup.h index cdd36ff7ef..1cbaa24f2a 100644 --- a/libraries/entities/src/HazePropertyGroup.h +++ b/libraries/entities/src/HazePropertyGroup.h @@ -21,6 +21,8 @@ #include "PropertyGroup.h" #include "EntityItemPropertiesMacros.h" +#include + class EntityItemProperties; class EncodeBitstreamParams; class OctreePacketData; @@ -74,38 +76,25 @@ public: EntityPropertyFlags& propertyFlags, bool overwriteLocalData, bool& somethingChanged) override; - static const float DEFAULT_HAZE_RANGE; - static const xColor DEFAULT_HAZE_COLOR; - static const xColor DEFAULT_HAZE_GLARE_COLOR; - static const float DEFAULT_HAZE_GLARE_ANGLE; - - static const float DEFAULT_HAZE_CEILING; - static const float DEFAULT_HAZE_BASE_REF; - - static const float DEFAULT_HAZE_BACKGROUND_BLEND; - - static const float DEFAULT_HAZE_KEYLIGHT_RANGE; - static const float DEFAULT_HAZE_KEYLIGHT_ALTITUDE; - // Range only parameters - DEFINE_PROPERTY(PROP_HAZE_RANGE, HazeRange, hazeRange, float, DEFAULT_HAZE_RANGE); - DEFINE_PROPERTY_REF(PROP_HAZE_COLOR, HazeColor, hazeColor, xColor, DEFAULT_HAZE_COLOR); - DEFINE_PROPERTY_REF(PROP_HAZE_GLARE_COLOR, HazeGlareColor, hazeGlareColor, xColor, DEFAULT_HAZE_GLARE_COLOR); + DEFINE_PROPERTY(PROP_HAZE_RANGE, HazeRange, hazeRange, float, model::initialHazeRange_m); + DEFINE_PROPERTY_REF(PROP_HAZE_COLOR, HazeColor, hazeColor, xColor, model::initialHazeColorXcolor); + DEFINE_PROPERTY_REF(PROP_HAZE_GLARE_COLOR, HazeGlareColor, hazeGlareColor, xColor, model::initialHazeGlareColorXcolor); DEFINE_PROPERTY(PROP_HAZE_ENABLE_GLARE, HazeEnableGlare, hazeEnableGlare, bool, false); - DEFINE_PROPERTY_REF(PROP_HAZE_GLARE_ANGLE, HazeGlareAngle, hazeGlareAngle, float, DEFAULT_HAZE_GLARE_ANGLE); + DEFINE_PROPERTY_REF(PROP_HAZE_GLARE_ANGLE, HazeGlareAngle, hazeGlareAngle, float, model::initialGlareAngle_degs); // Altitude parameters DEFINE_PROPERTY(PROP_HAZE_ALTITUDE_EFFECT, HazeAltitudeEffect, hazeAltitudeEffect, bool, false); - DEFINE_PROPERTY_REF(PROP_HAZE_CEILING, HazeCeiling, hazeCeiling, float, DEFAULT_HAZE_CEILING); - DEFINE_PROPERTY_REF(PROP_HAZE_BASE_REF, HazeBaseRef, hazeBaseRef, float, DEFAULT_HAZE_BASE_REF); + DEFINE_PROPERTY_REF(PROP_HAZE_CEILING, HazeCeiling, hazeCeiling, float, model::initialHazeBaseReference_m + model::initialHazeHeight_m); + DEFINE_PROPERTY_REF(PROP_HAZE_BASE_REF, HazeBaseRef, hazeBaseRef, float, model::initialHazeBaseReference_m); // Background (skybox) blend value - DEFINE_PROPERTY_REF(PROP_HAZE_BACKGROUND_BLEND, HazeBackgroundBlend, hazeBackgroundBlend, float, DEFAULT_HAZE_BACKGROUND_BLEND); + DEFINE_PROPERTY_REF(PROP_HAZE_BACKGROUND_BLEND, HazeBackgroundBlend, hazeBackgroundBlend, float, model::initialHazeBackgroundBlend); // hazeDirectional light attenuation DEFINE_PROPERTY(PROP_HAZE_ATTENUATE_KEYLIGHT, HazeAttenuateKeyLight, hazeAttenuateKeyLight, bool, false); - DEFINE_PROPERTY_REF(PROP_HAZE_KEYLIGHT_RANGE, HazeKeyLightRange, hazeKeyLightRange, float, DEFAULT_HAZE_KEYLIGHT_RANGE); - DEFINE_PROPERTY_REF(PROP_HAZE_KEYLIGHT_ALTITUDE, HazeKeyLightAltitude, hazeKeyLightAltitude, float, DEFAULT_HAZE_KEYLIGHT_ALTITUDE); + DEFINE_PROPERTY_REF(PROP_HAZE_KEYLIGHT_RANGE, HazeKeyLightRange, hazeKeyLightRange, float, model::initialHazeKeyLightRange_m); + DEFINE_PROPERTY_REF(PROP_HAZE_KEYLIGHT_ALTITUDE, HazeKeyLightAltitude, hazeKeyLightAltitude, float, model::initialHazeKeyLightAltitude_m); }; #endif // hifi_HazePropertyGroup_h diff --git a/libraries/entities/src/ZoneEntityItem.h b/libraries/entities/src/ZoneEntityItem.h index ddbb2ed914..628c228af6 100644 --- a/libraries/entities/src/ZoneEntityItem.h +++ b/libraries/entities/src/ZoneEntityItem.h @@ -19,6 +19,7 @@ #include "HazePropertyGroup.h" #include "StagePropertyGroup.h" #include +#include class ZoneEntityItem : public EntityItem { public: @@ -150,20 +151,20 @@ protected: uint32_t _hazeMode{ DEFAULT_HAZE_MODE }; - float _hazeRange{ HazePropertyGroup::DEFAULT_HAZE_RANGE }; - xColor _hazeColor{ HazePropertyGroup::DEFAULT_HAZE_COLOR }; - xColor _hazeGlareColor{ HazePropertyGroup::DEFAULT_HAZE_GLARE_COLOR }; + float _hazeRange{ model::initialHazeRange_m }; + xColor _hazeColor{ model::initialHazeColorXcolor }; + xColor _hazeGlareColor{ model::initialHazeGlareColorXcolor }; bool _hazeEnableGlare{ false }; - float _hazeGlareAngle{ HazePropertyGroup::DEFAULT_HAZE_GLARE_ANGLE }; + float _hazeGlareAngle{ model::initialGlareAngle_degs }; - float _hazeCeiling{ HazePropertyGroup::DEFAULT_HAZE_CEILING }; - float _hazeBaseRef{ HazePropertyGroup::DEFAULT_HAZE_BASE_REF }; + float _hazeCeiling{ model::initialHazeBaseReference_m + model::initialHazeHeight_m }; + float _hazeBaseRef{ model::initialHazeBaseReference_m }; - float _hazeBackgroundBlend{ HazePropertyGroup::DEFAULT_HAZE_BACKGROUND_BLEND }; + float _hazeBackgroundBlend{ model::initialHazeBackgroundBlend }; bool _hazeAttenuateKeyLight{ false }; - float _hazeKeyLightRange{ HazePropertyGroup::DEFAULT_HAZE_KEYLIGHT_RANGE }; - float _hazeKeyLightAltitude{ HazePropertyGroup::DEFAULT_HAZE_KEYLIGHT_ALTITUDE }; + float _hazeKeyLightRange{ model::initialHazeKeyLightRange_m }; + float _hazeKeyLightAltitude{ model::initialHazeKeyLightAltitude_m }; SkyboxPropertyGroup _skyboxProperties; HazePropertyGroup _hazeProperties; diff --git a/libraries/model/src/model/Haze.cpp b/libraries/model/src/model/Haze.cpp index 679d4ad3d1..1c9b989fd1 100644 --- a/libraries/model/src/model/Haze.cpp +++ b/libraries/model/src/model/Haze.cpp @@ -23,7 +23,7 @@ Haze::Haze() { enum HazeModes { HAZE_MODE_IS_ACTIVE = 1 << 0, HAZE_MODE_IS_ALTITUDE_BASED = 1 << 1, - HAZE_MODE_IS_DIRECTIONAL_LIGHT_ATTENUATED = 1 << 2, + HAZE_MODE_IS_KEYLIGHT_ATTENUATED = 1 << 2, HAZE_MODE_IS_MODULATE_COLOR = 1 << 3, HAZE_MODE_IS_ENABLE_LIGHT_BLEND = 1 << 4 }; @@ -55,25 +55,25 @@ void Haze::setHazeEnableGlare(const bool isHazeEnableGlare) { } } -void Haze::setDirectionalLightBlend(const float hazeDirectionalLightBlend) { +void Haze::setHazeGlareBlend(const float hazeGlareBlend) { auto& params = _hazeParametersBuffer.get(); - if (params.directionalLightBlend != hazeDirectionalLightBlend) { - _hazeParametersBuffer.edit().directionalLightBlend = hazeDirectionalLightBlend; + if (params.hazeGlareBlend != hazeGlareBlend) { + _hazeParametersBuffer.edit().hazeGlareBlend = hazeGlareBlend; } } -void Haze::setDirectionalLightColor(const glm::vec3 hazeDirectionalLightColor) { +void Haze::setHazeGlareColor(const glm::vec3 hazeGlareColor) { auto& params = _hazeParametersBuffer.get(); - if (params.directionalLightColor.r != hazeDirectionalLightColor.r) { - _hazeParametersBuffer.edit().directionalLightColor.r = hazeDirectionalLightColor.r; + if (params.hazeGlareColor.r != hazeGlareColor.r) { + _hazeParametersBuffer.edit().hazeGlareColor.r = hazeGlareColor.r; } - if (params.directionalLightColor.g != hazeDirectionalLightColor.g) { - _hazeParametersBuffer.edit().directionalLightColor.g = hazeDirectionalLightColor.g; + if (params.hazeGlareColor.g != hazeGlareColor.g) { + _hazeParametersBuffer.edit().hazeGlareColor.g = hazeGlareColor.g; } - if (params.directionalLightColor.b != hazeDirectionalLightColor.b) { - _hazeParametersBuffer.edit().directionalLightColor.b = hazeDirectionalLightColor.b; + if (params.hazeGlareColor.b != hazeGlareColor.b) { + _hazeParametersBuffer.edit().hazeGlareColor.b = hazeGlareColor.b; } } void Haze::setHazeActive(const bool isHazeActive) { @@ -99,10 +99,10 @@ void Haze::setAltitudeBased(const bool isAltitudeBased) { void Haze::setHazeAttenuateKeyLight(const bool isHazeAttenuateKeyLight) { auto& params = _hazeParametersBuffer.get(); - if (((params.hazeMode & HAZE_MODE_IS_DIRECTIONAL_LIGHT_ATTENUATED) == HAZE_MODE_IS_DIRECTIONAL_LIGHT_ATTENUATED ) && !isHazeAttenuateKeyLight) { - _hazeParametersBuffer.edit().hazeMode &= ~HAZE_MODE_IS_DIRECTIONAL_LIGHT_ATTENUATED; - } else if (((params.hazeMode & HAZE_MODE_IS_DIRECTIONAL_LIGHT_ATTENUATED) != HAZE_MODE_IS_DIRECTIONAL_LIGHT_ATTENUATED) && isHazeAttenuateKeyLight) { - _hazeParametersBuffer.edit().hazeMode |= HAZE_MODE_IS_DIRECTIONAL_LIGHT_ATTENUATED; + if (((params.hazeMode & HAZE_MODE_IS_KEYLIGHT_ATTENUATED) == HAZE_MODE_IS_KEYLIGHT_ATTENUATED) && !isHazeAttenuateKeyLight) { + _hazeParametersBuffer.edit().hazeMode &= ~HAZE_MODE_IS_KEYLIGHT_ATTENUATED; + } else if (((params.hazeMode & HAZE_MODE_IS_KEYLIGHT_ATTENUATED) != HAZE_MODE_IS_KEYLIGHT_ATTENUATED) && isHazeAttenuateKeyLight) { + _hazeParametersBuffer.edit().hazeMode |= HAZE_MODE_IS_KEYLIGHT_ATTENUATED; } } @@ -124,11 +124,11 @@ void Haze::setHazeRangeFactor(const float hazeRangeFactor) { } } -void Haze::setHazeAltitudeFactor(const float hazeAltitudeFactor) { +void Haze::setHazeAltitudeFactor(const float hazeHeightFactor) { auto& params = _hazeParametersBuffer.get(); - if (params.hazeAltitudeFactor != hazeAltitudeFactor) { - _hazeParametersBuffer.edit().hazeAltitudeFactor = hazeAltitudeFactor; + if (params.hazeHeightFactor != hazeHeightFactor) { + _hazeParametersBuffer.edit().hazeHeightFactor = hazeHeightFactor; } } @@ -156,11 +156,11 @@ void Haze::setHazeBaseReference(const float hazeBaseReference) { } } -void Haze::setHazeBackgroundBlendValue(const float hazeBackgroundBlendValue) { +void Haze::setHazeBackgroundBlend(const float hazeBackgroundBlend) { auto& params = _hazeParametersBuffer.get(); - if (params.hazeBackgroundBlendValue != hazeBackgroundBlendValue) { - _hazeParametersBuffer.edit().hazeBackgroundBlendValue = hazeBackgroundBlendValue; + if (params.hazeBackgroundBlend != hazeBackgroundBlend) { + _hazeParametersBuffer.edit().hazeBackgroundBlend = hazeBackgroundBlend; } } diff --git a/libraries/model/src/model/Haze.h b/libraries/model/src/model/Haze.h index 2ffdd2333b..bed82c80f9 100644 --- a/libraries/model/src/model/Haze.h +++ b/libraries/model/src/model/Haze.h @@ -15,56 +15,11 @@ #include "Transform.h" #include "NumericalConstants.h" +#include "HazeInit.h" + namespace model { - const float LOG_P_005 = logf(0.05f); - const float LOG_P_05 = logf(0.5f); - - // Derivation (d is distance, b is haze coefficient, f is attenuation, solve for f = 0.05 - // f = exp(-d * b) - // ln(f) = -d * b - // b = -ln(f)/d - inline glm::vec3 convertHazeRangeToHazeRangeFactor(const glm::vec3 hazeRange_m) { - return glm::vec3( - -LOG_P_005 / hazeRange_m.x, - -LOG_P_005 / hazeRange_m.y, - -LOG_P_005 / hazeRange_m.z); - } - - // limit range and altitude to no less than 1.0 metres - inline float convertHazeRangeToHazeRangeFactor(const float hazeRange_m) { return -LOG_P_005 / glm::max(hazeRange_m, 1.0f); } - - inline float convertHazeAltitudeToHazeAltitudeFactor(const float hazeAltitude_m) { return -LOG_P_005 / glm::max(hazeAltitude_m, 1.0f); } - - // Derivation (s is the proportion of sun blend, a is the angle at which the blend is 50%, solve for m = 0.5 - // s = dot(lookAngle, sunAngle) = cos(a) - // m = pow(s, p) - // log(m) = p * log(s) - // p = log(m) / log(s) - inline float convertDirectionalLightAngleToPower(const float directionalLightAngle) { - return LOG_P_05 / logf(cosf(RADIANS_PER_DEGREE * directionalLightAngle)); - } - - const glm::vec3 initialHazeColor{ 0.5f, 0.6f, 0.7f }; - const float initialDirectionalLightAngle_degs{ 30.0f }; - - const glm::vec3 initialDirectionalLightColor{ 1.0f, 0.9f, 0.7f }; - const float initialHazeBaseReference{ 0.0f }; - // Haze range is defined here as the range the visibility is reduced by 95% // Haze altitude is defined here as the altitude (above 0) that the haze is reduced by 95% - const float initialHazeRange_m{ 150.0f }; - const float initialHazeAltitude_m{ 150.0f }; - - const float initialHazeKeyLightRange_m{ 150.0f }; - const float initialHazeKeyLightAltitude_m{ 150.0f }; - - const float initialHazeBackgroundBlendValue{ 0.0f }; - - const glm::vec3 initialColorModulationFactor{ - convertHazeRangeToHazeRangeFactor(initialHazeRange_m), - convertHazeRangeToHazeRangeFactor(initialHazeRange_m), - convertHazeRangeToHazeRangeFactor(initialHazeRange_m) - }; class Haze { public: @@ -73,9 +28,9 @@ namespace model { Haze(); void setHazeColor(const glm::vec3 hazeColor); - void setDirectionalLightBlend(const float directionalLightBlend); + void setHazeGlareBlend(const float hazeGlareBlend); - void setDirectionalLightColor(const glm::vec3 directionalLightColor); + void setHazeGlareColor(const glm::vec3 hazeGlareColor); void setHazeBaseReference(const float hazeBaseReference); void setHazeActive(const bool isHazeActive); @@ -90,7 +45,7 @@ namespace model { void setHazeKeyLightRangeFactor(const float hazeKeyLightRange); void setHazeKeyLightAltitudeFactor(const float hazeKeyLightAltitude); - void setHazeBackgroundBlendValue(const float hazeBackgroundBlendValue); + void setHazeBackgroundBlend(const float hazeBackgroundBlend); void setZoneTransform(const glm::mat4& zoneTransform); @@ -101,10 +56,10 @@ namespace model { public: // DO NOT CHANGE ORDER HERE WITHOUT UNDERSTANDING THE std140 LAYOUT glm::vec3 hazeColor{ initialHazeColor }; - float directionalLightBlend{ convertDirectionalLightAngleToPower(initialDirectionalLightAngle_degs) }; + float hazeGlareBlend{ convertGlareAngleToPower(initialGlareAngle_degs) }; - glm::vec3 directionalLightColor{ initialDirectionalLightColor }; - float hazeBaseReference{ initialHazeBaseReference }; + glm::vec3 hazeGlareColor{ initialHazeGlareColor }; + float hazeBaseReference{ initialHazeBaseReference_m }; glm::vec3 colorModulationFactor{ initialColorModulationFactor }; int hazeMode{ 0 }; // bit 0 - set to activate haze attenuation of fragment color @@ -115,11 +70,11 @@ namespace model { glm::mat4 zoneTransform; // Amount of background (skybox) to display, overriding the haze effect for the background - float hazeBackgroundBlendValue{ initialHazeBackgroundBlendValue }; + float hazeBackgroundBlend{ initialHazeBackgroundBlend }; // The haze attenuation exponents used by both fragment and directional light attenuation float hazeRangeFactor{ convertHazeRangeToHazeRangeFactor(initialHazeRange_m) }; - float hazeAltitudeFactor{ convertHazeAltitudeToHazeAltitudeFactor(initialHazeAltitude_m) }; + float hazeHeightFactor{ convertHazeAltitudeToHazeAltitudeFactor(initialHazeHeight_m) }; float hazeKeyLightRangeFactor{ convertHazeRangeToHazeRangeFactor(initialHazeKeyLightRange_m) }; float hazeKeyLightAltitudeFactor{ convertHazeAltitudeToHazeAltitudeFactor(initialHazeKeyLightAltitude_m) }; diff --git a/libraries/model/src/model/HazeInit.h b/libraries/model/src/model/HazeInit.h new file mode 100644 index 0000000000..218a79fc1d --- /dev/null +++ b/libraries/model/src/model/HazeInit.h @@ -0,0 +1,69 @@ +// +// MakeHaze.h +// libraries/model/src/model +// +// Created by Nissim Hadar on 10/26/2017. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// +#ifndef hifi_model_HazeInit_h +#define hifi_model_HazeInit_h + +namespace model { + const float LOG_P_005 = logf(0.05f); + const float LOG_P_05 = logf(0.5f); + + // Derivation (d is distance, b is haze coefficient, f is attenuation, solve for f = 0.05 + // f = exp(-d * b) + // ln(f) = -d * b + // b = -ln(f)/d + inline glm::vec3 convertHazeRangeToHazeRangeFactor(const glm::vec3 hazeRange_m) { + return glm::vec3( + -LOG_P_005 / hazeRange_m.x, + -LOG_P_005 / hazeRange_m.y, + -LOG_P_005 / hazeRange_m.z); + } + + // limit range and altitude to no less than 1.0 metres + inline float convertHazeRangeToHazeRangeFactor(const float hazeRange_m) { return -LOG_P_005 / glm::max(hazeRange_m, 1.0f); } + + inline float convertHazeAltitudeToHazeAltitudeFactor(const float hazeHeight_m) { return -LOG_P_005 / glm::max(hazeHeight_m, 1.0f); } + + // Derivation (s is the proportion of sun blend, a is the angle at which the blend is 50%, solve for m = 0.5 + // s = dot(lookAngle, sunAngle) = cos(a) + // m = pow(s, p) + // log(m) = p * log(s) + // p = log(m) / log(s) + // limit to 0.1 degrees + inline float convertGlareAngleToPower(const float hazeGlareAngle) { + const float GLARE_ANGLE_LIMIT = 0.1f; + return LOG_P_05 / logf(cosf(RADIANS_PER_DEGREE * glm::max(GLARE_ANGLE_LIMIT, hazeGlareAngle))); + } + + const float initialHazeRange_m{ 1000.0f }; + const float initialHazeHeight_m{ 200.0f }; + + const float initialHazeKeyLightRange_m{ 1000.0f }; + const float initialHazeKeyLightAltitude_m{ 200.0f }; + + const float initialHazeBackgroundBlend{ 0.0f }; + + const glm::vec3 initialColorModulationFactor{ + convertHazeRangeToHazeRangeFactor(initialHazeRange_m), + convertHazeRangeToHazeRangeFactor(initialHazeRange_m), + convertHazeRangeToHazeRangeFactor(initialHazeRange_m) + }; + + const glm::vec3 initialHazeColor{ 0.5f, 0.6f, 0.7f }; // Bluish + const xColor initialHazeColorXcolor{ 128, 154, 179 }; + + const float initialGlareAngle_degs{ 20.0f }; + + const glm::vec3 initialHazeGlareColor{ 1.0f, 0.9f, 0.7f }; + const xColor initialHazeGlareColorXcolor{ 255, 229, 179 }; + + const float initialHazeBaseReference_m{ 0.0f }; +} +#endif // hifi_model_HazeInit_h diff --git a/libraries/render-utils/src/DeferredGlobalLight.slh b/libraries/render-utils/src/DeferredGlobalLight.slh index cc20f6335e..f70daf1e77 100644 --- a/libraries/render-utils/src/DeferredGlobalLight.slh +++ b/libraries/render-utils/src/DeferredGlobalLight.slh @@ -134,7 +134,7 @@ vec3 evalSkyboxGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscu color += directionalSpecular; // Attenuate the light if haze effect selected - if ((hazeParams.hazeMode & HAZE_MODE_IS_DIRECTIONAL_LIGHT_ATTENUATED) == HAZE_MODE_IS_DIRECTIONAL_LIGHT_ATTENUATED) { + if ((hazeParams.hazeMode & HAZE_MODE_IS_KEYLIGHT_ATTENUATED) == HAZE_MODE_IS_KEYLIGHT_ATTENUATED) { // Directional light attenuation is simulated by assuming the light source is at a fixed height above the // fragment. This height is where the haze density is reduced by 95% from the haze at the fragment's height // @@ -147,8 +147,8 @@ vec3 evalSkyboxGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscu // Height at which haze density is reduced by 95% (default set to 2000.0 for safety ,this should never happen) float height_95p = 2000.0; - if (hazeParams.hazeAltitudeFactorKeyLight > 0.0f) { - height_95p = -log(0.05) / hazeParams.hazeAltitudeFactorKeyLight; + if (hazeParams.hazeKeyLightAltitudeFactor > 0.0f) { + height_95p = -log(0.05) / hazeParams.hazeKeyLightAltitudeFactor; } // Note that the sine will always be positive @@ -168,8 +168,8 @@ vec3 evalSkyboxGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscu // Integration is from the fragment towards the light source // Note that the haze base reference affects only the haze density as function of altitude float hazeDensityDistribution = - hazeParams.hazeRangeFactorKeyLight * - exp(-hazeParams.hazeAltitudeFactorKeyLight * (worldFragPos.y - hazeParams.hazeBaseReference)); + hazeParams.hazeKeyLightRangeFactor * + exp(-hazeParams.hazeKeyLightAltitudeFactor * (worldFragPos.y - hazeParams.hazeBaseReference)); float hazeIntegral = hazeDensityDistribution * distance; diff --git a/libraries/render-utils/src/DeferredLightingEffect.cpp b/libraries/render-utils/src/DeferredLightingEffect.cpp index b6a91888a1..e6a33a9911 100644 --- a/libraries/render-utils/src/DeferredLightingEffect.cpp +++ b/libraries/render-utils/src/DeferredLightingEffect.cpp @@ -498,7 +498,7 @@ void RenderDeferredSetup::run(const render::RenderContextPointer& renderContext, auto lightStage = renderContext->_scene->getStage(); assert(lightStage); assert(lightStage->getNumLights() > 0); - auto lightAndShadow = lightStage->getCurrentKeyLightAndShadow(); + auto lightAndShadow = lightStage->getLightAndShadow(0); const auto& globalShadow = lightAndShadow.second; // Bind the shadow buffer @@ -509,7 +509,7 @@ void RenderDeferredSetup::run(const render::RenderContextPointer& renderContext, auto& program = deferredLightingEffect->_directionalSkyboxLight; LightLocationsPtr locations = deferredLightingEffect->_directionalSkyboxLightLocations; - auto keyLight = lightAndShadow.first; + auto keyLight = lightStage->getLight(0); // Setup the global directional pass pipeline { diff --git a/libraries/render-utils/src/DrawHaze.cpp b/libraries/render-utils/src/DrawHaze.cpp index bf254ce80e..071db8cf25 100644 --- a/libraries/render-utils/src/DrawHaze.cpp +++ b/libraries/render-utils/src/DrawHaze.cpp @@ -33,24 +33,24 @@ void HazeConfig::setHazeColorB(const float value) { hazeColorB = value; } -void HazeConfig::setDirectionalLightAngle_degs(const float value) { - hazeDirectionalLightAngle_degs = value; +void HazeConfig::setHazeGlareAngle_degs(const float value) { + hazeGlareAngle_degs = value; } -void HazeConfig::setDirectionalLightColorR(const float value) { - hazeDirectionalLightColorR = value; +void HazeConfig::setHazeGlareColorR(const float value) { + hazeGlareColorR = value; } -void HazeConfig::setDirectionalLightColorG(const float value) { - hazeDirectionalLightColorG = value; +void HazeConfig::setHazeGlareColorG(const float value) { + hazeGlareColorG = value; } -void HazeConfig::setDirectionalLightColorB(const float value) { - hazeDirectionalLightColorB = value; +void HazeConfig::setHazeGlareColorB(const float value) { + hazeGlareColorB = value; } void HazeConfig::setHazeBaseReference(const float value) { - hazeBaseReference = value; + hazeBaseReference_m = value; } void HazeConfig::setHazeActive(const bool active) { @@ -78,7 +78,7 @@ void HazeConfig::setHazeRange_m(const float value) { } void HazeConfig::setHazeAltitude_m(const float value) { - hazeAltitude_m = value; + hazeHeight_m = value; } void HazeConfig::setHazeKeyLightRange_m(const float value) { @@ -89,8 +89,8 @@ void HazeConfig::setHazeKeyLightAltitude_m(const float value) { hazeKeyLightAltitude_m = value; } -void HazeConfig::setHazeBackgroundBlendValue(const float value) { - hazeBackgroundBlendValue = value; +void HazeConfig::setHazeBackgroundBlend(const float value) { + hazeBackgroundBlend = value; } MakeHaze::MakeHaze() { @@ -99,10 +99,10 @@ MakeHaze::MakeHaze() { void MakeHaze::configure(const Config& config) { _haze->setHazeColor(glm::vec3(config.hazeColorR, config.hazeColorG, config.hazeColorB)); - _haze->setDirectionalLightBlend(model::convertDirectionalLightAngleToPower(config.hazeDirectionalLightAngle_degs)); + _haze->setHazeGlareBlend(model::convertGlareAngleToPower(config.hazeGlareAngle_degs)); - _haze->setDirectionalLightColor(glm::vec3(config.hazeDirectionalLightColorR, config.hazeDirectionalLightColorG, config.hazeDirectionalLightColorB)); - _haze->setHazeBaseReference(config.hazeBaseReference); + _haze->setHazeGlareColor(glm::vec3(config.hazeGlareColorR, config.hazeGlareColorG, config.hazeGlareColorB)); + _haze->setHazeBaseReference(config.hazeBaseReference_m); _haze->setHazeActive(config.isHazeActive); _haze->setAltitudeBased(config.isAltitudeBased); @@ -111,12 +111,12 @@ void MakeHaze::configure(const Config& config) { _haze->setHazeEnableGlare(config.isHazeEnableGlare); _haze->setHazeRangeFactor(model::convertHazeRangeToHazeRangeFactor(config.hazeRange_m)); - _haze->setHazeAltitudeFactor(model::convertHazeAltitudeToHazeAltitudeFactor(config.hazeAltitude_m)); + _haze->setHazeAltitudeFactor(model::convertHazeAltitudeToHazeAltitudeFactor(config.hazeHeight_m)); _haze->setHazeKeyLightRangeFactor(model::convertHazeRangeToHazeRangeFactor(config.hazeKeyLightRange_m)); _haze->setHazeKeyLightAltitudeFactor(model::convertHazeAltitudeToHazeAltitudeFactor(config.hazeKeyLightAltitude_m)); - _haze->setHazeBackgroundBlendValue(config.hazeBackgroundBlendValue); + _haze->setHazeBackgroundBlend(config.hazeBackgroundBlend); } void MakeHaze::run(const render::RenderContextPointer& renderContext, model::HazePointer& haze) { diff --git a/libraries/render-utils/src/DrawHaze.h b/libraries/render-utils/src/DrawHaze.h index 4a7b2135bd..e7a3f2c636 100644 --- a/libraries/render-utils/src/DrawHaze.h +++ b/libraries/render-utils/src/DrawHaze.h @@ -22,7 +22,7 @@ #include "SurfaceGeometryPass.h" -#include "model/Haze.h" +#include using LinearDepthFramebufferPointer = std::shared_ptr; @@ -32,12 +32,12 @@ class MakeHazeConfig : public render::Job::Config { Q_PROPERTY(float hazeColorR MEMBER hazeColorR WRITE setHazeColorR NOTIFY dirty); Q_PROPERTY(float hazeColorG MEMBER hazeColorG WRITE setHazeColorG NOTIFY dirty); Q_PROPERTY(float hazeColorB MEMBER hazeColorB WRITE setHazeColorB NOTIFY dirty); - Q_PROPERTY(float hazeDirectionalLightAngle_degs MEMBER hazeDirectionalLightAngle_degs WRITE setDirectionalLightAngle_degs NOTIFY dirty); + Q_PROPERTY(float hazeGlareAngle_degs MEMBER hazeGlareAngle_degs WRITE setHazeGlareAngle_degs NOTIFY dirty); - Q_PROPERTY(float hazeDirectionalLightColorR MEMBER hazeDirectionalLightColorR WRITE setDirectionalLightColorR NOTIFY dirty); - Q_PROPERTY(float hazeDirectionalLightColorG MEMBER hazeDirectionalLightColorG WRITE setDirectionalLightColorG NOTIFY dirty); - Q_PROPERTY(float hazeDirectionalLightColorB MEMBER hazeDirectionalLightColorB WRITE setDirectionalLightColorB NOTIFY dirty); - Q_PROPERTY(float hazeBaseReference MEMBER hazeBaseReference WRITE setHazeBaseReference NOTIFY dirty); + Q_PROPERTY(float hazeGlareColorR MEMBER hazeGlareColorR WRITE setHazeGlareColorR NOTIFY dirty); + Q_PROPERTY(float hazeGlareColorG MEMBER hazeGlareColorG WRITE setHazeGlareColorG NOTIFY dirty); + Q_PROPERTY(float hazeGlareColorB MEMBER hazeGlareColorB WRITE setHazeGlareColorB NOTIFY dirty); + Q_PROPERTY(float hazeBaseReference_m MEMBER hazeBaseReference_m WRITE setHazeBaseReference NOTIFY dirty); Q_PROPERTY(bool isHazeActive MEMBER isHazeActive WRITE setHazeActive NOTIFY dirty); Q_PROPERTY(bool isAltitudeBased MEMBER isAltitudeBased WRITE setAltitudeBased NOTIFY dirty); @@ -46,12 +46,12 @@ class MakeHazeConfig : public render::Job::Config { Q_PROPERTY(bool isHazeEnableGlare MEMBER isHazeEnableGlare WRITE setHazeEnableGlare NOTIFY dirty); Q_PROPERTY(float hazeRange_m MEMBER hazeRange_m WRITE setHazeRange_m NOTIFY dirty); - Q_PROPERTY(float hazeAltitude_m MEMBER hazeAltitude_m WRITE setHazeAltitude_m NOTIFY dirty); + Q_PROPERTY(float hazeHeight_m MEMBER hazeHeight_m WRITE setHazeAltitude_m NOTIFY dirty); Q_PROPERTY(float hazeKeyLightRange_m MEMBER hazeKeyLightRange_m WRITE setHazeKeyLightRange_m NOTIFY dirty); Q_PROPERTY(float hazeKeyLightAltitude_m MEMBER hazeKeyLightAltitude_m WRITE setHazeKeyLightAltitude_m NOTIFY dirty); - Q_PROPERTY(float hazeBackgroundBlendValue MEMBER hazeBackgroundBlendValue WRITE setHazeBackgroundBlendValue NOTIFY dirty); + Q_PROPERTY(float hazeBackgroundBlend MEMBER hazeBackgroundBlend WRITE setHazeBackgroundBlend NOTIFY dirty); public: MakeHazeConfig() : render::Job::Config() {} @@ -59,12 +59,12 @@ public: float hazeColorR{ model::initialHazeColor.r }; float hazeColorG{ model::initialHazeColor.g }; float hazeColorB{ model::initialHazeColor.b }; - float hazeDirectionalLightAngle_degs{ model::initialDirectionalLightAngle_degs }; + float hazeGlareAngle_degs{ model::initialGlareAngle_degs }; - float hazeDirectionalLightColorR{ model::initialDirectionalLightColor.r }; - float hazeDirectionalLightColorG{ model::initialDirectionalLightColor.g }; - float hazeDirectionalLightColorB{ model::initialDirectionalLightColor.b }; - float hazeBaseReference{ model::initialHazeBaseReference }; + float hazeGlareColorR{ model::initialHazeGlareColor.r }; + float hazeGlareColorG{ model::initialHazeGlareColor.g }; + float hazeGlareColorB{ model::initialHazeGlareColor.b }; + float hazeBaseReference_m{ model::initialHazeBaseReference_m }; bool isHazeActive{ false }; bool isAltitudeBased{ false }; @@ -73,23 +73,23 @@ public: bool isHazeEnableGlare{ false }; float hazeRange_m{ model::initialHazeRange_m }; - float hazeAltitude_m{ model::initialHazeAltitude_m }; + float hazeHeight_m{ model::initialHazeHeight_m }; float hazeKeyLightRange_m{ model::initialHazeKeyLightRange_m }; float hazeKeyLightAltitude_m{ model::initialHazeKeyLightAltitude_m }; - float hazeBackgroundBlendValue{ model::initialHazeBackgroundBlendValue }; + float hazeBackgroundBlend{ model::initialHazeBackgroundBlend }; public slots: void setHazeColorR(const float value) { hazeColorR = value; emit dirty(); } void setHazeColorG(const float value) { hazeColorG = value; emit dirty(); } void setHazeColorB(const float value) { hazeColorB = value; emit dirty(); } - void setDirectionalLightAngle_degs(const float value) { hazeDirectionalLightAngle_degs = value; emit dirty(); } + void setHazeGlareAngle_degs(const float value) { hazeGlareAngle_degs = value; emit dirty(); } - void setDirectionalLightColorR(const float value) { hazeDirectionalLightColorR = value; emit dirty(); } - void setDirectionalLightColorG(const float value) { hazeDirectionalLightColorG = value; emit dirty(); } - void setDirectionalLightColorB(const float value) { hazeDirectionalLightColorB = value; emit dirty(); } - void setHazeBaseReference(const float value) { hazeBaseReference = value; ; emit dirty(); } + void setHazeGlareColorR(const float value) { hazeGlareColorR = value; emit dirty(); } + void setHazeGlareColorG(const float value) { hazeGlareColorG = value; emit dirty(); } + void setHazeGlareColorB(const float value) { hazeGlareColorB = value; emit dirty(); } + void setHazeBaseReference(const float value) { hazeBaseReference_m = value; ; emit dirty(); } void setHazeActive(const bool active) { isHazeActive = active; emit dirty(); } void setAltitudeBased(const bool active) { isAltitudeBased = active; emit dirty(); } @@ -98,12 +98,12 @@ public slots: void setHazeEnableGlare(const bool active) { isHazeEnableGlare = active; emit dirty(); } void setHazeRange_m(const float value) { hazeRange_m = value; emit dirty(); } - void setHazeAltitude_m(const float value) { hazeAltitude_m = value; emit dirty(); } + void setHazeAltitude_m(const float value) { hazeHeight_m = value; emit dirty(); } void setHazeKeyLightRange_m(const float value) { hazeKeyLightRange_m = value; emit dirty(); } void setHazeKeyLightAltitude_m(const float value) { hazeKeyLightAltitude_m = value; emit dirty(); } - void setHazeBackgroundBlendValue(const float value) { hazeBackgroundBlendValue = value; ; emit dirty(); } + void setHazeBackgroundBlend(const float value) { hazeBackgroundBlend = value; ; emit dirty(); } signals: void dirty(); @@ -131,12 +131,12 @@ public: float hazeColorR{ model::initialHazeColor.r }; float hazeColorG{ model::initialHazeColor.g }; float hazeColorB{ model::initialHazeColor.b }; - float hazeDirectionalLightAngle_degs{ model::initialDirectionalLightAngle_degs }; + float hazeGlareAngle_degs{ model::initialGlareAngle_degs }; - float hazeDirectionalLightColorR{ model::initialDirectionalLightColor.r }; - float hazeDirectionalLightColorG{ model::initialDirectionalLightColor.g }; - float hazeDirectionalLightColorB{ model::initialDirectionalLightColor.b }; - float hazeBaseReference{ model::initialHazeBaseReference }; + float hazeGlareColorR{ model::initialHazeGlareColor.r }; + float hazeGlareColorG{ model::initialHazeGlareColor.g }; + float hazeGlareColorB{ model::initialHazeGlareColor.b }; + float hazeBaseReference_m{ model::initialHazeBaseReference_m }; bool isHazeActive{ false }; // Setting this to true will set haze to on bool isAltitudeBased{ false }; @@ -145,22 +145,22 @@ public: bool isHazeEnableGlare{ false }; float hazeRange_m{ model::initialHazeRange_m }; - float hazeAltitude_m{ model::initialHazeAltitude_m }; + float hazeHeight_m{ model::initialHazeHeight_m }; float hazeKeyLightRange_m{ model::initialHazeKeyLightRange_m }; float hazeKeyLightAltitude_m{ model::initialHazeKeyLightAltitude_m }; - float hazeBackgroundBlendValue{ model::initialHazeBackgroundBlendValue }; + float hazeBackgroundBlend{ model::initialHazeBackgroundBlend }; // methods void setHazeColorR(const float value); void setHazeColorG(const float value); void setHazeColorB(const float value); - void setDirectionalLightAngle_degs(const float value); + void setHazeGlareAngle_degs(const float value); - void setDirectionalLightColorR(const float value); - void setDirectionalLightColorG(const float value); - void setDirectionalLightColorB(const float value); + void setHazeGlareColorR(const float value); + void setHazeGlareColorG(const float value); + void setHazeGlareColorB(const float value); void setHazeBaseReference(const float value); void setHazeActive(const bool active); @@ -175,7 +175,7 @@ public: void setHazeKeyLightRange_m(const float value); void setHazeKeyLightAltitude_m(const float value); - void setHazeBackgroundBlendValue(const float value); + void setHazeBackgroundBlend(const float value); }; class DrawHaze { diff --git a/libraries/render-utils/src/Haze.slf b/libraries/render-utils/src/Haze.slf index 77c820e093..b366e6d639 100644 --- a/libraries/render-utils/src/Haze.slf +++ b/libraries/render-utils/src/Haze.slf @@ -60,15 +60,15 @@ void main(void) { Light light = getLight(); vec3 lightDirection = getLightDirection(light); - float directionalLightComponent = max(0.0, dot(eyeFragDir, -lightDirection)); - float power = min(1.0, pow(directionalLightComponent, hazeParams.directionalLightBlend)); + float glareComponent = max(0.0, dot(eyeFragDir, -lightDirection)); + float power = min(1.0, pow(glareComponent, hazeParams.hazeGlareBlend)); - vec4 directionalLightColor = vec4(hazeParams.directionalLightColor, 1.0); + vec4 glareColor = vec4(hazeParams.hazeGlareColor, 1.0); - // Use the haze colour for the belnd-out colour, if blend is not enabled + // Use the haze colour for the glare colour, if blend is not enabled vec4 blendedHazeColor; if ((hazeParams.hazeMode & HAZE_MODE_IS_ENABLE_LIGHT_BLEND) == HAZE_MODE_IS_ENABLE_LIGHT_BLEND) { - blendedHazeColor = mix(hazeColor, directionalLightColor, power); + blendedHazeColor = mix(hazeColor, glareColor, power); } else { blendedHazeColor = hazeColor; } @@ -86,14 +86,14 @@ void main(void) { // Note that the haze base reference affects only the haze density as function of altitude vec3 hazeDensityDistribution = hazeParams.colorModulationFactor * - exp(-hazeParams.hazeAltitudeFactor * (worldEyePos.y - hazeParams.hazeBaseReference)); + exp(-hazeParams.hazeHeightFactor * (worldEyePos.y - hazeParams.hazeBaseReference)); vec3 hazeIntegral = hazeDensityDistribution * distance; const float slopeThreshold = 0.01; float deltaHeight = worldFragPos.y - worldEyePos.y; if (abs(deltaHeight) > slopeThreshold) { - float t = hazeParams.hazeAltitudeFactor * deltaHeight; + float t = hazeParams.hazeHeightFactor * deltaHeight; hazeIntegral *= (1.0 - exp (-t)) / t; } @@ -117,14 +117,14 @@ void main(void) { // Note that the haze base reference affects only the haze density as function of altitude float hazeDensityDistribution = hazeParams.hazeRangeFactor * - exp(-hazeParams.hazeAltitudeFactor * (worldEyePos.y - hazeParams.hazeBaseReference)); + exp(-hazeParams.hazeHeightFactor * (worldEyePos.y - hazeParams.hazeBaseReference)); float hazeIntegral = hazeDensityDistribution * distance; const float slopeThreshold = 0.01; float deltaHeight = worldFragPos.y - worldEyePos.y; if (abs(deltaHeight) > slopeThreshold) { - float t = hazeParams.hazeAltitudeFactor * deltaHeight; + float t = hazeParams.hazeHeightFactor * deltaHeight; // Protect from wild values if (abs(t) > 0.0000001) { hazeIntegral *= (1.0 - exp (-t)) / t; @@ -140,7 +140,7 @@ void main(void) { // Mix with background at far range const float BLEND_DISTANCE = 27000.0; if (distance > BLEND_DISTANCE) { - outFragColor = mix(potentialFragColor, fragColor, hazeParams.backgroundBlendValue); + outFragColor = mix(potentialFragColor, fragColor, hazeParams.backgroundBlend); } else { outFragColor = potentialFragColor; } diff --git a/libraries/render-utils/src/Haze.slh b/libraries/render-utils/src/Haze.slh index 614431dce7..de7f0ac246 100644 --- a/libraries/render-utils/src/Haze.slh +++ b/libraries/render-utils/src/Haze.slh @@ -12,28 +12,28 @@ const int HAZE_MODE_IS_ACTIVE = 1 << 0; const int HAZE_MODE_IS_ALTITUDE_BASED = 1 << 1; -const int HAZE_MODE_IS_DIRECTIONAL_LIGHT_ATTENUATED = 1 << 2; +const int HAZE_MODE_IS_KEYLIGHT_ATTENUATED = 1 << 2; const int HAZE_MODE_IS_MODULATE_COLOR = 1 << 3; const int HAZE_MODE_IS_ENABLE_LIGHT_BLEND = 1 << 4; struct HazeParams { vec3 hazeColor; - float directionalLightBlend; + float hazeGlareBlend; - vec3 directionalLightColor; + vec3 hazeGlareColor; float hazeBaseReference; vec3 colorModulationFactor; int hazeMode; mat4 zoneTransform; - float backgroundBlendValue; + float backgroundBlend; float hazeRangeFactor; - float hazeAltitudeFactor; + float hazeHeightFactor; - float hazeRangeFactorKeyLight; - float hazeAltitudeFactorKeyLight; + float hazeKeyLightRangeFactor; + float hazeKeyLightAltitudeFactor; }; layout(std140) uniform hazeBuffer { diff --git a/libraries/render-utils/src/HazeStage.cpp b/libraries/render-utils/src/HazeStage.cpp index aa7a7f554c..6a6104a1df 100644 --- a/libraries/render-utils/src/HazeStage.cpp +++ b/libraries/render-utils/src/HazeStage.cpp @@ -21,10 +21,10 @@ FetchHazeStage::FetchHazeStage() { void FetchHazeStage::configure(const Config& config) { _haze->setHazeColor(glm::vec3(config.hazeColorR, config.hazeColorG, config.hazeColorB)); - _haze->setDirectionalLightBlend(model::convertDirectionalLightAngleToPower(config.hazeDirectionalLightAngle_degs)); + _haze->setHazeGlareBlend(model::convertGlareAngleToPower(config.hazeGlareAngle_degs)); - _haze->setDirectionalLightColor(glm::vec3(config.hazeDirectionalLightColorR, config.hazeDirectionalLightColorG, config.hazeDirectionalLightColorB)); - _haze->setHazeBaseReference(config.hazeBaseReference); + _haze->setHazeGlareColor(glm::vec3(config.hazeGlareColorR, config.hazeGlareColorG, config.hazeGlareColorB)); + _haze->setHazeBaseReference(config.hazeBaseReference_m); _haze->setHazeActive(config.isHazeActive); _haze->setAltitudeBased(config.isAltitudeBased); @@ -33,12 +33,12 @@ void FetchHazeStage::configure(const Config& config) { _haze->setHazeEnableGlare(config.isHazeEnableGlare); _haze->setHazeRangeFactor(model::convertHazeRangeToHazeRangeFactor(config.hazeRange_m)); - _haze->setHazeAltitudeFactor(model::convertHazeAltitudeToHazeAltitudeFactor(config.hazeAltitude_m)); + _haze->setHazeAltitudeFactor(model::convertHazeAltitudeToHazeAltitudeFactor(config.hazeHeight_m)); _haze->setHazeKeyLightRangeFactor(model::convertHazeRangeToHazeRangeFactor(config.hazeKeyLightRange_m)); _haze->setHazeKeyLightAltitudeFactor(model::convertHazeAltitudeToHazeAltitudeFactor(config.hazeKeyLightAltitude_m)); - _haze->setHazeBackgroundBlendValue(config.hazeBackgroundBlendValue); + _haze->setHazeBackgroundBlend(config.hazeBackgroundBlend); } HazeStage::Index HazeStage::findHaze(const HazePointer& haze) const { diff --git a/libraries/render-utils/src/HazeStage.h b/libraries/render-utils/src/HazeStage.h index 7cc0c659b0..e2d09f3011 100644 --- a/libraries/render-utils/src/HazeStage.h +++ b/libraries/render-utils/src/HazeStage.h @@ -19,7 +19,7 @@ #include #include -#include "model/Haze.h" +#include // Haze stage to set up haze-related rendering tasks class HazeStage : public render::Stage { @@ -86,12 +86,12 @@ class FetchHazeConfig : public render::Job::Config { Q_PROPERTY(float hazeColorR MEMBER hazeColorR WRITE setHazeColorR NOTIFY dirty); Q_PROPERTY(float hazeColorG MEMBER hazeColorG WRITE setHazeColorG NOTIFY dirty); Q_PROPERTY(float hazeColorB MEMBER hazeColorB WRITE setHazeColorB NOTIFY dirty); - Q_PROPERTY(float hazeDirectionalLightAngle_degs MEMBER hazeDirectionalLightAngle_degs WRITE setDirectionalLightAngle_degs NOTIFY dirty); + Q_PROPERTY(float hazeGlareAngle_degs MEMBER hazeGlareAngle_degs WRITE setHazeGlareAngle_degs NOTIFY dirty); - Q_PROPERTY(float hazeDirectionalLightColorR MEMBER hazeDirectionalLightColorR WRITE setDirectionalLightColorR NOTIFY dirty); - Q_PROPERTY(float hazeDirectionalLightColorG MEMBER hazeDirectionalLightColorG WRITE setDirectionalLightColorG NOTIFY dirty); - Q_PROPERTY(float hazeDirectionalLightColorB MEMBER hazeDirectionalLightColorB WRITE setDirectionalLightColorB NOTIFY dirty); - Q_PROPERTY(float hazeBaseReference MEMBER hazeBaseReference WRITE setHazeBaseReference NOTIFY dirty); + Q_PROPERTY(float hazeGlareColorR MEMBER hazeGlareColorR WRITE setHazeGlareColorR NOTIFY dirty); + Q_PROPERTY(float hazeGlareColorG MEMBER hazeGlareColorG WRITE setHazeGlareColorG NOTIFY dirty); + Q_PROPERTY(float hazeGlareColorB MEMBER hazeGlareColorB WRITE setHazeGlareColorB NOTIFY dirty); + Q_PROPERTY(float hazeBaseReference_m MEMBER hazeBaseReference_m WRITE setHazeBaseReference NOTIFY dirty); Q_PROPERTY(bool isHazeActive MEMBER isHazeActive WRITE setHazeActive NOTIFY dirty); Q_PROPERTY(bool isAltitudeBased MEMBER isAltitudeBased WRITE setAltitudeBased NOTIFY dirty); @@ -100,12 +100,12 @@ class FetchHazeConfig : public render::Job::Config { Q_PROPERTY(bool isHazeEnableGlare MEMBER isHazeEnableGlare WRITE setHazeEnableGlare NOTIFY dirty); Q_PROPERTY(float hazeRange_m MEMBER hazeRange_m WRITE setHazeRange_m NOTIFY dirty); - Q_PROPERTY(float hazeAltitude_m MEMBER hazeAltitude_m WRITE setHazeAltitude_m NOTIFY dirty); + Q_PROPERTY(float hazeHeight_m MEMBER hazeHeight_m WRITE setHazeAltitude_m NOTIFY dirty); Q_PROPERTY(float hazeKeyLightRange_m MEMBER hazeKeyLightRange_m WRITE setHazeKeyLightRange_m NOTIFY dirty); Q_PROPERTY(float hazeKeyLightAltitude_m MEMBER hazeKeyLightAltitude_m WRITE setHazeKeyLightAltitude_m NOTIFY dirty); - Q_PROPERTY(float hazeBackgroundBlendValue MEMBER hazeBackgroundBlendValue WRITE setHazeBackgroundBlendValue NOTIFY dirty); + Q_PROPERTY(float hazeBackgroundBlend MEMBER hazeBackgroundBlend WRITE setHazeBackgroundBlend NOTIFY dirty); public: FetchHazeConfig() : render::Job::Config() {} @@ -113,12 +113,12 @@ public: float hazeColorR{ model::initialHazeColor.r }; float hazeColorG{ model::initialHazeColor.g }; float hazeColorB{ model::initialHazeColor.b }; - float hazeDirectionalLightAngle_degs{ model::initialDirectionalLightAngle_degs }; + float hazeGlareAngle_degs{ model::initialGlareAngle_degs }; - float hazeDirectionalLightColorR{ model::initialDirectionalLightColor.r }; - float hazeDirectionalLightColorG{ model::initialDirectionalLightColor.g }; - float hazeDirectionalLightColorB{ model::initialDirectionalLightColor.b }; - float hazeBaseReference{ model::initialHazeBaseReference }; + float hazeGlareColorR{ model::initialHazeGlareColor.r }; + float hazeGlareColorG{ model::initialHazeGlareColor.g }; + float hazeGlareColorB{ model::initialHazeGlareColor.b }; + float hazeBaseReference_m{ model::initialHazeBaseReference_m }; bool isHazeActive{ false }; bool isAltitudeBased{ false }; @@ -127,23 +127,23 @@ public: bool isHazeEnableGlare{ false }; float hazeRange_m{ model::initialHazeRange_m }; - float hazeAltitude_m{ model::initialHazeAltitude_m }; + float hazeHeight_m{ model::initialHazeHeight_m }; float hazeKeyLightRange_m{ model::initialHazeKeyLightRange_m }; float hazeKeyLightAltitude_m{ model::initialHazeKeyLightAltitude_m }; - float hazeBackgroundBlendValue{ model::initialHazeBackgroundBlendValue }; + float hazeBackgroundBlend{ model::initialHazeBackgroundBlend }; public slots: void setHazeColorR(const float value) { hazeColorR = value; emit dirty(); } void setHazeColorG(const float value) { hazeColorG = value; emit dirty(); } void setHazeColorB(const float value) { hazeColorB = value; emit dirty(); } - void setDirectionalLightAngle_degs(const float value) { hazeDirectionalLightAngle_degs = value; emit dirty(); } + void setHazeGlareAngle_degs(const float value) { hazeGlareAngle_degs = value; emit dirty(); } - void setDirectionalLightColorR(const float value) { hazeDirectionalLightColorR = value; emit dirty(); } - void setDirectionalLightColorG(const float value) { hazeDirectionalLightColorG = value; emit dirty(); } - void setDirectionalLightColorB(const float value) { hazeDirectionalLightColorB = value; emit dirty(); } - void setHazeBaseReference(const float value) { hazeBaseReference = value; ; emit dirty(); } + void setHazeGlareColorR(const float value) { hazeGlareColorR = value; emit dirty(); } + void setHazeGlareColorG(const float value) { hazeGlareColorG = value; emit dirty(); } + void setHazeGlareColorB(const float value) { hazeGlareColorB = value; emit dirty(); } + void setHazeBaseReference(const float value) { hazeBaseReference_m = value; ; emit dirty(); } void setHazeActive(const bool active) { isHazeActive = active; emit dirty(); } void setAltitudeBased(const bool active) { isAltitudeBased = active; emit dirty(); } @@ -152,12 +152,12 @@ public slots: void setHazeEnableGlare(const bool active) { isHazeEnableGlare = active; emit dirty(); } void setHazeRange_m(const float value) { hazeRange_m = value; emit dirty(); } - void setHazeAltitude_m(const float value) { hazeAltitude_m = value; emit dirty(); } + void setHazeAltitude_m(const float value) { hazeHeight_m = value; emit dirty(); } void setHazeKeyLightRange_m(const float value) { hazeKeyLightRange_m = value; emit dirty(); } void setHazeKeyLightAltitude_m(const float value) { hazeKeyLightAltitude_m = value; emit dirty(); } - void setHazeBackgroundBlendValue(const float value) { hazeBackgroundBlendValue = value; ; emit dirty(); } + void setHazeBackgroundBlend(const float value) { hazeBackgroundBlend = value; ; emit dirty(); } signals: void dirty(); diff --git a/scripts/system/html/entityProperties.html b/scripts/system/html/entityProperties.html index 2d5dd35e66..f898eb3b9a 100644 --- a/scripts/system/html/entityProperties.html +++ b/scripts/system/html/entityProperties.html @@ -570,14 +570,14 @@
-
+
Haze Color
-
+
-
+
-
+
@@ -586,14 +586,14 @@
-
+
Glare Color
-
+
-
+
-
+
diff --git a/scripts/system/html/js/entityProperties.js b/scripts/system/html/js/entityProperties.js index a015eed714..0463ac4172 100644 --- a/scripts/system/html/js/entityProperties.js +++ b/scripts/system/html/js/entityProperties.js @@ -678,14 +678,14 @@ function loaded() { var elZoneHazeModeEnabled = document.getElementById("property-zone-haze-mode-enabled"); var elZoneHazeRange = document.getElementById("property-zone-haze-range"); - var elZoneHazeColor = document.getElementById("property-zone-haze-blend-in-color"); - var elZoneHazeColorRed = document.getElementById("property-zone-haze-blend-in-color-red"); - var elZoneHazeColorGreen = document.getElementById("property-zone-haze-blend-in-color-green"); - var elZoneHazeColorBlue = document.getElementById("property-zone-haze-blend-in-color-blue"); - var elZoneHazeGlareColor = document.getElementById("property-zone-haze-blend-out-color"); - var elZoneHazeGlareColorRed = document.getElementById("property-zone-haze-blend-out-color-red"); - var elZoneHazeGlareColorGreen = document.getElementById("property-zone-haze-blend-out-color-green"); - var elZoneHazeGlareColorBlue = document.getElementById("property-zone-haze-blend-out-color-blue"); + var elZoneHazeColor = document.getElementById("property-zone-haze-color"); + var elZoneHazeColorRed = document.getElementById("property-zone-haze-color-red"); + var elZoneHazeColorGreen = document.getElementById("property-zone-haze-color-green"); + var elZoneHazeColorBlue = document.getElementById("property-zone-haze-color-blue"); + var elZoneHazeGlareColor = document.getElementById("property-zone-haze-glare-color"); + var elZoneHazeGlareColorRed = document.getElementById("property-zone-haze-glare-color-red"); + var elZoneHazeGlareColorGreen = document.getElementById("property-zone-haze-glare-color-green"); + var elZoneHazeGlareColorBlue = document.getElementById("property-zone-haze-glare-color-blue"); var elZoneHazeEnableGlare = document.getElementById("property-zone-haze-enable-light-blend"); var elZonehazeGlareAngle = document.getElementById("property-zone-haze-blend-angle"); @@ -1474,15 +1474,15 @@ function loaded() { elZoneHazeRange.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('haze', 'hazeRange')); - colorPickers.push($('#property-zone-haze-blend-in-color').colpick({ + colorPickers.push($('#property-zone-haze-color').colpick({ colorScheme: 'dark', layout: 'hex', color: '000000', onShow: function(colpick) { - $('#property-zone-haze-blend-in-color').attr('active', 'true'); + $('#property-zone-haze-color').attr('active', 'true'); }, onHide: function(colpick) { - $('#property-zone-haze-blend-in-color').attr('active', 'false'); + $('#property-zone-haze-color').attr('active', 'false'); }, onSubmit: function(hsb, hex, rgb, el) { $(el).css('background-color', '#' + hex); @@ -1499,15 +1499,15 @@ function loaded() { elZoneHazeColorGreen.addEventListener('change', zoneHazeColorChangeFunction); elZoneHazeColorBlue.addEventListener('change', zoneHazeColorChangeFunction); - colorPickers.push($('#property-zone-haze-blend-out-color').colpick({ + colorPickers.push($('#property-zone-haze-glare-color').colpick({ colorScheme: 'dark', layout: 'hex', color: '000000', onShow: function(colpick) { - $('#property-zone-haze-blend-out-color').attr('active', 'true'); + $('#property-zone-haze-glare-color').attr('active', 'true'); }, onHide: function(colpick) { - $('#property-zone-haze-blend-out-color').attr('active', 'false'); + $('#property-zone-haze-glare-color').attr('active', 'false'); }, onSubmit: function(hsb, hex, rgb, el) { $(el).css('background-color', '#' + hex); From a5a135c2bada77b0c7daff7163227a24ec47884e Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Fri, 27 Oct 2017 15:39:14 -0700 Subject: [PATCH 04/12] Fixes for 8672-8674. --- libraries/entities/src/EntityPropertyFlags.h | 36 +++---- libraries/entities/src/HazePropertyGroup.cpp | 1 + libraries/entities/src/ZoneEntityItem.cpp | 100 ------------------- libraries/entities/src/ZoneEntityItem.h | 41 -------- libraries/model/src/model/Stage.h | 22 ++-- 5 files changed, 30 insertions(+), 170 deletions(-) diff --git a/libraries/entities/src/EntityPropertyFlags.h b/libraries/entities/src/EntityPropertyFlags.h index c20b362b04..f0f22b0091 100644 --- a/libraries/entities/src/EntityPropertyFlags.h +++ b/libraries/entities/src/EntityPropertyFlags.h @@ -202,6 +202,24 @@ enum EntityPropertyList { PROP_ENTITY_INSTANCE_NUMBER, PROP_CERTIFICATE_ID, + PROP_HAZE_MODE, + + PROP_HAZE_RANGE, + PROP_HAZE_COLOR, + PROP_HAZE_GLARE_COLOR, + PROP_HAZE_ENABLE_GLARE, + PROP_HAZE_GLARE_ANGLE, + + PROP_HAZE_ALTITUDE_EFFECT, + PROP_HAZE_CEILING, + PROP_HAZE_BASE_REF, + + PROP_HAZE_BACKGROUND_BLEND, + + PROP_HAZE_ATTENUATE_KEYLIGHT, + PROP_HAZE_KEYLIGHT_RANGE, + PROP_HAZE_KEYLIGHT_ALTITUDE, + //////////////////////////////////////////////////////////////////////////////////////////////////// // ATTENTION: add new properties to end of list just ABOVE this line PROP_AFTER_LAST_ITEM, @@ -234,24 +252,6 @@ enum EntityPropertyList { PROP_STAGE_AUTOMATIC_HOURDAY = PROP_ANIMATION_FRAME_INDEX, PROP_BACKGROUND_MODE = PROP_MODEL_URL, - PROP_HAZE_MODE = PROP_COLOR, - - PROP_HAZE_RANGE = PROP_INTENSITY, - PROP_HAZE_COLOR = PROP_CUTOFF, - PROP_HAZE_GLARE_COLOR = PROP_EXPONENT, - PROP_HAZE_ENABLE_GLARE = PROP_IS_SPOTLIGHT, - PROP_HAZE_GLARE_ANGLE = PROP_DIFFUSE_COLOR, - - PROP_HAZE_ALTITUDE_EFFECT = PROP_AMBIENT_COLOR_UNUSED, - PROP_HAZE_CEILING = PROP_SPECULAR_COLOR_UNUSED, - PROP_HAZE_BASE_REF = PROP_LINEAR_ATTENUATION_UNUSED, - - PROP_HAZE_BACKGROUND_BLEND = PROP_QUADRATIC_ATTENUATION_UNUSED, - - PROP_HAZE_ATTENUATE_KEYLIGHT = PROP_ANIMATION_FRAME_INDEX, - PROP_HAZE_KEYLIGHT_RANGE = PROP_MODEL_URL, - PROP_HAZE_KEYLIGHT_ALTITUDE = PROP_ANIMATION_URL, - PROP_SKYBOX_COLOR = PROP_ANIMATION_URL, PROP_SKYBOX_URL = PROP_ANIMATION_FPS, PROP_KEYLIGHT_AMBIENT_URL = PROP_ANIMATION_PLAYING, diff --git a/libraries/entities/src/HazePropertyGroup.cpp b/libraries/entities/src/HazePropertyGroup.cpp index 3cc3e69960..f137fca5ce 100644 --- a/libraries/entities/src/HazePropertyGroup.cpp +++ b/libraries/entities/src/HazePropertyGroup.cpp @@ -293,6 +293,7 @@ EntityPropertyFlags HazePropertyGroup::getEntityProperties(EncodeBitstreamParams requestedProperties += PROP_HAZE_ENABLE_GLARE; requestedProperties += PROP_HAZE_GLARE_ANGLE; + requestedProperties += PROP_HAZE_ALTITUDE_EFFECT; requestedProperties += PROP_HAZE_CEILING; requestedProperties += PROP_HAZE_BASE_REF; diff --git a/libraries/entities/src/ZoneEntityItem.cpp b/libraries/entities/src/ZoneEntityItem.cpp index 588c1f9386..8b3d22daaf 100644 --- a/libraries/entities/src/ZoneEntityItem.cpp +++ b/libraries/entities/src/ZoneEntityItem.cpp @@ -330,103 +330,3 @@ void ZoneEntityItem::setHazeMode(const uint32_t value) { uint32_t ZoneEntityItem::getHazeMode() const { return _hazeMode; } - -void ZoneEntityItem::setHazeRange(const float hazeRange) { - _hazeRange = hazeRange; - _hazePropertiesChanged = true; -} - -float ZoneEntityItem::getHazeRange() const { - return _hazeRange; -} - -void ZoneEntityItem::setHazeColor(const xColor hazeColor) { - _hazeColor = hazeColor; - _hazePropertiesChanged = true; -} - -xColor ZoneEntityItem::getHazeColor() const { - return _hazeColor; -} - -void ZoneEntityItem::setHazeGlareColor(const xColor hazeGlareColor) { - _hazeGlareColor = hazeGlareColor; - _hazePropertiesChanged = true; -} - -xColor ZoneEntityItem::getHazeGlareColor()const { - return _hazeGlareColor; -} - -void ZoneEntityItem::setHazeEnableGlare(const bool hazeEnableGlare) { - _hazeEnableGlare = hazeEnableGlare; - _hazePropertiesChanged = true; -} - -bool ZoneEntityItem::getHazeEnableGlare()const { - return _hazeEnableGlare; -} - -void ZoneEntityItem::setHazeGlareAngle(const float hazeGlareAngle) { - _hazeGlareAngle = hazeGlareAngle; - _hazePropertiesChanged = true; -} - -float ZoneEntityItem::getHazeGlareAngle() const { - return _hazeGlareAngle; -} - -void ZoneEntityItem::setHazeCeiling(const float hazeCeiling) { - _hazeCeiling = hazeCeiling; - _hazePropertiesChanged = true; -} - -float ZoneEntityItem::getHazeCeiling() const { - return _hazeCeiling; -} - -void ZoneEntityItem::setHazeBaseRef(const float hazeBaseRef) { - _hazeBaseRef = hazeBaseRef; - _hazePropertiesChanged = true; -} - -float ZoneEntityItem::getHazeBaseRef() const { - return _hazeBaseRef; -} - -void ZoneEntityItem::setHazeBackgroundBlend(const float hazeBackgroundBlend) { - _hazeBackgroundBlend = hazeBackgroundBlend; - _hazePropertiesChanged = true; -} - -float ZoneEntityItem::getHazeBackgroundBlend() const { - return _hazeBackgroundBlend; -} - -void ZoneEntityItem::setHazeAttenuateKeyLight(const bool hazeAttenuateKeyLight) { - _hazeAttenuateKeyLight = hazeAttenuateKeyLight; - _hazePropertiesChanged = true; -} - -bool ZoneEntityItem::getHazeAttenuateKeyLight() const { - return _hazeAttenuateKeyLight; -} - -void ZoneEntityItem::setHazeKeyLightRange(const float hazeKeyLightRange) { - _hazeKeyLightRange = hazeKeyLightRange; - _hazePropertiesChanged = true; -} - -float ZoneEntityItem::getHazeKeyLightRange() const { - return _hazeKeyLightRange; -} - -void ZoneEntityItem::setHazeKeyLightAltitude(const float hazeKeyLightAltitude) { - _hazeKeyLightAltitude = hazeKeyLightAltitude; - _hazePropertiesChanged = true; -} - -float ZoneEntityItem::getHazeKeyLightAltitude() const { - return _hazeKeyLightAltitude; -} - diff --git a/libraries/entities/src/ZoneEntityItem.h b/libraries/entities/src/ZoneEntityItem.h index 628c228af6..ba5f3b3dee 100644 --- a/libraries/entities/src/ZoneEntityItem.h +++ b/libraries/entities/src/ZoneEntityItem.h @@ -74,32 +74,6 @@ public: void setHazeMode(const uint32_t value); uint32_t getHazeMode() const; - void setHazeRange(const float hazeRange); - float getHazeRange() const; - void setHazeColor(const xColor hazeColor); - xColor getHazeColor() const; - void setHazeGlareColor(const xColor hazeGlareColor); - xColor getHazeGlareColor() const; - void setHazeEnableGlare(const bool hazeEnableGlare); - bool getHazeEnableGlare() const; - void setHazeGlareAngle(const float hazeGlareAngle); - float getHazeGlareAngle() const; - - void setHazeCeiling(const float hazeCeiling); - float getHazeCeiling() const; - void setHazeBaseRef(const float hazeBaseRef); - float getHazeBaseRef() const; - - void setHazeBackgroundBlend(const float hazeBackgroundBlend); - float getHazeBackgroundBlend() const; - - void setHazeAttenuateKeyLight(const bool hazeAttenuateKeyLight); - bool getHazeAttenuateKeyLight() const; - void setHazeKeyLightRange(const float hazeKeyLightRange); - float getHazeKeyLightRange() const; - void setHazeKeyLightAltitude(const float hazeKeyLightAltitude); - float getHazeKeyLightAltitude() const; - SkyboxPropertyGroup getSkyboxProperties() const { return resultWithReadLock([&] { return _skyboxProperties; }); } const HazePropertyGroup& getHazeProperties() const { return _hazeProperties; } @@ -151,21 +125,6 @@ protected: uint32_t _hazeMode{ DEFAULT_HAZE_MODE }; - float _hazeRange{ model::initialHazeRange_m }; - xColor _hazeColor{ model::initialHazeColorXcolor }; - xColor _hazeGlareColor{ model::initialHazeGlareColorXcolor }; - bool _hazeEnableGlare{ false }; - float _hazeGlareAngle{ model::initialGlareAngle_degs }; - - float _hazeCeiling{ model::initialHazeBaseReference_m + model::initialHazeHeight_m }; - float _hazeBaseRef{ model::initialHazeBaseReference_m }; - - float _hazeBackgroundBlend{ model::initialHazeBackgroundBlend }; - - bool _hazeAttenuateKeyLight{ false }; - float _hazeKeyLightRange{ model::initialHazeKeyLightRange_m }; - float _hazeKeyLightAltitude{ model::initialHazeKeyLightAltitude_m }; - SkyboxPropertyGroup _skyboxProperties; HazePropertyGroup _hazeProperties; StagePropertyGroup _stageProperties; diff --git a/libraries/model/src/model/Stage.h b/libraries/model/src/model/Stage.h index e009684c62..a2eb7e3945 100644 --- a/libraries/model/src/model/Stage.h +++ b/libraries/model/src/model/Stage.h @@ -219,21 +219,21 @@ protected: uint8_t _hazeMode = (uint8_t)HAZE_OFF; - float _hazeRange; - xColor _hazeColor; - xColor _hazeGlareColor; - bool _hazeEnableGlare; - float _hazeGlareAngle; + float _hazeRange{ model::initialHazeRange_m }; + xColor _hazeColor{ model::initialHazeColorXcolor }; + xColor _hazeGlareColor{ model::initialHazeGlareColorXcolor }; + bool _hazeEnableGlare{ false }; + float _hazeGlareAngle{ model::initialGlareAngle_degs }; - bool _hazeAltitudeEffect; - float _hazeCeiling; + bool _hazeAltitudeEffect{ false }; + float _hazeCeiling{ model::initialHazeBaseReference_m + model::initialHazeHeight_m }; float _hazeBaseRef; - float _hazeBackgroundBlend; + float _hazeBackgroundBlend{ model::initialHazeBackgroundBlend }; - bool _hazeAttenuateKeyLight; - float _hazeKeyLightRange; - float _hazeKeyLightAltitude; + bool _hazeAttenuateKeyLight{ false }; + float _hazeKeyLightRange{ model::initialHazeKeyLightRange_m }; + float _hazeKeyLightAltitude{ model::initialHazeKeyLightAltitude_m }; LightPointer _sunLight; mutable SkyboxPointer _skybox; From d6b3fa4cb1bd65bd24a3bf6e9014d2e8e684c5fa Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Mon, 30 Oct 2017 10:49:08 -0700 Subject: [PATCH 05/12] Removed references to Haze from Stage. --- libraries/model/src/model/Stage.cpp | 7 -- libraries/model/src/model/Stage.h | 58 ----------- .../src/SceneScriptingInterface.cpp | 95 ------------------- .../src/SceneScriptingInterface.h | 52 ---------- 4 files changed, 212 deletions(-) diff --git a/libraries/model/src/model/Stage.cpp b/libraries/model/src/model/Stage.cpp index cd2312122c..5854162cfa 100644 --- a/libraries/model/src/model/Stage.cpp +++ b/libraries/model/src/model/Stage.cpp @@ -256,10 +256,3 @@ void SunSkyStage::setSkybox(const SkyboxPointer& skybox) { _skybox = skybox; invalidate(); } - -void SunSkyStage::setHazeMode(uint32_t hazeMode) { - if (hazeMode < COMPONENT_MODE_ITEM_COUNT) { - _hazeMode = hazeMode; - invalidate(); - } -} diff --git a/libraries/model/src/model/Stage.h b/libraries/model/src/model/Stage.h index a2eb7e3945..5f48824568 100644 --- a/libraries/model/src/model/Stage.h +++ b/libraries/model/src/model/Stage.h @@ -15,7 +15,6 @@ #include "Light.h" #include "Skybox.h" -#include "Haze.h" namespace model { @@ -175,65 +174,8 @@ public: void setSkybox(const SkyboxPointer& skybox); const SkyboxPointer& getSkybox() const { valid(); return _skybox; } - // Haze - enum HazeMode { - HAZE_OFF, - HAZE_ON, - - NUM_HAZE_MODES - }; - - void setHazeMode(uint32_t mode); - uint32_t getHazeMode() const { return _hazeMode; } - - void setHazeRange(float hazeRange) { _hazeRange = hazeRange; } - float getHazeRange() const { return _hazeRange; } - void setHazeColor(const xColor hazeColor) { _hazeColor = hazeColor; } - xColor getHazeColor() { return _hazeColor; } - void setHazeGlareColor(const xColor hazeGlareColor) { _hazeGlareColor = hazeGlareColor; } - xColor getHazeGlareColor() const { return _hazeGlareColor; } - void setHazeEnableGlare(bool hazeEnableGlare) { _hazeEnableGlare = hazeEnableGlare; } - bool getHazeEnableGlare() const { return _hazeEnableGlare; } - void setHazeGlareAngle(float hazeGlareAngle) { _hazeGlareAngle = hazeGlareAngle; } - float getHazeGlareAngle() const { return _hazeGlareAngle; } - - void setHazeAltitudeEffect(bool hazeAltitudeEffect) { _hazeAltitudeEffect = hazeAltitudeEffect; } - bool getHazeAltitudeEffect() const { return _hazeAltitudeEffect; } - void setHazeCeiling(float hazeCeiling) { _hazeCeiling = hazeCeiling; } - float getHazeCeiling() const { return _hazeCeiling; } - void setHazeBaseRef(float hazeBaseRef) { _hazeBaseRef = hazeBaseRef; } - float getHazeBaseRef() const { return _hazeBaseRef; } - - void setHazeBackgroundBlend(float hazeBackgroundBlend) { _hazeBackgroundBlend = hazeBackgroundBlend; } - float getHazeBackgroundBlend() const { return _hazeBackgroundBlend; } - - void setHazeAttenuateKeyLight(bool hazeAttenuateKeyLight) { _hazeAttenuateKeyLight = hazeAttenuateKeyLight; } - bool getHazeAttenuateKeyLight() const { return _hazeAttenuateKeyLight; } - void setHazeKeyLightRange(float hazeKeyLightRange) { _hazeKeyLightRange = hazeKeyLightRange; } - float getHazeKeyLightRange() const { return _hazeKeyLightRange; } - void setHazeKeyLightAltitude(float hazeKeyLightAltitude) { _hazeKeyLightAltitude = hazeKeyLightAltitude; } - float getHazeKeyLightAltitude() const { return _hazeKeyLightAltitude; } - protected: BackgroundMode _backgroundMode = SKY_DEFAULT; - - uint8_t _hazeMode = (uint8_t)HAZE_OFF; - - float _hazeRange{ model::initialHazeRange_m }; - xColor _hazeColor{ model::initialHazeColorXcolor }; - xColor _hazeGlareColor{ model::initialHazeGlareColorXcolor }; - bool _hazeEnableGlare{ false }; - float _hazeGlareAngle{ model::initialGlareAngle_degs }; - - bool _hazeAltitudeEffect{ false }; - float _hazeCeiling{ model::initialHazeBaseReference_m + model::initialHazeHeight_m }; - float _hazeBaseRef; - - float _hazeBackgroundBlend{ model::initialHazeBackgroundBlend }; - - bool _hazeAttenuateKeyLight{ false }; - float _hazeKeyLightRange{ model::initialHazeKeyLightRange_m }; - float _hazeKeyLightAltitude{ model::initialHazeKeyLightAltitude_m }; LightPointer _sunLight; mutable SkyboxPointer _skybox; diff --git a/libraries/script-engine/src/SceneScriptingInterface.cpp b/libraries/script-engine/src/SceneScriptingInterface.cpp index aa22eaa2d1..3883b948df 100644 --- a/libraries/script-engine/src/SceneScriptingInterface.cpp +++ b/libraries/script-engine/src/SceneScriptingInterface.cpp @@ -129,101 +129,6 @@ QString SceneScripting::Stage::getBackgroundMode() const { }; } -void SceneScripting::Stage::setHazeMode(const QString& mode) { - if (mode == QString("haze off")) { - _skyStage->setHazeMode(model::SunSkyStage::HAZE_OFF); - } else if (mode == QString("haze on")) { - _skyStage->setHazeMode(model::SunSkyStage::HAZE_ON); - } -} - -QString SceneScripting::Stage::getHazeMode() const { - switch (_skyStage->getHazeMode()) { - case model::SunSkyStage::HAZE_OFF: - return QString("haze off"); - case model::SunSkyStage::HAZE_ON: - return QString("haze on"); - default: - return QString("inherit"); - }; -} - -void SceneScripting::Stage::setHazeRange(const float hazeRange) { - _skyStage->setHazeRange(hazeRange); -} -float SceneScripting::Stage::getHazeRange() const { - return _skyStage->getHazeRange(); -} -void SceneScripting::Stage::setHazeColor(const xColor hazeColor) { - _skyStage->setHazeColor(hazeColor); -} -xColor SceneScripting::Stage::getHazeColor() const { - return _skyStage->getHazeColor(); -} -void SceneScripting::Stage::setHazeGlareColor(const xColor hazeGlareColor) { - _skyStage->setHazeGlareColor(hazeGlareColor); -} -xColor SceneScripting::Stage::getHazeGlareColor() const { - return _skyStage->getHazeGlareColor(); -} -void SceneScripting::Stage::setHazeEnableGlare(const bool hazeEnableGlare) { - _skyStage->setHazeEnableGlare(hazeEnableGlare); -} -bool SceneScripting::Stage::getHazeEnableGlare() const { - return _skyStage->getHazeEnableGlare(); -} -void SceneScripting::Stage::setHazeGlareAngle(const float hazeGlareAngle) { - _skyStage->setHazeGlareAngle(hazeGlareAngle); -} -float SceneScripting::Stage::getHazeGlareAngle() const { - return _skyStage->getHazeGlareAngle(); -} - -void SceneScripting::Stage::setHazeAltitudeEffect(const bool hazeAltitudeEffect) { - _skyStage->setHazeAltitudeEffect(hazeAltitudeEffect); -} -bool SceneScripting::Stage::getHazeAltitudeEffect() const { - return _skyStage->getHazeAltitudeEffect(); -} -void SceneScripting::Stage::setHazeCeiling(const float hazeCeiling) { - _skyStage->setHazeCeiling(hazeCeiling); -} -float SceneScripting::Stage::getHazeCeiling() const { - return _skyStage->getHazeCeiling(); -} -void SceneScripting::Stage::setHazeBaseRef(const float hazeBaseRef) { - _skyStage->setHazeBaseRef(hazeBaseRef); -} -float SceneScripting::Stage::getHazeBaseRef() const { - return _skyStage->getHazeBaseRef(); -} - -void SceneScripting::Stage::setHazeBackgroundBlend(const float hazeBackgroundBlend) { - _skyStage->setHazeBackgroundBlend(hazeBackgroundBlend); -} -float SceneScripting::Stage::getHazeBackgroundBlend() const { - return _skyStage->getHazeBackgroundBlend(); -} - -void SceneScripting::Stage::setHazeAttenuateKeyLight(const bool hazeAttenuateKeyLight) { - _skyStage->setHazeAttenuateKeyLight(hazeAttenuateKeyLight); -} -bool SceneScripting::Stage::getHazeAttenuateKeyLight() const { - return _skyStage->getHazeAttenuateKeyLight(); -} -void SceneScripting::Stage::setHazeKeyLightRange(const float hazeKeyLightRange) { - _skyStage->setHazeKeyLightRange(hazeKeyLightRange); -} -float SceneScripting::Stage::getHazeKeyLightRange() const { - return _skyStage->getHazeKeyLightRange(); -} -void SceneScripting::Stage::setHazeKeyLightAltitude(const float hazeKeyLightAltitude) { - _skyStage->setHazeKeyLightAltitude(hazeKeyLightAltitude); -} -float SceneScripting::Stage::getHazeKeyLightAltitude() const { - return _skyStage->getHazeKeyLightAltitude(); -} - SceneScriptingInterface::SceneScriptingInterface() : _stage{ new SceneScripting::Stage{ _skyStage } } { // Let's make sure the sunSkyStage is using a proceduralSkybox _skyStage->setSkybox(model::SkyboxPointer(new ProceduralSkybox())); diff --git a/libraries/script-engine/src/SceneScriptingInterface.h b/libraries/script-engine/src/SceneScriptingInterface.h index 791390236a..7bc22eb3e6 100644 --- a/libraries/script-engine/src/SceneScriptingInterface.h +++ b/libraries/script-engine/src/SceneScriptingInterface.h @@ -121,58 +121,6 @@ namespace SceneScripting { void setBackgroundMode(const QString& mode); QString getBackgroundMode() const; - Q_PROPERTY(QString hazeMode READ getHazeMode WRITE setHazeMode) - void setHazeMode(const QString& mode); - QString getHazeMode() const; - - Q_PROPERTY(float hazeRange READ getHazeRange WRITE setHazeRange) - void setHazeRange(float value); - float getHazeRange() const; - - Q_PROPERTY(xColor hazeColor READ getHazeColor WRITE setHazeColor) - void setHazeColor(xColor value); - xColor getHazeColor() const; - - Q_PROPERTY(xColor hazeGlareColor READ getHazeGlareColor WRITE setHazeGlareColor) - void setHazeGlareColor(xColor value); - xColor getHazeGlareColor() const; - - Q_PROPERTY(bool hazeEnableGlare READ getHazeEnableGlare WRITE setHazeEnableGlare) - void setHazeEnableGlare(bool value); - bool getHazeEnableGlare() const; - - Q_PROPERTY(float hazeGlareAngle READ getHazeGlareAngle WRITE setHazeGlareAngle) - void setHazeGlareAngle(float value); - float getHazeGlareAngle() const; - - Q_PROPERTY(bool hazeAltitudeEffect READ getHazeAltitudeEffect WRITE setHazeAltitudeEffect) - void setHazeAltitudeEffect(bool value); - bool getHazeAltitudeEffect() const; - - Q_PROPERTY(float hazeCeiling READ getHazeCeiling WRITE setHazeCeiling) - void setHazeCeiling(float value); - float getHazeCeiling() const; - - Q_PROPERTY(float hazeBaseRef READ getHazeBaseRef WRITE setHazeBaseRef) - void setHazeBaseRef(float value); - float getHazeBaseRef() const; - - Q_PROPERTY(float hazeBackgroundBlend READ getHazeBackgroundBlend WRITE setHazeBackgroundBlend) - void setHazeBackgroundBlend(float value); - float getHazeBackgroundBlend() const; - - Q_PROPERTY(bool hazeAttenuateKeyLight READ getHazeAttenuateKeyLight WRITE setHazeAttenuateKeyLight) - void setHazeAttenuateKeyLight(bool value); - bool getHazeAttenuateKeyLight() const; - - Q_PROPERTY(float hazeKeyLightRange READ getHazeKeyLightRange WRITE setHazeKeyLightRange) - void setHazeKeyLightRange(float value); - float getHazeKeyLightRange() const; - - Q_PROPERTY(float hazeKeyLightAltitude READ getHazeKeyLightAltitude WRITE setHazeKeyLightAltitude) - void setHazeKeyLightAltitude(float value); - float getHazeKeyLightAltitude() const; - protected: model::SunSkyStagePointer _skyStage; LocationPointer _location; From 5fc68cae0d5d24f0745546a1d55397484e68c89d Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Mon, 30 Oct 2017 11:51:19 -0700 Subject: [PATCH 06/12] Converted Haze initialization values to static. --- libraries/entities/CMakeLists.txt | 2 +- libraries/entities/src/HazePropertyGroup.h | 20 +++---- libraries/entities/src/ZoneEntityItem.h | 2 +- libraries/model/src/model/Haze.cpp | 25 +++++++- libraries/model/src/model/Haze.h | 55 ++++++++++++++++- libraries/model/src/model/HazeInit.h | 69 ---------------------- libraries/render-utils/src/DrawHaze.h | 52 ++++++++-------- libraries/render-utils/src/HazeStage.h | 26 ++++---- 8 files changed, 128 insertions(+), 123 deletions(-) delete mode 100644 libraries/model/src/model/HazeInit.h diff --git a/libraries/entities/CMakeLists.txt b/libraries/entities/CMakeLists.txt index c23740654e..146aecf1f6 100644 --- a/libraries/entities/CMakeLists.txt +++ b/libraries/entities/CMakeLists.txt @@ -1,4 +1,4 @@ set(TARGET_NAME entities) setup_hifi_library(Network Script) include_directories(SYSTEM "${OPENSSL_INCLUDE_DIR}") -link_hifi_libraries(shared networking octree avatars model) +link_hifi_libraries(shared networking octree avatars model gpu) diff --git a/libraries/entities/src/HazePropertyGroup.h b/libraries/entities/src/HazePropertyGroup.h index 1cbaa24f2a..1585f35c45 100644 --- a/libraries/entities/src/HazePropertyGroup.h +++ b/libraries/entities/src/HazePropertyGroup.h @@ -21,7 +21,7 @@ #include "PropertyGroup.h" #include "EntityItemPropertiesMacros.h" -#include +#include class EntityItemProperties; class EncodeBitstreamParams; @@ -77,24 +77,24 @@ public: bool& somethingChanged) override; // Range only parameters - DEFINE_PROPERTY(PROP_HAZE_RANGE, HazeRange, hazeRange, float, model::initialHazeRange_m); - DEFINE_PROPERTY_REF(PROP_HAZE_COLOR, HazeColor, hazeColor, xColor, model::initialHazeColorXcolor); - DEFINE_PROPERTY_REF(PROP_HAZE_GLARE_COLOR, HazeGlareColor, hazeGlareColor, xColor, model::initialHazeGlareColorXcolor); + DEFINE_PROPERTY(PROP_HAZE_RANGE, HazeRange, hazeRange, float, model::Haze::initialHazeRange_m); + DEFINE_PROPERTY_REF(PROP_HAZE_COLOR, HazeColor, hazeColor, xColor, model::Haze::initialHazeColorXcolor); + DEFINE_PROPERTY_REF(PROP_HAZE_GLARE_COLOR, HazeGlareColor, hazeGlareColor, xColor, model::Haze::initialHazeGlareColorXcolor); DEFINE_PROPERTY(PROP_HAZE_ENABLE_GLARE, HazeEnableGlare, hazeEnableGlare, bool, false); - DEFINE_PROPERTY_REF(PROP_HAZE_GLARE_ANGLE, HazeGlareAngle, hazeGlareAngle, float, model::initialGlareAngle_degs); + DEFINE_PROPERTY_REF(PROP_HAZE_GLARE_ANGLE, HazeGlareAngle, hazeGlareAngle, float, model::Haze::initialGlareAngle_degs); // Altitude parameters DEFINE_PROPERTY(PROP_HAZE_ALTITUDE_EFFECT, HazeAltitudeEffect, hazeAltitudeEffect, bool, false); - DEFINE_PROPERTY_REF(PROP_HAZE_CEILING, HazeCeiling, hazeCeiling, float, model::initialHazeBaseReference_m + model::initialHazeHeight_m); - DEFINE_PROPERTY_REF(PROP_HAZE_BASE_REF, HazeBaseRef, hazeBaseRef, float, model::initialHazeBaseReference_m); + DEFINE_PROPERTY_REF(PROP_HAZE_CEILING, HazeCeiling, hazeCeiling, float, model::Haze::initialHazeBaseReference_m + model::Haze::initialHazeHeight_m); + DEFINE_PROPERTY_REF(PROP_HAZE_BASE_REF, HazeBaseRef, hazeBaseRef, float, model::Haze::initialHazeBaseReference_m); // Background (skybox) blend value - DEFINE_PROPERTY_REF(PROP_HAZE_BACKGROUND_BLEND, HazeBackgroundBlend, hazeBackgroundBlend, float, model::initialHazeBackgroundBlend); + DEFINE_PROPERTY_REF(PROP_HAZE_BACKGROUND_BLEND, HazeBackgroundBlend, hazeBackgroundBlend, float, model::Haze::initialHazeBackgroundBlend); // hazeDirectional light attenuation DEFINE_PROPERTY(PROP_HAZE_ATTENUATE_KEYLIGHT, HazeAttenuateKeyLight, hazeAttenuateKeyLight, bool, false); - DEFINE_PROPERTY_REF(PROP_HAZE_KEYLIGHT_RANGE, HazeKeyLightRange, hazeKeyLightRange, float, model::initialHazeKeyLightRange_m); - DEFINE_PROPERTY_REF(PROP_HAZE_KEYLIGHT_ALTITUDE, HazeKeyLightAltitude, hazeKeyLightAltitude, float, model::initialHazeKeyLightAltitude_m); + DEFINE_PROPERTY_REF(PROP_HAZE_KEYLIGHT_RANGE, HazeKeyLightRange, hazeKeyLightRange, float, model::Haze::initialHazeKeyLightRange_m); + DEFINE_PROPERTY_REF(PROP_HAZE_KEYLIGHT_ALTITUDE, HazeKeyLightAltitude, hazeKeyLightAltitude, float, model::Haze::initialHazeKeyLightAltitude_m); }; #endif // hifi_HazePropertyGroup_h diff --git a/libraries/entities/src/ZoneEntityItem.h b/libraries/entities/src/ZoneEntityItem.h index ba5f3b3dee..3f78591745 100644 --- a/libraries/entities/src/ZoneEntityItem.h +++ b/libraries/entities/src/ZoneEntityItem.h @@ -19,7 +19,7 @@ #include "HazePropertyGroup.h" #include "StagePropertyGroup.h" #include -#include +#include class ZoneEntityItem : public EntityItem { public: diff --git a/libraries/model/src/model/Haze.cpp b/libraries/model/src/model/Haze.cpp index 1c9b989fd1..92042364c2 100644 --- a/libraries/model/src/model/Haze.cpp +++ b/libraries/model/src/model/Haze.cpp @@ -9,12 +9,35 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include -#include #include "Haze.h" using namespace model; +const float Haze::initialHazeRange_m{ 1000.0f }; +const float Haze::initialHazeHeight_m{ 200.0f }; + +const float Haze::initialHazeKeyLightRange_m{ 1000.0f }; +const float Haze::initialHazeKeyLightAltitude_m{ 200.0f }; + +const float Haze::initialHazeBackgroundBlend{ 0.0f }; + +const glm::vec3 Haze::initialColorModulationFactor{ + convertHazeRangeToHazeRangeFactor(initialHazeRange_m), + convertHazeRangeToHazeRangeFactor(initialHazeRange_m), + convertHazeRangeToHazeRangeFactor(initialHazeRange_m) +}; + +const glm::vec3 Haze::initialHazeColor{ 0.5f, 0.6f, 0.7f }; // Bluish +const xColor Haze::initialHazeColorXcolor{ 128, 154, 179 }; + +const float Haze::initialGlareAngle_degs{ 20.0f }; + +const glm::vec3 Haze::initialHazeGlareColor{ 1.0f, 0.9f, 0.7f }; +const xColor Haze::initialHazeGlareColorXcolor{ 255, 229, 179 }; + +const float Haze::initialHazeBaseReference_m{ 0.0f }; + Haze::Haze() { Parameters parameters; _hazeParametersBuffer = gpu::BufferView(std::make_shared(sizeof(Parameters), (const gpu::Byte*) ¶meters)); diff --git a/libraries/model/src/model/Haze.h b/libraries/model/src/model/Haze.h index bed82c80f9..c361fcde8c 100644 --- a/libraries/model/src/model/Haze.h +++ b/libraries/model/src/model/Haze.h @@ -12,17 +12,68 @@ #define hifi_model_Haze_h #include +#include + #include "Transform.h" #include "NumericalConstants.h" -#include "HazeInit.h" - namespace model { + const float LOG_P_005 = logf(0.05f); + const float LOG_P_05 = logf(0.5f); + + // Derivation (d is distance, b is haze coefficient, f is attenuation, solve for f = 0.05 + // f = exp(-d * b) + // ln(f) = -d * b + // b = -ln(f)/d + inline glm::vec3 convertHazeRangeToHazeRangeFactor(const glm::vec3 hazeRange_m) { + return glm::vec3( + -LOG_P_005 / hazeRange_m.x, + -LOG_P_005 / hazeRange_m.y, + -LOG_P_005 / hazeRange_m.z); + } + + // limit range and altitude to no less than 1.0 metres + inline float convertHazeRangeToHazeRangeFactor(const float hazeRange_m) { return -LOG_P_005 / glm::max(hazeRange_m, 1.0f); } + + inline float convertHazeAltitudeToHazeAltitudeFactor(const float hazeHeight_m) { return -LOG_P_005 / glm::max(hazeHeight_m, 1.0f); } + + // Derivation (s is the proportion of sun blend, a is the angle at which the blend is 50%, solve for m = 0.5 + // s = dot(lookAngle, sunAngle) = cos(a) + // m = pow(s, p) + // log(m) = p * log(s) + // p = log(m) / log(s) + // limit to 0.1 degrees + inline float convertGlareAngleToPower(const float hazeGlareAngle) { + const float GLARE_ANGLE_LIMIT = 0.1f; + return LOG_P_05 / logf(cosf(RADIANS_PER_DEGREE * glm::max(GLARE_ANGLE_LIMIT, hazeGlareAngle))); + } + // Haze range is defined here as the range the visibility is reduced by 95% // Haze altitude is defined here as the altitude (above 0) that the haze is reduced by 95% class Haze { public: + // Initial values + static const float initialHazeRange_m; + static const float initialHazeHeight_m; + + static const float initialHazeKeyLightRange_m; + static const float initialHazeKeyLightAltitude_m; + + static const float initialHazeBackgroundBlend; + + static const glm::vec3 initialColorModulationFactor; + + static const glm::vec3 initialHazeColor; + static const xColor initialHazeColorXcolor; + + static const float initialGlareAngle_degs; + + static const glm::vec3 initialHazeGlareColor; + static const xColor initialHazeGlareColorXcolor; + + static const float initialHazeBaseReference_m; + using UniformBufferView = gpu::BufferView; Haze(); diff --git a/libraries/model/src/model/HazeInit.h b/libraries/model/src/model/HazeInit.h deleted file mode 100644 index 218a79fc1d..0000000000 --- a/libraries/model/src/model/HazeInit.h +++ /dev/null @@ -1,69 +0,0 @@ -// -// MakeHaze.h -// libraries/model/src/model -// -// Created by Nissim Hadar on 10/26/2017. -// Copyright 2014 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// -#ifndef hifi_model_HazeInit_h -#define hifi_model_HazeInit_h - -namespace model { - const float LOG_P_005 = logf(0.05f); - const float LOG_P_05 = logf(0.5f); - - // Derivation (d is distance, b is haze coefficient, f is attenuation, solve for f = 0.05 - // f = exp(-d * b) - // ln(f) = -d * b - // b = -ln(f)/d - inline glm::vec3 convertHazeRangeToHazeRangeFactor(const glm::vec3 hazeRange_m) { - return glm::vec3( - -LOG_P_005 / hazeRange_m.x, - -LOG_P_005 / hazeRange_m.y, - -LOG_P_005 / hazeRange_m.z); - } - - // limit range and altitude to no less than 1.0 metres - inline float convertHazeRangeToHazeRangeFactor(const float hazeRange_m) { return -LOG_P_005 / glm::max(hazeRange_m, 1.0f); } - - inline float convertHazeAltitudeToHazeAltitudeFactor(const float hazeHeight_m) { return -LOG_P_005 / glm::max(hazeHeight_m, 1.0f); } - - // Derivation (s is the proportion of sun blend, a is the angle at which the blend is 50%, solve for m = 0.5 - // s = dot(lookAngle, sunAngle) = cos(a) - // m = pow(s, p) - // log(m) = p * log(s) - // p = log(m) / log(s) - // limit to 0.1 degrees - inline float convertGlareAngleToPower(const float hazeGlareAngle) { - const float GLARE_ANGLE_LIMIT = 0.1f; - return LOG_P_05 / logf(cosf(RADIANS_PER_DEGREE * glm::max(GLARE_ANGLE_LIMIT, hazeGlareAngle))); - } - - const float initialHazeRange_m{ 1000.0f }; - const float initialHazeHeight_m{ 200.0f }; - - const float initialHazeKeyLightRange_m{ 1000.0f }; - const float initialHazeKeyLightAltitude_m{ 200.0f }; - - const float initialHazeBackgroundBlend{ 0.0f }; - - const glm::vec3 initialColorModulationFactor{ - convertHazeRangeToHazeRangeFactor(initialHazeRange_m), - convertHazeRangeToHazeRangeFactor(initialHazeRange_m), - convertHazeRangeToHazeRangeFactor(initialHazeRange_m) - }; - - const glm::vec3 initialHazeColor{ 0.5f, 0.6f, 0.7f }; // Bluish - const xColor initialHazeColorXcolor{ 128, 154, 179 }; - - const float initialGlareAngle_degs{ 20.0f }; - - const glm::vec3 initialHazeGlareColor{ 1.0f, 0.9f, 0.7f }; - const xColor initialHazeGlareColorXcolor{ 255, 229, 179 }; - - const float initialHazeBaseReference_m{ 0.0f }; -} -#endif // hifi_model_HazeInit_h diff --git a/libraries/render-utils/src/DrawHaze.h b/libraries/render-utils/src/DrawHaze.h index e7a3f2c636..786c39133b 100644 --- a/libraries/render-utils/src/DrawHaze.h +++ b/libraries/render-utils/src/DrawHaze.h @@ -56,15 +56,15 @@ class MakeHazeConfig : public render::Job::Config { public: MakeHazeConfig() : render::Job::Config() {} - float hazeColorR{ model::initialHazeColor.r }; - float hazeColorG{ model::initialHazeColor.g }; - float hazeColorB{ model::initialHazeColor.b }; - float hazeGlareAngle_degs{ model::initialGlareAngle_degs }; + float hazeColorR{ model::Haze::initialHazeColor.r }; + float hazeColorG{ model::Haze::initialHazeColor.g }; + float hazeColorB{ model::Haze::initialHazeColor.b }; + float hazeGlareAngle_degs{ model::Haze::initialGlareAngle_degs }; - float hazeGlareColorR{ model::initialHazeGlareColor.r }; - float hazeGlareColorG{ model::initialHazeGlareColor.g }; - float hazeGlareColorB{ model::initialHazeGlareColor.b }; - float hazeBaseReference_m{ model::initialHazeBaseReference_m }; + float hazeGlareColorR{ model::Haze::initialHazeGlareColor.r }; + float hazeGlareColorG{ model::Haze::initialHazeGlareColor.g }; + float hazeGlareColorB{ model::Haze::initialHazeGlareColor.b }; + float hazeBaseReference_m{ model::Haze::initialHazeBaseReference_m }; bool isHazeActive{ false }; bool isAltitudeBased{ false }; @@ -72,13 +72,13 @@ public: bool isModulateColorActive{ false }; bool isHazeEnableGlare{ false }; - float hazeRange_m{ model::initialHazeRange_m }; - float hazeHeight_m{ model::initialHazeHeight_m }; + float hazeRange_m{ model::Haze::initialHazeRange_m }; + float hazeHeight_m{ model::Haze::initialHazeHeight_m }; - float hazeKeyLightRange_m{ model::initialHazeKeyLightRange_m }; - float hazeKeyLightAltitude_m{ model::initialHazeKeyLightAltitude_m }; + float hazeKeyLightRange_m{ model::Haze::initialHazeKeyLightRange_m }; + float hazeKeyLightAltitude_m{ model::Haze::initialHazeKeyLightAltitude_m }; - float hazeBackgroundBlend{ model::initialHazeBackgroundBlend }; + float hazeBackgroundBlend{ model::Haze::initialHazeBackgroundBlend }; public slots: void setHazeColorR(const float value) { hazeColorR = value; emit dirty(); } @@ -128,15 +128,15 @@ public: HazeConfig() : render::Job::Config(true) {} // attributes - float hazeColorR{ model::initialHazeColor.r }; - float hazeColorG{ model::initialHazeColor.g }; - float hazeColorB{ model::initialHazeColor.b }; - float hazeGlareAngle_degs{ model::initialGlareAngle_degs }; + float hazeColorR{ model::Haze::initialHazeColor.r }; + float hazeColorG{ model::Haze::initialHazeColor.g }; + float hazeColorB{ model::Haze::initialHazeColor.b }; + float hazeGlareAngle_degs{ model::Haze::initialGlareAngle_degs }; - float hazeGlareColorR{ model::initialHazeGlareColor.r }; - float hazeGlareColorG{ model::initialHazeGlareColor.g }; - float hazeGlareColorB{ model::initialHazeGlareColor.b }; - float hazeBaseReference_m{ model::initialHazeBaseReference_m }; + float hazeGlareColorR{ model::Haze::initialHazeGlareColor.r }; + float hazeGlareColorG{ model::Haze::initialHazeGlareColor.g }; + float hazeGlareColorB{ model::Haze::initialHazeGlareColor.b }; + float hazeBaseReference_m{ model::Haze::initialHazeBaseReference_m }; bool isHazeActive{ false }; // Setting this to true will set haze to on bool isAltitudeBased{ false }; @@ -144,13 +144,13 @@ public: bool isModulateColorActive{ false }; bool isHazeEnableGlare{ false }; - float hazeRange_m{ model::initialHazeRange_m }; - float hazeHeight_m{ model::initialHazeHeight_m }; + float hazeRange_m{ model::Haze::initialHazeRange_m }; + float hazeHeight_m{ model::Haze::initialHazeHeight_m }; - float hazeKeyLightRange_m{ model::initialHazeKeyLightRange_m }; - float hazeKeyLightAltitude_m{ model::initialHazeKeyLightAltitude_m }; + float hazeKeyLightRange_m{ model::Haze::initialHazeKeyLightRange_m }; + float hazeKeyLightAltitude_m{ model::Haze::initialHazeKeyLightAltitude_m }; - float hazeBackgroundBlend{ model::initialHazeBackgroundBlend }; + float hazeBackgroundBlend{ model::Haze::initialHazeBackgroundBlend }; // methods void setHazeColorR(const float value); diff --git a/libraries/render-utils/src/HazeStage.h b/libraries/render-utils/src/HazeStage.h index e2d09f3011..e3b061dffd 100644 --- a/libraries/render-utils/src/HazeStage.h +++ b/libraries/render-utils/src/HazeStage.h @@ -110,15 +110,15 @@ class FetchHazeConfig : public render::Job::Config { public: FetchHazeConfig() : render::Job::Config() {} - float hazeColorR{ model::initialHazeColor.r }; - float hazeColorG{ model::initialHazeColor.g }; - float hazeColorB{ model::initialHazeColor.b }; - float hazeGlareAngle_degs{ model::initialGlareAngle_degs }; + float hazeColorR{ model::Haze::initialHazeColor.r }; + float hazeColorG{ model::Haze::initialHazeColor.g }; + float hazeColorB{ model::Haze::initialHazeColor.b }; + float hazeGlareAngle_degs{ model::Haze::initialGlareAngle_degs }; - float hazeGlareColorR{ model::initialHazeGlareColor.r }; - float hazeGlareColorG{ model::initialHazeGlareColor.g }; - float hazeGlareColorB{ model::initialHazeGlareColor.b }; - float hazeBaseReference_m{ model::initialHazeBaseReference_m }; + float hazeGlareColorR{ model::Haze::initialHazeGlareColor.r }; + float hazeGlareColorG{ model::Haze::initialHazeGlareColor.g }; + float hazeGlareColorB{ model::Haze::initialHazeGlareColor.b }; + float hazeBaseReference_m{ model::Haze::initialHazeBaseReference_m }; bool isHazeActive{ false }; bool isAltitudeBased{ false }; @@ -126,13 +126,13 @@ public: bool isModulateColorActive{ false }; bool isHazeEnableGlare{ false }; - float hazeRange_m{ model::initialHazeRange_m }; - float hazeHeight_m{ model::initialHazeHeight_m }; + float hazeRange_m{ model::Haze::initialHazeRange_m }; + float hazeHeight_m{ model::Haze::initialHazeHeight_m }; - float hazeKeyLightRange_m{ model::initialHazeKeyLightRange_m }; - float hazeKeyLightAltitude_m{ model::initialHazeKeyLightAltitude_m }; + float hazeKeyLightRange_m{ model::Haze::initialHazeKeyLightRange_m }; + float hazeKeyLightAltitude_m{ model::Haze::initialHazeKeyLightAltitude_m }; - float hazeBackgroundBlend{ model::initialHazeBackgroundBlend }; + float hazeBackgroundBlend{ model::Haze::initialHazeBackgroundBlend }; public slots: void setHazeColorR(const float value) { hazeColorR = value; emit dirty(); } From 6391282680d0f2732083fa95898f458a491b1242 Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Mon, 30 Oct 2017 12:05:23 -0700 Subject: [PATCH 07/12] Swapped location of keylight attenuation and the blending factor. --- scripts/system/html/entityProperties.html | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/system/html/entityProperties.html b/scripts/system/html/entityProperties.html index f898eb3b9a..10ccfc52a7 100644 --- a/scripts/system/html/entityProperties.html +++ b/scripts/system/html/entityProperties.html @@ -602,6 +602,12 @@
+
+
+ + +
+
@@ -614,12 +620,6 @@ min="-1000" max="50000" step="10">
-
-
- - -
-
From 1357877618759784482fa4aa9acd58b8d9dc7dcb Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Mon, 30 Oct 2017 12:41:09 -0700 Subject: [PATCH 08/12] Replaced separate RGB components of colours with vec3's. --- libraries/render-utils/src/DrawHaze.cpp | 28 ++++------------ libraries/render-utils/src/DrawHaze.h | 40 ++++++----------------- libraries/render-utils/src/HazeStage.cpp | 4 +-- libraries/render-utils/src/HazeStage.h | 24 ++++---------- scripts/developer/debugging/debugHaze.qml | 20 ++++++------ 5 files changed, 34 insertions(+), 82 deletions(-) diff --git a/libraries/render-utils/src/DrawHaze.cpp b/libraries/render-utils/src/DrawHaze.cpp index 071db8cf25..5c3d527e91 100644 --- a/libraries/render-utils/src/DrawHaze.cpp +++ b/libraries/render-utils/src/DrawHaze.cpp @@ -21,32 +21,16 @@ #include "Haze_frag.h" -void HazeConfig::setHazeColorR(const float value) { - hazeColorR = value; -} - -void HazeConfig::setHazeColorG(const float value) { - hazeColorG = value; -} - -void HazeConfig::setHazeColorB(const float value) { - hazeColorB = value; +void HazeConfig::setHazeColor(const glm::vec3 value) { + hazeColor = value; } void HazeConfig::setHazeGlareAngle_degs(const float value) { hazeGlareAngle_degs = value; } -void HazeConfig::setHazeGlareColorR(const float value) { - hazeGlareColorR = value; -} - -void HazeConfig::setHazeGlareColorG(const float value) { - hazeGlareColorG = value; -} - -void HazeConfig::setHazeGlareColorB(const float value) { - hazeGlareColorB = value; +void HazeConfig::setHazeGlareColor(const glm::vec3 value) { + hazeGlareColor = value; } void HazeConfig::setHazeBaseReference(const float value) { @@ -98,10 +82,10 @@ MakeHaze::MakeHaze() { } void MakeHaze::configure(const Config& config) { - _haze->setHazeColor(glm::vec3(config.hazeColorR, config.hazeColorG, config.hazeColorB)); + _haze->setHazeColor(config.hazeColor); _haze->setHazeGlareBlend(model::convertGlareAngleToPower(config.hazeGlareAngle_degs)); - _haze->setHazeGlareColor(glm::vec3(config.hazeGlareColorR, config.hazeGlareColorG, config.hazeGlareColorB)); + _haze->setHazeGlareColor(config.hazeGlareColor); _haze->setHazeBaseReference(config.hazeBaseReference_m); _haze->setHazeActive(config.isHazeActive); diff --git a/libraries/render-utils/src/DrawHaze.h b/libraries/render-utils/src/DrawHaze.h index 786c39133b..3005203c5b 100644 --- a/libraries/render-utils/src/DrawHaze.h +++ b/libraries/render-utils/src/DrawHaze.h @@ -29,14 +29,10 @@ using LinearDepthFramebufferPointer = std::shared_ptr; class MakeHazeConfig : public render::Job::Config { Q_OBJECT - Q_PROPERTY(float hazeColorR MEMBER hazeColorR WRITE setHazeColorR NOTIFY dirty); - Q_PROPERTY(float hazeColorG MEMBER hazeColorG WRITE setHazeColorG NOTIFY dirty); - Q_PROPERTY(float hazeColorB MEMBER hazeColorB WRITE setHazeColorB NOTIFY dirty); + Q_PROPERTY(glm::vec3 hazeColor MEMBER hazeColor WRITE setHazeColor NOTIFY dirty); Q_PROPERTY(float hazeGlareAngle_degs MEMBER hazeGlareAngle_degs WRITE setHazeGlareAngle_degs NOTIFY dirty); - Q_PROPERTY(float hazeGlareColorR MEMBER hazeGlareColorR WRITE setHazeGlareColorR NOTIFY dirty); - Q_PROPERTY(float hazeGlareColorG MEMBER hazeGlareColorG WRITE setHazeGlareColorG NOTIFY dirty); - Q_PROPERTY(float hazeGlareColorB MEMBER hazeGlareColorB WRITE setHazeGlareColorB NOTIFY dirty); + Q_PROPERTY(glm::vec3 hazeGlareColor MEMBER hazeGlareColor WRITE setHazeGlareColor NOTIFY dirty); Q_PROPERTY(float hazeBaseReference_m MEMBER hazeBaseReference_m WRITE setHazeBaseReference NOTIFY dirty); Q_PROPERTY(bool isHazeActive MEMBER isHazeActive WRITE setHazeActive NOTIFY dirty); @@ -56,14 +52,10 @@ class MakeHazeConfig : public render::Job::Config { public: MakeHazeConfig() : render::Job::Config() {} - float hazeColorR{ model::Haze::initialHazeColor.r }; - float hazeColorG{ model::Haze::initialHazeColor.g }; - float hazeColorB{ model::Haze::initialHazeColor.b }; + glm::vec3 hazeColor{ model::Haze::initialHazeColor }; float hazeGlareAngle_degs{ model::Haze::initialGlareAngle_degs }; - float hazeGlareColorR{ model::Haze::initialHazeGlareColor.r }; - float hazeGlareColorG{ model::Haze::initialHazeGlareColor.g }; - float hazeGlareColorB{ model::Haze::initialHazeGlareColor.b }; + glm::vec3 hazeGlareColor{ model::Haze::initialHazeGlareColor }; float hazeBaseReference_m{ model::Haze::initialHazeBaseReference_m }; bool isHazeActive{ false }; @@ -81,14 +73,10 @@ public: float hazeBackgroundBlend{ model::Haze::initialHazeBackgroundBlend }; public slots: - void setHazeColorR(const float value) { hazeColorR = value; emit dirty(); } - void setHazeColorG(const float value) { hazeColorG = value; emit dirty(); } - void setHazeColorB(const float value) { hazeColorB = value; emit dirty(); } + void setHazeColor(const glm::vec3 value) { hazeColor = value; emit dirty(); } void setHazeGlareAngle_degs(const float value) { hazeGlareAngle_degs = value; emit dirty(); } - void setHazeGlareColorR(const float value) { hazeGlareColorR = value; emit dirty(); } - void setHazeGlareColorG(const float value) { hazeGlareColorG = value; emit dirty(); } - void setHazeGlareColorB(const float value) { hazeGlareColorB = value; emit dirty(); } + void setHazeGlareColor(const glm::vec3 value) { hazeGlareColor = value; emit dirty(); } void setHazeBaseReference(const float value) { hazeBaseReference_m = value; ; emit dirty(); } void setHazeActive(const bool active) { isHazeActive = active; emit dirty(); } @@ -128,14 +116,10 @@ public: HazeConfig() : render::Job::Config(true) {} // attributes - float hazeColorR{ model::Haze::initialHazeColor.r }; - float hazeColorG{ model::Haze::initialHazeColor.g }; - float hazeColorB{ model::Haze::initialHazeColor.b }; + glm::vec3 hazeColor{ model::Haze::initialHazeColor }; float hazeGlareAngle_degs{ model::Haze::initialGlareAngle_degs }; - float hazeGlareColorR{ model::Haze::initialHazeGlareColor.r }; - float hazeGlareColorG{ model::Haze::initialHazeGlareColor.g }; - float hazeGlareColorB{ model::Haze::initialHazeGlareColor.b }; + glm::vec3 hazeGlareColor{ model::Haze::initialHazeGlareColor }; float hazeBaseReference_m{ model::Haze::initialHazeBaseReference_m }; bool isHazeActive{ false }; // Setting this to true will set haze to on @@ -153,14 +137,10 @@ public: float hazeBackgroundBlend{ model::Haze::initialHazeBackgroundBlend }; // methods - void setHazeColorR(const float value); - void setHazeColorG(const float value); - void setHazeColorB(const float value); + void setHazeColor(const glm::vec3 value); void setHazeGlareAngle_degs(const float value); - void setHazeGlareColorR(const float value); - void setHazeGlareColorG(const float value); - void setHazeGlareColorB(const float value); + void setHazeGlareColor(const glm::vec3 value); void setHazeBaseReference(const float value); void setHazeActive(const bool active); diff --git a/libraries/render-utils/src/HazeStage.cpp b/libraries/render-utils/src/HazeStage.cpp index 6a6104a1df..71baecb0e4 100644 --- a/libraries/render-utils/src/HazeStage.cpp +++ b/libraries/render-utils/src/HazeStage.cpp @@ -20,10 +20,10 @@ FetchHazeStage::FetchHazeStage() { } void FetchHazeStage::configure(const Config& config) { - _haze->setHazeColor(glm::vec3(config.hazeColorR, config.hazeColorG, config.hazeColorB)); + _haze->setHazeColor(config.hazeColor); _haze->setHazeGlareBlend(model::convertGlareAngleToPower(config.hazeGlareAngle_degs)); - _haze->setHazeGlareColor(glm::vec3(config.hazeGlareColorR, config.hazeGlareColorG, config.hazeGlareColorB)); + _haze->setHazeGlareColor(config.hazeGlareColor); _haze->setHazeBaseReference(config.hazeBaseReference_m); _haze->setHazeActive(config.isHazeActive); diff --git a/libraries/render-utils/src/HazeStage.h b/libraries/render-utils/src/HazeStage.h index e3b061dffd..1f1a94a806 100644 --- a/libraries/render-utils/src/HazeStage.h +++ b/libraries/render-utils/src/HazeStage.h @@ -83,14 +83,10 @@ protected: class FetchHazeConfig : public render::Job::Config { Q_OBJECT - Q_PROPERTY(float hazeColorR MEMBER hazeColorR WRITE setHazeColorR NOTIFY dirty); - Q_PROPERTY(float hazeColorG MEMBER hazeColorG WRITE setHazeColorG NOTIFY dirty); - Q_PROPERTY(float hazeColorB MEMBER hazeColorB WRITE setHazeColorB NOTIFY dirty); + Q_PROPERTY(glm::vec3 hazeColor MEMBER hazeColor WRITE setHazeColor NOTIFY dirty); Q_PROPERTY(float hazeGlareAngle_degs MEMBER hazeGlareAngle_degs WRITE setHazeGlareAngle_degs NOTIFY dirty); - Q_PROPERTY(float hazeGlareColorR MEMBER hazeGlareColorR WRITE setHazeGlareColorR NOTIFY dirty); - Q_PROPERTY(float hazeGlareColorG MEMBER hazeGlareColorG WRITE setHazeGlareColorG NOTIFY dirty); - Q_PROPERTY(float hazeGlareColorB MEMBER hazeGlareColorB WRITE setHazeGlareColorB NOTIFY dirty); + Q_PROPERTY(glm::vec3 hazeGlareColor MEMBER hazeGlareColor WRITE setHazeGlareColor NOTIFY dirty); Q_PROPERTY(float hazeBaseReference_m MEMBER hazeBaseReference_m WRITE setHazeBaseReference NOTIFY dirty); Q_PROPERTY(bool isHazeActive MEMBER isHazeActive WRITE setHazeActive NOTIFY dirty); @@ -110,14 +106,10 @@ class FetchHazeConfig : public render::Job::Config { public: FetchHazeConfig() : render::Job::Config() {} - float hazeColorR{ model::Haze::initialHazeColor.r }; - float hazeColorG{ model::Haze::initialHazeColor.g }; - float hazeColorB{ model::Haze::initialHazeColor.b }; + glm::vec3 hazeColor{ model::Haze::initialHazeColor }; float hazeGlareAngle_degs{ model::Haze::initialGlareAngle_degs }; - float hazeGlareColorR{ model::Haze::initialHazeGlareColor.r }; - float hazeGlareColorG{ model::Haze::initialHazeGlareColor.g }; - float hazeGlareColorB{ model::Haze::initialHazeGlareColor.b }; + glm::vec3 hazeGlareColor{ model::Haze::initialHazeGlareColor }; float hazeBaseReference_m{ model::Haze::initialHazeBaseReference_m }; bool isHazeActive{ false }; @@ -135,14 +127,10 @@ public: float hazeBackgroundBlend{ model::Haze::initialHazeBackgroundBlend }; public slots: - void setHazeColorR(const float value) { hazeColorR = value; emit dirty(); } - void setHazeColorG(const float value) { hazeColorG = value; emit dirty(); } - void setHazeColorB(const float value) { hazeColorB = value; emit dirty(); } + void setHazeColor(const glm::vec3 value) { hazeColor = value; emit dirty(); } void setHazeGlareAngle_degs(const float value) { hazeGlareAngle_degs = value; emit dirty(); } - void setHazeGlareColorR(const float value) { hazeGlareColorR = value; emit dirty(); } - void setHazeGlareColorG(const float value) { hazeGlareColorG = value; emit dirty(); } - void setHazeGlareColorB(const float value) { hazeGlareColorB = value; emit dirty(); } + void setHazeGlareColor(const glm::vec3 value) { hazeGlareColor = value; emit dirty(); } void setHazeBaseReference(const float value) { hazeBaseReference_m = value; ; emit dirty(); } void setHazeActive(const bool active) { isHazeActive = active; emit dirty(); } diff --git a/scripts/developer/debugging/debugHaze.qml b/scripts/developer/debugging/debugHaze.qml index e197050efd..5a18f88c79 100644 --- a/scripts/developer/debugging/debugHaze.qml +++ b/scripts/developer/debugging/debugHaze.qml @@ -68,7 +68,7 @@ Item { label: "Haze Color R" integral: false config: root.hazeModel - property: "hazeColorR" + property: "hazeColor.r" max: 1.0 min: 0.0 width: 280 @@ -78,7 +78,7 @@ Item { label: "Haze Color G" integral: false config: root.hazeModel - property: "hazeColorG" + property: "hazeColor.g" max: 1.0 min: 0.0 width: 280 @@ -88,7 +88,7 @@ Item { label: "Haze Color B" integral: false config: root.hazeModel - property: "hazeColorB" + property: "hazeColor.b" max: 1.0 min: 0.0 width: 280 @@ -98,7 +98,7 @@ Item { label: "Sun R" integral: false config: root.hazeModel - property: "hazeDirectionalLightColorR" + property: "hazeGlareColor.r" max: 1.0 min: 0.0 width: 280 @@ -108,7 +108,7 @@ Item { label: "Sun G" integral: false config: root.hazeModel - property: "hazeDirectionalLightColorG" + property: "hazeGlareColor.g" max: 1.0 min: 0.0 width: 280 @@ -118,7 +118,7 @@ Item { label: "Sun B" integral: false config: root.hazeModel - property: "hazeDirectionalLightColorB" + property: "hazeGlareColor.b" max: 1.0 min: 0.0 width: 280 @@ -128,7 +128,7 @@ Item { label: "Sun glare angle" integral: false config: root.hazeModel - property: "hazeDirectionalLightAngle_degs" + property: "hazeGlareAngle_degs" max: 70.0 min: 0.0 width: 280 @@ -148,7 +148,7 @@ Item { label: "BG Blend" integral: false config: root.hazeModel - property: "hazeBackgroundBlendValue" + property: "hazeBackgroundBlend" max: 1.0 min: 0.0 width: 280 @@ -156,9 +156,9 @@ Item { CheckBox { text: "Keylight Attenuation" - checked: root.hazeModel["isDirectionaLightAttenuationActive"] + checked: root.hazeModel["isKeyLightAttenuationActive"] onCheckedChanged: { - root.hazeModel["isDirectionaLightAttenuationActive"] = checked; + root.hazeModel["isKeyLightAttenuationActive"] = checked; } } From b00db6a68f9557682c57a88fd8975582c7d43c3a Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Mon, 30 Oct 2017 19:20:49 -0700 Subject: [PATCH 09/12] Correction. --- libraries/render-utils/src/DeferredLightingEffect.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/render-utils/src/DeferredLightingEffect.cpp b/libraries/render-utils/src/DeferredLightingEffect.cpp index 428dbc623e..2187cb70b1 100644 --- a/libraries/render-utils/src/DeferredLightingEffect.cpp +++ b/libraries/render-utils/src/DeferredLightingEffect.cpp @@ -498,7 +498,7 @@ void RenderDeferredSetup::run(const render::RenderContextPointer& renderContext, auto lightStage = renderContext->_scene->getStage(); assert(lightStage); assert(lightStage->getNumLights() > 0); - auto lightAndShadow = lightStage->getLightAndShadow(0); + auto lightAndShadow = lightStage->getCurrentKeyLightAndShadow(); const auto& globalShadow = lightAndShadow.second; // Bind the shadow buffer @@ -509,7 +509,7 @@ void RenderDeferredSetup::run(const render::RenderContextPointer& renderContext, auto& program = deferredLightingEffect->_directionalSkyboxLight; LightLocationsPtr locations = deferredLightingEffect->_directionalSkyboxLightLocations; - auto keyLight = lightStage->getLight(0); + auto keyLight = lightAndShadow.first; model::LightPointer keyAmbientLight; if (lightStage && lightStage->_currentFrame._ambientLights.size()) { From 636f7858a3492b1f7b8ee6588e0ad847483bbc2f Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Mon, 30 Oct 2017 19:45:08 -0700 Subject: [PATCH 10/12] Removed _degs and _m suffixes. --- libraries/entities/src/HazePropertyGroup.h | 12 ++--- libraries/model/src/model/Haze.cpp | 18 +++---- libraries/model/src/model/Haze.h | 36 +++++++------- libraries/render-utils/src/DrawHaze.cpp | 34 ++++++------- libraries/render-utils/src/DrawHaze.h | 58 +++++++++++----------- libraries/render-utils/src/HazeStage.cpp | 12 ++--- libraries/render-utils/src/HazeStage.h | 36 +++++++------- 7 files changed, 103 insertions(+), 103 deletions(-) diff --git a/libraries/entities/src/HazePropertyGroup.h b/libraries/entities/src/HazePropertyGroup.h index 1585f35c45..17db8a6369 100644 --- a/libraries/entities/src/HazePropertyGroup.h +++ b/libraries/entities/src/HazePropertyGroup.h @@ -77,24 +77,24 @@ public: bool& somethingChanged) override; // Range only parameters - DEFINE_PROPERTY(PROP_HAZE_RANGE, HazeRange, hazeRange, float, model::Haze::initialHazeRange_m); + DEFINE_PROPERTY(PROP_HAZE_RANGE, HazeRange, hazeRange, float, model::Haze::initialHazeRange); DEFINE_PROPERTY_REF(PROP_HAZE_COLOR, HazeColor, hazeColor, xColor, model::Haze::initialHazeColorXcolor); DEFINE_PROPERTY_REF(PROP_HAZE_GLARE_COLOR, HazeGlareColor, hazeGlareColor, xColor, model::Haze::initialHazeGlareColorXcolor); DEFINE_PROPERTY(PROP_HAZE_ENABLE_GLARE, HazeEnableGlare, hazeEnableGlare, bool, false); - DEFINE_PROPERTY_REF(PROP_HAZE_GLARE_ANGLE, HazeGlareAngle, hazeGlareAngle, float, model::Haze::initialGlareAngle_degs); + DEFINE_PROPERTY_REF(PROP_HAZE_GLARE_ANGLE, HazeGlareAngle, hazeGlareAngle, float, model::Haze::initialGlareAngle); // Altitude parameters DEFINE_PROPERTY(PROP_HAZE_ALTITUDE_EFFECT, HazeAltitudeEffect, hazeAltitudeEffect, bool, false); - DEFINE_PROPERTY_REF(PROP_HAZE_CEILING, HazeCeiling, hazeCeiling, float, model::Haze::initialHazeBaseReference_m + model::Haze::initialHazeHeight_m); - DEFINE_PROPERTY_REF(PROP_HAZE_BASE_REF, HazeBaseRef, hazeBaseRef, float, model::Haze::initialHazeBaseReference_m); + DEFINE_PROPERTY_REF(PROP_HAZE_CEILING, HazeCeiling, hazeCeiling, float, model::Haze::initialHazeBaseReference + model::Haze::initialHazeHeight); + DEFINE_PROPERTY_REF(PROP_HAZE_BASE_REF, HazeBaseRef, hazeBaseRef, float, model::Haze::initialHazeBaseReference); // Background (skybox) blend value DEFINE_PROPERTY_REF(PROP_HAZE_BACKGROUND_BLEND, HazeBackgroundBlend, hazeBackgroundBlend, float, model::Haze::initialHazeBackgroundBlend); // hazeDirectional light attenuation DEFINE_PROPERTY(PROP_HAZE_ATTENUATE_KEYLIGHT, HazeAttenuateKeyLight, hazeAttenuateKeyLight, bool, false); - DEFINE_PROPERTY_REF(PROP_HAZE_KEYLIGHT_RANGE, HazeKeyLightRange, hazeKeyLightRange, float, model::Haze::initialHazeKeyLightRange_m); - DEFINE_PROPERTY_REF(PROP_HAZE_KEYLIGHT_ALTITUDE, HazeKeyLightAltitude, hazeKeyLightAltitude, float, model::Haze::initialHazeKeyLightAltitude_m); + DEFINE_PROPERTY_REF(PROP_HAZE_KEYLIGHT_RANGE, HazeKeyLightRange, hazeKeyLightRange, float, model::Haze::initialHazeKeyLightRange); + DEFINE_PROPERTY_REF(PROP_HAZE_KEYLIGHT_ALTITUDE, HazeKeyLightAltitude, hazeKeyLightAltitude, float, model::Haze::initialHazeKeyLightAltitude); }; #endif // hifi_HazePropertyGroup_h diff --git a/libraries/model/src/model/Haze.cpp b/libraries/model/src/model/Haze.cpp index 92042364c2..f29824936f 100644 --- a/libraries/model/src/model/Haze.cpp +++ b/libraries/model/src/model/Haze.cpp @@ -14,29 +14,29 @@ using namespace model; -const float Haze::initialHazeRange_m{ 1000.0f }; -const float Haze::initialHazeHeight_m{ 200.0f }; +const float Haze::initialHazeRange{ 1000.0f }; +const float Haze::initialHazeHeight{ 200.0f }; -const float Haze::initialHazeKeyLightRange_m{ 1000.0f }; -const float Haze::initialHazeKeyLightAltitude_m{ 200.0f }; +const float Haze::initialHazeKeyLightRange{ 1000.0f }; +const float Haze::initialHazeKeyLightAltitude{ 200.0f }; const float Haze::initialHazeBackgroundBlend{ 0.0f }; const glm::vec3 Haze::initialColorModulationFactor{ - convertHazeRangeToHazeRangeFactor(initialHazeRange_m), - convertHazeRangeToHazeRangeFactor(initialHazeRange_m), - convertHazeRangeToHazeRangeFactor(initialHazeRange_m) + convertHazeRangeToHazeRangeFactor(initialHazeRange), + convertHazeRangeToHazeRangeFactor(initialHazeRange), + convertHazeRangeToHazeRangeFactor(initialHazeRange) }; const glm::vec3 Haze::initialHazeColor{ 0.5f, 0.6f, 0.7f }; // Bluish const xColor Haze::initialHazeColorXcolor{ 128, 154, 179 }; -const float Haze::initialGlareAngle_degs{ 20.0f }; +const float Haze::initialGlareAngle{ 20.0f }; const glm::vec3 Haze::initialHazeGlareColor{ 1.0f, 0.9f, 0.7f }; const xColor Haze::initialHazeGlareColorXcolor{ 255, 229, 179 }; -const float Haze::initialHazeBaseReference_m{ 0.0f }; +const float Haze::initialHazeBaseReference{ 0.0f }; Haze::Haze() { Parameters parameters; diff --git a/libraries/model/src/model/Haze.h b/libraries/model/src/model/Haze.h index c361fcde8c..00e8f3625c 100644 --- a/libraries/model/src/model/Haze.h +++ b/libraries/model/src/model/Haze.h @@ -25,17 +25,17 @@ namespace model { // f = exp(-d * b) // ln(f) = -d * b // b = -ln(f)/d - inline glm::vec3 convertHazeRangeToHazeRangeFactor(const glm::vec3 hazeRange_m) { + inline glm::vec3 convertHazeRangeToHazeRangeFactor(const glm::vec3 hazeRange) { return glm::vec3( - -LOG_P_005 / hazeRange_m.x, - -LOG_P_005 / hazeRange_m.y, - -LOG_P_005 / hazeRange_m.z); + -LOG_P_005 / hazeRange.x, + -LOG_P_005 / hazeRange.y, + -LOG_P_005 / hazeRange.z); } // limit range and altitude to no less than 1.0 metres - inline float convertHazeRangeToHazeRangeFactor(const float hazeRange_m) { return -LOG_P_005 / glm::max(hazeRange_m, 1.0f); } + inline float convertHazeRangeToHazeRangeFactor(const float hazeRange) { return -LOG_P_005 / glm::max(hazeRange, 1.0f); } - inline float convertHazeAltitudeToHazeAltitudeFactor(const float hazeHeight_m) { return -LOG_P_005 / glm::max(hazeHeight_m, 1.0f); } + inline float convertHazeAltitudeToHazeAltitudeFactor(const float hazeHeight) { return -LOG_P_005 / glm::max(hazeHeight, 1.0f); } // Derivation (s is the proportion of sun blend, a is the angle at which the blend is 50%, solve for m = 0.5 // s = dot(lookAngle, sunAngle) = cos(a) @@ -54,11 +54,11 @@ namespace model { class Haze { public: // Initial values - static const float initialHazeRange_m; - static const float initialHazeHeight_m; + static const float initialHazeRange; + static const float initialHazeHeight; - static const float initialHazeKeyLightRange_m; - static const float initialHazeKeyLightAltitude_m; + static const float initialHazeKeyLightRange; + static const float initialHazeKeyLightAltitude; static const float initialHazeBackgroundBlend; @@ -67,12 +67,12 @@ namespace model { static const glm::vec3 initialHazeColor; static const xColor initialHazeColorXcolor; - static const float initialGlareAngle_degs; + static const float initialGlareAngle; static const glm::vec3 initialHazeGlareColor; static const xColor initialHazeGlareColorXcolor; - static const float initialHazeBaseReference_m; + static const float initialHazeBaseReference; using UniformBufferView = gpu::BufferView; @@ -107,10 +107,10 @@ namespace model { public: // DO NOT CHANGE ORDER HERE WITHOUT UNDERSTANDING THE std140 LAYOUT glm::vec3 hazeColor{ initialHazeColor }; - float hazeGlareBlend{ convertGlareAngleToPower(initialGlareAngle_degs) }; + float hazeGlareBlend{ convertGlareAngleToPower(initialGlareAngle) }; glm::vec3 hazeGlareColor{ initialHazeGlareColor }; - float hazeBaseReference{ initialHazeBaseReference_m }; + float hazeBaseReference{ initialHazeBaseReference }; glm::vec3 colorModulationFactor{ initialColorModulationFactor }; int hazeMode{ 0 }; // bit 0 - set to activate haze attenuation of fragment color @@ -124,11 +124,11 @@ namespace model { float hazeBackgroundBlend{ initialHazeBackgroundBlend }; // The haze attenuation exponents used by both fragment and directional light attenuation - float hazeRangeFactor{ convertHazeRangeToHazeRangeFactor(initialHazeRange_m) }; - float hazeHeightFactor{ convertHazeAltitudeToHazeAltitudeFactor(initialHazeHeight_m) }; + float hazeRangeFactor{ convertHazeRangeToHazeRangeFactor(initialHazeRange) }; + float hazeHeightFactor{ convertHazeAltitudeToHazeAltitudeFactor(initialHazeHeight) }; - float hazeKeyLightRangeFactor{ convertHazeRangeToHazeRangeFactor(initialHazeKeyLightRange_m) }; - float hazeKeyLightAltitudeFactor{ convertHazeAltitudeToHazeAltitudeFactor(initialHazeKeyLightAltitude_m) }; + float hazeKeyLightRangeFactor{ convertHazeRangeToHazeRangeFactor(initialHazeKeyLightRange) }; + float hazeKeyLightAltitudeFactor{ convertHazeAltitudeToHazeAltitudeFactor(initialHazeKeyLightAltitude) }; Parameters() {} }; diff --git a/libraries/render-utils/src/DrawHaze.cpp b/libraries/render-utils/src/DrawHaze.cpp index 5c3d527e91..3be74da26a 100644 --- a/libraries/render-utils/src/DrawHaze.cpp +++ b/libraries/render-utils/src/DrawHaze.cpp @@ -25,8 +25,8 @@ void HazeConfig::setHazeColor(const glm::vec3 value) { hazeColor = value; } -void HazeConfig::setHazeGlareAngle_degs(const float value) { - hazeGlareAngle_degs = value; +void HazeConfig::setHazeGlareAngle(const float value) { + hazeGlareAngle = value; } void HazeConfig::setHazeGlareColor(const glm::vec3 value) { @@ -34,7 +34,7 @@ void HazeConfig::setHazeGlareColor(const glm::vec3 value) { } void HazeConfig::setHazeBaseReference(const float value) { - hazeBaseReference_m = value; + hazeBaseReference = value; } void HazeConfig::setHazeActive(const bool active) { @@ -57,20 +57,20 @@ void HazeConfig::setHazeEnableGlare(const bool active) { isHazeEnableGlare = active; } -void HazeConfig::setHazeRange_m(const float value) { - hazeRange_m = value; +void HazeConfig::setHazeRange(const float value) { + hazeRange = value; } -void HazeConfig::setHazeAltitude_m(const float value) { - hazeHeight_m = value; +void HazeConfig::setHazeAltitude(const float value) { + hazeHeight = value; } -void HazeConfig::setHazeKeyLightRange_m(const float value) { - hazeKeyLightRange_m = value; +void HazeConfig::setHazeKeyLightRange(const float value) { + hazeKeyLightRange = value; } -void HazeConfig::setHazeKeyLightAltitude_m(const float value) { - hazeKeyLightAltitude_m = value; +void HazeConfig::setHazeKeyLightAltitude(const float value) { + hazeKeyLightAltitude = value; } void HazeConfig::setHazeBackgroundBlend(const float value) { @@ -83,10 +83,10 @@ MakeHaze::MakeHaze() { void MakeHaze::configure(const Config& config) { _haze->setHazeColor(config.hazeColor); - _haze->setHazeGlareBlend(model::convertGlareAngleToPower(config.hazeGlareAngle_degs)); + _haze->setHazeGlareBlend(model::convertGlareAngleToPower(config.hazeGlareAngle)); _haze->setHazeGlareColor(config.hazeGlareColor); - _haze->setHazeBaseReference(config.hazeBaseReference_m); + _haze->setHazeBaseReference(config.hazeBaseReference); _haze->setHazeActive(config.isHazeActive); _haze->setAltitudeBased(config.isAltitudeBased); @@ -94,11 +94,11 @@ void MakeHaze::configure(const Config& config) { _haze->setModulateColorActive(config.isModulateColorActive); _haze->setHazeEnableGlare(config.isHazeEnableGlare); - _haze->setHazeRangeFactor(model::convertHazeRangeToHazeRangeFactor(config.hazeRange_m)); - _haze->setHazeAltitudeFactor(model::convertHazeAltitudeToHazeAltitudeFactor(config.hazeHeight_m)); + _haze->setHazeRangeFactor(model::convertHazeRangeToHazeRangeFactor(config.hazeRange)); + _haze->setHazeAltitudeFactor(model::convertHazeAltitudeToHazeAltitudeFactor(config.hazeHeight)); - _haze->setHazeKeyLightRangeFactor(model::convertHazeRangeToHazeRangeFactor(config.hazeKeyLightRange_m)); - _haze->setHazeKeyLightAltitudeFactor(model::convertHazeAltitudeToHazeAltitudeFactor(config.hazeKeyLightAltitude_m)); + _haze->setHazeKeyLightRangeFactor(model::convertHazeRangeToHazeRangeFactor(config.hazeKeyLightRange)); + _haze->setHazeKeyLightAltitudeFactor(model::convertHazeAltitudeToHazeAltitudeFactor(config.hazeKeyLightAltitude)); _haze->setHazeBackgroundBlend(config.hazeBackgroundBlend); } diff --git a/libraries/render-utils/src/DrawHaze.h b/libraries/render-utils/src/DrawHaze.h index 3005203c5b..15337c850b 100644 --- a/libraries/render-utils/src/DrawHaze.h +++ b/libraries/render-utils/src/DrawHaze.h @@ -30,10 +30,10 @@ class MakeHazeConfig : public render::Job::Config { Q_OBJECT Q_PROPERTY(glm::vec3 hazeColor MEMBER hazeColor WRITE setHazeColor NOTIFY dirty); - Q_PROPERTY(float hazeGlareAngle_degs MEMBER hazeGlareAngle_degs WRITE setHazeGlareAngle_degs NOTIFY dirty); + Q_PROPERTY(float hazeGlareAngle MEMBER hazeGlareAngle WRITE setHazeGlareAngle NOTIFY dirty); Q_PROPERTY(glm::vec3 hazeGlareColor MEMBER hazeGlareColor WRITE setHazeGlareColor NOTIFY dirty); - Q_PROPERTY(float hazeBaseReference_m MEMBER hazeBaseReference_m WRITE setHazeBaseReference NOTIFY dirty); + Q_PROPERTY(float hazeBaseReference MEMBER hazeBaseReference WRITE setHazeBaseReference NOTIFY dirty); Q_PROPERTY(bool isHazeActive MEMBER isHazeActive WRITE setHazeActive NOTIFY dirty); Q_PROPERTY(bool isAltitudeBased MEMBER isAltitudeBased WRITE setAltitudeBased NOTIFY dirty); @@ -41,11 +41,11 @@ class MakeHazeConfig : public render::Job::Config { Q_PROPERTY(bool isModulateColorActive MEMBER isModulateColorActive WRITE setModulateColorActive NOTIFY dirty); Q_PROPERTY(bool isHazeEnableGlare MEMBER isHazeEnableGlare WRITE setHazeEnableGlare NOTIFY dirty); - Q_PROPERTY(float hazeRange_m MEMBER hazeRange_m WRITE setHazeRange_m NOTIFY dirty); - Q_PROPERTY(float hazeHeight_m MEMBER hazeHeight_m WRITE setHazeAltitude_m NOTIFY dirty); + Q_PROPERTY(float hazeRange MEMBER hazeRange WRITE setHazeRange NOTIFY dirty); + Q_PROPERTY(float hazeHeight MEMBER hazeHeight WRITE setHazeAltitude NOTIFY dirty); - Q_PROPERTY(float hazeKeyLightRange_m MEMBER hazeKeyLightRange_m WRITE setHazeKeyLightRange_m NOTIFY dirty); - Q_PROPERTY(float hazeKeyLightAltitude_m MEMBER hazeKeyLightAltitude_m WRITE setHazeKeyLightAltitude_m NOTIFY dirty); + Q_PROPERTY(float hazeKeyLightRange MEMBER hazeKeyLightRange WRITE setHazeKeyLightRange NOTIFY dirty); + Q_PROPERTY(float hazeKeyLightAltitude MEMBER hazeKeyLightAltitude WRITE setHazeKeyLightAltitude NOTIFY dirty); Q_PROPERTY(float hazeBackgroundBlend MEMBER hazeBackgroundBlend WRITE setHazeBackgroundBlend NOTIFY dirty); @@ -53,10 +53,10 @@ public: MakeHazeConfig() : render::Job::Config() {} glm::vec3 hazeColor{ model::Haze::initialHazeColor }; - float hazeGlareAngle_degs{ model::Haze::initialGlareAngle_degs }; + float hazeGlareAngle{ model::Haze::initialGlareAngle }; glm::vec3 hazeGlareColor{ model::Haze::initialHazeGlareColor }; - float hazeBaseReference_m{ model::Haze::initialHazeBaseReference_m }; + float hazeBaseReference{ model::Haze::initialHazeBaseReference }; bool isHazeActive{ false }; bool isAltitudeBased{ false }; @@ -64,20 +64,20 @@ public: bool isModulateColorActive{ false }; bool isHazeEnableGlare{ false }; - float hazeRange_m{ model::Haze::initialHazeRange_m }; - float hazeHeight_m{ model::Haze::initialHazeHeight_m }; + float hazeRange{ model::Haze::initialHazeRange }; + float hazeHeight{ model::Haze::initialHazeHeight }; - float hazeKeyLightRange_m{ model::Haze::initialHazeKeyLightRange_m }; - float hazeKeyLightAltitude_m{ model::Haze::initialHazeKeyLightAltitude_m }; + float hazeKeyLightRange{ model::Haze::initialHazeKeyLightRange }; + float hazeKeyLightAltitude{ model::Haze::initialHazeKeyLightAltitude }; float hazeBackgroundBlend{ model::Haze::initialHazeBackgroundBlend }; public slots: void setHazeColor(const glm::vec3 value) { hazeColor = value; emit dirty(); } - void setHazeGlareAngle_degs(const float value) { hazeGlareAngle_degs = value; emit dirty(); } + void setHazeGlareAngle(const float value) { hazeGlareAngle = value; emit dirty(); } void setHazeGlareColor(const glm::vec3 value) { hazeGlareColor = value; emit dirty(); } - void setHazeBaseReference(const float value) { hazeBaseReference_m = value; ; emit dirty(); } + void setHazeBaseReference(const float value) { hazeBaseReference = value; ; emit dirty(); } void setHazeActive(const bool active) { isHazeActive = active; emit dirty(); } void setAltitudeBased(const bool active) { isAltitudeBased = active; emit dirty(); } @@ -85,11 +85,11 @@ public slots: void setModulateColorActive(const bool active) { isModulateColorActive = active; emit dirty(); } void setHazeEnableGlare(const bool active) { isHazeEnableGlare = active; emit dirty(); } - void setHazeRange_m(const float value) { hazeRange_m = value; emit dirty(); } - void setHazeAltitude_m(const float value) { hazeHeight_m = value; emit dirty(); } + void setHazeRange(const float value) { hazeRange = value; emit dirty(); } + void setHazeAltitude(const float value) { hazeHeight = value; emit dirty(); } - void setHazeKeyLightRange_m(const float value) { hazeKeyLightRange_m = value; emit dirty(); } - void setHazeKeyLightAltitude_m(const float value) { hazeKeyLightAltitude_m = value; emit dirty(); } + void setHazeKeyLightRange(const float value) { hazeKeyLightRange = value; emit dirty(); } + void setHazeKeyLightAltitude(const float value) { hazeKeyLightAltitude = value; emit dirty(); } void setHazeBackgroundBlend(const float value) { hazeBackgroundBlend = value; ; emit dirty(); } @@ -117,10 +117,10 @@ public: // attributes glm::vec3 hazeColor{ model::Haze::initialHazeColor }; - float hazeGlareAngle_degs{ model::Haze::initialGlareAngle_degs }; + float hazeGlareAngle{ model::Haze::initialGlareAngle }; glm::vec3 hazeGlareColor{ model::Haze::initialHazeGlareColor }; - float hazeBaseReference_m{ model::Haze::initialHazeBaseReference_m }; + float hazeBaseReference{ model::Haze::initialHazeBaseReference }; bool isHazeActive{ false }; // Setting this to true will set haze to on bool isAltitudeBased{ false }; @@ -128,17 +128,17 @@ public: bool isModulateColorActive{ false }; bool isHazeEnableGlare{ false }; - float hazeRange_m{ model::Haze::initialHazeRange_m }; - float hazeHeight_m{ model::Haze::initialHazeHeight_m }; + float hazeRange{ model::Haze::initialHazeRange }; + float hazeHeight{ model::Haze::initialHazeHeight }; - float hazeKeyLightRange_m{ model::Haze::initialHazeKeyLightRange_m }; - float hazeKeyLightAltitude_m{ model::Haze::initialHazeKeyLightAltitude_m }; + float hazeKeyLightRange{ model::Haze::initialHazeKeyLightRange }; + float hazeKeyLightAltitude{ model::Haze::initialHazeKeyLightAltitude }; float hazeBackgroundBlend{ model::Haze::initialHazeBackgroundBlend }; // methods void setHazeColor(const glm::vec3 value); - void setHazeGlareAngle_degs(const float value); + void setHazeGlareAngle(const float value); void setHazeGlareColor(const glm::vec3 value); void setHazeBaseReference(const float value); @@ -149,11 +149,11 @@ public: void setModulateColorActive(const bool active); void setHazeEnableGlare(const bool active); - void setHazeRange_m(const float value); - void setHazeAltitude_m(const float value); + void setHazeRange(const float value); + void setHazeAltitude(const float value); - void setHazeKeyLightRange_m(const float value); - void setHazeKeyLightAltitude_m(const float value); + void setHazeKeyLightRange(const float value); + void setHazeKeyLightAltitude(const float value); void setHazeBackgroundBlend(const float value); }; diff --git a/libraries/render-utils/src/HazeStage.cpp b/libraries/render-utils/src/HazeStage.cpp index 71baecb0e4..c9e6ef90cb 100644 --- a/libraries/render-utils/src/HazeStage.cpp +++ b/libraries/render-utils/src/HazeStage.cpp @@ -21,10 +21,10 @@ FetchHazeStage::FetchHazeStage() { void FetchHazeStage::configure(const Config& config) { _haze->setHazeColor(config.hazeColor); - _haze->setHazeGlareBlend(model::convertGlareAngleToPower(config.hazeGlareAngle_degs)); + _haze->setHazeGlareBlend(model::convertGlareAngleToPower(config.hazeGlareAngle)); _haze->setHazeGlareColor(config.hazeGlareColor); - _haze->setHazeBaseReference(config.hazeBaseReference_m); + _haze->setHazeBaseReference(config.hazeBaseReference); _haze->setHazeActive(config.isHazeActive); _haze->setAltitudeBased(config.isAltitudeBased); @@ -32,11 +32,11 @@ void FetchHazeStage::configure(const Config& config) { _haze->setModulateColorActive(config.isModulateColorActive); _haze->setHazeEnableGlare(config.isHazeEnableGlare); - _haze->setHazeRangeFactor(model::convertHazeRangeToHazeRangeFactor(config.hazeRange_m)); - _haze->setHazeAltitudeFactor(model::convertHazeAltitudeToHazeAltitudeFactor(config.hazeHeight_m)); + _haze->setHazeRangeFactor(model::convertHazeRangeToHazeRangeFactor(config.hazeRange)); + _haze->setHazeAltitudeFactor(model::convertHazeAltitudeToHazeAltitudeFactor(config.hazeHeight)); - _haze->setHazeKeyLightRangeFactor(model::convertHazeRangeToHazeRangeFactor(config.hazeKeyLightRange_m)); - _haze->setHazeKeyLightAltitudeFactor(model::convertHazeAltitudeToHazeAltitudeFactor(config.hazeKeyLightAltitude_m)); + _haze->setHazeKeyLightRangeFactor(model::convertHazeRangeToHazeRangeFactor(config.hazeKeyLightRange)); + _haze->setHazeKeyLightAltitudeFactor(model::convertHazeAltitudeToHazeAltitudeFactor(config.hazeKeyLightAltitude)); _haze->setHazeBackgroundBlend(config.hazeBackgroundBlend); } diff --git a/libraries/render-utils/src/HazeStage.h b/libraries/render-utils/src/HazeStage.h index 1f1a94a806..42f26a2679 100644 --- a/libraries/render-utils/src/HazeStage.h +++ b/libraries/render-utils/src/HazeStage.h @@ -84,10 +84,10 @@ class FetchHazeConfig : public render::Job::Config { Q_OBJECT Q_PROPERTY(glm::vec3 hazeColor MEMBER hazeColor WRITE setHazeColor NOTIFY dirty); - Q_PROPERTY(float hazeGlareAngle_degs MEMBER hazeGlareAngle_degs WRITE setHazeGlareAngle_degs NOTIFY dirty); + Q_PROPERTY(float hazeGlareAngle MEMBER hazeGlareAngle WRITE setHazeGlareAngle NOTIFY dirty); Q_PROPERTY(glm::vec3 hazeGlareColor MEMBER hazeGlareColor WRITE setHazeGlareColor NOTIFY dirty); - Q_PROPERTY(float hazeBaseReference_m MEMBER hazeBaseReference_m WRITE setHazeBaseReference NOTIFY dirty); + Q_PROPERTY(float hazeBaseReference MEMBER hazeBaseReference WRITE setHazeBaseReference NOTIFY dirty); Q_PROPERTY(bool isHazeActive MEMBER isHazeActive WRITE setHazeActive NOTIFY dirty); Q_PROPERTY(bool isAltitudeBased MEMBER isAltitudeBased WRITE setAltitudeBased NOTIFY dirty); @@ -95,11 +95,11 @@ class FetchHazeConfig : public render::Job::Config { Q_PROPERTY(bool isModulateColorActive MEMBER isModulateColorActive WRITE setModulateColorActive NOTIFY dirty); Q_PROPERTY(bool isHazeEnableGlare MEMBER isHazeEnableGlare WRITE setHazeEnableGlare NOTIFY dirty); - Q_PROPERTY(float hazeRange_m MEMBER hazeRange_m WRITE setHazeRange_m NOTIFY dirty); - Q_PROPERTY(float hazeHeight_m MEMBER hazeHeight_m WRITE setHazeAltitude_m NOTIFY dirty); + Q_PROPERTY(float hazeRange MEMBER hazeRange WRITE setHazeRange NOTIFY dirty); + Q_PROPERTY(float hazeHeight MEMBER hazeHeight WRITE setHazeAltitude NOTIFY dirty); - Q_PROPERTY(float hazeKeyLightRange_m MEMBER hazeKeyLightRange_m WRITE setHazeKeyLightRange_m NOTIFY dirty); - Q_PROPERTY(float hazeKeyLightAltitude_m MEMBER hazeKeyLightAltitude_m WRITE setHazeKeyLightAltitude_m NOTIFY dirty); + Q_PROPERTY(float hazeKeyLightRange MEMBER hazeKeyLightRange WRITE setHazeKeyLightRange NOTIFY dirty); + Q_PROPERTY(float hazeKeyLightAltitude MEMBER hazeKeyLightAltitude WRITE setHazeKeyLightAltitude NOTIFY dirty); Q_PROPERTY(float hazeBackgroundBlend MEMBER hazeBackgroundBlend WRITE setHazeBackgroundBlend NOTIFY dirty); @@ -107,10 +107,10 @@ public: FetchHazeConfig() : render::Job::Config() {} glm::vec3 hazeColor{ model::Haze::initialHazeColor }; - float hazeGlareAngle_degs{ model::Haze::initialGlareAngle_degs }; + float hazeGlareAngle{ model::Haze::initialGlareAngle }; glm::vec3 hazeGlareColor{ model::Haze::initialHazeGlareColor }; - float hazeBaseReference_m{ model::Haze::initialHazeBaseReference_m }; + float hazeBaseReference{ model::Haze::initialHazeBaseReference }; bool isHazeActive{ false }; bool isAltitudeBased{ false }; @@ -118,20 +118,20 @@ public: bool isModulateColorActive{ false }; bool isHazeEnableGlare{ false }; - float hazeRange_m{ model::Haze::initialHazeRange_m }; - float hazeHeight_m{ model::Haze::initialHazeHeight_m }; + float hazeRange{ model::Haze::initialHazeRange }; + float hazeHeight{ model::Haze::initialHazeHeight }; - float hazeKeyLightRange_m{ model::Haze::initialHazeKeyLightRange_m }; - float hazeKeyLightAltitude_m{ model::Haze::initialHazeKeyLightAltitude_m }; + float hazeKeyLightRange{ model::Haze::initialHazeKeyLightRange }; + float hazeKeyLightAltitude{ model::Haze::initialHazeKeyLightAltitude }; float hazeBackgroundBlend{ model::Haze::initialHazeBackgroundBlend }; public slots: void setHazeColor(const glm::vec3 value) { hazeColor = value; emit dirty(); } - void setHazeGlareAngle_degs(const float value) { hazeGlareAngle_degs = value; emit dirty(); } + void setHazeGlareAngle(const float value) { hazeGlareAngle = value; emit dirty(); } void setHazeGlareColor(const glm::vec3 value) { hazeGlareColor = value; emit dirty(); } - void setHazeBaseReference(const float value) { hazeBaseReference_m = value; ; emit dirty(); } + void setHazeBaseReference(const float value) { hazeBaseReference = value; ; emit dirty(); } void setHazeActive(const bool active) { isHazeActive = active; emit dirty(); } void setAltitudeBased(const bool active) { isAltitudeBased = active; emit dirty(); } @@ -139,11 +139,11 @@ public slots: void setModulateColorActive(const bool active) { isModulateColorActive = active; emit dirty(); } void setHazeEnableGlare(const bool active) { isHazeEnableGlare = active; emit dirty(); } - void setHazeRange_m(const float value) { hazeRange_m = value; emit dirty(); } - void setHazeAltitude_m(const float value) { hazeHeight_m = value; emit dirty(); } + void setHazeRange(const float value) { hazeRange = value; emit dirty(); } + void setHazeAltitude(const float value) { hazeHeight = value; emit dirty(); } - void setHazeKeyLightRange_m(const float value) { hazeKeyLightRange_m = value; emit dirty(); } - void setHazeKeyLightAltitude_m(const float value) { hazeKeyLightAltitude_m = value; emit dirty(); } + void setHazeKeyLightRange(const float value) { hazeKeyLightRange = value; emit dirty(); } + void setHazeKeyLightAltitude(const float value) { hazeKeyLightAltitude = value; emit dirty(); } void setHazeBackgroundBlend(const float value) { hazeBackgroundBlend = value; ; emit dirty(); } From 3ddf970be3b950bb93d4ff78ce197ac3c4037ba5 Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Mon, 30 Oct 2017 21:40:14 -0700 Subject: [PATCH 11/12] Removed haze init variables from the model namespace. --- libraries/entities/CMakeLists.txt | 2 +- libraries/entities/src/HazePropertyGroup.h | 33 ++++++++---- libraries/entities/src/ZoneEntityItem.h | 1 - libraries/model/src/model/Haze.cpp | 26 ++++----- libraries/model/src/model/Haze.h | 61 +++++++++++----------- libraries/render-utils/src/DrawHaze.h | 39 +++++++------- libraries/render-utils/src/HazeStage.h | 18 +++---- 7 files changed, 90 insertions(+), 90 deletions(-) diff --git a/libraries/entities/CMakeLists.txt b/libraries/entities/CMakeLists.txt index 146aecf1f6..c23740654e 100644 --- a/libraries/entities/CMakeLists.txt +++ b/libraries/entities/CMakeLists.txt @@ -1,4 +1,4 @@ set(TARGET_NAME entities) setup_hifi_library(Network Script) include_directories(SYSTEM "${OPENSSL_INCLUDE_DIR}") -link_hifi_libraries(shared networking octree avatars model gpu) +link_hifi_libraries(shared networking octree avatars model) diff --git a/libraries/entities/src/HazePropertyGroup.h b/libraries/entities/src/HazePropertyGroup.h index 17db8a6369..965f112af9 100644 --- a/libraries/entities/src/HazePropertyGroup.h +++ b/libraries/entities/src/HazePropertyGroup.h @@ -21,14 +21,25 @@ #include "PropertyGroup.h" #include "EntityItemPropertiesMacros.h" -#include - class EntityItemProperties; class EncodeBitstreamParams; class OctreePacketData; class EntityTreeElementExtraEncodeData; class ReadBitstreamToTreeParams; +static const float initialHazeRange{ 1000.0f }; +static const xColor initialHazeGlareColorXcolor{ 255, 229, 179 }; +static const xColor initialHazeColorXcolor{ 128, 154, 179 }; +static const float initialGlareAngle{ 20.0f }; + +static const float initialHazeBaseReference{ 0.0f }; +static const float initialHazeHeight{ 200.0f }; + +static const float initialHazeBackgroundBlend{ 0.0f }; + +static const float initialHazeKeyLightRange{ 1000.0f }; +static const float initialHazeKeyLightAltitude{ 200.0f }; + class HazePropertyGroup : public PropertyGroup { public: // EntityItemProperty related helpers @@ -77,24 +88,24 @@ public: bool& somethingChanged) override; // Range only parameters - DEFINE_PROPERTY(PROP_HAZE_RANGE, HazeRange, hazeRange, float, model::Haze::initialHazeRange); - DEFINE_PROPERTY_REF(PROP_HAZE_COLOR, HazeColor, hazeColor, xColor, model::Haze::initialHazeColorXcolor); - DEFINE_PROPERTY_REF(PROP_HAZE_GLARE_COLOR, HazeGlareColor, hazeGlareColor, xColor, model::Haze::initialHazeGlareColorXcolor); + DEFINE_PROPERTY(PROP_HAZE_RANGE, HazeRange, hazeRange, float, initialHazeRange); + DEFINE_PROPERTY_REF(PROP_HAZE_COLOR, HazeColor, hazeColor, xColor, initialHazeColorXcolor); + DEFINE_PROPERTY_REF(PROP_HAZE_GLARE_COLOR, HazeGlareColor, hazeGlareColor, xColor, initialHazeGlareColorXcolor); DEFINE_PROPERTY(PROP_HAZE_ENABLE_GLARE, HazeEnableGlare, hazeEnableGlare, bool, false); - DEFINE_PROPERTY_REF(PROP_HAZE_GLARE_ANGLE, HazeGlareAngle, hazeGlareAngle, float, model::Haze::initialGlareAngle); + DEFINE_PROPERTY_REF(PROP_HAZE_GLARE_ANGLE, HazeGlareAngle, hazeGlareAngle, float, initialGlareAngle); // Altitude parameters DEFINE_PROPERTY(PROP_HAZE_ALTITUDE_EFFECT, HazeAltitudeEffect, hazeAltitudeEffect, bool, false); - DEFINE_PROPERTY_REF(PROP_HAZE_CEILING, HazeCeiling, hazeCeiling, float, model::Haze::initialHazeBaseReference + model::Haze::initialHazeHeight); - DEFINE_PROPERTY_REF(PROP_HAZE_BASE_REF, HazeBaseRef, hazeBaseRef, float, model::Haze::initialHazeBaseReference); + DEFINE_PROPERTY_REF(PROP_HAZE_CEILING, HazeCeiling, hazeCeiling, float, initialHazeBaseReference + initialHazeHeight); + DEFINE_PROPERTY_REF(PROP_HAZE_BASE_REF, HazeBaseRef, hazeBaseRef, float, initialHazeBaseReference); // Background (skybox) blend value - DEFINE_PROPERTY_REF(PROP_HAZE_BACKGROUND_BLEND, HazeBackgroundBlend, hazeBackgroundBlend, float, model::Haze::initialHazeBackgroundBlend); + DEFINE_PROPERTY_REF(PROP_HAZE_BACKGROUND_BLEND, HazeBackgroundBlend, hazeBackgroundBlend, float, initialHazeBackgroundBlend); // hazeDirectional light attenuation DEFINE_PROPERTY(PROP_HAZE_ATTENUATE_KEYLIGHT, HazeAttenuateKeyLight, hazeAttenuateKeyLight, bool, false); - DEFINE_PROPERTY_REF(PROP_HAZE_KEYLIGHT_RANGE, HazeKeyLightRange, hazeKeyLightRange, float, model::Haze::initialHazeKeyLightRange); - DEFINE_PROPERTY_REF(PROP_HAZE_KEYLIGHT_ALTITUDE, HazeKeyLightAltitude, hazeKeyLightAltitude, float, model::Haze::initialHazeKeyLightAltitude); + DEFINE_PROPERTY_REF(PROP_HAZE_KEYLIGHT_RANGE, HazeKeyLightRange, hazeKeyLightRange, float, initialHazeKeyLightRange); + DEFINE_PROPERTY_REF(PROP_HAZE_KEYLIGHT_ALTITUDE, HazeKeyLightAltitude, hazeKeyLightAltitude, float, initialHazeKeyLightAltitude); }; #endif // hifi_HazePropertyGroup_h diff --git a/libraries/entities/src/ZoneEntityItem.h b/libraries/entities/src/ZoneEntityItem.h index 3f78591745..46e8a00c24 100644 --- a/libraries/entities/src/ZoneEntityItem.h +++ b/libraries/entities/src/ZoneEntityItem.h @@ -19,7 +19,6 @@ #include "HazePropertyGroup.h" #include "StagePropertyGroup.h" #include -#include class ZoneEntityItem : public EntityItem { public: diff --git a/libraries/model/src/model/Haze.cpp b/libraries/model/src/model/Haze.cpp index f29824936f..01cb32a98b 100644 --- a/libraries/model/src/model/Haze.cpp +++ b/libraries/model/src/model/Haze.cpp @@ -14,29 +14,21 @@ using namespace model; -const float Haze::initialHazeRange{ 1000.0f }; -const float Haze::initialHazeHeight{ 200.0f }; +const float HazeInit::initialHazeRange{ 1000.0f }; +const float HazeInit::initialHazeHeight{ 200.0f }; -const float Haze::initialHazeKeyLightRange{ 1000.0f }; -const float Haze::initialHazeKeyLightAltitude{ 200.0f }; +const float HazeInit::initialHazeKeyLightRange{ 1000.0f }; +const float HazeInit::initialHazeKeyLightAltitude{ 200.0f }; -const float Haze::initialHazeBackgroundBlend{ 0.0f }; +const float HazeInit::initialHazeBackgroundBlend{ 0.0f }; -const glm::vec3 Haze::initialColorModulationFactor{ - convertHazeRangeToHazeRangeFactor(initialHazeRange), - convertHazeRangeToHazeRangeFactor(initialHazeRange), - convertHazeRangeToHazeRangeFactor(initialHazeRange) -}; +const glm::vec3 HazeInit::initialHazeColor{ 0.5f, 0.6f, 0.7f }; // Bluish -const glm::vec3 Haze::initialHazeColor{ 0.5f, 0.6f, 0.7f }; // Bluish -const xColor Haze::initialHazeColorXcolor{ 128, 154, 179 }; +const float HazeInit::initialGlareAngle{ 20.0f }; -const float Haze::initialGlareAngle{ 20.0f }; +const glm::vec3 HazeInit::initialHazeGlareColor{ 1.0f, 0.9f, 0.7f }; -const glm::vec3 Haze::initialHazeGlareColor{ 1.0f, 0.9f, 0.7f }; -const xColor Haze::initialHazeGlareColorXcolor{ 255, 229, 179 }; - -const float Haze::initialHazeBaseReference{ 0.0f }; +const float HazeInit::initialHazeBaseReference{ 0.0f }; Haze::Haze() { Parameters parameters; diff --git a/libraries/model/src/model/Haze.h b/libraries/model/src/model/Haze.h index 00e8f3625c..b02a044459 100644 --- a/libraries/model/src/model/Haze.h +++ b/libraries/model/src/model/Haze.h @@ -17,6 +17,26 @@ #include "Transform.h" #include "NumericalConstants.h" +class HazeInit { +public: + // Initial values + static const float initialHazeRange; + static const float initialHazeHeight; + + static const float initialHazeKeyLightRange; + static const float initialHazeKeyLightAltitude; + + static const float initialHazeBackgroundBlend; + + static const glm::vec3 initialHazeColor; + + static const float initialGlareAngle; + + static const glm::vec3 initialHazeGlareColor; + + static const float initialHazeBaseReference; +}; + namespace model { const float LOG_P_005 = logf(0.05f); const float LOG_P_05 = logf(0.5f); @@ -53,27 +73,6 @@ namespace model { class Haze { public: - // Initial values - static const float initialHazeRange; - static const float initialHazeHeight; - - static const float initialHazeKeyLightRange; - static const float initialHazeKeyLightAltitude; - - static const float initialHazeBackgroundBlend; - - static const glm::vec3 initialColorModulationFactor; - - static const glm::vec3 initialHazeColor; - static const xColor initialHazeColorXcolor; - - static const float initialGlareAngle; - - static const glm::vec3 initialHazeGlareColor; - static const xColor initialHazeGlareColorXcolor; - - static const float initialHazeBaseReference; - using UniformBufferView = gpu::BufferView; Haze(); @@ -106,13 +105,13 @@ namespace model { class Parameters { public: // DO NOT CHANGE ORDER HERE WITHOUT UNDERSTANDING THE std140 LAYOUT - glm::vec3 hazeColor{ initialHazeColor }; - float hazeGlareBlend{ convertGlareAngleToPower(initialGlareAngle) }; + glm::vec3 hazeColor{ HazeInit::initialHazeColor }; + float hazeGlareBlend{ convertGlareAngleToPower(HazeInit::initialGlareAngle) }; - glm::vec3 hazeGlareColor{ initialHazeGlareColor }; - float hazeBaseReference{ initialHazeBaseReference }; + glm::vec3 hazeGlareColor{ HazeInit::initialHazeGlareColor }; + float hazeBaseReference{ HazeInit::initialHazeBaseReference }; - glm::vec3 colorModulationFactor{ initialColorModulationFactor }; + glm::vec3 colorModulationFactor; int hazeMode{ 0 }; // bit 0 - set to activate haze attenuation of fragment color // bit 1 - set to add the effect of altitude to the haze attenuation // bit 2 - set to activate directional light attenuation mode @@ -121,14 +120,14 @@ namespace model { glm::mat4 zoneTransform; // Amount of background (skybox) to display, overriding the haze effect for the background - float hazeBackgroundBlend{ initialHazeBackgroundBlend }; + float hazeBackgroundBlend{ HazeInit::initialHazeBackgroundBlend }; // The haze attenuation exponents used by both fragment and directional light attenuation - float hazeRangeFactor{ convertHazeRangeToHazeRangeFactor(initialHazeRange) }; - float hazeHeightFactor{ convertHazeAltitudeToHazeAltitudeFactor(initialHazeHeight) }; + float hazeRangeFactor{ convertHazeRangeToHazeRangeFactor(HazeInit::initialHazeRange) }; + float hazeHeightFactor{ convertHazeAltitudeToHazeAltitudeFactor(HazeInit::initialHazeHeight) }; - float hazeKeyLightRangeFactor{ convertHazeRangeToHazeRangeFactor(initialHazeKeyLightRange) }; - float hazeKeyLightAltitudeFactor{ convertHazeAltitudeToHazeAltitudeFactor(initialHazeKeyLightAltitude) }; + float hazeKeyLightRangeFactor{ convertHazeRangeToHazeRangeFactor(HazeInit::initialHazeKeyLightRange) }; + float hazeKeyLightAltitudeFactor{ convertHazeAltitudeToHazeAltitudeFactor(HazeInit::initialHazeKeyLightAltitude) }; Parameters() {} }; diff --git a/libraries/render-utils/src/DrawHaze.h b/libraries/render-utils/src/DrawHaze.h index 15337c850b..c460d38bf1 100644 --- a/libraries/render-utils/src/DrawHaze.h +++ b/libraries/render-utils/src/DrawHaze.h @@ -19,11 +19,10 @@ #include #include #include +#include #include "SurfaceGeometryPass.h" -#include - using LinearDepthFramebufferPointer = std::shared_ptr; class MakeHazeConfig : public render::Job::Config { @@ -52,11 +51,11 @@ class MakeHazeConfig : public render::Job::Config { public: MakeHazeConfig() : render::Job::Config() {} - glm::vec3 hazeColor{ model::Haze::initialHazeColor }; - float hazeGlareAngle{ model::Haze::initialGlareAngle }; + glm::vec3 hazeColor{ HazeInit::initialHazeColor }; + float hazeGlareAngle{ HazeInit::initialGlareAngle }; - glm::vec3 hazeGlareColor{ model::Haze::initialHazeGlareColor }; - float hazeBaseReference{ model::Haze::initialHazeBaseReference }; + glm::vec3 hazeGlareColor{ HazeInit::initialHazeGlareColor }; + float hazeBaseReference{ HazeInit::initialHazeBaseReference }; bool isHazeActive{ false }; bool isAltitudeBased{ false }; @@ -64,13 +63,13 @@ public: bool isModulateColorActive{ false }; bool isHazeEnableGlare{ false }; - float hazeRange{ model::Haze::initialHazeRange }; - float hazeHeight{ model::Haze::initialHazeHeight }; + float hazeRange{ HazeInit::initialHazeRange }; + float hazeHeight{ HazeInit::initialHazeHeight }; - float hazeKeyLightRange{ model::Haze::initialHazeKeyLightRange }; - float hazeKeyLightAltitude{ model::Haze::initialHazeKeyLightAltitude }; + float hazeKeyLightRange{ HazeInit::initialHazeKeyLightRange }; + float hazeKeyLightAltitude{ HazeInit::initialHazeKeyLightAltitude }; - float hazeBackgroundBlend{ model::Haze::initialHazeBackgroundBlend }; + float hazeBackgroundBlend{ HazeInit::initialHazeBackgroundBlend }; public slots: void setHazeColor(const glm::vec3 value) { hazeColor = value; emit dirty(); } @@ -116,11 +115,11 @@ public: HazeConfig() : render::Job::Config(true) {} // attributes - glm::vec3 hazeColor{ model::Haze::initialHazeColor }; - float hazeGlareAngle{ model::Haze::initialGlareAngle }; + glm::vec3 hazeColor{ HazeInit::initialHazeColor }; + float hazeGlareAngle{ HazeInit::initialGlareAngle }; - glm::vec3 hazeGlareColor{ model::Haze::initialHazeGlareColor }; - float hazeBaseReference{ model::Haze::initialHazeBaseReference }; + glm::vec3 hazeGlareColor{ HazeInit::initialHazeGlareColor }; + float hazeBaseReference{ HazeInit::initialHazeBaseReference }; bool isHazeActive{ false }; // Setting this to true will set haze to on bool isAltitudeBased{ false }; @@ -128,13 +127,13 @@ public: bool isModulateColorActive{ false }; bool isHazeEnableGlare{ false }; - float hazeRange{ model::Haze::initialHazeRange }; - float hazeHeight{ model::Haze::initialHazeHeight }; + float hazeRange{ HazeInit::initialHazeRange }; + float hazeHeight{ HazeInit::initialHazeHeight }; - float hazeKeyLightRange{ model::Haze::initialHazeKeyLightRange }; - float hazeKeyLightAltitude{ model::Haze::initialHazeKeyLightAltitude }; + float hazeKeyLightRange{ HazeInit::initialHazeKeyLightRange }; + float hazeKeyLightAltitude{ HazeInit::initialHazeKeyLightAltitude }; - float hazeBackgroundBlend{ model::Haze::initialHazeBackgroundBlend }; + float hazeBackgroundBlend{ HazeInit::initialHazeBackgroundBlend }; // methods void setHazeColor(const glm::vec3 value); diff --git a/libraries/render-utils/src/HazeStage.h b/libraries/render-utils/src/HazeStage.h index 42f26a2679..ac5a8dd6f5 100644 --- a/libraries/render-utils/src/HazeStage.h +++ b/libraries/render-utils/src/HazeStage.h @@ -106,11 +106,11 @@ class FetchHazeConfig : public render::Job::Config { public: FetchHazeConfig() : render::Job::Config() {} - glm::vec3 hazeColor{ model::Haze::initialHazeColor }; - float hazeGlareAngle{ model::Haze::initialGlareAngle }; + glm::vec3 hazeColor{ HazeInit::initialHazeColor }; + float hazeGlareAngle{ HazeInit::initialGlareAngle }; - glm::vec3 hazeGlareColor{ model::Haze::initialHazeGlareColor }; - float hazeBaseReference{ model::Haze::initialHazeBaseReference }; + glm::vec3 hazeGlareColor{ HazeInit::initialHazeGlareColor }; + float hazeBaseReference{ HazeInit::initialHazeBaseReference }; bool isHazeActive{ false }; bool isAltitudeBased{ false }; @@ -118,13 +118,13 @@ public: bool isModulateColorActive{ false }; bool isHazeEnableGlare{ false }; - float hazeRange{ model::Haze::initialHazeRange }; - float hazeHeight{ model::Haze::initialHazeHeight }; + float hazeRange{ HazeInit::initialHazeRange }; + float hazeHeight{ HazeInit::initialHazeHeight }; - float hazeKeyLightRange{ model::Haze::initialHazeKeyLightRange }; - float hazeKeyLightAltitude{ model::Haze::initialHazeKeyLightAltitude }; + float hazeKeyLightRange{ HazeInit::initialHazeKeyLightRange }; + float hazeKeyLightAltitude{ HazeInit::initialHazeKeyLightAltitude }; - float hazeBackgroundBlend{ model::Haze::initialHazeBackgroundBlend }; + float hazeBackgroundBlend{ HazeInit::initialHazeBackgroundBlend }; public slots: void setHazeColor(const glm::vec3 value) { hazeColor = value; emit dirty(); } From 03d2ca19b9b161393f0c718a1550bd7235ba61f0 Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Tue, 31 Oct 2017 13:46:58 -0700 Subject: [PATCH 12/12] Moving consts into mode::Haze namespace. --- .../src/RenderableZoneEntityItem.cpp | 10 +- libraries/entities/src/HazePropertyGroup.h | 28 ++--- libraries/model/src/model/Haze.cpp | 21 ++-- libraries/model/src/model/Haze.h | 116 +++++++++--------- .../networking/src/udt/PacketHeaders.cpp | 2 +- libraries/networking/src/udt/PacketHeaders.h | 3 +- libraries/render-utils/src/DrawHaze.cpp | 10 +- libraries/render-utils/src/DrawHaze.h | 36 +++--- libraries/render-utils/src/HazeStage.cpp | 10 +- libraries/render-utils/src/HazeStage.h | 18 +-- 10 files changed, 127 insertions(+), 127 deletions(-) diff --git a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp index 877e245006..7c96f00ede 100644 --- a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp @@ -342,23 +342,23 @@ void ZoneEntityRenderer::updateHazeFromEntity(const TypedEntityPointer& entity) haze->setHazeActive(hazeMode == COMPONENT_MODE_ENABLED); haze->setAltitudeBased(_hazeProperties.getHazeAltitudeEffect()); - haze->setHazeRangeFactor(model::convertHazeRangeToHazeRangeFactor(_hazeProperties.getHazeRange())); + haze->setHazeRangeFactor(model::Haze::convertHazeRangeToHazeRangeFactor(_hazeProperties.getHazeRange())); xColor hazeColor = _hazeProperties.getHazeColor(); haze->setHazeColor(glm::vec3(hazeColor.red / 255.0, hazeColor.green / 255.0, hazeColor.blue / 255.0)); xColor hazeGlareColor = _hazeProperties.getHazeGlareColor(); haze->setHazeGlareColor(glm::vec3(hazeGlareColor.red / 255.0, hazeGlareColor.green / 255.0, hazeGlareColor.blue / 255.0)); haze->setHazeEnableGlare(_hazeProperties.getHazeEnableGlare()); - haze->setHazeGlareBlend(model::convertGlareAngleToPower(_hazeProperties.getHazeGlareAngle())); + haze->setHazeGlareBlend(model::Haze::convertGlareAngleToPower(_hazeProperties.getHazeGlareAngle())); float hazeAltitude = _hazeProperties.getHazeCeiling() - _hazeProperties.getHazeBaseRef(); - haze->setHazeAltitudeFactor(model::convertHazeAltitudeToHazeAltitudeFactor(hazeAltitude)); + haze->setHazeAltitudeFactor(model::Haze::convertHazeAltitudeToHazeAltitudeFactor(hazeAltitude)); haze->setHazeBaseReference(_hazeProperties.getHazeBaseRef()); haze->setHazeBackgroundBlend(_hazeProperties.getHazeBackgroundBlend()); haze->setHazeAttenuateKeyLight(_hazeProperties.getHazeAttenuateKeyLight()); - haze->setHazeKeyLightRangeFactor(model::convertHazeRangeToHazeRangeFactor(_hazeProperties.getHazeKeyLightRange())); - haze->setHazeKeyLightAltitudeFactor(model::convertHazeAltitudeToHazeAltitudeFactor(_hazeProperties.getHazeKeyLightAltitude())); + haze->setHazeKeyLightRangeFactor(model::Haze::convertHazeRangeToHazeRangeFactor(_hazeProperties.getHazeKeyLightRange())); + haze->setHazeKeyLightAltitudeFactor(model::Haze::convertHazeAltitudeToHazeAltitudeFactor(_hazeProperties.getHazeKeyLightAltitude())); haze->setZoneTransform(entity->getTransform().getMatrix()); } diff --git a/libraries/entities/src/HazePropertyGroup.h b/libraries/entities/src/HazePropertyGroup.h index 965f112af9..939391caf9 100644 --- a/libraries/entities/src/HazePropertyGroup.h +++ b/libraries/entities/src/HazePropertyGroup.h @@ -27,18 +27,18 @@ class OctreePacketData; class EntityTreeElementExtraEncodeData; class ReadBitstreamToTreeParams; -static const float initialHazeRange{ 1000.0f }; +static const float INITIAL_HAZE_RANGE{ 1000.0f }; static const xColor initialHazeGlareColorXcolor{ 255, 229, 179 }; static const xColor initialHazeColorXcolor{ 128, 154, 179 }; -static const float initialGlareAngle{ 20.0f }; +static const float INITIAL_HAZE_GLARE_ANGLE{ 20.0f }; -static const float initialHazeBaseReference{ 0.0f }; -static const float initialHazeHeight{ 200.0f }; +static const float INITIAL_HAZE_BASE_REFERENCE{ 0.0f }; +static const float INITIAL_HAZE_HEIGHT{ 200.0f }; -static const float initialHazeBackgroundBlend{ 0.0f }; +static const float INITIAL_HAZE_BACKGROUND_BLEND{ 0.0f }; -static const float initialHazeKeyLightRange{ 1000.0f }; -static const float initialHazeKeyLightAltitude{ 200.0f }; +static const float INITIAL_KEY_LIGHT_RANGE{ 1000.0f }; +static const float INITIAL_KEY_LIGHT_ALTITUDE{ 200.0f }; class HazePropertyGroup : public PropertyGroup { public: @@ -88,24 +88,24 @@ public: bool& somethingChanged) override; // Range only parameters - DEFINE_PROPERTY(PROP_HAZE_RANGE, HazeRange, hazeRange, float, initialHazeRange); + DEFINE_PROPERTY(PROP_HAZE_RANGE, HazeRange, hazeRange, float, INITIAL_HAZE_RANGE); DEFINE_PROPERTY_REF(PROP_HAZE_COLOR, HazeColor, hazeColor, xColor, initialHazeColorXcolor); DEFINE_PROPERTY_REF(PROP_HAZE_GLARE_COLOR, HazeGlareColor, hazeGlareColor, xColor, initialHazeGlareColorXcolor); DEFINE_PROPERTY(PROP_HAZE_ENABLE_GLARE, HazeEnableGlare, hazeEnableGlare, bool, false); - DEFINE_PROPERTY_REF(PROP_HAZE_GLARE_ANGLE, HazeGlareAngle, hazeGlareAngle, float, initialGlareAngle); + DEFINE_PROPERTY_REF(PROP_HAZE_GLARE_ANGLE, HazeGlareAngle, hazeGlareAngle, float, INITIAL_HAZE_GLARE_ANGLE); // Altitude parameters DEFINE_PROPERTY(PROP_HAZE_ALTITUDE_EFFECT, HazeAltitudeEffect, hazeAltitudeEffect, bool, false); - DEFINE_PROPERTY_REF(PROP_HAZE_CEILING, HazeCeiling, hazeCeiling, float, initialHazeBaseReference + initialHazeHeight); - DEFINE_PROPERTY_REF(PROP_HAZE_BASE_REF, HazeBaseRef, hazeBaseRef, float, initialHazeBaseReference); + DEFINE_PROPERTY_REF(PROP_HAZE_CEILING, HazeCeiling, hazeCeiling, float, INITIAL_HAZE_BASE_REFERENCE + INITIAL_HAZE_HEIGHT); + DEFINE_PROPERTY_REF(PROP_HAZE_BASE_REF, HazeBaseRef, hazeBaseRef, float, INITIAL_HAZE_BASE_REFERENCE); // Background (skybox) blend value - DEFINE_PROPERTY_REF(PROP_HAZE_BACKGROUND_BLEND, HazeBackgroundBlend, hazeBackgroundBlend, float, initialHazeBackgroundBlend); + DEFINE_PROPERTY_REF(PROP_HAZE_BACKGROUND_BLEND, HazeBackgroundBlend, hazeBackgroundBlend, float, INITIAL_HAZE_BACKGROUND_BLEND); // hazeDirectional light attenuation DEFINE_PROPERTY(PROP_HAZE_ATTENUATE_KEYLIGHT, HazeAttenuateKeyLight, hazeAttenuateKeyLight, bool, false); - DEFINE_PROPERTY_REF(PROP_HAZE_KEYLIGHT_RANGE, HazeKeyLightRange, hazeKeyLightRange, float, initialHazeKeyLightRange); - DEFINE_PROPERTY_REF(PROP_HAZE_KEYLIGHT_ALTITUDE, HazeKeyLightAltitude, hazeKeyLightAltitude, float, initialHazeKeyLightAltitude); + DEFINE_PROPERTY_REF(PROP_HAZE_KEYLIGHT_RANGE, HazeKeyLightRange, hazeKeyLightRange, float, INITIAL_KEY_LIGHT_RANGE); + DEFINE_PROPERTY_REF(PROP_HAZE_KEYLIGHT_ALTITUDE, HazeKeyLightAltitude, hazeKeyLightAltitude, float, INITIAL_KEY_LIGHT_ALTITUDE); }; #endif // hifi_HazePropertyGroup_h diff --git a/libraries/model/src/model/Haze.cpp b/libraries/model/src/model/Haze.cpp index 01cb32a98b..c9c73bcee9 100644 --- a/libraries/model/src/model/Haze.cpp +++ b/libraries/model/src/model/Haze.cpp @@ -14,21 +14,24 @@ using namespace model; -const float HazeInit::initialHazeRange{ 1000.0f }; -const float HazeInit::initialHazeHeight{ 200.0f }; +const float Haze::INITIAL_HAZE_RANGE{ 1000.0f }; +const float Haze::INITIAL_HAZE_HEIGHT{ 200.0f }; -const float HazeInit::initialHazeKeyLightRange{ 1000.0f }; -const float HazeInit::initialHazeKeyLightAltitude{ 200.0f }; +const float Haze::INITIAL_KEY_LIGHT_RANGE{ 1000.0f }; +const float Haze::INITIAL_KEY_LIGHT_ALTITUDE{ 200.0f }; -const float HazeInit::initialHazeBackgroundBlend{ 0.0f }; +const float Haze::INITIAL_HAZE_BACKGROUND_BLEND{ 0.0f }; -const glm::vec3 HazeInit::initialHazeColor{ 0.5f, 0.6f, 0.7f }; // Bluish +const glm::vec3 Haze::INITIAL_HAZE_COLOR{ 0.5f, 0.6f, 0.7f }; // Bluish -const float HazeInit::initialGlareAngle{ 20.0f }; +const float Haze::INITIAL_HAZE_GLARE_ANGLE{ 20.0f }; -const glm::vec3 HazeInit::initialHazeGlareColor{ 1.0f, 0.9f, 0.7f }; +const glm::vec3 Haze::INITIAL_HAZE_GLARE_COLOR{ 1.0f, 0.9f, 0.7f }; -const float HazeInit::initialHazeBaseReference{ 0.0f }; +const float Haze::INITIAL_HAZE_BASE_REFERENCE{ 0.0f }; + +const float Haze::LOG_P_005{ logf(0.05f)}; +const float Haze::LOG_P_05{ logf(0.5f) }; Haze::Haze() { Parameters parameters; diff --git a/libraries/model/src/model/Haze.h b/libraries/model/src/model/Haze.h index b02a044459..a0cc7c3bc7 100644 --- a/libraries/model/src/model/Haze.h +++ b/libraries/model/src/model/Haze.h @@ -17,63 +17,58 @@ #include "Transform.h" #include "NumericalConstants.h" -class HazeInit { -public: - // Initial values - static const float initialHazeRange; - static const float initialHazeHeight; - - static const float initialHazeKeyLightRange; - static const float initialHazeKeyLightAltitude; - - static const float initialHazeBackgroundBlend; - - static const glm::vec3 initialHazeColor; - - static const float initialGlareAngle; - - static const glm::vec3 initialHazeGlareColor; - - static const float initialHazeBaseReference; -}; - namespace model { - const float LOG_P_005 = logf(0.05f); - const float LOG_P_05 = logf(0.5f); - - // Derivation (d is distance, b is haze coefficient, f is attenuation, solve for f = 0.05 - // f = exp(-d * b) - // ln(f) = -d * b - // b = -ln(f)/d - inline glm::vec3 convertHazeRangeToHazeRangeFactor(const glm::vec3 hazeRange) { - return glm::vec3( - -LOG_P_005 / hazeRange.x, - -LOG_P_005 / hazeRange.y, - -LOG_P_005 / hazeRange.z); - } - - // limit range and altitude to no less than 1.0 metres - inline float convertHazeRangeToHazeRangeFactor(const float hazeRange) { return -LOG_P_005 / glm::max(hazeRange, 1.0f); } - - inline float convertHazeAltitudeToHazeAltitudeFactor(const float hazeHeight) { return -LOG_P_005 / glm::max(hazeHeight, 1.0f); } - - // Derivation (s is the proportion of sun blend, a is the angle at which the blend is 50%, solve for m = 0.5 - // s = dot(lookAngle, sunAngle) = cos(a) - // m = pow(s, p) - // log(m) = p * log(s) - // p = log(m) / log(s) - // limit to 0.1 degrees - inline float convertGlareAngleToPower(const float hazeGlareAngle) { - const float GLARE_ANGLE_LIMIT = 0.1f; - return LOG_P_05 / logf(cosf(RADIANS_PER_DEGREE * glm::max(GLARE_ANGLE_LIMIT, hazeGlareAngle))); - } - // Haze range is defined here as the range the visibility is reduced by 95% // Haze altitude is defined here as the altitude (above 0) that the haze is reduced by 95% class Haze { public: - using UniformBufferView = gpu::BufferView; + // Initial values + static const float INITIAL_HAZE_RANGE; + static const float INITIAL_HAZE_HEIGHT; + + static const float INITIAL_KEY_LIGHT_RANGE; + static const float INITIAL_KEY_LIGHT_ALTITUDE; + + static const float INITIAL_HAZE_BACKGROUND_BLEND; + + static const glm::vec3 INITIAL_HAZE_COLOR; + + static const float INITIAL_HAZE_GLARE_ANGLE; + + static const glm::vec3 INITIAL_HAZE_GLARE_COLOR; + + static const float INITIAL_HAZE_BASE_REFERENCE; + + static const float LOG_P_005; + static const float LOG_P_05; + + // Derivation (d is distance, b is haze coefficient, f is attenuation, solve for f = 0.05 + // f = exp(-d * b) + // ln(f) = -d * b + // b = -ln(f)/d + static inline glm::vec3 convertHazeRangeToHazeRangeFactor(const glm::vec3 hazeRange) { + return glm::vec3( + -LOG_P_005 / hazeRange.x, + -LOG_P_005 / hazeRange.y, + -LOG_P_005 / hazeRange.z); + } + + // limit range and altitude to no less than 1.0 metres + static inline float convertHazeRangeToHazeRangeFactor(const float hazeRange) { return -LOG_P_005 / glm::max(hazeRange, 1.0f); } + + static inline float convertHazeAltitudeToHazeAltitudeFactor(const float hazeHeight) { return -LOG_P_005 / glm::max(hazeHeight, 1.0f); } + + // Derivation (s is the proportion of sun blend, a is the angle at which the blend is 50%, solve for m = 0.5 + // s = dot(lookAngle, sunAngle) = cos(a) + // m = pow(s, p) + // log(m) = p * log(s) + // p = log(m) / log(s) + // limit to 0.1 degrees + static inline float convertGlareAngleToPower(const float hazeGlareAngle) { + const float GLARE_ANGLE_LIMIT = 0.1f; + return LOG_P_05 / logf(cosf(RADIANS_PER_DEGREE * glm::max(GLARE_ANGLE_LIMIT, hazeGlareAngle))); + } Haze(); @@ -99,17 +94,18 @@ namespace model { void setZoneTransform(const glm::mat4& zoneTransform); + using UniformBufferView = gpu::BufferView; UniformBufferView getHazeParametersBuffer() const { return _hazeParametersBuffer; } protected: class Parameters { public: // DO NOT CHANGE ORDER HERE WITHOUT UNDERSTANDING THE std140 LAYOUT - glm::vec3 hazeColor{ HazeInit::initialHazeColor }; - float hazeGlareBlend{ convertGlareAngleToPower(HazeInit::initialGlareAngle) }; + glm::vec3 hazeColor{ INITIAL_HAZE_COLOR }; + float hazeGlareBlend{ convertGlareAngleToPower(INITIAL_HAZE_GLARE_ANGLE) }; - glm::vec3 hazeGlareColor{ HazeInit::initialHazeGlareColor }; - float hazeBaseReference{ HazeInit::initialHazeBaseReference }; + glm::vec3 hazeGlareColor{ INITIAL_HAZE_GLARE_COLOR }; + float hazeBaseReference{ INITIAL_HAZE_BASE_REFERENCE }; glm::vec3 colorModulationFactor; int hazeMode{ 0 }; // bit 0 - set to activate haze attenuation of fragment color @@ -120,14 +116,14 @@ namespace model { glm::mat4 zoneTransform; // Amount of background (skybox) to display, overriding the haze effect for the background - float hazeBackgroundBlend{ HazeInit::initialHazeBackgroundBlend }; + float hazeBackgroundBlend{ INITIAL_HAZE_BACKGROUND_BLEND }; // The haze attenuation exponents used by both fragment and directional light attenuation - float hazeRangeFactor{ convertHazeRangeToHazeRangeFactor(HazeInit::initialHazeRange) }; - float hazeHeightFactor{ convertHazeAltitudeToHazeAltitudeFactor(HazeInit::initialHazeHeight) }; + float hazeRangeFactor{ convertHazeRangeToHazeRangeFactor(INITIAL_HAZE_RANGE) }; + float hazeHeightFactor{ convertHazeAltitudeToHazeAltitudeFactor(INITIAL_HAZE_HEIGHT) }; - float hazeKeyLightRangeFactor{ convertHazeRangeToHazeRangeFactor(HazeInit::initialHazeKeyLightRange) }; - float hazeKeyLightAltitudeFactor{ convertHazeAltitudeToHazeAltitudeFactor(HazeInit::initialHazeKeyLightAltitude) }; + float hazeKeyLightRangeFactor{ convertHazeRangeToHazeRangeFactor(INITIAL_KEY_LIGHT_RANGE) }; + float hazeKeyLightAltitudeFactor{ convertHazeAltitudeToHazeAltitudeFactor(INITIAL_KEY_LIGHT_ALTITUDE) }; Parameters() {} }; diff --git a/libraries/networking/src/udt/PacketHeaders.cpp b/libraries/networking/src/udt/PacketHeaders.cpp index 09ee41b31d..9a98393fa1 100644 --- a/libraries/networking/src/udt/PacketHeaders.cpp +++ b/libraries/networking/src/udt/PacketHeaders.cpp @@ -30,7 +30,7 @@ PacketVersion versionForPacketType(PacketType packetType) { case PacketType::EntityEdit: case PacketType::EntityData: case PacketType::EntityPhysics: - return static_cast(EntityVersion::HasDynamicOwnershipTests); + return static_cast(EntityVersion::HazeEffect); case PacketType::EntityQuery: return static_cast(EntityQueryPacketVersion::JSONFilterWithFamilyTree); diff --git a/libraries/networking/src/udt/PacketHeaders.h b/libraries/networking/src/udt/PacketHeaders.h index 049cb0f1a8..e00b4139c3 100644 --- a/libraries/networking/src/udt/PacketHeaders.h +++ b/libraries/networking/src/udt/PacketHeaders.h @@ -196,7 +196,8 @@ QDebug operator<<(QDebug debug, const PacketType& type); enum class EntityVersion : PacketVersion { StrokeColorProperty = 77, - HasDynamicOwnershipTests + HasDynamicOwnershipTests, + HazeEffect }; enum class EntityScriptCallMethodVersion : PacketVersion { diff --git a/libraries/render-utils/src/DrawHaze.cpp b/libraries/render-utils/src/DrawHaze.cpp index 3be74da26a..7cf07d8f33 100644 --- a/libraries/render-utils/src/DrawHaze.cpp +++ b/libraries/render-utils/src/DrawHaze.cpp @@ -83,7 +83,7 @@ MakeHaze::MakeHaze() { void MakeHaze::configure(const Config& config) { _haze->setHazeColor(config.hazeColor); - _haze->setHazeGlareBlend(model::convertGlareAngleToPower(config.hazeGlareAngle)); + _haze->setHazeGlareBlend(model::Haze::convertGlareAngleToPower(config.hazeGlareAngle)); _haze->setHazeGlareColor(config.hazeGlareColor); _haze->setHazeBaseReference(config.hazeBaseReference); @@ -94,11 +94,11 @@ void MakeHaze::configure(const Config& config) { _haze->setModulateColorActive(config.isModulateColorActive); _haze->setHazeEnableGlare(config.isHazeEnableGlare); - _haze->setHazeRangeFactor(model::convertHazeRangeToHazeRangeFactor(config.hazeRange)); - _haze->setHazeAltitudeFactor(model::convertHazeAltitudeToHazeAltitudeFactor(config.hazeHeight)); + _haze->setHazeRangeFactor(model::Haze::convertHazeRangeToHazeRangeFactor(config.hazeRange)); + _haze->setHazeAltitudeFactor(model::Haze::convertHazeAltitudeToHazeAltitudeFactor(config.hazeHeight)); - _haze->setHazeKeyLightRangeFactor(model::convertHazeRangeToHazeRangeFactor(config.hazeKeyLightRange)); - _haze->setHazeKeyLightAltitudeFactor(model::convertHazeAltitudeToHazeAltitudeFactor(config.hazeKeyLightAltitude)); + _haze->setHazeKeyLightRangeFactor(model::Haze::convertHazeRangeToHazeRangeFactor(config.hazeKeyLightRange)); + _haze->setHazeKeyLightAltitudeFactor(model::Haze::convertHazeAltitudeToHazeAltitudeFactor(config.hazeKeyLightAltitude)); _haze->setHazeBackgroundBlend(config.hazeBackgroundBlend); } diff --git a/libraries/render-utils/src/DrawHaze.h b/libraries/render-utils/src/DrawHaze.h index c460d38bf1..f158daa0c6 100644 --- a/libraries/render-utils/src/DrawHaze.h +++ b/libraries/render-utils/src/DrawHaze.h @@ -51,11 +51,11 @@ class MakeHazeConfig : public render::Job::Config { public: MakeHazeConfig() : render::Job::Config() {} - glm::vec3 hazeColor{ HazeInit::initialHazeColor }; - float hazeGlareAngle{ HazeInit::initialGlareAngle }; + glm::vec3 hazeColor{ model::Haze::INITIAL_HAZE_COLOR }; + float hazeGlareAngle{ model::Haze::INITIAL_HAZE_GLARE_ANGLE }; - glm::vec3 hazeGlareColor{ HazeInit::initialHazeGlareColor }; - float hazeBaseReference{ HazeInit::initialHazeBaseReference }; + glm::vec3 hazeGlareColor{ model::Haze::INITIAL_HAZE_GLARE_COLOR }; + float hazeBaseReference{ model::Haze::INITIAL_HAZE_BASE_REFERENCE }; bool isHazeActive{ false }; bool isAltitudeBased{ false }; @@ -63,13 +63,13 @@ public: bool isModulateColorActive{ false }; bool isHazeEnableGlare{ false }; - float hazeRange{ HazeInit::initialHazeRange }; - float hazeHeight{ HazeInit::initialHazeHeight }; + float hazeRange{ model::Haze::INITIAL_HAZE_RANGE }; + float hazeHeight{ model::Haze::INITIAL_HAZE_HEIGHT }; - float hazeKeyLightRange{ HazeInit::initialHazeKeyLightRange }; - float hazeKeyLightAltitude{ HazeInit::initialHazeKeyLightAltitude }; + float hazeKeyLightRange{ model::Haze::INITIAL_KEY_LIGHT_RANGE }; + float hazeKeyLightAltitude{ model::Haze::INITIAL_KEY_LIGHT_ALTITUDE }; - float hazeBackgroundBlend{ HazeInit::initialHazeBackgroundBlend }; + float hazeBackgroundBlend{ model::Haze::INITIAL_HAZE_BACKGROUND_BLEND }; public slots: void setHazeColor(const glm::vec3 value) { hazeColor = value; emit dirty(); } @@ -115,11 +115,11 @@ public: HazeConfig() : render::Job::Config(true) {} // attributes - glm::vec3 hazeColor{ HazeInit::initialHazeColor }; - float hazeGlareAngle{ HazeInit::initialGlareAngle }; + glm::vec3 hazeColor{ model::Haze::INITIAL_HAZE_COLOR }; + float hazeGlareAngle{ model::Haze::INITIAL_HAZE_GLARE_ANGLE }; - glm::vec3 hazeGlareColor{ HazeInit::initialHazeGlareColor }; - float hazeBaseReference{ HazeInit::initialHazeBaseReference }; + glm::vec3 hazeGlareColor{ model::Haze::INITIAL_HAZE_GLARE_COLOR }; + float hazeBaseReference{ model::Haze::INITIAL_HAZE_BASE_REFERENCE }; bool isHazeActive{ false }; // Setting this to true will set haze to on bool isAltitudeBased{ false }; @@ -127,13 +127,13 @@ public: bool isModulateColorActive{ false }; bool isHazeEnableGlare{ false }; - float hazeRange{ HazeInit::initialHazeRange }; - float hazeHeight{ HazeInit::initialHazeHeight }; + float hazeRange{ model::Haze::INITIAL_HAZE_RANGE }; + float hazeHeight{ model::Haze::INITIAL_HAZE_HEIGHT }; - float hazeKeyLightRange{ HazeInit::initialHazeKeyLightRange }; - float hazeKeyLightAltitude{ HazeInit::initialHazeKeyLightAltitude }; + float hazeKeyLightRange{ model::Haze::INITIAL_KEY_LIGHT_RANGE }; + float hazeKeyLightAltitude{ model::Haze::INITIAL_KEY_LIGHT_ALTITUDE }; - float hazeBackgroundBlend{ HazeInit::initialHazeBackgroundBlend }; + float hazeBackgroundBlend{ model::Haze::INITIAL_HAZE_BACKGROUND_BLEND }; // methods void setHazeColor(const glm::vec3 value); diff --git a/libraries/render-utils/src/HazeStage.cpp b/libraries/render-utils/src/HazeStage.cpp index c9e6ef90cb..7a12ee3c8a 100644 --- a/libraries/render-utils/src/HazeStage.cpp +++ b/libraries/render-utils/src/HazeStage.cpp @@ -21,7 +21,7 @@ FetchHazeStage::FetchHazeStage() { void FetchHazeStage::configure(const Config& config) { _haze->setHazeColor(config.hazeColor); - _haze->setHazeGlareBlend(model::convertGlareAngleToPower(config.hazeGlareAngle)); + _haze->setHazeGlareBlend(model::Haze::convertGlareAngleToPower(config.hazeGlareAngle)); _haze->setHazeGlareColor(config.hazeGlareColor); _haze->setHazeBaseReference(config.hazeBaseReference); @@ -32,11 +32,11 @@ void FetchHazeStage::configure(const Config& config) { _haze->setModulateColorActive(config.isModulateColorActive); _haze->setHazeEnableGlare(config.isHazeEnableGlare); - _haze->setHazeRangeFactor(model::convertHazeRangeToHazeRangeFactor(config.hazeRange)); - _haze->setHazeAltitudeFactor(model::convertHazeAltitudeToHazeAltitudeFactor(config.hazeHeight)); + _haze->setHazeRangeFactor(model::Haze::convertHazeRangeToHazeRangeFactor(config.hazeRange)); + _haze->setHazeAltitudeFactor(model::Haze::convertHazeAltitudeToHazeAltitudeFactor(config.hazeHeight)); - _haze->setHazeKeyLightRangeFactor(model::convertHazeRangeToHazeRangeFactor(config.hazeKeyLightRange)); - _haze->setHazeKeyLightAltitudeFactor(model::convertHazeAltitudeToHazeAltitudeFactor(config.hazeKeyLightAltitude)); + _haze->setHazeKeyLightRangeFactor(model::Haze::convertHazeRangeToHazeRangeFactor(config.hazeKeyLightRange)); + _haze->setHazeKeyLightAltitudeFactor(model::Haze::convertHazeAltitudeToHazeAltitudeFactor(config.hazeKeyLightAltitude)); _haze->setHazeBackgroundBlend(config.hazeBackgroundBlend); } diff --git a/libraries/render-utils/src/HazeStage.h b/libraries/render-utils/src/HazeStage.h index ac5a8dd6f5..102f299d8f 100644 --- a/libraries/render-utils/src/HazeStage.h +++ b/libraries/render-utils/src/HazeStage.h @@ -106,11 +106,11 @@ class FetchHazeConfig : public render::Job::Config { public: FetchHazeConfig() : render::Job::Config() {} - glm::vec3 hazeColor{ HazeInit::initialHazeColor }; - float hazeGlareAngle{ HazeInit::initialGlareAngle }; + glm::vec3 hazeColor{ model::Haze::INITIAL_HAZE_COLOR }; + float hazeGlareAngle{ model::Haze::INITIAL_HAZE_GLARE_ANGLE }; - glm::vec3 hazeGlareColor{ HazeInit::initialHazeGlareColor }; - float hazeBaseReference{ HazeInit::initialHazeBaseReference }; + glm::vec3 hazeGlareColor{ model::Haze::INITIAL_HAZE_GLARE_COLOR }; + float hazeBaseReference{ model::Haze::INITIAL_HAZE_BASE_REFERENCE }; bool isHazeActive{ false }; bool isAltitudeBased{ false }; @@ -118,13 +118,13 @@ public: bool isModulateColorActive{ false }; bool isHazeEnableGlare{ false }; - float hazeRange{ HazeInit::initialHazeRange }; - float hazeHeight{ HazeInit::initialHazeHeight }; + float hazeRange{ model::Haze::INITIAL_HAZE_RANGE }; + float hazeHeight{ model::Haze::INITIAL_HAZE_HEIGHT }; - float hazeKeyLightRange{ HazeInit::initialHazeKeyLightRange }; - float hazeKeyLightAltitude{ HazeInit::initialHazeKeyLightAltitude }; + float hazeKeyLightRange{ model::Haze::INITIAL_KEY_LIGHT_RANGE }; + float hazeKeyLightAltitude{ model::Haze::INITIAL_KEY_LIGHT_ALTITUDE }; - float hazeBackgroundBlend{ HazeInit::initialHazeBackgroundBlend }; + float hazeBackgroundBlend{ model::Haze::INITIAL_HAZE_BACKGROUND_BLEND }; public slots: void setHazeColor(const glm::vec3 value) { hazeColor = value; emit dirty(); }