From 953ddfdcd3d016a0031f188c3d50ca608b7c9946 Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Thu, 21 Sep 2017 14:54:16 -0700 Subject: [PATCH 01/94] First version of adding haze to the zone. --- .../src/RenderableZoneEntityItem.h | 3 +- .../entities/src/EntityItemProperties.cpp | 5 +- libraries/entities/src/EntityItemProperties.h | 2 + libraries/entities/src/EntityPropertyFlags.h | 2 + libraries/entities/src/HazePropertyGroup.cpp | 149 ++++++++++++++++ libraries/entities/src/HazePropertyGroup.h | 90 ++++++++++ libraries/entities/src/ZoneEntityItem.h | 11 +- libraries/model/src/model/Haze.cpp | 163 ++++++++++++++++++ libraries/model/src/model/Haze.h | 115 ++++++++++++ libraries/model/src/model/Stage.cpp | 11 ++ libraries/model/src/model/Stage.h | 17 ++ libraries/octree/src/OctreePacketData.h | 1 + libraries/shared/src/HazeMode.h | 24 +++ 13 files changed, 590 insertions(+), 3 deletions(-) create mode 100644 libraries/entities/src/HazePropertyGroup.cpp create mode 100644 libraries/entities/src/HazePropertyGroup.h create mode 100644 libraries/model/src/model/Haze.cpp create mode 100644 libraries/model/src/model/Haze.h create mode 100644 libraries/shared/src/HazeMode.h diff --git a/libraries/entities-renderer/src/RenderableZoneEntityItem.h b/libraries/entities-renderer/src/RenderableZoneEntityItem.h index 80fe393f48..9b2de86173 100644 --- a/libraries/entities-renderer/src/RenderableZoneEntityItem.h +++ b/libraries/entities-renderer/src/RenderableZoneEntityItem.h @@ -14,6 +14,7 @@ #include #include +#include #include #include #include @@ -57,7 +58,7 @@ private: model::LightPointer editAmbientLight() { _needAmbientUpdate = true; return _ambientLight; } model::SunSkyStagePointer editBackground() { _needBackgroundUpdate = true; return _background; } model::SkyboxPointer editSkybox() { return editBackground()->getSkybox(); } - + model::HazePointer editHaze() { return editBackground()->getHaze(); } bool _needsInitialSimulation{ true }; glm::vec3 _lastPosition; diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp index d6de4ec614..bfbcfa0d22 100644 --- a/libraries/entities/src/EntityItemProperties.cpp +++ b/libraries/entities/src/EntityItemProperties.cpp @@ -71,6 +71,7 @@ void EntityItemProperties::debugDump() const { getAnimation().debugDump(); getSkybox().debugDump(); + getHaze().debugDump(); getKeyLight().debugDump(); qCDebug(entities) << " changed properties..."; @@ -1588,7 +1589,8 @@ bool EntityItemProperties::decodeEntityEditPacket(const unsigned char* data, int READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_SHAPE_TYPE, ShapeType, setShapeType); READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_COMPOUND_SHAPE_URL, QString, setCompoundShapeURL); READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_BACKGROUND_MODE, BackgroundMode, setBackgroundMode); - properties.getSkybox().decodeFromEditPacket(propertyFlags, dataAt , processedBytes); + properties.getSkybox().decodeFromEditPacket(propertyFlags, dataAt, processedBytes); + properties.getHaze().decodeFromEditPacket(propertyFlags, dataAt, processedBytes); READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_FLYING_ALLOWED, bool, setFlyingAllowed); READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_GHOSTING_ALLOWED, bool, setGhostingAllowed); @@ -2153,6 +2155,7 @@ QList EntityItemProperties::listChangedProperties() { getAnimation().listChangedProperties(out); getKeyLight().listChangedProperties(out); getSkybox().listChangedProperties(out); + getHaze().listChangedProperties(out); getStage().listChangedProperties(out); return out; diff --git a/libraries/entities/src/EntityItemProperties.h b/libraries/entities/src/EntityItemProperties.h index dd8ce952d3..891558f314 100644 --- a/libraries/entities/src/EntityItemProperties.h +++ b/libraries/entities/src/EntityItemProperties.h @@ -40,6 +40,7 @@ #include "PolyVoxEntityItem.h" #include "SimulationOwner.h" #include "SkyboxPropertyGroup.h" +#include "HazePropertyGroup.h" #include "StagePropertyGroup.h" #include "TextEntityItem.h" #include "ZoneEntityItem.h" @@ -179,6 +180,7 @@ public: DEFINE_PROPERTY_REF_ENUM(PROP_BACKGROUND_MODE, BackgroundMode, backgroundMode, BackgroundMode, BACKGROUND_MODE_INHERIT); DEFINE_PROPERTY_GROUP(Stage, stage, StagePropertyGroup); DEFINE_PROPERTY_GROUP(Skybox, skybox, SkyboxPropertyGroup); + DEFINE_PROPERTY_GROUP(Haze, haze, HazePropertyGroup); DEFINE_PROPERTY_GROUP(Animation, animation, AnimationPropertyGroup); DEFINE_PROPERTY_REF(PROP_SOURCE_URL, SourceUrl, sourceUrl, QString, ""); DEFINE_PROPERTY(PROP_LINE_WIDTH, LineWidth, lineWidth, float, LineEntityItem::DEFAULT_LINE_WIDTH); diff --git a/libraries/entities/src/EntityPropertyFlags.h b/libraries/entities/src/EntityPropertyFlags.h index d97be6348f..a5867f2edf 100644 --- a/libraries/entities/src/EntityPropertyFlags.h +++ b/libraries/entities/src/EntityPropertyFlags.h @@ -221,6 +221,8 @@ enum EntityPropertyList { PROP_BACKGROUND_MODE = PROP_MODEL_URL, PROP_SKYBOX_COLOR = PROP_ANIMATION_URL, PROP_SKYBOX_URL = PROP_ANIMATION_FPS, + PROP_HAZE_COLOR = PROP_ANIMATION_URL, + PROP_HAZE_URL = PROP_ANIMATION_FPS, PROP_KEYLIGHT_AMBIENT_URL = PROP_ANIMATION_PLAYING, // Aliases/Piggyback properties for Web. These properties intentionally reuse the enum values for diff --git a/libraries/entities/src/HazePropertyGroup.cpp b/libraries/entities/src/HazePropertyGroup.cpp new file mode 100644 index 0000000000..ab3cb53901 --- /dev/null +++ b/libraries/entities/src/HazePropertyGroup.cpp @@ -0,0 +1,149 @@ +// +// HazePropertyGroup.h +// libraries/entities/src +// +// Created by Nissim hadar on 9/21/17. +// Copyright 2013 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 +// + +#include + +#include "HazePropertyGroup.h" +#include "EntityItemProperties.h" +#include "EntityItemPropertiesMacros.h" + +const xColor HazePropertyGroup::DEFAULT_COLOR = { 0, 0, 0 }; + +void HazePropertyGroup::copyToScriptValue(const EntityPropertyFlags& desiredProperties, QScriptValue& properties, QScriptEngine* engine, bool skipDefaults, EntityItemProperties& defaultEntityProperties) const { + COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_COLOR, Haze, haze, Color, color); + COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_URL, Haze, haze, URL, url); +} + +void HazePropertyGroup::copyFromScriptValue(const QScriptValue& object, bool& _defaultSettings) { + COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(haze, color, xColor, setColor); + COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(haze, url, QString, setURL); +} + +void HazePropertyGroup::merge(const HazePropertyGroup& other) { + COPY_PROPERTY_IF_CHANGED(color); + COPY_PROPERTY_IF_CHANGED(url); +} + + +void HazePropertyGroup::debugDump() const { + qCDebug(entities) << " HazePropertyGroup: ---------------------------------------------"; + qCDebug(entities) << " Color:" << getColor() << " has changed:" << colorChanged(); + qCDebug(entities) << " URL:" << getURL() << " has changed:" << urlChanged(); +} + +void HazePropertyGroup::listChangedProperties(QList& out) { + if (colorChanged()) { + out << "haze-color"; + } + if (urlChanged()) { + out << "haze-url"; + } +} + +bool HazePropertyGroup::appendToEditPacket(OctreePacketData* packetData, + EntityPropertyFlags& requestedProperties, + EntityPropertyFlags& propertyFlags, + EntityPropertyFlags& propertiesDidntFit, + int& propertyCount, + OctreeElement::AppendState& appendState) const { + + bool successPropertyFits = true; + + APPEND_ENTITY_PROPERTY(PROP_HAZE_COLOR, getColor()); + APPEND_ENTITY_PROPERTY(PROP_HAZE_URL, getURL()); + + return true; +} + + +bool HazePropertyGroup::decodeFromEditPacket(EntityPropertyFlags& propertyFlags, const unsigned char*& dataAt , int& processedBytes) { + + int bytesRead = 0; + bool overwriteLocalData = true; + bool somethingChanged = false; + + READ_ENTITY_PROPERTY(PROP_HAZE_COLOR, xColor, setColor); + READ_ENTITY_PROPERTY(PROP_HAZE_URL, QString, setURL); + + DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_COLOR, Color); + DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_URL, URL); + + processedBytes += bytesRead; + + Q_UNUSED(somethingChanged); + + return true; +} + +void HazePropertyGroup::markAllChanged() { + _colorChanged = true; + _urlChanged = true; +} + +EntityPropertyFlags HazePropertyGroup::getChangedProperties() const { + EntityPropertyFlags changedProperties; + + CHECK_PROPERTY_CHANGE(PROP_HAZE_COLOR, color); + CHECK_PROPERTY_CHANGE(PROP_HAZE_URL, url); + + return changedProperties; +} + +void HazePropertyGroup::getProperties(EntityItemProperties& properties) const { + COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Haze, Color, getColor); + COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Haze, URL, getURL); +} + +bool HazePropertyGroup::setProperties(const EntityItemProperties& properties) { + bool somethingChanged = false; + + SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Haze, Color, color, setColor); + SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Haze, URL, url, setURL); + + return somethingChanged; +} + +EntityPropertyFlags HazePropertyGroup::getEntityProperties(EncodeBitstreamParams& params) const { + EntityPropertyFlags requestedProperties; + + requestedProperties += PROP_HAZE_COLOR; + requestedProperties += PROP_HAZE_URL; + + return requestedProperties; +} + +void HazePropertyGroup::appendSubclassData(OctreePacketData* packetData, EncodeBitstreamParams& params, + EntityTreeElementExtraEncodeDataPointer entityTreeElementExtraEncodeData, + EntityPropertyFlags& requestedProperties, + EntityPropertyFlags& propertyFlags, + EntityPropertyFlags& propertiesDidntFit, + int& propertyCount, + OctreeElement::AppendState& appendState) const { + + bool successPropertyFits = true; + + APPEND_ENTITY_PROPERTY(PROP_HAZE_COLOR, getColor()); + APPEND_ENTITY_PROPERTY(PROP_HAZE_URL, getURL()); +} + +int HazePropertyGroup::readEntitySubclassDataFromBuffer(const unsigned char* data, int bytesLeftToRead, + ReadBitstreamToTreeParams& args, + EntityPropertyFlags& propertyFlags, bool overwriteLocalData, + bool& somethingChanged) { + + int bytesRead = 0; + const unsigned char* dataAt = data; + + READ_ENTITY_PROPERTY(PROP_HAZE_COLOR, xColor, setColor); + READ_ENTITY_PROPERTY(PROP_HAZE_URL, QString, setURL); + + return bytesRead; +} diff --git a/libraries/entities/src/HazePropertyGroup.h b/libraries/entities/src/HazePropertyGroup.h new file mode 100644 index 0000000000..72ec2d7aad --- /dev/null +++ b/libraries/entities/src/HazePropertyGroup.h @@ -0,0 +1,90 @@ +// +// HazePropertyGroup.h +// libraries/entities/src +// +// Created by Nissim hadar on 9/21/17. +// Copyright 2013 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_HazePropertyGroup_h +#define hifi_HazePropertyGroup_h + +#include + +#include + +#include + +#include "PropertyGroup.h" +#include "EntityItemPropertiesMacros.h" + +class EntityItemProperties; +class EncodeBitstreamParams; +class OctreePacketData; +class EntityTreeElementExtraEncodeData; +class ReadBitstreamToTreeParams; + +class HazePropertyGroup : public PropertyGroup { +public: + // EntityItemProperty related helpers + virtual void copyToScriptValue(const EntityPropertyFlags& desiredProperties, QScriptValue& properties, + QScriptEngine* engine, bool skipDefaults, + EntityItemProperties& defaultEntityProperties) const override; + virtual void copyFromScriptValue(const QScriptValue& object, bool& _defaultSettings) override; + + void merge(const HazePropertyGroup& other); + + virtual void debugDump() const override; + virtual void listChangedProperties(QList& out) override; + + virtual bool appendToEditPacket(OctreePacketData* packetData, + EntityPropertyFlags& requestedProperties, + EntityPropertyFlags& propertyFlags, + EntityPropertyFlags& propertiesDidntFit, + int& propertyCount, + OctreeElement::AppendState& appendState) const override; + + virtual bool decodeFromEditPacket(EntityPropertyFlags& propertyFlags, + const unsigned char*& dataAt, int& processedBytes) override; + virtual void markAllChanged() override; + virtual EntityPropertyFlags getChangedProperties() const override; + + // EntityItem related helpers + // methods for getting/setting all properties of an entity + virtual void getProperties(EntityItemProperties& propertiesOut) const override; + + /// returns true if something changed + virtual bool setProperties(const EntityItemProperties& properties) override; + + virtual EntityPropertyFlags getEntityProperties(EncodeBitstreamParams& params) const override; + + virtual void appendSubclassData(OctreePacketData* packetData, EncodeBitstreamParams& params, + EntityTreeElementExtraEncodeDataPointer entityTreeElementExtraEncodeData, + EntityPropertyFlags& requestedProperties, + EntityPropertyFlags& propertyFlags, + EntityPropertyFlags& propertiesDidntFit, + int& propertyCount, + OctreeElement::AppendState& appendState) const override; + + virtual int readEntitySubclassDataFromBuffer(const unsigned char* data, int bytesLeftToRead, + ReadBitstreamToTreeParams& args, + EntityPropertyFlags& propertyFlags, bool overwriteLocalData, + bool& somethingChanged) override; + + glm::vec3 getColorVec3() const { + const quint8 MAX_COLOR = 255; + glm::vec3 color = { (float)_color.red / (float)MAX_COLOR, + (float)_color.green / (float)MAX_COLOR, + (float)_color.blue / (float)MAX_COLOR }; + return color; + } + + static const xColor DEFAULT_COLOR; + DEFINE_PROPERTY_REF(PROP_HAZE_COLOR, Color, color, xColor, DEFAULT_COLOR); + DEFINE_PROPERTY_REF(PROP_HAZE_URL, URL, url, QString, ""); +}; + +#endif // hifi_HazePropertyGroup_h diff --git a/libraries/entities/src/ZoneEntityItem.h b/libraries/entities/src/ZoneEntityItem.h index 14e7cd2f40..93c3b7286d 100644 --- a/libraries/entities/src/ZoneEntityItem.h +++ b/libraries/entities/src/ZoneEntityItem.h @@ -16,6 +16,7 @@ #include "EntityItem.h" #include "EntityTree.h" #include "SkyboxPropertyGroup.h" +#include "HazePropertyGroup.h" #include "StagePropertyGroup.h" class ZoneEntityItem : public EntityItem { @@ -68,7 +69,12 @@ public: void setBackgroundMode(BackgroundMode value) { _backgroundMode = value; _backgroundPropertiesChanged = true; } BackgroundMode getBackgroundMode() const { return _backgroundMode; } + void setHazeMode(HazeMode value) { _hazeMode = value; _hazePropertiesChanged = true; } + HazeMode getHazeMode() const { return _hazeMode; } + SkyboxPropertyGroup getSkyboxProperties() const { return resultWithReadLock([&] { return _skyboxProperties; }); } + HazePropertyGroup getHazeProperties() const { return resultWithReadLock([&] { return _hazeProperties; }); } + const StagePropertyGroup& getStageProperties() const { return _stageProperties; } bool getFlyingAllowed() const { return _flyingAllowed; } @@ -106,9 +112,11 @@ protected: QString _compoundShapeURL; BackgroundMode _backgroundMode = BACKGROUND_MODE_INHERIT; + HazeMode _hazeMode = HAZE_MODE_INHERIT; StagePropertyGroup _stageProperties; SkyboxPropertyGroup _skyboxProperties; + HazePropertyGroup _hazeProperties; bool _flyingAllowed { DEFAULT_FLYING_ALLOWED }; bool _ghostingAllowed { DEFAULT_GHOSTING_ALLOWED }; @@ -116,7 +124,8 @@ protected: // Dirty flags turn true when either keylight properties is changing values. bool _keyLightPropertiesChanged { false }; - bool _backgroundPropertiesChanged { false }; + bool _backgroundPropertiesChanged{ false }; + bool _hazePropertiesChanged{ false }; bool _skyboxPropertiesChanged { false }; bool _stagePropertiesChanged { false }; diff --git a/libraries/model/src/model/Haze.cpp b/libraries/model/src/model/Haze.cpp new file mode 100644 index 0000000000..9844579af2 --- /dev/null +++ b/libraries/model/src/model/Haze.cpp @@ -0,0 +1,163 @@ +// +// Haze.cpp +// libraries/model/src/model +// +// Created by Nissim Hadar on 9/13/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 +// +#include +#include + +#include "Haze.h" + +using namespace model; + +Haze::Haze() { + Parameters parameters; + _parametersBuffer = gpu::BufferView(std::make_shared(sizeof(Parameters), (const gpu::Byte*) ¶meters)); +} + +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_MODULATE_COLOR = 1 << 3 +}; + + +// For color modulated mode, the colour values are used as range values, which are then converted to range factors +// This is separate for each colour. +// The colour value is converted from [0.0 .. 1.0] to [5.0 .. 3000.0] +void Haze::setHazeColor(const glm::vec3 hazeColor) { + auto& params = _parametersBuffer.get(); + + if (params.hazeColor.r != hazeColor.r) { + _parametersBuffer.edit().hazeColor.r = hazeColor.r; + + float range = hazeColor.r * 2995.0f + 5.0f; + float factor = convertHazeRangeToHazeRangeFactor(range); + _parametersBuffer.edit().colorModulationFactor.r = factor; + } + if (params.hazeColor.g != hazeColor.g) { + _parametersBuffer.edit().hazeColor.g = hazeColor.g; + + float range = hazeColor.g * 2995.0f + 5.0f; + float factor = convertHazeRangeToHazeRangeFactor(range); + _parametersBuffer.edit().colorModulationFactor.g = factor; + } + + if (params.hazeColor.b != hazeColor.b) { + _parametersBuffer.edit().hazeColor.b = hazeColor.b; + + float range = hazeColor.b * 2995.0f + 5.0f; + float factor = convertHazeRangeToHazeRangeFactor(range); + _parametersBuffer.edit().colorModulationFactor.b = factor; + } +} + +void Haze::setDirectionalLightBlend(const float directionalLightBlend) { + auto& params = _parametersBuffer.get(); + + if (params.directionalLightBlend != directionalLightBlend) { + _parametersBuffer.edit().directionalLightBlend = directionalLightBlend; + } +} + +void Haze::setDirectionalLightColor(const glm::vec3 directionalLightColor) { + auto& params = _parametersBuffer.get(); + + if (params.directionalLightColor.r != directionalLightColor.r) { + _parametersBuffer.edit().directionalLightColor.r = directionalLightColor.r; + } + if (params.directionalLightColor.g != directionalLightColor.g) { + _parametersBuffer.edit().directionalLightColor.g = directionalLightColor.g; + } + if (params.directionalLightColor.b != directionalLightColor.b) { + _parametersBuffer.edit().directionalLightColor.b = directionalLightColor.b; + } +} +void Haze::setIsHazeActive(const bool isHazeActive) { + auto& params = _parametersBuffer.get(); + + if (((params.hazeMode & HAZE_MODE_IS_ACTIVE) == HAZE_MODE_IS_ACTIVE )&& !isHazeActive) { + _parametersBuffer.edit().hazeMode &= ~HAZE_MODE_IS_ACTIVE; + } + else if (((params.hazeMode & HAZE_MODE_IS_ACTIVE) != HAZE_MODE_IS_ACTIVE) && isHazeActive) { + _parametersBuffer.edit().hazeMode |= HAZE_MODE_IS_ACTIVE; + } +} + +void Haze::setIsAltitudeBased(const bool isAltitudeBased) { + auto& params = _parametersBuffer.get(); + + if (((params.hazeMode & HAZE_MODE_IS_ALTITUDE_BASED) == HAZE_MODE_IS_ALTITUDE_BASED )&& !isAltitudeBased) { + _parametersBuffer.edit().hazeMode &= ~HAZE_MODE_IS_ALTITUDE_BASED; + } + else if (((params.hazeMode & HAZE_MODE_IS_ALTITUDE_BASED) != HAZE_MODE_IS_ALTITUDE_BASED) && isAltitudeBased) { + _parametersBuffer.edit().hazeMode |= HAZE_MODE_IS_ALTITUDE_BASED; + } +} + +void Haze::setIsDirectionaLightAttenuationActive(const bool isDirectionaLightAttenuationActive) { + auto& params = _parametersBuffer.get(); + + if (((params.hazeMode & HAZE_MODE_IS_DIRECTIONAL_LIGHT_ATTENUATED) == HAZE_MODE_IS_DIRECTIONAL_LIGHT_ATTENUATED ) && !isDirectionaLightAttenuationActive) { + _parametersBuffer.edit().hazeMode &= ~HAZE_MODE_IS_DIRECTIONAL_LIGHT_ATTENUATED; + } + else if (((params.hazeMode & HAZE_MODE_IS_DIRECTIONAL_LIGHT_ATTENUATED) != HAZE_MODE_IS_DIRECTIONAL_LIGHT_ATTENUATED) && isDirectionaLightAttenuationActive) { + _parametersBuffer.edit().hazeMode |= HAZE_MODE_IS_DIRECTIONAL_LIGHT_ATTENUATED; + } +} + +void Haze::setIsModulateColorActive(const bool isModulateColorActive) { + auto& params = _parametersBuffer.get(); + + if (((params.hazeMode & HAZE_MODE_IS_MODULATE_COLOR) == HAZE_MODE_IS_MODULATE_COLOR ) && !isModulateColorActive) { + _parametersBuffer.edit().hazeMode &= ~HAZE_MODE_IS_MODULATE_COLOR; + } + else if (((params.hazeMode & HAZE_MODE_IS_MODULATE_COLOR) != HAZE_MODE_IS_MODULATE_COLOR) && isModulateColorActive) { + _parametersBuffer.edit().hazeMode |= HAZE_MODE_IS_MODULATE_COLOR; + } +} + +void Haze::setHazeRangeFactor(const float hazeRangeFactor) { + auto& params = _parametersBuffer.get(); + + if (params.hazeRangeFactor != hazeRangeFactor) { + _parametersBuffer.edit().hazeRangeFactor = hazeRangeFactor; + } +} + +void Haze::setHazeAltitudeFactor(const float hazeAltitudeFactor) { + auto& params = _parametersBuffer.get(); + + if (params.hazeAltitudeFactor != hazeAltitudeFactor) { + _parametersBuffer.edit().hazeAltitudeFactor = hazeAltitudeFactor; + } +} + +void Haze::setHazeRangeFactorKeyLight(const float hazeRangeFactorKeyLight) { + auto& params = _parametersBuffer.get(); + + if (params.hazeRangeFactorKeyLight != hazeRangeFactorKeyLight) { + _parametersBuffer.edit().hazeRangeFactorKeyLight = hazeRangeFactorKeyLight; + } +} + +void Haze::setHazeAltitudeFactorKeyLight(const float hazeAltitudeFactorKeyLight) { + auto& params = _parametersBuffer.get(); + + if (params.hazeAltitudeFactorKeyLight != hazeAltitudeFactorKeyLight) { + _parametersBuffer.edit().hazeAltitudeFactorKeyLight = hazeAltitudeFactorKeyLight; + } +} +void Haze::setHazeBaseReference(const float hazeBaseReference) { + auto& params = _parametersBuffer.get(); + + if (params.hazeBaseReference != hazeBaseReference) { + _parametersBuffer.edit().hazeBaseReference = hazeBaseReference; + } +} diff --git a/libraries/model/src/model/Haze.h b/libraries/model/src/model/Haze.h new file mode 100644 index 0000000000..de026bd4ea --- /dev/null +++ b/libraries/model/src/model/Haze.h @@ -0,0 +1,115 @@ +// +// MakeHaze.h +// libraries/model/src/model +// +// Created by Nissim Hadar on 9/13/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_Haze_h +#define hifi_model_Haze_h + +#include +#include "NumericalConstants.h" + +namespace model { + + const double p_005 = 0.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 + inline float convertHazeRangeToHazeRangeFactor(const float hazeRange_m) { return (float)-log(p_005) / hazeRange_m; } + + inline float convertHazeAltitudeToHazeAltitudeFactor(const float hazeAltitude_m) { + return (float)-log(p_005) / hazeAltitude_m; + } + + // Derivation (s is th 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(0.5) / log(cos(RADIANS_PER_DEGREE * directionalLightAngle)); + } + + const glm::vec3 initialHazeColor{ 0.5, 0.6, 0.7 }; + const float initialDirectionalLightAngle_degs{ 30.0f }; + + const glm::vec3 initialDirectionalLightColor{ 1.0, 0.9, 0.7 }; + 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 initialHazeRangeKeyLight_m = 150.0f; + const float initialHazeAltitudeKeyLight_m = 150.0f; + + const glm::vec3 initialColorModulationFactor{ + convertHazeRangeToHazeRangeFactor(initialHazeRange_m), + convertHazeRangeToHazeRangeFactor(initialHazeRange_m), + convertHazeRangeToHazeRangeFactor(initialHazeRange_m) + }; + + class Haze { + public: + using UniformBufferView = gpu::BufferView; + + Haze(); + + void setHazeColor(const glm::vec3 hazeColor); + void setDirectionalLightBlend(const float directionalLightBlend); + + void setDirectionalLightColor(const glm::vec3 directionalLightColor); + void setHazeBaseReference(const float hazeBaseReference); + + void setIsHazeActive(const bool isHazeActive); + void setIsAltitudeBased(const bool isAltitudeBased); + void setIsDirectionaLightAttenuationActive(const bool isDirectionaLightAttenuationActive); + void setIsModulateColorActive(const bool isModulateColorActive); + + void setHazeRangeFactor(const float hazeRange); + void setHazeAltitudeFactor(const float hazeAltitude); + + void setHazeRangeFactorKeyLight(const float hazeRangeKeyLight); + void setHazeAltitudeFactorKeyLight(const float hazeAltitudeKeyLight); + + UniformBufferView getParametersBuffer() const { return _parametersBuffer; } + + protected: + class Parameters { + public: + // DO NOT CHANGE ORDER HERE WITHOUT UNDERSTANDING THE std140 LAYOUT + glm::vec3 hazeColor{ initialHazeColor }; + float directionalLightBlend{ convertDirectionalLightAngleToPower(initialDirectionalLightAngle_degs) }; + + glm::vec3 directionalLightColor{ initialDirectionalLightColor }; + float hazeBaseReference{ initialHazeBaseReference }; + + glm::vec3 colorModulationFactor{ initialColorModulationFactor }; + 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 + + // The haze attenuation exponents used by both fragment and directional light attenuation + float hazeRangeFactor{ convertHazeRangeToHazeRangeFactor(initialHazeRange_m) }; + float hazeAltitudeFactor{ convertHazeAltitudeToHazeAltitudeFactor(initialHazeAltitude_m) }; + + float hazeRangeFactorKeyLight{ convertHazeRangeToHazeRangeFactor(initialHazeRangeKeyLight_m) }; + float hazeAltitudeFactorKeyLight{ convertHazeAltitudeToHazeAltitudeFactor(initialHazeAltitudeKeyLight_m) }; + + Parameters() {} + }; + + UniformBufferView _parametersBuffer; + }; + + using HazePointer = std::shared_ptr; +} +#endif // hifi_model_Haze_h diff --git a/libraries/model/src/model/Stage.cpp b/libraries/model/src/model/Stage.cpp index 6cfb77f2b2..62e9e6adda 100644 --- a/libraries/model/src/model/Stage.cpp +++ b/libraries/model/src/model/Stage.cpp @@ -255,3 +255,14 @@ void SunSkyStage::setSkybox(const SkyboxPointer& skybox) { _skybox = skybox; invalidate(); } + +// Haze +void SunSkyStage::setHazeMode(HazeMode mode) { + _hazeMode = mode; + invalidate(); +} + +void SunSkyStage::setHaze(const HazePointer& haze) { + _haze = haze; + invalidate(); +} diff --git a/libraries/model/src/model/Stage.h b/libraries/model/src/model/Stage.h index 5f48824568..5074bc7a67 100644 --- a/libraries/model/src/model/Stage.h +++ b/libraries/model/src/model/Stage.h @@ -15,6 +15,7 @@ #include "Light.h" #include "Skybox.h" +#include "Haze.h" namespace model { @@ -174,11 +175,27 @@ public: void setSkybox(const SkyboxPointer& skybox); const SkyboxPointer& getSkybox() const { valid(); return _skybox; } + // Haze + enum HazeMode { + NO_HAZE, + YES_HAZE, + + NUM_HAZE_MODES + }; + + void setHazeMode(HazeMode mode); + HazeMode gethazeMode() const { return _hazeMode; } + + void setHaze(const HazePointer& haze); + const HazePointer& getHaze() const { valid(); return _haze; } + protected: BackgroundMode _backgroundMode = SKY_DEFAULT; + HazeMode _hazeMode = NO_HAZE; LightPointer _sunLight; mutable SkyboxPointer _skybox; + mutable HazePointer _haze; float _dayTime = 12.0f; int _yearTime = 0; diff --git a/libraries/octree/src/OctreePacketData.h b/libraries/octree/src/OctreePacketData.h index ed6a49941b..d0255d60ab 100644 --- a/libraries/octree/src/OctreePacketData.h +++ b/libraries/octree/src/OctreePacketData.h @@ -29,6 +29,7 @@ #include #include +#include #include #include #include diff --git a/libraries/shared/src/HazeMode.h b/libraries/shared/src/HazeMode.h new file mode 100644 index 0000000000..ff0caef36b --- /dev/null +++ b/libraries/shared/src/HazeMode.h @@ -0,0 +1,24 @@ +// +// HazeMode.h +// libraries/entities/src +// +// Created by Nissim hadar on 9/21/17. +// Copyright 2013 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_HazeMode_h +#define hifi_HazeMode_h + +enum HazeMode { + HAZE_MODE_INHERIT, + HAZE_MODE_SKYBOX, + + HAZE_MODE_ITEM_COUNT, +}; + + +#endif // hifi_HazeMode_h + From 5e1d470553401b2914c166b47eb6028985a5d728 Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Fri, 22 Sep 2017 09:48:22 -0700 Subject: [PATCH 02/94] WIP --- .../entities/src/EntityItemProperties.cpp | 13 +++++ libraries/entities/src/EntityItemProperties.h | 3 ++ libraries/entities/src/EntityPropertyFlags.h | 4 +- libraries/entities/src/HazePropertyGroup.cpp | 53 ++++++------------- libraries/entities/src/HazePropertyGroup.h | 12 +---- libraries/entities/src/ZoneEntityItem.cpp | 30 +++++++++-- libraries/shared/src/HazeMode.h | 6 +-- scripts/system/html/entityProperties.html | 9 ++++ scripts/system/html/js/entityProperties.js | 5 ++ 9 files changed, 80 insertions(+), 55 deletions(-) diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp index bfbcfa0d22..d6555de1af 100644 --- a/libraries/entities/src/EntityItemProperties.cpp +++ b/libraries/entities/src/EntityItemProperties.cpp @@ -201,6 +201,13 @@ const std::array BACKGROUND_MODES = BackgroundPair { BACKGROUND_MODE_SKYBOX, { "skybox" } } } }; +using HazePair = std::pair; +const std::array HAZE_MODES = { { + HazePair{ HAZE_MODE_INHERIT,{ "inherit" } }, + HazePair{ HAZE_MODE_OFF,{ "off" } }, + HazePair{ HAZE_MODE_ON,{ "on" } } + } }; + QString EntityItemProperties::getBackgroundModeAsString() const { return BACKGROUND_MODES[_backgroundMode].second; } @@ -219,6 +226,10 @@ void EntityItemProperties::setBackgroundModeFromString(const QString& background } } +QString EntityItemProperties::getHazeModeString(HazeMode mode) { + return HAZE_MODES[mode].second; +} + EntityPropertyFlags EntityItemProperties::getChangedProperties() const { EntityPropertyFlags changedProperties; @@ -1039,6 +1050,8 @@ void EntityItemProperties::entityPropertyFlagsFromScriptValue(const QScriptValue ADD_GROUP_PROPERTY_TO_MAP(PROP_SKYBOX_COLOR, Skybox, skybox, Color, color); ADD_GROUP_PROPERTY_TO_MAP(PROP_SKYBOX_URL, Skybox, skybox, URL, url); + ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_HAZE_ACTIVE, Haze, haze, HazeActive, hazeActive); + ADD_GROUP_PROPERTY_TO_MAP(PROP_STAGE_SUN_MODEL_ENABLED, Stage, stage, SunModelEnabled, sunModelEnabled); ADD_GROUP_PROPERTY_TO_MAP(PROP_STAGE_LATITUDE, Stage, stage, Latitude, latitude); ADD_GROUP_PROPERTY_TO_MAP(PROP_STAGE_LONGITUDE, Stage, stage, Longitude, longitude); diff --git a/libraries/entities/src/EntityItemProperties.h b/libraries/entities/src/EntityItemProperties.h index 891558f314..423e846a5c 100644 --- a/libraries/entities/src/EntityItemProperties.h +++ b/libraries/entities/src/EntityItemProperties.h @@ -178,6 +178,7 @@ public: DEFINE_PROPERTY_REF(PROP_VOXEL_SURFACE_STYLE, VoxelSurfaceStyle, voxelSurfaceStyle, uint16_t, PolyVoxEntityItem::DEFAULT_VOXEL_SURFACE_STYLE); DEFINE_PROPERTY_REF(PROP_NAME, Name, name, QString, ENTITY_ITEM_DEFAULT_NAME); DEFINE_PROPERTY_REF_ENUM(PROP_BACKGROUND_MODE, BackgroundMode, backgroundMode, BackgroundMode, BACKGROUND_MODE_INHERIT); + DEFINE_PROPERTY_REF_ENUM(PROP_HAZE_MODE, HazeMode, hazeMode, HazeMode, HAZE_MODE_INHERIT); DEFINE_PROPERTY_GROUP(Stage, stage, StagePropertyGroup); DEFINE_PROPERTY_GROUP(Skybox, skybox, SkyboxPropertyGroup); DEFINE_PROPERTY_GROUP(Haze, haze, HazePropertyGroup); @@ -230,6 +231,7 @@ public: DEFINE_PROPERTY_REF(PROP_SERVER_SCRIPTS, ServerScripts, serverScripts, QString, ENTITY_ITEM_DEFAULT_SERVER_SCRIPTS); static QString getBackgroundModeString(BackgroundMode mode); + static QString getHazeModeString(HazeMode mode); public: @@ -430,6 +432,7 @@ inline QDebug operator<<(QDebug debug, const EntityItemProperties& properties) { DEBUG_PROPERTY_IF_CHANGED(debug, properties, RadiusFinish, radiusFinish, ""); DEBUG_PROPERTY_IF_CHANGED(debug, properties, MarketplaceID, marketplaceID, ""); DEBUG_PROPERTY_IF_CHANGED(debug, properties, BackgroundMode, backgroundMode, ""); + DEBUG_PROPERTY_IF_CHANGED(debug, properties, HazeMode, hazeMode, ""); DEBUG_PROPERTY_IF_CHANGED(debug, properties, VoxelVolumeSize, voxelVolumeSize, ""); DEBUG_PROPERTY_IF_CHANGED(debug, properties, VoxelData, voxelData, ""); DEBUG_PROPERTY_IF_CHANGED(debug, properties, VoxelSurfaceStyle, voxelSurfaceStyle, ""); diff --git a/libraries/entities/src/EntityPropertyFlags.h b/libraries/entities/src/EntityPropertyFlags.h index a5867f2edf..fda1d290ab 100644 --- a/libraries/entities/src/EntityPropertyFlags.h +++ b/libraries/entities/src/EntityPropertyFlags.h @@ -219,10 +219,10 @@ enum EntityPropertyList { PROP_STAGE_HOUR = PROP_QUADRATIC_ATTENUATION_UNUSED, PROP_STAGE_AUTOMATIC_HOURDAY = PROP_ANIMATION_FRAME_INDEX, PROP_BACKGROUND_MODE = PROP_MODEL_URL, + PROP_HAZE_MODE = PROP_MODEL_URL, PROP_SKYBOX_COLOR = PROP_ANIMATION_URL, PROP_SKYBOX_URL = PROP_ANIMATION_FPS, - PROP_HAZE_COLOR = PROP_ANIMATION_URL, - PROP_HAZE_URL = PROP_ANIMATION_FPS, + PROP_HAZE_HAZE_ACTIVE = PROP_ANIMATION_FRAME_INDEX, PROP_KEYLIGHT_AMBIENT_URL = PROP_ANIMATION_PLAYING, // Aliases/Piggyback properties for Web. These properties intentionally reuse the enum values for diff --git a/libraries/entities/src/HazePropertyGroup.cpp b/libraries/entities/src/HazePropertyGroup.cpp index ab3cb53901..d0208f020e 100644 --- a/libraries/entities/src/HazePropertyGroup.cpp +++ b/libraries/entities/src/HazePropertyGroup.cpp @@ -15,36 +15,27 @@ #include "EntityItemProperties.h" #include "EntityItemPropertiesMacros.h" -const xColor HazePropertyGroup::DEFAULT_COLOR = { 0, 0, 0 }; - void HazePropertyGroup::copyToScriptValue(const EntityPropertyFlags& desiredProperties, QScriptValue& properties, QScriptEngine* engine, bool skipDefaults, EntityItemProperties& defaultEntityProperties) const { - COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_COLOR, Haze, haze, Color, color); - COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_URL, Haze, haze, URL, url); + COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_HAZE_ACTIVE, Haze, haze, HazeActive, hazeActive); } void HazePropertyGroup::copyFromScriptValue(const QScriptValue& object, bool& _defaultSettings) { - COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(haze, color, xColor, setColor); - COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(haze, url, QString, setURL); + COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(haze, hazeActive, bool, setHazeActive); } void HazePropertyGroup::merge(const HazePropertyGroup& other) { - COPY_PROPERTY_IF_CHANGED(color); - COPY_PROPERTY_IF_CHANGED(url); + COPY_PROPERTY_IF_CHANGED(hazeActive); } void HazePropertyGroup::debugDump() const { qCDebug(entities) << " HazePropertyGroup: ---------------------------------------------"; - qCDebug(entities) << " Color:" << getColor() << " has changed:" << colorChanged(); - qCDebug(entities) << " URL:" << getURL() << " has changed:" << urlChanged(); + qCDebug(entities) << " HazeActive :" << getHazeActive() << " has changed:" << hazeActiveChanged(); } void HazePropertyGroup::listChangedProperties(QList& out) { - if (colorChanged()) { - out << "haze-color"; - } - if (urlChanged()) { - out << "haze-url"; + if (hazeActiveChanged()) { + out << "haze-hazeActive"; } } @@ -57,8 +48,7 @@ bool HazePropertyGroup::appendToEditPacket(OctreePacketData* packetData, bool successPropertyFits = true; - APPEND_ENTITY_PROPERTY(PROP_HAZE_COLOR, getColor()); - APPEND_ENTITY_PROPERTY(PROP_HAZE_URL, getURL()); + APPEND_ENTITY_PROPERTY(PROP_HAZE_HAZE_ACTIVE, getHazeActive()); return true; } @@ -70,11 +60,9 @@ bool HazePropertyGroup::decodeFromEditPacket(EntityPropertyFlags& propertyFlags, bool overwriteLocalData = true; bool somethingChanged = false; - READ_ENTITY_PROPERTY(PROP_HAZE_COLOR, xColor, setColor); - READ_ENTITY_PROPERTY(PROP_HAZE_URL, QString, setURL); + READ_ENTITY_PROPERTY(PROP_HAZE_HAZE_ACTIVE, bool, setHazeActive); - DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_COLOR, Color); - DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_URL, URL); + DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_HAZE_ACTIVE, HazeActive); processedBytes += bytesRead; @@ -84,29 +72,25 @@ bool HazePropertyGroup::decodeFromEditPacket(EntityPropertyFlags& propertyFlags, } void HazePropertyGroup::markAllChanged() { - _colorChanged = true; - _urlChanged = true; + _hazeActiveChanged = true; } EntityPropertyFlags HazePropertyGroup::getChangedProperties() const { EntityPropertyFlags changedProperties; - - CHECK_PROPERTY_CHANGE(PROP_HAZE_COLOR, color); - CHECK_PROPERTY_CHANGE(PROP_HAZE_URL, url); + + CHECK_PROPERTY_CHANGE(PROP_HAZE_HAZE_ACTIVE, hazeActive); return changedProperties; } void HazePropertyGroup::getProperties(EntityItemProperties& properties) const { - COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Haze, Color, getColor); - COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Haze, URL, getURL); + COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Haze, HazeActive, getHazeActive); } bool HazePropertyGroup::setProperties(const EntityItemProperties& properties) { bool somethingChanged = false; - SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Haze, Color, color, setColor); - SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Haze, URL, url, setURL); + SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Haze, HazeActive, hazeActive, setHazeActive); return somethingChanged; } @@ -114,8 +98,7 @@ bool HazePropertyGroup::setProperties(const EntityItemProperties& properties) { EntityPropertyFlags HazePropertyGroup::getEntityProperties(EncodeBitstreamParams& params) const { EntityPropertyFlags requestedProperties; - requestedProperties += PROP_HAZE_COLOR; - requestedProperties += PROP_HAZE_URL; + requestedProperties += PROP_HAZE_HAZE_ACTIVE; return requestedProperties; } @@ -130,8 +113,7 @@ void HazePropertyGroup::appendSubclassData(OctreePacketData* packetData, EncodeB bool successPropertyFits = true; - APPEND_ENTITY_PROPERTY(PROP_HAZE_COLOR, getColor()); - APPEND_ENTITY_PROPERTY(PROP_HAZE_URL, getURL()); + APPEND_ENTITY_PROPERTY(PROP_HAZE_HAZE_ACTIVE, getHazeActive()); } int HazePropertyGroup::readEntitySubclassDataFromBuffer(const unsigned char* data, int bytesLeftToRead, @@ -142,8 +124,7 @@ int HazePropertyGroup::readEntitySubclassDataFromBuffer(const unsigned char* dat int bytesRead = 0; const unsigned char* dataAt = data; - READ_ENTITY_PROPERTY(PROP_HAZE_COLOR, xColor, setColor); - READ_ENTITY_PROPERTY(PROP_HAZE_URL, QString, setURL); + READ_ENTITY_PROPERTY(PROP_HAZE_HAZE_ACTIVE, bool, setHazeActive); return bytesRead; } diff --git a/libraries/entities/src/HazePropertyGroup.h b/libraries/entities/src/HazePropertyGroup.h index 72ec2d7aad..305110d8cf 100644 --- a/libraries/entities/src/HazePropertyGroup.h +++ b/libraries/entities/src/HazePropertyGroup.h @@ -74,17 +74,7 @@ public: EntityPropertyFlags& propertyFlags, bool overwriteLocalData, bool& somethingChanged) override; - glm::vec3 getColorVec3() const { - const quint8 MAX_COLOR = 255; - glm::vec3 color = { (float)_color.red / (float)MAX_COLOR, - (float)_color.green / (float)MAX_COLOR, - (float)_color.blue / (float)MAX_COLOR }; - return color; - } - - static const xColor DEFAULT_COLOR; - DEFINE_PROPERTY_REF(PROP_HAZE_COLOR, Color, color, xColor, DEFAULT_COLOR); - DEFINE_PROPERTY_REF(PROP_HAZE_URL, URL, url, QString, ""); + DEFINE_PROPERTY(PROP_HAZE_HAZE_ACTIVE, HazeActive, hazeActive, bool, false); }; #endif // hifi_HazePropertyGroup_h diff --git a/libraries/entities/src/ZoneEntityItem.cpp b/libraries/entities/src/ZoneEntityItem.cpp index 88e4f3c9e6..7957ec9347 100644 --- a/libraries/entities/src/ZoneEntityItem.cpp +++ b/libraries/entities/src/ZoneEntityItem.cpp @@ -44,6 +44,7 @@ ZoneEntityItem::ZoneEntityItem(const EntityItemID& entityItemID) : EntityItem(en _compoundShapeURL = DEFAULT_COMPOUND_SHAPE_URL; _backgroundMode = BACKGROUND_MODE_INHERIT; + _hazeMode = HAZE_MODE_OFF; } EntityItemProperties ZoneEntityItem::getProperties(EntityPropertyFlags desiredProperties) const { @@ -59,11 +60,15 @@ EntityItemProperties ZoneEntityItem::getProperties(EntityPropertyFlags desiredPr COPY_ENTITY_PROPERTY_TO_PROPERTIES(shapeType, getShapeType); COPY_ENTITY_PROPERTY_TO_PROPERTIES(compoundShapeURL, getCompoundShapeURL); COPY_ENTITY_PROPERTY_TO_PROPERTIES(backgroundMode, getBackgroundMode); + COPY_ENTITY_PROPERTY_TO_PROPERTIES(hazeMode, getHazeMode); // Contains a QString property, must be synchronized withReadLock([&] { _skyboxProperties.getProperties(properties); }); + withReadLock([&] { + _hazeProperties.getProperties(properties); + }); COPY_ENTITY_PROPERTY_TO_PROPERTIES(flyingAllowed, getFlyingAllowed); COPY_ENTITY_PROPERTY_TO_PROPERTIES(ghostingAllowed, getGhostingAllowed); @@ -112,8 +117,11 @@ bool ZoneEntityItem::setSubClassProperties(const EntityItemProperties& propertie withWriteLock([&] { _skyboxPropertiesChanged = _skyboxProperties.setProperties(properties); }); + withWriteLock([&] { + _hazePropertiesChanged = _hazeProperties.setProperties(properties); + }); - somethingChanged = somethingChanged || _keyLightPropertiesChanged || _stagePropertiesChanged || _skyboxPropertiesChanged; + somethingChanged = somethingChanged || _keyLightPropertiesChanged || _stagePropertiesChanged || _skyboxPropertiesChanged || _hazePropertiesChanged; return somethingChanged; } @@ -154,6 +162,15 @@ int ZoneEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data, bytesRead += bytesFromSkybox; dataAt += bytesFromSkybox; + int bytesFromHaze; + withWriteLock([&] { + bytesFromHaze = _hazeProperties.readEntitySubclassDataFromBuffer(dataAt, (bytesLeftToRead - bytesRead), args, + propertyFlags, overwriteLocalData, _hazePropertiesChanged); + }); + somethingChanged = somethingChanged || _hazePropertiesChanged; + bytesRead += bytesFromHaze; + dataAt += bytesFromHaze; + READ_ENTITY_PROPERTY(PROP_FLYING_ALLOWED, bool, setFlyingAllowed); READ_ENTITY_PROPERTY(PROP_GHOSTING_ALLOWED, bool, setGhostingAllowed); READ_ENTITY_PROPERTY(PROP_FILTER_URL, QString, setFilterURL); @@ -178,7 +195,9 @@ EntityPropertyFlags ZoneEntityItem::getEntityProperties(EncodeBitstreamParams& p withReadLock([&] { requestedProperties += _skyboxProperties.getEntityProperties(params); }); - + withReadLock([&] { + requestedProperties += _hazeProperties.getEntityProperties(params); + }); requestedProperties += PROP_FLYING_ALLOWED; requestedProperties += PROP_GHOSTING_ALLOWED; requestedProperties += PROP_FILTER_URL; @@ -208,7 +227,10 @@ void ZoneEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBits APPEND_ENTITY_PROPERTY(PROP_BACKGROUND_MODE, (uint32_t)getBackgroundMode()); // could this be a uint16?? _skyboxProperties.appendSubclassData(packetData, params, modelTreeElementExtraEncodeData, requestedProperties, - propertyFlags, propertiesDidntFit, propertyCount, appendState); + propertyFlags, propertiesDidntFit, propertyCount, appendState); + + _hazeProperties.appendSubclassData(packetData, params, modelTreeElementExtraEncodeData, requestedProperties, + propertyFlags, propertiesDidntFit, propertyCount, appendState); APPEND_ENTITY_PROPERTY(PROP_FLYING_ALLOWED, getFlyingAllowed()); APPEND_ENTITY_PROPERTY(PROP_GHOSTING_ALLOWED, getGhostingAllowed()); @@ -226,6 +248,7 @@ void ZoneEntityItem::debugDump() const { _keyLightProperties.debugDump(); _stageProperties.debugDump(); _skyboxProperties.debugDump(); + _hazeProperties.debugDump(); } ShapeType ZoneEntityItem::getShapeType() const { @@ -291,5 +314,6 @@ void ZoneEntityItem::resetRenderingPropertiesChanged() { _backgroundPropertiesChanged = false; _stagePropertiesChanged = false; _skyboxPropertiesChanged = false; + _hazePropertiesChanged = false; }); } diff --git a/libraries/shared/src/HazeMode.h b/libraries/shared/src/HazeMode.h index ff0caef36b..201a459098 100644 --- a/libraries/shared/src/HazeMode.h +++ b/libraries/shared/src/HazeMode.h @@ -13,12 +13,12 @@ #define hifi_HazeMode_h enum HazeMode { + HAZE_MODE_OFF, + HAZE_MODE_ON, HAZE_MODE_INHERIT, - HAZE_MODE_SKYBOX, - HAZE_MODE_ITEM_COUNT, + HAZE_MODE_ITEM_COUNT }; - #endif // hifi_HazeMode_h diff --git a/scripts/system/html/entityProperties.html b/scripts/system/html/entityProperties.html index 43cd281bbd..6e3c5eeca6 100644 --- a/scripts/system/html/entityProperties.html +++ b/scripts/system/html/entityProperties.html @@ -543,6 +543,15 @@ +
+ + Haze + +
+ + +
+
Stage diff --git a/scripts/system/html/js/entityProperties.js b/scripts/system/html/js/entityProperties.js index 58173a794c..439576abdf 100644 --- a/scripts/system/html/js/entityProperties.js +++ b/scripts/system/html/js/entityProperties.js @@ -657,6 +657,8 @@ function loaded() { var elZoneKeyLightDirectionZ = document.getElementById("property-zone-key-light-direction-z"); var elZoneKeyLightAmbientURL = document.getElementById("property-zone-key-ambient-url"); + var elZoneHazeActive = document.getElementById("property-zone-haze-haze-active"); + var elZoneStageLatitude = document.getElementById("property-zone-stage-latitude"); var elZoneStageLongitude = document.getElementById("property-zone-stage-longitude"); var elZoneStageAltitude = document.getElementById("property-zone-stage-altitude"); @@ -975,6 +977,7 @@ function loaded() { elZoneKeyLightDirectionY.value = properties.keyLight.direction.y.toFixed(2); elZoneKeyLightAmbientURL.value = properties.keyLight.ambientURL; + elZoneHazeActive.checked = properties.haze.hazeActive; elZoneStageLatitude.value = properties.stage.latitude.toFixed(2); elZoneStageLongitude.value = properties.stage.longitude.toFixed(2); @@ -1370,6 +1373,8 @@ function loaded() { elZoneKeyLightDirectionX.addEventListener('change', zoneKeyLightDirectionChangeFunction); elZoneKeyLightDirectionY.addEventListener('change', zoneKeyLightDirectionChangeFunction); + elZoneHazeActive.addEventListener('change', createEmitGroupCheckedPropertyUpdateFunction('haze', 'hazeActive')); + elZoneStageLatitude.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('stage', 'latitude')); elZoneStageLongitude.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('stage', 'longitude')); elZoneStageAltitude.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('stage', 'altitude')); From 736a6aa311b36bc4473d35a85a2d26a820fb7e7c Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Fri, 22 Sep 2017 18:20:35 -0700 Subject: [PATCH 03/94] Haze checkbox in UI doesn't disable the UI. --- .../entities-renderer/src/RenderableZoneEntityItem.cpp | 4 +++- .../entities-renderer/src/RenderableZoneEntityItem.h | 1 + libraries/entities/src/EntityItemProperties.cpp | 9 +++++++++ libraries/entities/src/ZoneEntityItem.h | 1 + 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp index caf9cae341..e5ae541099 100644 --- a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp @@ -171,6 +171,8 @@ void ZoneEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scen bool sunChanged = entity->keyLightPropertiesChanged(); bool backgroundChanged = entity->backgroundPropertiesChanged(); bool skyboxChanged = entity->skyboxPropertiesChanged(); + bool hazeChanged = entity->hazePropertiesChanged(); + entity->resetRenderingPropertiesChanged(); _lastPosition = entity->getPosition(); _lastRotation = entity->getRotation(); @@ -179,7 +181,7 @@ void ZoneEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scen _keyLightProperties = entity->getKeyLightProperties(); _stageProperties = entity->getStageProperties(); _skyboxProperties = entity->getSkyboxProperties(); - + _hazeProperties = entity->getHazeProperties(); #if 0 if (_lastShapeURL != _typedEntity->getCompoundShapeURL()) { diff --git a/libraries/entities-renderer/src/RenderableZoneEntityItem.h b/libraries/entities-renderer/src/RenderableZoneEntityItem.h index 9b2de86173..b5c42529d2 100644 --- a/libraries/entities-renderer/src/RenderableZoneEntityItem.h +++ b/libraries/entities-renderer/src/RenderableZoneEntityItem.h @@ -93,6 +93,7 @@ private: KeyLightPropertyGroup _keyLightProperties; StagePropertyGroup _stageProperties; SkyboxPropertyGroup _skyboxProperties; + HazePropertyGroup _hazeProperties; // More attributes used for rendering: QString _ambientTextureURL; diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp index d6555de1af..2156a2aa82 100644 --- a/libraries/entities/src/EntityItemProperties.cpp +++ b/libraries/entities/src/EntityItemProperties.cpp @@ -27,6 +27,7 @@ AnimationPropertyGroup EntityItemProperties::_staticAnimation; SkyboxPropertyGroup EntityItemProperties::_staticSkybox; +HazePropertyGroup EntityItemProperties::_staticHaze; StagePropertyGroup EntityItemProperties::_staticStage; KeyLightPropertyGroup EntityItemProperties::_staticKeyLight; @@ -349,6 +350,7 @@ EntityPropertyFlags EntityItemProperties::getChangedProperties() const { changedProperties += _animation.getChangedProperties(); changedProperties += _keyLight.getChangedProperties(); changedProperties += _skybox.getChangedProperties(); + changedProperties += _haze.getChangedProperties(); changedProperties += _stage.getChangedProperties(); return changedProperties; @@ -512,6 +514,7 @@ QScriptValue EntityItemProperties::copyToScriptValue(QScriptEngine* engine, bool COPY_PROPERTY_TO_QSCRIPTVALUE_GETTER(PROP_BACKGROUND_MODE, backgroundMode, getBackgroundModeAsString()); _stage.copyToScriptValue(_desiredProperties, properties, engine, skipDefaults, defaultEntityProperties); + _haze.copyToScriptValue(_desiredProperties, properties, engine, skipDefaults, defaultEntityProperties); _skybox.copyToScriptValue(_desiredProperties, properties, engine, skipDefaults, defaultEntityProperties); COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_FLYING_ALLOWED, flyingAllowed); @@ -714,6 +717,7 @@ void EntityItemProperties::copyFromScriptValue(const QScriptValue& object, bool _animation.copyFromScriptValue(object, _defaultSettings); _keyLight.copyFromScriptValue(object, _defaultSettings); _skybox.copyFromScriptValue(object, _defaultSettings); + _haze.copyFromScriptValue(object, _defaultSettings); _stage.copyFromScriptValue(object, _defaultSettings); COPY_PROPERTY_FROM_QSCRIPTVALUE(xTextureURL, QString, setXTextureURL); @@ -843,6 +847,7 @@ void EntityItemProperties::merge(const EntityItemProperties& other) { _animation.merge(other._animation); _keyLight.merge(other._keyLight); _skybox.merge(other._skybox); + _haze.merge(other._haze); _stage.merge(other._stage); COPY_PROPERTY_IF_CHANGED(xTextureURL); @@ -1312,6 +1317,9 @@ bool EntityItemProperties::encodeEntityEditPacket(PacketType command, EntityItem APPEND_ENTITY_PROPERTY(PROP_FLYING_ALLOWED, properties.getFlyingAllowed()); APPEND_ENTITY_PROPERTY(PROP_GHOSTING_ALLOWED, properties.getGhostingAllowed()); APPEND_ENTITY_PROPERTY(PROP_FILTER_URL, properties.getFilterURL()); + + _staticHaze.setProperties(properties); + _staticHaze.appendToEditPacket(packetData, requestedProperties, propertyFlags, propertiesDidntFit, propertyCount, appendState); } if (properties.getType() == EntityTypes::PolyVox) { @@ -1769,6 +1777,7 @@ void EntityItemProperties::markAllChanged() { _animation.markAllChanged(); _skybox.markAllChanged(); + _haze.markAllChanged(); _stage.markAllChanged(); _sourceUrlChanged = true; diff --git a/libraries/entities/src/ZoneEntityItem.h b/libraries/entities/src/ZoneEntityItem.h index 93c3b7286d..cbc47083fe 100644 --- a/libraries/entities/src/ZoneEntityItem.h +++ b/libraries/entities/src/ZoneEntityItem.h @@ -88,6 +88,7 @@ public: bool backgroundPropertiesChanged() const { return _backgroundPropertiesChanged; } bool stagePropertiesChanged() const { return _stagePropertiesChanged; } bool skyboxPropertiesChanged() const { return _skyboxPropertiesChanged; } + bool hazePropertiesChanged() const { return _hazePropertiesChanged; } void resetRenderingPropertiesChanged(); From c2eea7d40b5fb88f6d51976dafae7812f22ba656 Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Fri, 22 Sep 2017 18:37:21 -0700 Subject: [PATCH 04/94] Minor cleanup. --- .../entities-renderer/src/RenderableZoneEntityItem.cpp | 2 +- libraries/entities-renderer/src/RenderableZoneEntityItem.h | 2 +- libraries/entities/src/EntityItemProperties.cpp | 7 ++++--- libraries/entities/src/EntityItemProperties.h | 2 +- libraries/entities/src/ZoneEntityItem.cpp | 4 ++-- libraries/entities/src/ZoneEntityItem.h | 7 ++++--- 6 files changed, 13 insertions(+), 11 deletions(-) diff --git a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp index e5ae541099..01dadf82a5 100644 --- a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp @@ -179,9 +179,9 @@ void ZoneEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scen _lastDimensions = entity->getDimensions(); _keyLightProperties = entity->getKeyLightProperties(); - _stageProperties = entity->getStageProperties(); _skyboxProperties = entity->getSkyboxProperties(); _hazeProperties = entity->getHazeProperties(); + _stageProperties = entity->getStageProperties(); #if 0 if (_lastShapeURL != _typedEntity->getCompoundShapeURL()) { diff --git a/libraries/entities-renderer/src/RenderableZoneEntityItem.h b/libraries/entities-renderer/src/RenderableZoneEntityItem.h index b5c42529d2..b64541738c 100644 --- a/libraries/entities-renderer/src/RenderableZoneEntityItem.h +++ b/libraries/entities-renderer/src/RenderableZoneEntityItem.h @@ -91,9 +91,9 @@ private: bool _needBackgroundUpdate{ true }; KeyLightPropertyGroup _keyLightProperties; - StagePropertyGroup _stageProperties; SkyboxPropertyGroup _skyboxProperties; HazePropertyGroup _hazeProperties; + StagePropertyGroup _stageProperties; // More attributes used for rendering: QString _ambientTextureURL; diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp index 2156a2aa82..96347ff653 100644 --- a/libraries/entities/src/EntityItemProperties.cpp +++ b/libraries/entities/src/EntityItemProperties.cpp @@ -513,9 +513,9 @@ QScriptValue EntityItemProperties::copyToScriptValue(QScriptEngine* engine, bool COPY_PROPERTY_TO_QSCRIPTVALUE_GETTER(PROP_BACKGROUND_MODE, backgroundMode, getBackgroundModeAsString()); - _stage.copyToScriptValue(_desiredProperties, properties, engine, skipDefaults, defaultEntityProperties); - _haze.copyToScriptValue(_desiredProperties, properties, engine, skipDefaults, defaultEntityProperties); _skybox.copyToScriptValue(_desiredProperties, properties, engine, skipDefaults, defaultEntityProperties); + _haze.copyToScriptValue(_desiredProperties, properties, engine, skipDefaults, defaultEntityProperties); + _stage.copyToScriptValue(_desiredProperties, properties, engine, skipDefaults, defaultEntityProperties); COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_FLYING_ALLOWED, flyingAllowed); COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_GHOSTING_ALLOWED, ghostingAllowed); @@ -1610,8 +1610,9 @@ bool EntityItemProperties::decodeEntityEditPacket(const unsigned char* data, int READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_SHAPE_TYPE, ShapeType, setShapeType); READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_COMPOUND_SHAPE_URL, QString, setCompoundShapeURL); READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_BACKGROUND_MODE, BackgroundMode, setBackgroundMode); - properties.getSkybox().decodeFromEditPacket(propertyFlags, dataAt, processedBytes); + properties.getHaze().decodeFromEditPacket(propertyFlags, dataAt, processedBytes); + properties.getSkybox().decodeFromEditPacket(propertyFlags, dataAt, processedBytes); READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_FLYING_ALLOWED, bool, setFlyingAllowed); READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_GHOSTING_ALLOWED, bool, setGhostingAllowed); diff --git a/libraries/entities/src/EntityItemProperties.h b/libraries/entities/src/EntityItemProperties.h index 423e846a5c..7c1015bb61 100644 --- a/libraries/entities/src/EntityItemProperties.h +++ b/libraries/entities/src/EntityItemProperties.h @@ -179,9 +179,9 @@ public: DEFINE_PROPERTY_REF(PROP_NAME, Name, name, QString, ENTITY_ITEM_DEFAULT_NAME); DEFINE_PROPERTY_REF_ENUM(PROP_BACKGROUND_MODE, BackgroundMode, backgroundMode, BackgroundMode, BACKGROUND_MODE_INHERIT); DEFINE_PROPERTY_REF_ENUM(PROP_HAZE_MODE, HazeMode, hazeMode, HazeMode, HAZE_MODE_INHERIT); - DEFINE_PROPERTY_GROUP(Stage, stage, StagePropertyGroup); DEFINE_PROPERTY_GROUP(Skybox, skybox, SkyboxPropertyGroup); DEFINE_PROPERTY_GROUP(Haze, haze, HazePropertyGroup); + DEFINE_PROPERTY_GROUP(Stage, stage, StagePropertyGroup); DEFINE_PROPERTY_GROUP(Animation, animation, AnimationPropertyGroup); DEFINE_PROPERTY_REF(PROP_SOURCE_URL, SourceUrl, sourceUrl, QString, ""); DEFINE_PROPERTY(PROP_LINE_WIDTH, LineWidth, lineWidth, float, LineEntityItem::DEFAULT_LINE_WIDTH); diff --git a/libraries/entities/src/ZoneEntityItem.cpp b/libraries/entities/src/ZoneEntityItem.cpp index 7957ec9347..d758e89099 100644 --- a/libraries/entities/src/ZoneEntityItem.cpp +++ b/libraries/entities/src/ZoneEntityItem.cpp @@ -246,9 +246,9 @@ void ZoneEntityItem::debugDump() const { qCDebug(entities) << " _backgroundMode:" << EntityItemProperties::getBackgroundModeString(_backgroundMode); _keyLightProperties.debugDump(); - _stageProperties.debugDump(); _skyboxProperties.debugDump(); _hazeProperties.debugDump(); + _stageProperties.debugDump(); } ShapeType ZoneEntityItem::getShapeType() const { @@ -312,8 +312,8 @@ void ZoneEntityItem::resetRenderingPropertiesChanged() { withWriteLock([&] { _keyLightPropertiesChanged = false; _backgroundPropertiesChanged = false; - _stagePropertiesChanged = false; _skyboxPropertiesChanged = false; _hazePropertiesChanged = false; + _stagePropertiesChanged = false; }); } diff --git a/libraries/entities/src/ZoneEntityItem.h b/libraries/entities/src/ZoneEntityItem.h index cbc47083fe..3ed5c3f88f 100644 --- a/libraries/entities/src/ZoneEntityItem.h +++ b/libraries/entities/src/ZoneEntityItem.h @@ -73,6 +73,7 @@ public: HazeMode getHazeMode() const { return _hazeMode; } SkyboxPropertyGroup getSkyboxProperties() const { return resultWithReadLock([&] { return _skyboxProperties; }); } + HazePropertyGroup getHazeProperties() const { return resultWithReadLock([&] { return _hazeProperties; }); } const StagePropertyGroup& getStageProperties() const { return _stageProperties; } @@ -86,9 +87,9 @@ public: bool keyLightPropertiesChanged() const { return _keyLightPropertiesChanged; } bool backgroundPropertiesChanged() const { return _backgroundPropertiesChanged; } - bool stagePropertiesChanged() const { return _stagePropertiesChanged; } bool skyboxPropertiesChanged() const { return _skyboxPropertiesChanged; } bool hazePropertiesChanged() const { return _hazePropertiesChanged; } + bool stagePropertiesChanged() const { return _stagePropertiesChanged; } void resetRenderingPropertiesChanged(); @@ -115,9 +116,9 @@ protected: BackgroundMode _backgroundMode = BACKGROUND_MODE_INHERIT; HazeMode _hazeMode = HAZE_MODE_INHERIT; - StagePropertyGroup _stageProperties; SkyboxPropertyGroup _skyboxProperties; HazePropertyGroup _hazeProperties; + StagePropertyGroup _stageProperties; bool _flyingAllowed { DEFAULT_FLYING_ALLOWED }; bool _ghostingAllowed { DEFAULT_GHOSTING_ALLOWED }; @@ -126,8 +127,8 @@ protected: // Dirty flags turn true when either keylight properties is changing values. bool _keyLightPropertiesChanged { false }; bool _backgroundPropertiesChanged{ false }; - bool _hazePropertiesChanged{ false }; bool _skyboxPropertiesChanged { false }; + bool _hazePropertiesChanged{ false }; bool _stagePropertiesChanged { false }; static bool _drawZoneBoundaries; From c4419fede802689994cf2d61ad4c8217192daa76 Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Fri, 22 Sep 2017 19:07:05 -0700 Subject: [PATCH 05/94] Bumped up the version number. --- libraries/networking/src/udt/PacketHeaders.cpp | 2 +- libraries/networking/src/udt/PacketHeaders.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/networking/src/udt/PacketHeaders.cpp b/libraries/networking/src/udt/PacketHeaders.cpp index b95f2ff6a0..e5004e575e 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 VERSION_ENTITIES_ANIMATION_ALLOW_TRANSLATION_PROPERTIES; + return VERSION_ENTITIES_HAZE; case PacketType::EntityQuery: return static_cast(EntityQueryPacketVersion::JSONFilterWithFamilyTree); case PacketType::AvatarIdentity: diff --git a/libraries/networking/src/udt/PacketHeaders.h b/libraries/networking/src/udt/PacketHeaders.h index 4fefc6ab3a..530223fc97 100644 --- a/libraries/networking/src/udt/PacketHeaders.h +++ b/libraries/networking/src/udt/PacketHeaders.h @@ -266,6 +266,7 @@ const PacketVersion VERSION_ENTITIES_BULLET_DYNAMICS = 70; const PacketVersion VERSION_ENTITIES_HAS_SHOULD_HIGHLIGHT = 71; const PacketVersion VERSION_ENTITIES_HAS_HIGHLIGHT_SCRIPTING_INTERFACE = 72; const PacketVersion VERSION_ENTITIES_ANIMATION_ALLOW_TRANSLATION_PROPERTIES = 73; +const PacketVersion VERSION_ENTITIES_HAZE = 74; enum class EntityQueryPacketVersion: PacketVersion { JSONFilter = 18, From 678b4e35b1df1be8adff3bd02c1907bf80efc1f7 Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Sun, 24 Sep 2017 14:06:00 -0700 Subject: [PATCH 06/94] Before replacing "Haze Active" checkbox with "Haze Mode" combo. --- .../src/RenderableModelEntityItem.cpp | 4 ++-- .../src/RenderableZoneEntityItem.cpp | 15 ++++++++++++ .../src/RenderableZoneEntityItem.h | 3 +++ .../entities/src/EntityItemProperties.cpp | 13 +++++++++++ .../entities/src/KeyLightPropertyGroup.cpp | 2 +- libraries/entities/src/ZoneEntityItem.cpp | 14 +++++------ libraries/model/src/model/Stage.cpp | 3 ++- libraries/model/src/model/Stage.h | 8 +++---- libraries/octree/src/OctreePacketData.h | 1 + .../src/SceneScriptingInterface.cpp | 23 ++++++++++++++++++- .../src/SceneScriptingInterface.h | 4 ++++ 11 files changed, 74 insertions(+), 16 deletions(-) diff --git a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp index 2508b598af..4d4ca5ab13 100644 --- a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp @@ -319,7 +319,7 @@ void RenderableModelEntityItem::computeShapeInfo(ShapeInfo& shapeInfo) { // should never fall in here when collision model not fully loaded // hence we assert that all geometries exist and are loaded - assert(_model && _model->isLoaded() && _compoundShapeResource && _compoundShapeResource->isLoaded()); + ////assert(_model && _model->isLoaded() && _compoundShapeResource && _compoundShapeResource->isLoaded()); const FBXGeometry& collisionGeometry = _compoundShapeResource->getFBXGeometry(); ShapeInfo::PointCollection& pointCollection = shapeInfo.getPointCollection(); @@ -408,7 +408,7 @@ void RenderableModelEntityItem::computeShapeInfo(ShapeInfo& shapeInfo) { shapeInfo.setParams(type, dimensions, getCompoundShapeURL()); } else if (type >= SHAPE_TYPE_SIMPLE_HULL && type <= SHAPE_TYPE_STATIC_MESH) { // should never fall in here when model not fully loaded - assert(_model && _model->isLoaded()); + ////assert(_model && _model->isLoaded()); updateModelBounds(); model->updateGeometry(); diff --git a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp index 01dadf82a5..9f8567aa54 100644 --- a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp @@ -211,9 +211,14 @@ void ZoneEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scen if (sunChanged || skyboxChanged) { updateKeyAmbientFromEntity(); } + if (backgroundChanged || skyboxChanged) { updateKeyBackgroundFromEntity(entity); } + + if (hazeChanged) { + updateHazeFromEntity(entity); + } } void ZoneEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPointer& entity) { @@ -300,9 +305,16 @@ void ZoneEntityRenderer::updateKeyAmbientFromEntity() { } } +void ZoneEntityRenderer::updateHazeFromEntity(const TypedEntityPointer& entity) { + const auto& haze = editHaze(); + + haze->setIsHazeActive(entity->getHazeMode() == HAZE_MODE_ON); +} + void ZoneEntityRenderer::updateKeyBackgroundFromEntity(const TypedEntityPointer& entity) { editBackground(); setBackgroundMode(entity->getBackgroundMode()); + setHazeMode(entity->getHazeMode()); setSkyboxColor(_skyboxProperties.getColorVec3()); setProceduralUserData(entity->getUserData()); setSkyboxURL(_skyboxProperties.getURL()); @@ -409,6 +421,9 @@ void ZoneEntityRenderer::updateSkyboxMap() { void ZoneEntityRenderer::setBackgroundMode(BackgroundMode mode) { _backgroundMode = mode; } +void ZoneEntityRenderer::setHazeMode(HazeMode mode) { + _hazeMode = mode; +} void ZoneEntityRenderer::setSkyboxColor(const glm::vec3& color) { editSkybox()->setColor(color); diff --git a/libraries/entities-renderer/src/RenderableZoneEntityItem.h b/libraries/entities-renderer/src/RenderableZoneEntityItem.h index b64541738c..faff8e2daa 100644 --- a/libraries/entities-renderer/src/RenderableZoneEntityItem.h +++ b/libraries/entities-renderer/src/RenderableZoneEntityItem.h @@ -45,12 +45,14 @@ private: void updateKeyZoneItemFromEntity(); void updateKeySunFromEntity(); void updateKeyAmbientFromEntity(); + void updateHazeFromEntity(const TypedEntityPointer& entity); void updateKeyBackgroundFromEntity(const TypedEntityPointer& entity); void updateAmbientMap(); void updateSkyboxMap(); void setAmbientURL(const QString& ambientUrl); void setSkyboxURL(const QString& skyboxUrl); void setBackgroundMode(BackgroundMode mode); + void setHazeMode(HazeMode mode); void setSkyboxColor(const glm::vec3& color); void setProceduralUserData(const QString& userData); @@ -78,6 +80,7 @@ private: const model::LightPointer _ambientLight{ std::make_shared() }; const model::SunSkyStagePointer _background{ std::make_shared() }; BackgroundMode _backgroundMode{ BACKGROUND_MODE_INHERIT }; + HazeMode _hazeMode{ HAZE_MODE_INHERIT }; indexed_container::Index _sunIndex{ LightStage::INVALID_INDEX }; indexed_container::Index _ambientIndex{ LightStage::INVALID_INDEX }; diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp index 96347ff653..a2f344b3aa 100644 --- a/libraries/entities/src/EntityItemProperties.cpp +++ b/libraries/entities/src/EntityItemProperties.cpp @@ -227,9 +227,22 @@ void EntityItemProperties::setBackgroundModeFromString(const QString& background } } +QString EntityItemProperties::getHazeModeAsString() const { + return HAZE_MODES[_hazeMode].second; +} + QString EntityItemProperties::getHazeModeString(HazeMode mode) { return HAZE_MODES[mode].second; } +void EntityItemProperties::setHazeModeFromString(const QString& hazeMode) { + auto result = std::find_if(HAZE_MODES.begin(), HAZE_MODES.end(), [&](const HazePair& pair) { + return (pair.second == hazeMode); + }); + if (result != HAZE_MODES.end()) { + _hazeMode = result->first; + _hazeModeChanged = true; + } +} EntityPropertyFlags EntityItemProperties::getChangedProperties() const { EntityPropertyFlags changedProperties; diff --git a/libraries/entities/src/KeyLightPropertyGroup.cpp b/libraries/entities/src/KeyLightPropertyGroup.cpp index f0d059af67..4246da309b 100644 --- a/libraries/entities/src/KeyLightPropertyGroup.cpp +++ b/libraries/entities/src/KeyLightPropertyGroup.cpp @@ -1,5 +1,5 @@ // -// KeyLightPropertyGroup.h +// KeyLightPropertyGroup.cpp // libraries/entities/src // // Created by Sam Gateau on 2015/10/23. diff --git a/libraries/entities/src/ZoneEntityItem.cpp b/libraries/entities/src/ZoneEntityItem.cpp index d758e89099..364fa01e58 100644 --- a/libraries/entities/src/ZoneEntityItem.cpp +++ b/libraries/entities/src/ZoneEntityItem.cpp @@ -44,7 +44,7 @@ ZoneEntityItem::ZoneEntityItem(const EntityItemID& entityItemID) : EntityItem(en _compoundShapeURL = DEFAULT_COMPOUND_SHAPE_URL; _backgroundMode = BACKGROUND_MODE_INHERIT; - _hazeMode = HAZE_MODE_OFF; + _hazeMode = HAZE_MODE_INHERIT; } EntityItemProperties ZoneEntityItem::getProperties(EntityPropertyFlags desiredProperties) const { @@ -66,9 +66,8 @@ EntityItemProperties ZoneEntityItem::getProperties(EntityPropertyFlags desiredPr withReadLock([&] { _skyboxProperties.getProperties(properties); }); - withReadLock([&] { - _hazeProperties.getProperties(properties); - }); + + _hazeProperties.getProperties(properties); COPY_ENTITY_PROPERTY_TO_PROPERTIES(flyingAllowed, getFlyingAllowed); COPY_ENTITY_PROPERTY_TO_PROPERTIES(ghostingAllowed, getGhostingAllowed); @@ -108,6 +107,7 @@ bool ZoneEntityItem::setSubClassProperties(const EntityItemProperties& propertie SET_ENTITY_PROPERTY_FROM_PROPERTIES(shapeType, setShapeType); SET_ENTITY_PROPERTY_FROM_PROPERTIES(compoundShapeURL, setCompoundShapeURL); SET_ENTITY_PROPERTY_FROM_PROPERTIES(backgroundMode, setBackgroundMode); + SET_ENTITY_PROPERTY_FROM_PROPERTIES(hazeMode, setHazeMode); SET_ENTITY_PROPERTY_FROM_PROPERTIES(flyingAllowed, setFlyingAllowed); SET_ENTITY_PROPERTY_FROM_PROPERTIES(ghostingAllowed, setGhostingAllowed); @@ -117,9 +117,8 @@ bool ZoneEntityItem::setSubClassProperties(const EntityItemProperties& propertie withWriteLock([&] { _skyboxPropertiesChanged = _skyboxProperties.setProperties(properties); }); - withWriteLock([&] { - _hazePropertiesChanged = _hazeProperties.setProperties(properties); - }); + + _hazePropertiesChanged = _hazeProperties.setProperties(properties); somethingChanged = somethingChanged || _keyLightPropertiesChanged || _stagePropertiesChanged || _skyboxPropertiesChanged || _hazePropertiesChanged; @@ -152,6 +151,7 @@ int ZoneEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data, READ_ENTITY_PROPERTY(PROP_SHAPE_TYPE, ShapeType, setShapeType); READ_ENTITY_PROPERTY(PROP_COMPOUND_SHAPE_URL, QString, setCompoundShapeURL); READ_ENTITY_PROPERTY(PROP_BACKGROUND_MODE, BackgroundMode, setBackgroundMode); + READ_ENTITY_PROPERTY(PROP_BACKGROUND_MODE, HazeMode, setHazeMode); int bytesFromSkybox; withWriteLock([&] { diff --git a/libraries/model/src/model/Stage.cpp b/libraries/model/src/model/Stage.cpp index 62e9e6adda..b24b58e7cf 100644 --- a/libraries/model/src/model/Stage.cpp +++ b/libraries/model/src/model/Stage.cpp @@ -139,7 +139,8 @@ const float NUM_HOURS_PER_HALF_DAY = NUM_HOURS_PER_DAY * 0.5f; SunSkyStage::SunSkyStage() : _sunLight(std::make_shared()), - _skybox(std::make_shared()) + _skybox(std::make_shared()), + _haze(std::make_shared()) { _sunLight->setType(Light::SUN); // Default ambient sphere (for lack of skybox) diff --git a/libraries/model/src/model/Stage.h b/libraries/model/src/model/Stage.h index 5074bc7a67..567c64ec38 100644 --- a/libraries/model/src/model/Stage.h +++ b/libraries/model/src/model/Stage.h @@ -177,21 +177,21 @@ public: // Haze enum HazeMode { - NO_HAZE, - YES_HAZE, + HAZE_OFF, + HAZE_ON, NUM_HAZE_MODES }; void setHazeMode(HazeMode mode); - HazeMode gethazeMode() const { return _hazeMode; } + HazeMode getHazeMode() const { return _hazeMode; } void setHaze(const HazePointer& haze); const HazePointer& getHaze() const { valid(); return _haze; } protected: BackgroundMode _backgroundMode = SKY_DEFAULT; - HazeMode _hazeMode = NO_HAZE; + HazeMode _hazeMode = HAZE_OFF; LightPointer _sunLight; mutable SkyboxPointer _skybox; diff --git a/libraries/octree/src/OctreePacketData.h b/libraries/octree/src/OctreePacketData.h index d0255d60ab..0b93343b09 100644 --- a/libraries/octree/src/OctreePacketData.h +++ b/libraries/octree/src/OctreePacketData.h @@ -259,6 +259,7 @@ public: static int unpackDataFromBytes(const unsigned char* dataBytes, glm::quat& result) { int bytes = unpackOrientationQuatFromBytes(dataBytes, result); return bytes; } static int unpackDataFromBytes(const unsigned char* dataBytes, ShapeType& result) { memcpy(&result, dataBytes, sizeof(result)); return sizeof(result); } static int unpackDataFromBytes(const unsigned char* dataBytes, BackgroundMode& result) { memcpy(&result, dataBytes, sizeof(result)); return sizeof(result); } + static int unpackDataFromBytes(const unsigned char* dataBytes, HazeMode& result) { memcpy(&result, dataBytes, sizeof(result)); return sizeof(result); } static int unpackDataFromBytes(const unsigned char* dataBytes, QString& result); static int unpackDataFromBytes(const unsigned char* dataBytes, QUuid& result); static int unpackDataFromBytes(const unsigned char* dataBytes, xColor& result); diff --git a/libraries/script-engine/src/SceneScriptingInterface.cpp b/libraries/script-engine/src/SceneScriptingInterface.cpp index 3883b948df..9c8eb79b49 100644 --- a/libraries/script-engine/src/SceneScriptingInterface.cpp +++ b/libraries/script-engine/src/SceneScriptingInterface.cpp @@ -113,7 +113,8 @@ bool SceneScripting::Stage::isSunModelEnabled() const { void SceneScripting::Stage::setBackgroundMode(const QString& mode) { if (mode == QString("inherit")) { _skyStage->setBackgroundMode(model::SunSkyStage::NO_BACKGROUND); - } else if (mode == QString("skybox")) { + } + else if (mode == QString("skybox")) { _skyStage->setBackgroundMode(model::SunSkyStage::SKY_BOX); } } @@ -129,6 +130,26 @@ 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"); + }; +} + 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 7bc22eb3e6..9eb9a59ce3 100644 --- a/libraries/script-engine/src/SceneScriptingInterface.h +++ b/libraries/script-engine/src/SceneScriptingInterface.h @@ -121,6 +121,10 @@ 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; + protected: model::SunSkyStagePointer _skyStage; LocationPointer _location; From 6cbf0877089c4ffce0399386f93ce65a454dfaa6 Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Sun, 24 Sep 2017 15:08:22 -0700 Subject: [PATCH 07/94] First version with combo for Haze Mode. --- .../src/RenderableZoneEntityItem.cpp | 2 +- .../entities/src/EntityItemProperties.cpp | 23 +++++++++++++------ libraries/entities/src/ZoneEntityItem.cpp | 1 + libraries/shared/src/HazeMode.h | 4 ++-- scripts/system/html/entityProperties.html | 10 +++++--- scripts/system/html/js/entityProperties.js | 8 ++++--- 6 files changed, 32 insertions(+), 16 deletions(-) diff --git a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp index 9f8567aa54..fb0141ae4a 100644 --- a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp @@ -308,7 +308,7 @@ void ZoneEntityRenderer::updateKeyAmbientFromEntity() { void ZoneEntityRenderer::updateHazeFromEntity(const TypedEntityPointer& entity) { const auto& haze = editHaze(); - haze->setIsHazeActive(entity->getHazeMode() == HAZE_MODE_ON); + haze->setIsHazeActive(entity->getHazeMode() == HAZE_MODE_ENABLED); } void ZoneEntityRenderer::updateKeyBackgroundFromEntity(const TypedEntityPointer& entity) { diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp index a2f344b3aa..23ebbc81bc 100644 --- a/libraries/entities/src/EntityItemProperties.cpp +++ b/libraries/entities/src/EntityItemProperties.cpp @@ -202,13 +202,6 @@ const std::array BACKGROUND_MODES = BackgroundPair { BACKGROUND_MODE_SKYBOX, { "skybox" } } } }; -using HazePair = std::pair; -const std::array HAZE_MODES = { { - HazePair{ HAZE_MODE_INHERIT,{ "inherit" } }, - HazePair{ HAZE_MODE_OFF,{ "off" } }, - HazePair{ HAZE_MODE_ON,{ "on" } } - } }; - QString EntityItemProperties::getBackgroundModeAsString() const { return BACKGROUND_MODES[_backgroundMode].second; } @@ -227,6 +220,13 @@ void EntityItemProperties::setBackgroundModeFromString(const QString& background } } +using HazePair = std::pair; +const std::array HAZE_MODES = { { + HazePair{ HAZE_MODE_INHERIT,{ "inherit" } }, + HazePair{ HAZE_MODE_DISABLED,{ "disabled" } }, + HazePair{ HAZE_MODE_ENABLED,{ "enabled" } } +} }; + QString EntityItemProperties::getHazeModeAsString() const { return HAZE_MODES[_hazeMode].second; } @@ -317,6 +317,7 @@ EntityPropertyFlags EntityItemProperties::getChangedProperties() const { CHECK_PROPERTY_CHANGE(PROP_MARKETPLACE_ID, marketplaceID); CHECK_PROPERTY_CHANGE(PROP_NAME, name); CHECK_PROPERTY_CHANGE(PROP_BACKGROUND_MODE, backgroundMode); + CHECK_PROPERTY_CHANGE(PROP_HAZE_MODE, hazeMode); CHECK_PROPERTY_CHANGE(PROP_SOURCE_URL, sourceUrl); CHECK_PROPERTY_CHANGE(PROP_VOXEL_VOLUME_SIZE, voxelVolumeSize); CHECK_PROPERTY_CHANGE(PROP_VOXEL_DATA, voxelData); @@ -525,6 +526,7 @@ QScriptValue EntityItemProperties::copyToScriptValue(QScriptEngine* engine, bool _keyLight.copyToScriptValue(_desiredProperties, properties, engine, skipDefaults, defaultEntityProperties); COPY_PROPERTY_TO_QSCRIPTVALUE_GETTER(PROP_BACKGROUND_MODE, backgroundMode, getBackgroundModeAsString()); + COPY_PROPERTY_TO_QSCRIPTVALUE_GETTER(PROP_HAZE_MODE, hazeMode, getHazeModeAsString()); _skybox.copyToScriptValue(_desiredProperties, properties, engine, skipDefaults, defaultEntityProperties); _haze.copyToScriptValue(_desiredProperties, properties, engine, skipDefaults, defaultEntityProperties); @@ -704,6 +706,7 @@ void EntityItemProperties::copyFromScriptValue(const QScriptValue& object, bool COPY_PROPERTY_FROM_QSCRIPTVALUE(collisionSoundURL, QString, setCollisionSoundURL); COPY_PROPERTY_FROM_QSCRITPTVALUE_ENUM(backgroundMode, BackgroundMode); + COPY_PROPERTY_FROM_QSCRITPTVALUE_ENUM(hazeMode, HazeMode); COPY_PROPERTY_FROM_QSCRIPTVALUE(sourceUrl, QString, setSourceUrl); COPY_PROPERTY_FROM_QSCRIPTVALUE(voxelVolumeSize, glmVec3, setVoxelVolumeSize); COPY_PROPERTY_FROM_QSCRIPTVALUE(voxelData, QByteArray, setVoxelData); @@ -843,6 +846,7 @@ void EntityItemProperties::merge(const EntityItemProperties& other) { COPY_PROPERTY_IF_CHANGED(collisionSoundURL); COPY_PROPERTY_IF_CHANGED(backgroundMode); + COPY_PROPERTY_IF_CHANGED(hazeMode); COPY_PROPERTY_IF_CHANGED(sourceUrl); COPY_PROPERTY_IF_CHANGED(voxelVolumeSize); COPY_PROPERTY_IF_CHANGED(voxelData); @@ -1021,6 +1025,7 @@ void EntityItemProperties::entityPropertyFlagsFromScriptValue(const QScriptValue ADD_PROPERTY_TO_MAP(PROP_VOXEL_SURFACE_STYLE, VoxelSurfaceStyle, voxelSurfaceStyle, uint16_t); ADD_PROPERTY_TO_MAP(PROP_NAME, Name, name, QString); ADD_PROPERTY_TO_MAP(PROP_BACKGROUND_MODE, BackgroundMode, backgroundMode, BackgroundMode); + ADD_PROPERTY_TO_MAP(PROP_HAZE_MODE, HazeMode, hazeMode, HazeMode); ADD_PROPERTY_TO_MAP(PROP_SOURCE_URL, SourceUrl, sourceUrl, QString); ADD_PROPERTY_TO_MAP(PROP_LINE_WIDTH, LineWidth, lineWidth, float); ADD_PROPERTY_TO_MAP(PROP_LINE_POINTS, LinePoints, linePoints, QVector); @@ -1788,6 +1793,7 @@ void EntityItemProperties::markAllChanged() { _keyLight.markAllChanged(); _backgroundModeChanged = true; + _hazeModeChanged = true; _animation.markAllChanged(); _skybox.markAllChanged(); @@ -2097,6 +2103,9 @@ QList EntityItemProperties::listChangedProperties() { if (backgroundModeChanged()) { out += "backgroundMode"; } + if (hazeModeChanged()) { + out += "hazeMode"; + } if (voxelVolumeSizeChanged()) { out += "voxelVolumeSize"; } diff --git a/libraries/entities/src/ZoneEntityItem.cpp b/libraries/entities/src/ZoneEntityItem.cpp index 364fa01e58..c6a2f573f2 100644 --- a/libraries/entities/src/ZoneEntityItem.cpp +++ b/libraries/entities/src/ZoneEntityItem.cpp @@ -244,6 +244,7 @@ void ZoneEntityItem::debugDump() const { qCDebug(entities) << " dimensions:" << debugTreeVector(getDimensions()); qCDebug(entities) << " getLastEdited:" << debugTime(getLastEdited(), now); qCDebug(entities) << " _backgroundMode:" << EntityItemProperties::getBackgroundModeString(_backgroundMode); + qCDebug(entities) << " _hazeMode:" << EntityItemProperties::getHazeModeString(_hazeMode); _keyLightProperties.debugDump(); _skyboxProperties.debugDump(); diff --git a/libraries/shared/src/HazeMode.h b/libraries/shared/src/HazeMode.h index 201a459098..18f67bdf31 100644 --- a/libraries/shared/src/HazeMode.h +++ b/libraries/shared/src/HazeMode.h @@ -13,9 +13,9 @@ #define hifi_HazeMode_h enum HazeMode { - HAZE_MODE_OFF, - HAZE_MODE_ON, HAZE_MODE_INHERIT, + HAZE_MODE_DISABLED, + HAZE_MODE_ENABLED, HAZE_MODE_ITEM_COUNT }; diff --git a/scripts/system/html/entityProperties.html b/scripts/system/html/entityProperties.html index 6e3c5eeca6..c16f214213 100644 --- a/scripts/system/html/entityProperties.html +++ b/scripts/system/html/entityProperties.html @@ -547,9 +547,13 @@ Haze -
- - +
diff --git a/scripts/system/html/js/entityProperties.js b/scripts/system/html/js/entityProperties.js index 439576abdf..caaf56f7bb 100644 --- a/scripts/system/html/js/entityProperties.js +++ b/scripts/system/html/js/entityProperties.js @@ -657,7 +657,7 @@ function loaded() { var elZoneKeyLightDirectionZ = document.getElementById("property-zone-key-light-direction-z"); var elZoneKeyLightAmbientURL = document.getElementById("property-zone-key-ambient-url"); - var elZoneHazeActive = document.getElementById("property-zone-haze-haze-active"); + var elZoneHazeMode = document.getElementById("property-zone-haze-mode"); var elZoneStageLatitude = document.getElementById("property-zone-stage-latitude"); var elZoneStageLongitude = document.getElementById("property-zone-stage-longitude"); @@ -977,7 +977,8 @@ function loaded() { elZoneKeyLightDirectionY.value = properties.keyLight.direction.y.toFixed(2); elZoneKeyLightAmbientURL.value = properties.keyLight.ambientURL; - elZoneHazeActive.checked = properties.haze.hazeActive; + elZoneHazeMode.value = properties.hazeMode; + setDropdownText(elZoneHazeMode); elZoneStageLatitude.value = properties.stage.latitude.toFixed(2); elZoneStageLongitude.value = properties.stage.longitude.toFixed(2); @@ -1373,7 +1374,7 @@ function loaded() { elZoneKeyLightDirectionX.addEventListener('change', zoneKeyLightDirectionChangeFunction); elZoneKeyLightDirectionY.addEventListener('change', zoneKeyLightDirectionChangeFunction); - elZoneHazeActive.addEventListener('change', createEmitGroupCheckedPropertyUpdateFunction('haze', 'hazeActive')); + elZoneHazeMode.addEventListener('change', createEmitTextPropertyUpdateFunction('hazeMode')); elZoneStageLatitude.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('stage', 'latitude')); elZoneStageLongitude.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('stage', 'longitude')); @@ -1384,6 +1385,7 @@ function loaded() { elZoneBackgroundMode.addEventListener('change', createEmitTextPropertyUpdateFunction('backgroundMode')); + var zoneSkyboxColorChangeFunction = createEmitGroupColorPropertyUpdateFunction('skybox', 'color', elZoneSkyboxColorRed, elZoneSkyboxColorGreen, elZoneSkyboxColorBlue); elZoneSkyboxColorRed.addEventListener('change', zoneSkyboxColorChangeFunction); From 543bc5a71b4d45b2e154e11858448328df7ee5b1 Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Sun, 24 Sep 2017 18:25:20 -0700 Subject: [PATCH 08/94] HazeMode calls Haze::setIsHazeActive. --- libraries/entities-renderer/src/RenderableZoneEntityItem.cpp | 1 + libraries/entities/src/EntityItemProperties.cpp | 1 + libraries/entities/src/ZoneEntityItem.cpp | 3 +-- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp index fb0141ae4a..eecc06e3dc 100644 --- a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp @@ -235,6 +235,7 @@ ItemKey ZoneEntityRenderer::getKey() { bool ZoneEntityRenderer::needsRenderUpdateFromTypedEntity(const TypedEntityPointer& entity) const { if (entity->keyLightPropertiesChanged() || entity->backgroundPropertiesChanged() || + entity->hazePropertiesChanged() || entity->skyboxPropertiesChanged()) { return true; } diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp index 23ebbc81bc..064876916a 100644 --- a/libraries/entities/src/EntityItemProperties.cpp +++ b/libraries/entities/src/EntityItemProperties.cpp @@ -1328,6 +1328,7 @@ bool EntityItemProperties::encodeEntityEditPacket(PacketType command, EntityItem APPEND_ENTITY_PROPERTY(PROP_COMPOUND_SHAPE_URL, properties.getCompoundShapeURL()); APPEND_ENTITY_PROPERTY(PROP_BACKGROUND_MODE, (uint32_t)properties.getBackgroundMode()); + APPEND_ENTITY_PROPERTY(PROP_HAZE_MODE, (uint32_t)properties.getHazeMode()); _staticSkybox.setProperties(properties); _staticSkybox.appendToEditPacket(packetData, requestedProperties, propertyFlags, propertiesDidntFit, propertyCount, appendState); diff --git a/libraries/entities/src/ZoneEntityItem.cpp b/libraries/entities/src/ZoneEntityItem.cpp index c6a2f573f2..9a5573bd39 100644 --- a/libraries/entities/src/ZoneEntityItem.cpp +++ b/libraries/entities/src/ZoneEntityItem.cpp @@ -118,8 +118,6 @@ bool ZoneEntityItem::setSubClassProperties(const EntityItemProperties& propertie _skyboxPropertiesChanged = _skyboxProperties.setProperties(properties); }); - _hazePropertiesChanged = _hazeProperties.setProperties(properties); - somethingChanged = somethingChanged || _keyLightPropertiesChanged || _stagePropertiesChanged || _skyboxPropertiesChanged || _hazePropertiesChanged; return somethingChanged; @@ -225,6 +223,7 @@ void ZoneEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBits APPEND_ENTITY_PROPERTY(PROP_SHAPE_TYPE, (uint32_t)getShapeType()); APPEND_ENTITY_PROPERTY(PROP_COMPOUND_SHAPE_URL, getCompoundShapeURL()); APPEND_ENTITY_PROPERTY(PROP_BACKGROUND_MODE, (uint32_t)getBackgroundMode()); // could this be a uint16?? + APPEND_ENTITY_PROPERTY(PROP_HAZE_MODE, (uint32_t)getHazeMode()); _skyboxProperties.appendSubclassData(packetData, params, modelTreeElementExtraEncodeData, requestedProperties, propertyFlags, propertiesDidntFit, propertyCount, appendState); From 27af4685e7570ba10ae03dc2da1909c498ff8bc2 Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Mon, 25 Sep 2017 09:32:52 -0700 Subject: [PATCH 09/94] Added range and altitude to UI. --- .../entities/src/EntityItemProperties.cpp | 3 +- libraries/entities/src/EntityPropertyFlags.h | 5 +- libraries/entities/src/HazePropertyGroup.cpp | 57 +++++++++++++------ libraries/entities/src/HazePropertyGroup.h | 6 +- libraries/entities/src/ZoneEntityItem.h | 2 + libraries/model/src/model/Stage.h | 9 +++ .../src/SceneScriptingInterface.cpp | 16 ++++++ .../src/SceneScriptingInterface.h | 8 +++ scripts/system/html/entityProperties.html | 6 ++ scripts/system/html/js/entityProperties.js | 8 ++- 10 files changed, 98 insertions(+), 22 deletions(-) diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp index 064876916a..c2a0f67a61 100644 --- a/libraries/entities/src/EntityItemProperties.cpp +++ b/libraries/entities/src/EntityItemProperties.cpp @@ -1073,7 +1073,8 @@ void EntityItemProperties::entityPropertyFlagsFromScriptValue(const QScriptValue ADD_GROUP_PROPERTY_TO_MAP(PROP_SKYBOX_COLOR, Skybox, skybox, Color, color); ADD_GROUP_PROPERTY_TO_MAP(PROP_SKYBOX_URL, Skybox, skybox, URL, url); - ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_HAZE_ACTIVE, Haze, haze, HazeActive, hazeActive); + ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_HAZE_RANGE, Haze, haze, HazeRange, hazeRange); + ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_HAZE_ALTITUDE, Haze, haze, HazeAltitude, hazeAltitude); ADD_GROUP_PROPERTY_TO_MAP(PROP_STAGE_SUN_MODEL_ENABLED, Stage, stage, SunModelEnabled, sunModelEnabled); ADD_GROUP_PROPERTY_TO_MAP(PROP_STAGE_LATITUDE, Stage, stage, Latitude, latitude); diff --git a/libraries/entities/src/EntityPropertyFlags.h b/libraries/entities/src/EntityPropertyFlags.h index fda1d290ab..e3076e57ee 100644 --- a/libraries/entities/src/EntityPropertyFlags.h +++ b/libraries/entities/src/EntityPropertyFlags.h @@ -219,10 +219,11 @@ enum EntityPropertyList { PROP_STAGE_HOUR = PROP_QUADRATIC_ATTENUATION_UNUSED, PROP_STAGE_AUTOMATIC_HOURDAY = PROP_ANIMATION_FRAME_INDEX, PROP_BACKGROUND_MODE = PROP_MODEL_URL, - PROP_HAZE_MODE = PROP_MODEL_URL, + PROP_HAZE_MODE = PROP_COLOR, + PROP_HAZE_HAZE_RANGE = PROP_INTENSITY, + PROP_HAZE_HAZE_ALTITUDE = PROP_CUTOFF, PROP_SKYBOX_COLOR = PROP_ANIMATION_URL, PROP_SKYBOX_URL = PROP_ANIMATION_FPS, - PROP_HAZE_HAZE_ACTIVE = PROP_ANIMATION_FRAME_INDEX, PROP_KEYLIGHT_AMBIENT_URL = PROP_ANIMATION_PLAYING, // Aliases/Piggyback properties for Web. These properties intentionally reuse the enum values for diff --git a/libraries/entities/src/HazePropertyGroup.cpp b/libraries/entities/src/HazePropertyGroup.cpp index d0208f020e..2b4aabed3c 100644 --- a/libraries/entities/src/HazePropertyGroup.cpp +++ b/libraries/entities/src/HazePropertyGroup.cpp @@ -15,27 +15,40 @@ #include "EntityItemProperties.h" #include "EntityItemPropertiesMacros.h" +const float HazePropertyGroup::DEFAULT_HAZE_RANGE = 1000.0f; +const float HazePropertyGroup::DEFAULT_HAZE_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_HAZE_ACTIVE, Haze, haze, HazeActive, hazeActive); + COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_HAZE_RANGE, Haze, haze, HazeRange, hazeRange); + COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_HAZE_ALTITUDE, Haze, haze, HazeAltitude, hazeAltitude); } void HazePropertyGroup::copyFromScriptValue(const QScriptValue& object, bool& _defaultSettings) { - COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(haze, hazeActive, bool, setHazeActive); + COPY_PROPERTY_FROM_QSCRIPTVALUE_GETTER(hazeHazeRange, float, setHazeRange, getHazeRange); + COPY_PROPERTY_FROM_QSCRIPTVALUE_GETTER(hazeHazeAltitude, float, setHazeAltitude, getHazeAltitude); + + COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(haze, hazeRange, float, setHazeRange); + COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(haze, hazeAltitude, float, setHazeAltitude); } void HazePropertyGroup::merge(const HazePropertyGroup& other) { - COPY_PROPERTY_IF_CHANGED(hazeActive); + COPY_PROPERTY_IF_CHANGED(hazeRange); + COPY_PROPERTY_IF_CHANGED(hazeAltitude); } void HazePropertyGroup::debugDump() const { qCDebug(entities) << " HazePropertyGroup: ---------------------------------------------"; - qCDebug(entities) << " HazeActive :" << getHazeActive() << " has changed:" << hazeActiveChanged(); + qCDebug(entities) << " _hazeRange:" << _hazeRange; + qCDebug(entities) << " _hazeAltitude:" << _hazeAltitude; } void HazePropertyGroup::listChangedProperties(QList& out) { - if (hazeActiveChanged()) { - out << "haze-hazeActive"; + if (hazeRangeChanged()) { + out << "haze-range"; + } + if (hazeAltitudeChanged()) { + out << "haze-altitude"; } } @@ -48,7 +61,8 @@ bool HazePropertyGroup::appendToEditPacket(OctreePacketData* packetData, bool successPropertyFits = true; - APPEND_ENTITY_PROPERTY(PROP_HAZE_HAZE_ACTIVE, getHazeActive()); + APPEND_ENTITY_PROPERTY(PROP_HAZE_HAZE_RANGE, getHazeRange()); + APPEND_ENTITY_PROPERTY(PROP_HAZE_HAZE_ALTITUDE, getHazeAltitude()); return true; } @@ -60,9 +74,11 @@ bool HazePropertyGroup::decodeFromEditPacket(EntityPropertyFlags& propertyFlags, bool overwriteLocalData = true; bool somethingChanged = false; - READ_ENTITY_PROPERTY(PROP_HAZE_HAZE_ACTIVE, bool, setHazeActive); + READ_ENTITY_PROPERTY(PROP_HAZE_HAZE_RANGE, float, setHazeRange); + READ_ENTITY_PROPERTY(PROP_HAZE_HAZE_ALTITUDE, float, setHazeAltitude); - DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_HAZE_ACTIVE, HazeActive); + DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_HAZE_RANGE, HazeRange); + DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_HAZE_ALTITUDE, HazeAltitude); processedBytes += bytesRead; @@ -72,25 +88,29 @@ bool HazePropertyGroup::decodeFromEditPacket(EntityPropertyFlags& propertyFlags, } void HazePropertyGroup::markAllChanged() { - _hazeActiveChanged = true; + _hazeRangeChanged = true; + _hazeAltitudeChanged = true; } EntityPropertyFlags HazePropertyGroup::getChangedProperties() const { EntityPropertyFlags changedProperties; - CHECK_PROPERTY_CHANGE(PROP_HAZE_HAZE_ACTIVE, hazeActive); + CHECK_PROPERTY_CHANGE(PROP_HAZE_HAZE_RANGE, hazeRange); + CHECK_PROPERTY_CHANGE(PROP_HAZE_HAZE_ALTITUDE, hazeAltitude); return changedProperties; } void HazePropertyGroup::getProperties(EntityItemProperties& properties) const { - COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Haze, HazeActive, getHazeActive); + COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Haze, HazeRange, getHazeRange); + COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Haze, HazeAltitude, getHazeAltitude); } bool HazePropertyGroup::setProperties(const EntityItemProperties& properties) { bool somethingChanged = false; - SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Haze, HazeActive, hazeActive, setHazeActive); + SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Haze, HazeRange, hazeRange, setHazeRange); + SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Haze, HazeAltitude, hazeAltitude, setHazeAltitude); return somethingChanged; } @@ -98,8 +118,9 @@ bool HazePropertyGroup::setProperties(const EntityItemProperties& properties) { EntityPropertyFlags HazePropertyGroup::getEntityProperties(EncodeBitstreamParams& params) const { EntityPropertyFlags requestedProperties; - requestedProperties += PROP_HAZE_HAZE_ACTIVE; - + requestedProperties += PROP_HAZE_HAZE_RANGE; + requestedProperties += PROP_HAZE_HAZE_ALTITUDE; + return requestedProperties; } @@ -113,7 +134,8 @@ void HazePropertyGroup::appendSubclassData(OctreePacketData* packetData, EncodeB bool successPropertyFits = true; - APPEND_ENTITY_PROPERTY(PROP_HAZE_HAZE_ACTIVE, getHazeActive()); + APPEND_ENTITY_PROPERTY(PROP_HAZE_HAZE_RANGE, getHazeRange()); + APPEND_ENTITY_PROPERTY(PROP_HAZE_HAZE_ALTITUDE, getHazeAltitude()); } int HazePropertyGroup::readEntitySubclassDataFromBuffer(const unsigned char* data, int bytesLeftToRead, @@ -124,7 +146,8 @@ int HazePropertyGroup::readEntitySubclassDataFromBuffer(const unsigned char* dat int bytesRead = 0; const unsigned char* dataAt = data; - READ_ENTITY_PROPERTY(PROP_HAZE_HAZE_ACTIVE, bool, setHazeActive); + READ_ENTITY_PROPERTY(PROP_HAZE_HAZE_ALTITUDE, float, setHazeRange); + READ_ENTITY_PROPERTY(PROP_HAZE_HAZE_ALTITUDE, float, setHazeAltitude); return bytesRead; } diff --git a/libraries/entities/src/HazePropertyGroup.h b/libraries/entities/src/HazePropertyGroup.h index 305110d8cf..f5b3f65bcb 100644 --- a/libraries/entities/src/HazePropertyGroup.h +++ b/libraries/entities/src/HazePropertyGroup.h @@ -74,7 +74,11 @@ public: EntityPropertyFlags& propertyFlags, bool overwriteLocalData, bool& somethingChanged) override; - DEFINE_PROPERTY(PROP_HAZE_HAZE_ACTIVE, HazeActive, hazeActive, bool, false); + static const float DEFAULT_HAZE_RANGE; + static const float DEFAULT_HAZE_ALTITUDE; + + DEFINE_PROPERTY(PROP_HAZE_HAZE_RANGE, HazeRange, hazeRange, float, DEFAULT_HAZE_RANGE); + DEFINE_PROPERTY(PROP_HAZE_HAZE_ALTITUDE, HazeAltitude, hazeAltitude, float, DEFAULT_HAZE_ALTITUDE); }; #endif // hifi_HazePropertyGroup_h diff --git a/libraries/entities/src/ZoneEntityItem.h b/libraries/entities/src/ZoneEntityItem.h index 3ed5c3f88f..3b6eca03c1 100644 --- a/libraries/entities/src/ZoneEntityItem.h +++ b/libraries/entities/src/ZoneEntityItem.h @@ -115,6 +115,8 @@ protected: BackgroundMode _backgroundMode = BACKGROUND_MODE_INHERIT; HazeMode _hazeMode = HAZE_MODE_INHERIT; + float _hazeRange = 1000.0; + float _hazeAltitude = 200.0; SkyboxPropertyGroup _skyboxProperties; HazePropertyGroup _hazeProperties; diff --git a/libraries/model/src/model/Stage.h b/libraries/model/src/model/Stage.h index 567c64ec38..6935f51657 100644 --- a/libraries/model/src/model/Stage.h +++ b/libraries/model/src/model/Stage.h @@ -186,12 +186,21 @@ public: void setHazeMode(HazeMode mode); HazeMode getHazeMode() const { return _hazeMode; } + void setHazeRange(float hazeRange) { _hazeRange = hazeRange; } + float getHazeRange() const { return _hazeRange; } + + void setHazeAltitude(float hazeAltitude) { _hazeAltitude = hazeAltitude; } + float getHazeAltitude() const { return _hazeAltitude; } + void setHaze(const HazePointer& haze); const HazePointer& getHaze() const { valid(); return _haze; } protected: BackgroundMode _backgroundMode = SKY_DEFAULT; + HazeMode _hazeMode = HAZE_OFF; + float _hazeRange; + float _hazeAltitude; LightPointer _sunLight; mutable SkyboxPointer _skybox; diff --git a/libraries/script-engine/src/SceneScriptingInterface.cpp b/libraries/script-engine/src/SceneScriptingInterface.cpp index 9c8eb79b49..953fafcd23 100644 --- a/libraries/script-engine/src/SceneScriptingInterface.cpp +++ b/libraries/script-engine/src/SceneScriptingInterface.cpp @@ -150,6 +150,22 @@ QString SceneScripting::Stage::getHazeMode() const { }; } +void SceneScripting::Stage::setHazeRange(const float hazeRange) { + _skyStage->setHazeRange(hazeRange); +} + +float SceneScripting::Stage::getHazeRange() const { + return _skyStage->getHazeRange(); +} + +void SceneScripting::Stage::setHazeAltitude(const float hazeAltitude) { + _skyStage->setHazeAltitude(hazeAltitude); +} + +float SceneScripting::Stage::getHazeAltitude() const { + return _skyStage->getHazeAltitude(); +} + 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 9eb9a59ce3..342f2c548c 100644 --- a/libraries/script-engine/src/SceneScriptingInterface.h +++ b/libraries/script-engine/src/SceneScriptingInterface.h @@ -125,6 +125,14 @@ namespace SceneScripting { 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(float hazeAltitude READ getHazeAltitude WRITE setHazeAltitude) + void setHazeAltitude(float value); + float getHazeAltitude() const; + protected: model::SunSkyStagePointer _skyStage; LocationPointer _location; diff --git a/scripts/system/html/entityProperties.html b/scripts/system/html/entityProperties.html index c16f214213..5859733f86 100644 --- a/scripts/system/html/entityProperties.html +++ b/scripts/system/html/entityProperties.html @@ -555,6 +555,12 @@ +
+
+
+
+
+
diff --git a/scripts/system/html/js/entityProperties.js b/scripts/system/html/js/entityProperties.js index caaf56f7bb..ad190c47ef 100644 --- a/scripts/system/html/js/entityProperties.js +++ b/scripts/system/html/js/entityProperties.js @@ -658,6 +658,8 @@ function loaded() { var elZoneKeyLightAmbientURL = document.getElementById("property-zone-key-ambient-url"); var elZoneHazeMode = document.getElementById("property-zone-haze-mode"); + var elZoneHazeRange = document.getElementById("property-zone-haze-range"); + var elZoneHazeAltitude = document.getElementById("property-zone-haze-altitude"); var elZoneStageLatitude = document.getElementById("property-zone-stage-latitude"); var elZoneStageLongitude = document.getElementById("property-zone-stage-longitude"); @@ -980,6 +982,9 @@ function loaded() { elZoneHazeMode.value = properties.hazeMode; setDropdownText(elZoneHazeMode); + elZoneHazeRange.value = properties.haze.hazeRange.toFixed(2); + elZoneHazeAltitude.value = properties.haze.hazeAltitude.toFixed(2); + elZoneStageLatitude.value = properties.stage.latitude.toFixed(2); elZoneStageLongitude.value = properties.stage.longitude.toFixed(2); elZoneStageAltitude.value = properties.stage.altitude.toFixed(2); @@ -1375,6 +1380,8 @@ function loaded() { elZoneKeyLightDirectionY.addEventListener('change', zoneKeyLightDirectionChangeFunction); elZoneHazeMode.addEventListener('change', createEmitTextPropertyUpdateFunction('hazeMode')); + elZoneHazeRange.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('haze', 'hazeRange')); + elZoneStageLatitude.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('haze', 'hazeAltitude')); elZoneStageLatitude.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('stage', 'latitude')); elZoneStageLongitude.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('stage', 'longitude')); @@ -1383,7 +1390,6 @@ function loaded() { elZoneStageDay.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('stage', 'day')); elZoneStageHour.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('stage', 'hour')); - elZoneBackgroundMode.addEventListener('change', createEmitTextPropertyUpdateFunction('backgroundMode')); var zoneSkyboxColorChangeFunction = createEmitGroupColorPropertyUpdateFunction('skybox', 'color', From f92707a00cfbd35700322a5fe1c2a82a593ba811 Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Tue, 26 Sep 2017 18:08:41 -0700 Subject: [PATCH 10/94] WIP --- .../src/RenderableEntityItem.cpp | 1 + libraries/entities/src/EntityItemProperties.h | 4 ++++ libraries/entities/src/HazePropertyGroup.cpp | 2 +- libraries/entities/src/ZoneEntityItem.cpp | 15 ++++++++++++++- libraries/entities/src/ZoneEntityItem.h | 18 +++++++++++------- libraries/gl/src/gl/GLShaders.cpp | 15 +++++++++------ 6 files changed, 40 insertions(+), 15 deletions(-) diff --git a/libraries/entities-renderer/src/RenderableEntityItem.cpp b/libraries/entities-renderer/src/RenderableEntityItem.cpp index ea514d3181..d472ffc63e 100644 --- a/libraries/entities-renderer/src/RenderableEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableEntityItem.cpp @@ -270,6 +270,7 @@ void EntityRenderer::removeFromScene(const ScenePointer& scene, Transaction& tra Item::clearID(_renderItemID); } +#pragma optimize("", off) void EntityRenderer::updateInScene(const ScenePointer& scene, Transaction& transaction) { if (!isValidRenderItem()) { return; diff --git a/libraries/entities/src/EntityItemProperties.h b/libraries/entities/src/EntityItemProperties.h index 7c1015bb61..bbc3a2e753 100644 --- a/libraries/entities/src/EntityItemProperties.h +++ b/libraries/entities/src/EntityItemProperties.h @@ -178,7 +178,11 @@ public: DEFINE_PROPERTY_REF(PROP_VOXEL_SURFACE_STYLE, VoxelSurfaceStyle, voxelSurfaceStyle, uint16_t, PolyVoxEntityItem::DEFAULT_VOXEL_SURFACE_STYLE); DEFINE_PROPERTY_REF(PROP_NAME, Name, name, QString, ENTITY_ITEM_DEFAULT_NAME); DEFINE_PROPERTY_REF_ENUM(PROP_BACKGROUND_MODE, BackgroundMode, backgroundMode, BackgroundMode, BACKGROUND_MODE_INHERIT); + DEFINE_PROPERTY_REF_ENUM(PROP_HAZE_MODE, HazeMode, hazeMode, HazeMode, HAZE_MODE_INHERIT); + DEFINE_PROPERTY(PROP_HAZE_HAZE_RANGE, HazeRange, hazeRange, float, HazePropertyGroup::DEFAULT_HAZE_RANGE); + DEFINE_PROPERTY(PROP_HAZE_HAZE_ALTITUDE, HazeAltitude, hazeAltitude, float, HazePropertyGroup::DEFAULT_HAZE_ALTITUDE); + DEFINE_PROPERTY_GROUP(Skybox, skybox, SkyboxPropertyGroup); DEFINE_PROPERTY_GROUP(Haze, haze, HazePropertyGroup); DEFINE_PROPERTY_GROUP(Stage, stage, StagePropertyGroup); diff --git a/libraries/entities/src/HazePropertyGroup.cpp b/libraries/entities/src/HazePropertyGroup.cpp index 2b4aabed3c..205a1a2765 100644 --- a/libraries/entities/src/HazePropertyGroup.cpp +++ b/libraries/entities/src/HazePropertyGroup.cpp @@ -146,7 +146,7 @@ int HazePropertyGroup::readEntitySubclassDataFromBuffer(const unsigned char* dat int bytesRead = 0; const unsigned char* dataAt = data; - READ_ENTITY_PROPERTY(PROP_HAZE_HAZE_ALTITUDE, float, setHazeRange); + READ_ENTITY_PROPERTY(PROP_HAZE_HAZE_RANGE, float, setHazeRange); READ_ENTITY_PROPERTY(PROP_HAZE_HAZE_ALTITUDE, float, setHazeAltitude); return bytesRead; diff --git a/libraries/entities/src/ZoneEntityItem.cpp b/libraries/entities/src/ZoneEntityItem.cpp index 9a5573bd39..2d2f3c9051 100644 --- a/libraries/entities/src/ZoneEntityItem.cpp +++ b/libraries/entities/src/ZoneEntityItem.cpp @@ -44,7 +44,6 @@ ZoneEntityItem::ZoneEntityItem(const EntityItemID& entityItemID) : EntityItem(en _compoundShapeURL = DEFAULT_COMPOUND_SHAPE_URL; _backgroundMode = BACKGROUND_MODE_INHERIT; - _hazeMode = HAZE_MODE_INHERIT; } EntityItemProperties ZoneEntityItem::getProperties(EntityPropertyFlags desiredProperties) const { @@ -60,6 +59,7 @@ EntityItemProperties ZoneEntityItem::getProperties(EntityPropertyFlags desiredPr COPY_ENTITY_PROPERTY_TO_PROPERTIES(shapeType, getShapeType); COPY_ENTITY_PROPERTY_TO_PROPERTIES(compoundShapeURL, getCompoundShapeURL); COPY_ENTITY_PROPERTY_TO_PROPERTIES(backgroundMode, getBackgroundMode); + COPY_ENTITY_PROPERTY_TO_PROPERTIES(hazeMode, getHazeMode); // Contains a QString property, must be synchronized @@ -107,6 +107,7 @@ bool ZoneEntityItem::setSubClassProperties(const EntityItemProperties& propertie SET_ENTITY_PROPERTY_FROM_PROPERTIES(shapeType, setShapeType); SET_ENTITY_PROPERTY_FROM_PROPERTIES(compoundShapeURL, setCompoundShapeURL); SET_ENTITY_PROPERTY_FROM_PROPERTIES(backgroundMode, setBackgroundMode); + SET_ENTITY_PROPERTY_FROM_PROPERTIES(hazeMode, setHazeMode); SET_ENTITY_PROPERTY_FROM_PROPERTIES(flyingAllowed, setFlyingAllowed); @@ -149,6 +150,7 @@ int ZoneEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data, READ_ENTITY_PROPERTY(PROP_SHAPE_TYPE, ShapeType, setShapeType); READ_ENTITY_PROPERTY(PROP_COMPOUND_SHAPE_URL, QString, setCompoundShapeURL); READ_ENTITY_PROPERTY(PROP_BACKGROUND_MODE, BackgroundMode, setBackgroundMode); + READ_ENTITY_PROPERTY(PROP_BACKGROUND_MODE, HazeMode, setHazeMode); int bytesFromSkybox; @@ -223,6 +225,7 @@ void ZoneEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBits APPEND_ENTITY_PROPERTY(PROP_SHAPE_TYPE, (uint32_t)getShapeType()); APPEND_ENTITY_PROPERTY(PROP_COMPOUND_SHAPE_URL, getCompoundShapeURL()); APPEND_ENTITY_PROPERTY(PROP_BACKGROUND_MODE, (uint32_t)getBackgroundMode()); // could this be a uint16?? + APPEND_ENTITY_PROPERTY(PROP_HAZE_MODE, (uint32_t)getHazeMode()); _skyboxProperties.appendSubclassData(packetData, params, modelTreeElementExtraEncodeData, requestedProperties, @@ -317,3 +320,13 @@ void ZoneEntityItem::resetRenderingPropertiesChanged() { _stagePropertiesChanged = false; }); } + +void ZoneEntityItem::setHazeMode(HazeMode value) { + _hazeMode = value; + _hazePropertiesChanged = true; +} + +HazeMode ZoneEntityItem::getHazeMode() const { + return _hazeMode; +} + diff --git a/libraries/entities/src/ZoneEntityItem.h b/libraries/entities/src/ZoneEntityItem.h index 3b6eca03c1..744cf24cac 100644 --- a/libraries/entities/src/ZoneEntityItem.h +++ b/libraries/entities/src/ZoneEntityItem.h @@ -69,12 +69,12 @@ public: void setBackgroundMode(BackgroundMode value) { _backgroundMode = value; _backgroundPropertiesChanged = true; } BackgroundMode getBackgroundMode() const { return _backgroundMode; } - void setHazeMode(HazeMode value) { _hazeMode = value; _hazePropertiesChanged = true; } - HazeMode getHazeMode() const { return _hazeMode; } + void setHazeMode(HazeMode value); + HazeMode getHazeMode() const; SkyboxPropertyGroup getSkyboxProperties() const { return resultWithReadLock([&] { return _skyboxProperties; }); } - HazePropertyGroup getHazeProperties() const { return resultWithReadLock([&] { return _hazeProperties; }); } + const HazePropertyGroup& getHazeProperties() const { return _hazeProperties; } const StagePropertyGroup& getStageProperties() const { return _stageProperties; } @@ -88,7 +88,12 @@ public: bool keyLightPropertiesChanged() const { return _keyLightPropertiesChanged; } bool backgroundPropertiesChanged() const { return _backgroundPropertiesChanged; } bool skyboxPropertiesChanged() const { return _skyboxPropertiesChanged; } - bool hazePropertiesChanged() const { return _hazePropertiesChanged; } + +#pragma optimize("", off) + bool hazePropertiesChanged() const { + return _hazePropertiesChanged; + } + bool stagePropertiesChanged() const { return _stagePropertiesChanged; } void resetRenderingPropertiesChanged(); @@ -114,9 +119,8 @@ protected: QString _compoundShapeURL; BackgroundMode _backgroundMode = BACKGROUND_MODE_INHERIT; - HazeMode _hazeMode = HAZE_MODE_INHERIT; - float _hazeRange = 1000.0; - float _hazeAltitude = 200.0; + + HazeMode _hazeMode{ HAZE_MODE_INHERIT }; SkyboxPropertyGroup _skyboxProperties; HazePropertyGroup _hazeProperties; diff --git a/libraries/gl/src/gl/GLShaders.cpp b/libraries/gl/src/gl/GLShaders.cpp index 8ef0198676..4b82803d2c 100644 --- a/libraries/gl/src/gl/GLShaders.cpp +++ b/libraries/gl/src/gl/GLShaders.cpp @@ -2,6 +2,9 @@ #include "GLLogging.h" +#include +#include + namespace gl { @@ -38,15 +41,15 @@ namespace gl { if (!compiled) { // save the source code to a temp file so we can debug easily - /* + std::ofstream filestream; - filestream.open("debugshader.glsl"); + filestream.open("D:\\debugshader.glsl"); if (filestream.is_open()) { filestream << srcstr[0]; filestream << srcstr[1]; filestream.close(); } - */ + GLint infoLength = 0; glGetShaderiv(glshader, GL_INFO_LOG_LENGTH, &infoLength); @@ -55,13 +58,13 @@ namespace gl { glGetShaderInfoLog(glshader, infoLength, NULL, temp); - /* - filestream.open("debugshader.glsl.info.txt"); + + filestream.open("D:\\debugshader.glsl.info.txt"); if (filestream.is_open()) { filestream << std::string(temp); filestream.close(); } - */ + qCWarning(glLogging) << "GLShader::compileShader - failed to compile the gl shader object:"; for (auto s : srcstr) { From 2394d0931cc053eda2fefa19bac31a46fdc4b4a6 Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Tue, 26 Sep 2017 19:05:11 -0700 Subject: [PATCH 11/94] Adding HazeStage --- .../src/RenderableEntityItem.cpp | 1 - libraries/entities/src/ZoneEntityItem.h | 1 - libraries/render-utils/src/HazeStage.cpp | 63 ++++++++++++++ libraries/render-utils/src/HazeStage.h | 82 +++++++++++++++++++ 4 files changed, 145 insertions(+), 2 deletions(-) create mode 100644 libraries/render-utils/src/HazeStage.cpp create mode 100644 libraries/render-utils/src/HazeStage.h diff --git a/libraries/entities-renderer/src/RenderableEntityItem.cpp b/libraries/entities-renderer/src/RenderableEntityItem.cpp index d472ffc63e..ea514d3181 100644 --- a/libraries/entities-renderer/src/RenderableEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableEntityItem.cpp @@ -270,7 +270,6 @@ void EntityRenderer::removeFromScene(const ScenePointer& scene, Transaction& tra Item::clearID(_renderItemID); } -#pragma optimize("", off) void EntityRenderer::updateInScene(const ScenePointer& scene, Transaction& transaction) { if (!isValidRenderItem()) { return; diff --git a/libraries/entities/src/ZoneEntityItem.h b/libraries/entities/src/ZoneEntityItem.h index 744cf24cac..344c9df553 100644 --- a/libraries/entities/src/ZoneEntityItem.h +++ b/libraries/entities/src/ZoneEntityItem.h @@ -89,7 +89,6 @@ public: bool backgroundPropertiesChanged() const { return _backgroundPropertiesChanged; } bool skyboxPropertiesChanged() const { return _skyboxPropertiesChanged; } -#pragma optimize("", off) bool hazePropertiesChanged() const { return _hazePropertiesChanged; } diff --git a/libraries/render-utils/src/HazeStage.cpp b/libraries/render-utils/src/HazeStage.cpp new file mode 100644 index 0000000000..a72c9d7254 --- /dev/null +++ b/libraries/render-utils/src/HazeStage.cpp @@ -0,0 +1,63 @@ +// +// HazeStage.cpp +// +// Created by Nissim Hadar on 9/26/2017. +// Copyright 2015 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 +// +#include "HazeStage.h" + +#include "DeferredLightingEffect.h" + +#include + +std::string HazeStage::_stageName { "HAZE_STAGE"}; + +HazeStage::Index HazeStage::findHaze(const HazePointer& haze) const { + auto found = _hazeMap.find(haze); + if (found != _hazeMap.end()) { + return INVALID_INDEX; + } else { + return (*found).second; + } + +} + +HazeStage::Index HazeStage::addHaze(const HazePointer& haze) { + + auto found = _hazeMap.find(haze); + if (found == _hazeMap.end()) { + auto hazeId = _hazes.newElement(haze); + // Avoid failing to allocate a haze, just pass + if (hazeId != INVALID_INDEX) { + + // Insert the haze and its index in the reverse map + _hazeMap.insert(HazeMap::value_type(haze, hazeId)); + } + return hazeId; + } else { + return (*found).second; + } +} + +HazeStage::HazePointer HazeStage::removeHaze(Index index) { + HazePointer removed = _hazes.freeElement(index); + + if (removed) { + _hazeMap.erase(removed); + } + return removed; +} + +HazeStageSetup::HazeStageSetup() { +} + +void HazeStageSetup::run(const render::RenderContextPointer& renderContext) { + auto stage = renderContext->_scene->getStage(HazeStage::getName()); + if (!stage) { + renderContext->_scene->resetStage(HazeStage::getName(), std::make_shared()); + } +} + diff --git a/libraries/render-utils/src/HazeStage.h b/libraries/render-utils/src/HazeStage.h new file mode 100644 index 0000000000..e920326380 --- /dev/null +++ b/libraries/render-utils/src/HazeStage.h @@ -0,0 +1,82 @@ +// +// HazeStage.h + +// Created by Nissim Hadar on 9/26/2017. +// Copyright 2015 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_render_utils_HazeStage_h +#define hifi_render_utils_HazeStage_h + +#include +#include +#include +#include +#include + +#include "LightingModel.h" + +// Haze stage to set up haze-related rendering tasks +class HazeStage : public render::Stage { +public: + static std::string _stageName; + static const std::string& getName() { return _stageName; } + + using Index = render::indexed_container::Index; + static const Index INVALID_INDEX { render::indexed_container::INVALID_INDEX }; + static bool isIndexInvalid(Index index) { return index == INVALID_INDEX; } + + using HazePointer = model::SunSkyStagePointer; + using Hazes = render::indexed_container::IndexedPointerVector; + using HazeMap = std::unordered_map; + + using HazeIndices = std::vector; + + + Index findHaze(const HazePointer& haze) const; + Index addHaze(const HazePointer& haze); + + HazePointer removeHaze(Index index); + + bool checkHazeId(Index index) const { return _hazes.checkIndex(index); } + + Index getNumHazes() const { return _hazes.getNumElements(); } + Index getNumFreeHazes() const { return _hazes.getNumFreeIndices(); } + Index getNumAllocatedHazes() const { return _hazes.getNumAllocatedIndices(); } + + HazePointer getHaze(Index hazeId) const { + return _hazes.get(hazeId); + } + + Hazes _hazes; + HazeMap _hazeMap; + + class Frame { + public: + Frame() {} + + void clear() { _hazes.clear(); } + + void pushHaze(HazeStage::Index index) { _hazes.emplace_back(index); } + + HazeStage::HazeIndices _hazes; + }; + + Frame _currentFrame; +}; +using HazeStagePointer = std::shared_ptr; + +class HazeStageSetup { +public: + using JobModel = render::Job::Model; + + HazeStageSetup(); + void run(const render::RenderContextPointer& renderContext); + +protected: +}; + +#endif From 4d501d6510dad6e56d77cd1a1135a1d2febb719a Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Wed, 27 Sep 2017 08:01:19 -0700 Subject: [PATCH 12/94] Adding HazeStage --- .../src/RenderableZoneEntityItem.cpp | 24 ++++++++++++++++++- .../src/RenderableZoneEntityItem.h | 8 ++++++- libraries/model/src/model/Haze.h | 2 +- libraries/render-utils/src/HazeStage.h | 4 ++-- .../render-utils/src/UpdateSceneTask.cpp | 2 ++ 5 files changed, 35 insertions(+), 5 deletions(-) diff --git a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp index eecc06e3dc..8b0a7e9f88 100644 --- a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp @@ -52,6 +52,12 @@ void ZoneEntityRenderer::onRemoveFromSceneTyped(const TypedEntityPointer& entity _backgroundStage->removeBackground(_backgroundIndex); } } + + if (_hazeStage) { + if (!HazeStage::isIndexInvalid(_hazeIndex)) { + _hazeStage->removeHaze(_hazeIndex); + } + } } void ZoneEntityRenderer::doRender(RenderArgs* args) { @@ -95,6 +101,11 @@ void ZoneEntityRenderer::doRender(RenderArgs* args) { assert(_backgroundStage); } + if (!_hazeStage) { + _hazeStage = args->_scene->getStage(); + assert(_hazeStage); + } + { // Sun // Need an update ? if (_needSunUpdate) { @@ -129,11 +140,22 @@ void ZoneEntityRenderer::doRender(RenderArgs* args) { if (_needBackgroundUpdate) { if (BackgroundStage::isIndexInvalid(_backgroundIndex)) { _backgroundIndex = _backgroundStage->addBackground(_background); - } else { + } + else { } _needBackgroundUpdate = false; } + + if (_needHazeUpdate) { + if (HazeStage::isIndexInvalid(_hazeIndex)) { + _hazeIndex = _hazeStage->addHaze(_haze); + } + else { + + } + _needHazeUpdate = false; + } } if (_visible) { diff --git a/libraries/entities-renderer/src/RenderableZoneEntityItem.h b/libraries/entities-renderer/src/RenderableZoneEntityItem.h index faff8e2daa..c955e07d11 100644 --- a/libraries/entities-renderer/src/RenderableZoneEntityItem.h +++ b/libraries/entities-renderer/src/RenderableZoneEntityItem.h @@ -18,6 +18,7 @@ #include #include #include +#include #include #include "RenderableEntityItem.h" #if 0 @@ -60,7 +61,7 @@ private: model::LightPointer editAmbientLight() { _needAmbientUpdate = true; return _ambientLight; } model::SunSkyStagePointer editBackground() { _needBackgroundUpdate = true; return _background; } model::SkyboxPointer editSkybox() { return editBackground()->getSkybox(); } - model::HazePointer editHaze() { return editBackground()->getHaze(); } + model::HazePointer editHaze() { _needHazeUpdate = true; return _haze; } bool _needsInitialSimulation{ true }; glm::vec3 _lastPosition; @@ -79,6 +80,7 @@ private: const model::LightPointer _sunLight{ std::make_shared() }; const model::LightPointer _ambientLight{ std::make_shared() }; const model::SunSkyStagePointer _background{ std::make_shared() }; + const model::HazePointer _haze{ std::make_shared() }; BackgroundMode _backgroundMode{ BACKGROUND_MODE_INHERIT }; HazeMode _hazeMode{ HAZE_MODE_INHERIT }; @@ -88,10 +90,14 @@ private: BackgroundStagePointer _backgroundStage; BackgroundStage::Index _backgroundIndex{ BackgroundStage::INVALID_INDEX }; + HazeStagePointer _hazeStage; + HazeStage::Index _hazeIndex{ HazeStage::INVALID_INDEX }; + bool _needUpdate{ true }; bool _needSunUpdate{ true }; bool _needAmbientUpdate{ true }; bool _needBackgroundUpdate{ true }; + bool _needHazeUpdate{ true }; KeyLightPropertyGroup _keyLightProperties; SkyboxPropertyGroup _skyboxProperties; diff --git a/libraries/model/src/model/Haze.h b/libraries/model/src/model/Haze.h index de026bd4ea..60fa59a5ba 100644 --- a/libraries/model/src/model/Haze.h +++ b/libraries/model/src/model/Haze.h @@ -110,6 +110,6 @@ namespace model { UniformBufferView _parametersBuffer; }; - using HazePointer = std::shared_ptr; + typedef std::shared_ptr HazePointer; } #endif // hifi_model_Haze_h diff --git a/libraries/render-utils/src/HazeStage.h b/libraries/render-utils/src/HazeStage.h index e920326380..15b65d9ab7 100644 --- a/libraries/render-utils/src/HazeStage.h +++ b/libraries/render-utils/src/HazeStage.h @@ -29,8 +29,8 @@ public: static const Index INVALID_INDEX { render::indexed_container::INVALID_INDEX }; static bool isIndexInvalid(Index index) { return index == INVALID_INDEX; } - using HazePointer = model::SunSkyStagePointer; - using Hazes = render::indexed_container::IndexedPointerVector; + using HazePointer = model::HazePointer; + using Hazes = render::indexed_container::IndexedPointerVector; using HazeMap = std::unordered_map; using HazeIndices = std::vector; diff --git a/libraries/render-utils/src/UpdateSceneTask.cpp b/libraries/render-utils/src/UpdateSceneTask.cpp index 0e0c3f087b..06e02907f2 100644 --- a/libraries/render-utils/src/UpdateSceneTask.cpp +++ b/libraries/render-utils/src/UpdateSceneTask.cpp @@ -13,12 +13,14 @@ #include #include "LightStage.h" #include "BackgroundStage.h" +#include "HazeStage.h" #include #include "DeferredLightingEffect.h" void UpdateSceneTask::build(JobModel& task, const render::Varying& input, render::Varying& output) { task.addJob("LightStageSetup"); task.addJob("BackgroundStageSetup"); + task.addJob("HazeStageSetup"); task.addJob("TransitionStageSetup"); task.addJob("DefaultLightingSetup"); From eaab056d66df3b4133ec614972888077b0713cb8 Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Wed, 27 Sep 2017 09:12:57 -0700 Subject: [PATCH 13/94] Adding HazeStage --- libraries/model/src/model/Stage.cpp | 5 ----- libraries/model/src/model/Stage.h | 3 --- .../render-utils/src/DeferredLightingEffect.cpp | 14 +++++++++++++- .../render-utils/src/DeferredLightingEffect.h | 3 +++ 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/libraries/model/src/model/Stage.cpp b/libraries/model/src/model/Stage.cpp index b24b58e7cf..d09323d07b 100644 --- a/libraries/model/src/model/Stage.cpp +++ b/libraries/model/src/model/Stage.cpp @@ -262,8 +262,3 @@ void SunSkyStage::setHazeMode(HazeMode mode) { _hazeMode = mode; invalidate(); } - -void SunSkyStage::setHaze(const HazePointer& haze) { - _haze = haze; - invalidate(); -} diff --git a/libraries/model/src/model/Stage.h b/libraries/model/src/model/Stage.h index 6935f51657..fe5e9e2a78 100644 --- a/libraries/model/src/model/Stage.h +++ b/libraries/model/src/model/Stage.h @@ -192,9 +192,6 @@ public: void setHazeAltitude(float hazeAltitude) { _hazeAltitude = hazeAltitude; } float getHazeAltitude() const { return _hazeAltitude; } - void setHaze(const HazePointer& haze); - const HazePointer& getHaze() const { valid(); return _haze; } - protected: BackgroundMode _backgroundMode = SKY_DEFAULT; diff --git a/libraries/render-utils/src/DeferredLightingEffect.cpp b/libraries/render-utils/src/DeferredLightingEffect.cpp index 2b5fdc1d74..c07fd0d6c4 100644 --- a/libraries/render-utils/src/DeferredLightingEffect.cpp +++ b/libraries/render-utils/src/DeferredLightingEffect.cpp @@ -720,7 +720,7 @@ void DefaultLightingSetup::run(const RenderContextPointer& renderContext) { } auto lightStage = renderContext->_scene->getStage(); - if (lightStage) { + if (lightStage) { // Allocate a default global light directional and ambient auto lp = std::make_shared(); @@ -759,5 +759,17 @@ void DefaultLightingSetup::run(const RenderContextPointer& renderContext) { _defaultBackgroundID = backgroundStage->addBackground(_defaultBackground); } } + + if (_defaultHaze == nullptr) { + auto hazeStage = renderContext->_scene->getStage(); + if (hazeStage) { + + auto haze = std::make_shared(); + haze->setIsHazeActive(false); + + _defaultHaze = haze; + _defaultHazeID = hazeStage->addHaze(_defaultHaze); + } + } } diff --git a/libraries/render-utils/src/DeferredLightingEffect.h b/libraries/render-utils/src/DeferredLightingEffect.h index a4d62ea407..1f8ba88e27 100644 --- a/libraries/render-utils/src/DeferredLightingEffect.h +++ b/libraries/render-utils/src/DeferredLightingEffect.h @@ -31,6 +31,7 @@ #include "LightStage.h" #include "LightClusters.h" #include "BackgroundStage.h" +#include "HazeStage.h" #include "SurfaceGeometryPass.h" #include "SubsurfaceScattering.h" @@ -182,7 +183,9 @@ protected: model::LightPointer _defaultLight; LightStage::Index _defaultLightID{ LightStage::INVALID_INDEX }; model::SunSkyStagePointer _defaultBackground; + model::HazePointer _defaultHaze{ nullptr }; BackgroundStage::Index _defaultBackgroundID{ BackgroundStage::INVALID_INDEX }; + HazeStage::Index _defaultHazeID{ HazeStage::INVALID_INDEX }; model::SkyboxPointer _defaultSkybox { new ProceduralSkybox() }; gpu::TexturePointer _defaultSkyboxTexture; gpu::TexturePointer _defaultSkyboxAmbientTexture; From 55fafeacb15fc150562a2043b106039f4aef8e0f Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Wed, 27 Sep 2017 17:43:09 -0700 Subject: [PATCH 14/94] Implemented HazePropertyGroup and added the haze shader. Shader does not work yet! --- .../src/RenderableZoneEntityItem.cpp | 1 + .../src/RenderableZoneEntityItem.h | 1 + .../entities/src/EntityItemProperties.cpp | 4 +- libraries/entities/src/EntityItemProperties.h | 4 +- libraries/entities/src/EntityPropertyFlags.h | 17 +- libraries/entities/src/HazePropertyGroup.cpp | 255 ++++++++++++++++-- libraries/entities/src/HazePropertyGroup.h | 37 ++- libraries/model/src/model/Haze.h | 92 ++++--- libraries/render-utils/src/DrawHaze.cpp | 151 +++++++++++ libraries/render-utils/src/DrawHaze.h | 95 +++++++ libraries/render-utils/src/Haze.slf | 143 ++++++++++ libraries/render-utils/src/Haze.slh | 44 +++ libraries/render-utils/src/HazeStage.cpp | 11 +- libraries/render-utils/src/HazeStage.h | 14 +- .../render-utils/src/RenderDeferredTask.cpp | 13 +- .../src/directional_skybox_light.slf | 2 +- 16 files changed, 798 insertions(+), 86 deletions(-) create mode 100644 libraries/render-utils/src/DrawHaze.cpp create mode 100644 libraries/render-utils/src/DrawHaze.h create mode 100644 libraries/render-utils/src/Haze.slf create mode 100644 libraries/render-utils/src/Haze.slh diff --git a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp index 8b0a7e9f88..6ee0e86fe8 100644 --- a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp @@ -60,6 +60,7 @@ void ZoneEntityRenderer::onRemoveFromSceneTyped(const TypedEntityPointer& entity } } +#pragma optimize("", off); void ZoneEntityRenderer::doRender(RenderArgs* args) { #if 0 if (ZoneEntityItem::getDrawZoneBoundaries()) { diff --git a/libraries/entities-renderer/src/RenderableZoneEntityItem.h b/libraries/entities-renderer/src/RenderableZoneEntityItem.h index c955e07d11..26403a2483 100644 --- a/libraries/entities-renderer/src/RenderableZoneEntityItem.h +++ b/libraries/entities-renderer/src/RenderableZoneEntityItem.h @@ -81,6 +81,7 @@ private: const model::LightPointer _ambientLight{ std::make_shared() }; const model::SunSkyStagePointer _background{ std::make_shared() }; const model::HazePointer _haze{ std::make_shared() }; + BackgroundMode _backgroundMode{ BACKGROUND_MODE_INHERIT }; HazeMode _hazeMode{ HAZE_MODE_INHERIT }; diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp index c2a0f67a61..868f5a6dd7 100644 --- a/libraries/entities/src/EntityItemProperties.cpp +++ b/libraries/entities/src/EntityItemProperties.cpp @@ -1073,8 +1073,8 @@ void EntityItemProperties::entityPropertyFlagsFromScriptValue(const QScriptValue ADD_GROUP_PROPERTY_TO_MAP(PROP_SKYBOX_COLOR, Skybox, skybox, Color, color); ADD_GROUP_PROPERTY_TO_MAP(PROP_SKYBOX_URL, Skybox, skybox, URL, url); - ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_HAZE_RANGE, Haze, haze, HazeRange, hazeRange); - ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_HAZE_ALTITUDE, Haze, haze, HazeAltitude, hazeAltitude); + ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_RANGE, Haze, haze, HazeRange, hazeRange); + ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_ALTITUDE, Haze, haze, HazeAltitude, hazeAltitude); ADD_GROUP_PROPERTY_TO_MAP(PROP_STAGE_SUN_MODEL_ENABLED, Stage, stage, SunModelEnabled, sunModelEnabled); ADD_GROUP_PROPERTY_TO_MAP(PROP_STAGE_LATITUDE, Stage, stage, Latitude, latitude); diff --git a/libraries/entities/src/EntityItemProperties.h b/libraries/entities/src/EntityItemProperties.h index bbc3a2e753..25799fcc0c 100644 --- a/libraries/entities/src/EntityItemProperties.h +++ b/libraries/entities/src/EntityItemProperties.h @@ -180,8 +180,8 @@ public: DEFINE_PROPERTY_REF_ENUM(PROP_BACKGROUND_MODE, BackgroundMode, backgroundMode, BackgroundMode, BACKGROUND_MODE_INHERIT); DEFINE_PROPERTY_REF_ENUM(PROP_HAZE_MODE, HazeMode, hazeMode, HazeMode, HAZE_MODE_INHERIT); - DEFINE_PROPERTY(PROP_HAZE_HAZE_RANGE, HazeRange, hazeRange, float, HazePropertyGroup::DEFAULT_HAZE_RANGE); - DEFINE_PROPERTY(PROP_HAZE_HAZE_ALTITUDE, HazeAltitude, hazeAltitude, float, HazePropertyGroup::DEFAULT_HAZE_ALTITUDE); + DEFINE_PROPERTY(PROP_HAZE_RANGE, HazeRange, hazeRange, float, HazePropertyGroup::DEFAULT_HAZE_RANGE); + DEFINE_PROPERTY(PROP_HAZE_ALTITUDE, HazeAltitude, hazeAltitude, float, HazePropertyGroup::DEFAULT_HAZE_ALTITUDE); DEFINE_PROPERTY_GROUP(Skybox, skybox, SkyboxPropertyGroup); DEFINE_PROPERTY_GROUP(Haze, haze, HazePropertyGroup); diff --git a/libraries/entities/src/EntityPropertyFlags.h b/libraries/entities/src/EntityPropertyFlags.h index e3076e57ee..46fb31d7aa 100644 --- a/libraries/entities/src/EntityPropertyFlags.h +++ b/libraries/entities/src/EntityPropertyFlags.h @@ -219,9 +219,22 @@ enum EntityPropertyList { PROP_STAGE_HOUR = PROP_QUADRATIC_ATTENUATION_UNUSED, PROP_STAGE_AUTOMATIC_HOURDAY = PROP_ANIMATION_FRAME_INDEX, PROP_BACKGROUND_MODE = PROP_MODEL_URL, + PROP_HAZE_MODE = PROP_COLOR, - PROP_HAZE_HAZE_RANGE = PROP_INTENSITY, - PROP_HAZE_HAZE_ALTITUDE = PROP_CUTOFF, + + PROP_HAZE_RANGE = PROP_INTENSITY, + PROP_HAZE_BLEND_IN_COLOR = PROP_CUTOFF, + PROP_HAZE_BLEND_OUT_COLOR = PROP_EXPONENT, + PROP_HAZE_LIGHT_BLEND_ANGLE = PROP_IS_SPOTLIGHT, + + PROP_HAZE_ALTITUDE = PROP_DIFFUSE_COLOR, + PROP_HAZE_BASE_REF = PROP_AMBIENT_COLOR_UNUSED, + + PROP_HAZE_BACKGROUND_BLEND = PROP_SPECULAR_COLOR_UNUSED, + + PROP_HAZE_KEYLIGHT_RANGE = PROP_LINEAR_ATTENUATION_UNUSED, + PROP_HAZE_KEYLIGHT_ALTITUDE = PROP_QUADRATIC_ATTENUATION_UNUSED, + 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 205a1a2765..fa7278b2d3 100644 --- a/libraries/entities/src/HazePropertyGroup.cpp +++ b/libraries/entities/src/HazePropertyGroup.cpp @@ -15,41 +15,125 @@ #include "EntityItemProperties.h" #include "EntityItemPropertiesMacros.h" -const float HazePropertyGroup::DEFAULT_HAZE_RANGE = 1000.0f; -const float HazePropertyGroup::DEFAULT_HAZE_ALTITUDE = 200.0f; +const uint8_t HazePropertyGroup::DEFAULT_HAZE_MODE{ 0 }; + +const float HazePropertyGroup::DEFAULT_HAZE_RANGE{ 1000.0f }; +const xColor HazePropertyGroup::DEFAULT_HAZE_BLEND_IN_COLOR{ 128, 154, 179 }; // Bluish +const xColor HazePropertyGroup::DEFAULT_HAZE_BLEND_OUT_COLOR{ 255, 229, 179 }; // Yellowish +const float HazePropertyGroup::DEFAULT_LIGHT_BLEND_ANGLE{ 20.0 }; + +const float HazePropertyGroup::DEFAULT_HAZE_ALTITUDE{ 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_HAZE_RANGE, Haze, haze, HazeRange, hazeRange); - COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_HAZE_ALTITUDE, Haze, haze, HazeAltitude, hazeAltitude); + COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_MODE, Haze, haze, HazeMode, hazeMode); + + COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_BLEND_IN_COLOR, Haze, haze, HazeRange, hazeRange); + COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_BLEND_IN_COLOR, Haze, haze, HazeBlendInColor, hazeBlendIncolor); + COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_BLEND_OUT_COLOR, Haze, haze, HazeBlendOutColor, hazeBlendOutcolor); + COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_LIGHT_BLEND_ANGLE, Haze, haze, HazeLightBlendAngle, hazeLightBlendAngle); + + COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_ALTITUDE, Haze, haze, HazeAltitude, hazeAltitude); + COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_BASE_REF, Haze, haze, HazeBaseRef, hazeBaseRef); + + COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_BACKGROUND_BLEND, Haze, haze, HazeBackgroundBlend, hazeBackgroundBlend); + + COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_KEYLIGHT_RANGE, Haze, haze, HazeKeyLightRange, hazeKeyLightRange); + COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_KEYLIGHT_ALTITUDE, Haze, haze, HazeKeyLightAltitude, hazeKeyLightAltitude); } void HazePropertyGroup::copyFromScriptValue(const QScriptValue& object, bool& _defaultSettings) { - COPY_PROPERTY_FROM_QSCRIPTVALUE_GETTER(hazeHazeRange, float, setHazeRange, getHazeRange); - COPY_PROPERTY_FROM_QSCRIPTVALUE_GETTER(hazeHazeAltitude, float, setHazeAltitude, getHazeAltitude); + COPY_PROPERTY_FROM_QSCRIPTVALUE_GETTER(hazeMode, uint8_t, setHazeMode, getHazeMode); - COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(haze, hazeRange, float, setHazeRange); - COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(haze, hazeAltitude, float, setHazeAltitude); + COPY_PROPERTY_FROM_QSCRIPTVALUE_GETTER(hazeHazeRange, float, setHazeRange, getHazeRange); + COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(haze, hazeBlendInColor, xColor, setHazeBlendInColor); + COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(haze, hazeBlendOutColor, xColor, setHazeBlendOutColor); + COPY_PROPERTY_FROM_QSCRIPTVALUE_GETTER(hazeHazeLightBlendAngle, float, setHazeLightBlendAngle, getHazeLightBlendAngle); + + COPY_PROPERTY_FROM_QSCRIPTVALUE_GETTER(hazeHazeAltitude, float, setHazeAltitude, getHazeAltitude); + COPY_PROPERTY_FROM_QSCRIPTVALUE_GETTER(hazeHazeBaseRef, float, setHazeBaseRef, getHazeBaseRef); + + COPY_PROPERTY_FROM_QSCRIPTVALUE_GETTER(hazeHazeBackgroundBlend, float, setHazeBackgroundBlend, getHazeBackgroundBlend); + + COPY_PROPERTY_FROM_QSCRIPTVALUE_GETTER(hazeHazeKeyLightRange, float, setHazeKeyLightRange, getHazeKeyLightRange); + COPY_PROPERTY_FROM_QSCRIPTVALUE_GETTER(hazeHazeKeyLightAltitude, float, setHazeKeyLightAltitude, getHazeKeyLightAltitude); } void HazePropertyGroup::merge(const HazePropertyGroup& other) { - COPY_PROPERTY_IF_CHANGED(hazeRange); - COPY_PROPERTY_IF_CHANGED(hazeAltitude); -} + COPY_PROPERTY_IF_CHANGED(hazeMode); + COPY_PROPERTY_IF_CHANGED(hazeRange); + COPY_PROPERTY_IF_CHANGED(hazeBlendInColor); + COPY_PROPERTY_IF_CHANGED(hazeBlendOutColor); + COPY_PROPERTY_IF_CHANGED(hazeLightBlendAngle); + + COPY_PROPERTY_IF_CHANGED(hazeAltitude); + COPY_PROPERTY_IF_CHANGED(hazeBaseRef); + + COPY_PROPERTY_IF_CHANGED(hazeBackgroundBlend); + + COPY_PROPERTY_IF_CHANGED(hazeKeyLightRange); + COPY_PROPERTY_IF_CHANGED(hazeKeyLightAltitude); +} void HazePropertyGroup::debugDump() const { qCDebug(entities) << " HazePropertyGroup: ---------------------------------------------"; + qCDebug(entities) << " _hazeMode:" << _hazeMode; + qCDebug(entities) << " _hazeRange:" << _hazeRange; + qCDebug(entities) << " _hazeBlendInColor:" << _hazeBlendInColor; + qCDebug(entities) << " _hazeBlendOutColor:" << _hazeBlendInColor; + qCDebug(entities) << " _hazeLightBlendAngle:" << _hazeLightBlendAngle; + qCDebug(entities) << " _hazeAltitude:" << _hazeAltitude; + qCDebug(entities) << " _hazeBaseRef:" << _hazeBaseRef; + + qCDebug(entities) << " _hazeBackgroundBlend:" << _hazeBackgroundBlend; + + qCDebug(entities) << " _hazeKeyLightRange:" << _hazeKeyLightRange; + qCDebug(entities) << " _hazeKeyLightAltitude:" << _hazeKeyLightAltitude; } void HazePropertyGroup::listChangedProperties(QList& out) { + if (hazeModeChanged()) { + out << "haze-mode"; + } + if (hazeRangeChanged()) { out << "haze-range"; } + if (hazeBlendInColorChanged()) { + out << "haze-blendInColor"; + } + if (hazeBlendOutColorChanged()) { + out << "haze-blendOutColor"; + } + if (hazeLightBlendAngleChanged()) { + out << "haze-lightBlendAngle"; + } + if (hazeAltitudeChanged()) { out << "haze-altitude"; } + if (hazeBaseRefChanged()) { + out << "haze-baseRef"; + } + + if (hazeBackgroundBlendChanged()) { + out << "haze-backgroundBlend"; + } + + if (hazeKeyLightRangeChanged()) { + out << "haze-keyLightRange"; + } + if (hazeKeyLightAltitudeChanged()) { + out << "haze-keyLightAltitude"; + } } bool HazePropertyGroup::appendToEditPacket(OctreePacketData* packetData, @@ -61,24 +145,59 @@ bool HazePropertyGroup::appendToEditPacket(OctreePacketData* packetData, bool successPropertyFits = true; - APPEND_ENTITY_PROPERTY(PROP_HAZE_HAZE_RANGE, getHazeRange()); - APPEND_ENTITY_PROPERTY(PROP_HAZE_HAZE_ALTITUDE, getHazeAltitude()); + APPEND_ENTITY_PROPERTY(PROP_HAZE_MODE, getHazeMode()); + + APPEND_ENTITY_PROPERTY(PROP_HAZE_RANGE, getHazeRange()); + APPEND_ENTITY_PROPERTY(PROP_HAZE_BLEND_IN_COLOR, getHazeBlendInColor()); + APPEND_ENTITY_PROPERTY(PROP_HAZE_BLEND_OUT_COLOR, getHazeBlendOutColor()); + APPEND_ENTITY_PROPERTY(PROP_HAZE_LIGHT_BLEND_ANGLE, getHazeLightBlendAngle()); + + APPEND_ENTITY_PROPERTY(PROP_HAZE_ALTITUDE, getHazeAltitude()); + APPEND_ENTITY_PROPERTY(PROP_HAZE_BASE_REF, getHazeBaseRef()); + + APPEND_ENTITY_PROPERTY(PROP_HAZE_BACKGROUND_BLEND, getHazeBackgroundBlend()); + + APPEND_ENTITY_PROPERTY(PROP_HAZE_KEYLIGHT_RANGE, getHazeKeyLightRange()); + APPEND_ENTITY_PROPERTY(PROP_HAZE_KEYLIGHT_ALTITUDE, getHazeKeyLightAltitude()); return true; } - bool HazePropertyGroup::decodeFromEditPacket(EntityPropertyFlags& propertyFlags, const unsigned char*& dataAt , int& processedBytes) { int bytesRead = 0; bool overwriteLocalData = true; bool somethingChanged = false; - READ_ENTITY_PROPERTY(PROP_HAZE_HAZE_RANGE, float, setHazeRange); - READ_ENTITY_PROPERTY(PROP_HAZE_HAZE_ALTITUDE, float, setHazeAltitude); + READ_ENTITY_PROPERTY(PROP_HAZE_MODE, uint8_t, setHazeMode); - DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_HAZE_RANGE, HazeRange); - DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_HAZE_ALTITUDE, HazeAltitude); + READ_ENTITY_PROPERTY(PROP_HAZE_RANGE, float, setHazeRange); + READ_ENTITY_PROPERTY(PROP_HAZE_BLEND_IN_COLOR, xColor, setHazeBlendInColor); + READ_ENTITY_PROPERTY(PROP_HAZE_BLEND_OUT_COLOR, xColor, setHazeBlendOutColor); + READ_ENTITY_PROPERTY(PROP_HAZE_LIGHT_BLEND_ANGLE, float, setHazeLightBlendAngle); + + READ_ENTITY_PROPERTY(PROP_HAZE_ALTITUDE, float, setHazeAltitude); + READ_ENTITY_PROPERTY(PROP_HAZE_BASE_REF, float, setHazeBaseRef); + + READ_ENTITY_PROPERTY(PROP_HAZE_BACKGROUND_BLEND, float, setHazeBackgroundBlend); + + READ_ENTITY_PROPERTY(PROP_HAZE_KEYLIGHT_RANGE, float, setHazeKeyLightRange); + READ_ENTITY_PROPERTY(PROP_HAZE_KEYLIGHT_ALTITUDE, float, setHazeKeyLightAltitude); + + DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_RANGE, HazeMode); + + DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_RANGE, HazeRange); + DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_BLEND_IN_COLOR, HazeBlendInColor); + DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_BLEND_OUT_COLOR, HazeBlendOutColor); + DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_LIGHT_BLEND_ANGLE, HazeLightBlendAngle); + + DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_ALTITUDE, HazeAltitude); + DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_BASE_REF, HazeBaseRef); + + DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_BACKGROUND_BLEND, HazeBackgroundBlend); + + DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_KEYLIGHT_RANGE, HazeKeyLightRange); + DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_KEYLIGHT_ALTITUDE, HazeKeyLightAltitude); processedBytes += bytesRead; @@ -88,29 +207,77 @@ bool HazePropertyGroup::decodeFromEditPacket(EntityPropertyFlags& propertyFlags, } void HazePropertyGroup::markAllChanged() { + _hazeModeChanged; + _hazeRangeChanged = true; + _hazeBlendInColorChanged = true; + _hazeBlendOutColorChanged = true; + _hazeLightBlendAngleChanged = true; + + _hazeAltitudeChanged = true; + _hazeBaseRefChanged = true; + + _hazeBackgroundBlendChanged = true; + + _hazeKeyLightRangeChanged = true; _hazeAltitudeChanged = true; } EntityPropertyFlags HazePropertyGroup::getChangedProperties() const { EntityPropertyFlags changedProperties; - CHECK_PROPERTY_CHANGE(PROP_HAZE_HAZE_RANGE, hazeRange); - CHECK_PROPERTY_CHANGE(PROP_HAZE_HAZE_ALTITUDE, hazeAltitude); + CHECK_PROPERTY_CHANGE(PROP_HAZE_MODE, hazeMode); + + CHECK_PROPERTY_CHANGE(PROP_HAZE_RANGE, hazeRange); + CHECK_PROPERTY_CHANGE(PROP_HAZE_BLEND_IN_COLOR, hazeBlendInColor); + CHECK_PROPERTY_CHANGE(PROP_HAZE_BLEND_OUT_COLOR, hazeBlendOutColor); + CHECK_PROPERTY_CHANGE(PROP_HAZE_LIGHT_BLEND_ANGLE, hazeLightBlendAngle); + + CHECK_PROPERTY_CHANGE(PROP_HAZE_ALTITUDE, hazeAltitude); + CHECK_PROPERTY_CHANGE(PROP_HAZE_BASE_REF, hazeBaseRef); + + CHECK_PROPERTY_CHANGE(PROP_HAZE_BACKGROUND_BLEND, hazeBackgroundBlend); + + CHECK_PROPERTY_CHANGE(PROP_HAZE_KEYLIGHT_RANGE, hazeKeyLightRange); + CHECK_PROPERTY_CHANGE(PROP_HAZE_KEYLIGHT_ALTITUDE, hazeKeyLightAltitude); return changedProperties; } void HazePropertyGroup::getProperties(EntityItemProperties& properties) const { + COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Haze, HazeMode, getHazeMode); + COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Haze, HazeRange, getHazeRange); + COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Haze, HazeBlendInColor, getHazeBlendInColor); + COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Haze, HazeBlendOutColor, getHazeBlendOutColor); + COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Haze, HazeLightBlendAngle, getHazeLightBlendAngle); + COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Haze, HazeAltitude, getHazeAltitude); + COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Haze, HazeBaseRef, getHazeBaseRef); + + COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Haze, HazeBackgroundBlend, getHazeBackgroundBlend); + + COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Haze, HazeKeyLightRange, getHazeKeyLightRange); + COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Haze, HazeKeyLightAltitude, getHazeKeyLightAltitude); } bool HazePropertyGroup::setProperties(const EntityItemProperties& properties) { bool somethingChanged = false; + SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Haze, HazeMode, hazeMode, setHazeMode); + SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Haze, HazeRange, hazeRange, setHazeRange); + SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Haze, HazeBlendInColor, hazeBlendInColor, setHazeBlendInColor); + SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Haze, HazeBlendOutColor, hazeBlendOutColor, setHazeBlendOutColor); + SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Haze, HazeLightBlendAngle, hazeLightBlendAngle, setHazeLightBlendAngle); + SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Haze, HazeAltitude, hazeAltitude, setHazeAltitude); + SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Haze, HazeBaseRef, hazeBaseRef, setHazeBaseRef); + + SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Haze, HazeBackgroundBlend, hazeBackgroundBlend, setHazeBackgroundBlend); + + SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Haze, HazeKeyLightRange, hazeKeyLightRange, setHazeKeyLightRange); + SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Haze, HazeKeyLightAltitude, hazeKeyLightAltitude, setHazeKeyLightAltitude); return somethingChanged; } @@ -118,8 +285,20 @@ bool HazePropertyGroup::setProperties(const EntityItemProperties& properties) { EntityPropertyFlags HazePropertyGroup::getEntityProperties(EncodeBitstreamParams& params) const { EntityPropertyFlags requestedProperties; - requestedProperties += PROP_HAZE_HAZE_RANGE; - requestedProperties += PROP_HAZE_HAZE_ALTITUDE; + requestedProperties += PROP_HAZE_MODE; + + requestedProperties += PROP_HAZE_RANGE; + requestedProperties += PROP_HAZE_BLEND_IN_COLOR; + requestedProperties += PROP_HAZE_BLEND_OUT_COLOR; + requestedProperties += PROP_HAZE_LIGHT_BLEND_ANGLE; + + requestedProperties += PROP_HAZE_ALTITUDE; + requestedProperties += PROP_HAZE_BASE_REF; + + requestedProperties += PROP_HAZE_BACKGROUND_BLEND; + + requestedProperties += PROP_HAZE_KEYLIGHT_RANGE; + requestedProperties += PROP_HAZE_KEYLIGHT_ALTITUDE; return requestedProperties; } @@ -134,8 +313,20 @@ void HazePropertyGroup::appendSubclassData(OctreePacketData* packetData, EncodeB bool successPropertyFits = true; - APPEND_ENTITY_PROPERTY(PROP_HAZE_HAZE_RANGE, getHazeRange()); - APPEND_ENTITY_PROPERTY(PROP_HAZE_HAZE_ALTITUDE, getHazeAltitude()); + APPEND_ENTITY_PROPERTY(PROP_HAZE_MODE, getHazeMode()); + + APPEND_ENTITY_PROPERTY(PROP_HAZE_RANGE, getHazeRange()); + APPEND_ENTITY_PROPERTY(PROP_HAZE_BLEND_IN_COLOR, getHazeBlendInColor()); + APPEND_ENTITY_PROPERTY(PROP_HAZE_BLEND_OUT_COLOR, getHazeBlendOutColor()); + APPEND_ENTITY_PROPERTY(PROP_HAZE_LIGHT_BLEND_ANGLE, getHazeLightBlendAngle()); + + APPEND_ENTITY_PROPERTY(PROP_HAZE_ALTITUDE, getHazeAltitude()); + APPEND_ENTITY_PROPERTY(PROP_HAZE_BASE_REF, getHazeBaseRef()); + + APPEND_ENTITY_PROPERTY(PROP_HAZE_BACKGROUND_BLEND, getHazeBackgroundBlend()); + + APPEND_ENTITY_PROPERTY(PROP_HAZE_KEYLIGHT_RANGE, getHazeKeyLightRange()); + APPEND_ENTITY_PROPERTY(PROP_HAZE_KEYLIGHT_ALTITUDE, getHazeKeyLightAltitude()); } int HazePropertyGroup::readEntitySubclassDataFromBuffer(const unsigned char* data, int bytesLeftToRead, @@ -146,8 +337,20 @@ int HazePropertyGroup::readEntitySubclassDataFromBuffer(const unsigned char* dat int bytesRead = 0; const unsigned char* dataAt = data; - READ_ENTITY_PROPERTY(PROP_HAZE_HAZE_RANGE, float, setHazeRange); - READ_ENTITY_PROPERTY(PROP_HAZE_HAZE_ALTITUDE, float, setHazeAltitude); + READ_ENTITY_PROPERTY(PROP_HAZE_MODE, uint8_t, setHazeMode); + + READ_ENTITY_PROPERTY(PROP_HAZE_RANGE, float, setHazeRange); + READ_ENTITY_PROPERTY(PROP_HAZE_BLEND_IN_COLOR, xColor, setHazeBlendInColor); + READ_ENTITY_PROPERTY(PROP_HAZE_BLEND_OUT_COLOR, xColor, setHazeBlendOutColor); + READ_ENTITY_PROPERTY(PROP_HAZE_LIGHT_BLEND_ANGLE, float, setHazeLightBlendAngle); + + READ_ENTITY_PROPERTY(PROP_HAZE_ALTITUDE, float, setHazeAltitude); + READ_ENTITY_PROPERTY(PROP_HAZE_BASE_REF, float, setHazeBaseRef); + + READ_ENTITY_PROPERTY(PROP_HAZE_BACKGROUND_BLEND, float, setHazeBackgroundBlend); + + READ_ENTITY_PROPERTY(PROP_HAZE_KEYLIGHT_RANGE, float, setHazeKeyLightRange); + READ_ENTITY_PROPERTY(PROP_HAZE_KEYLIGHT_ALTITUDE, float, setHazeKeyLightAltitude); return bytesRead; } diff --git a/libraries/entities/src/HazePropertyGroup.h b/libraries/entities/src/HazePropertyGroup.h index f5b3f65bcb..78cf1d6e46 100644 --- a/libraries/entities/src/HazePropertyGroup.h +++ b/libraries/entities/src/HazePropertyGroup.h @@ -74,11 +74,40 @@ public: EntityPropertyFlags& propertyFlags, bool overwriteLocalData, bool& somethingChanged) override; - static const float DEFAULT_HAZE_RANGE; - static const float DEFAULT_HAZE_ALTITUDE; + static const uint8_t DEFAULT_HAZE_MODE; - DEFINE_PROPERTY(PROP_HAZE_HAZE_RANGE, HazeRange, hazeRange, float, DEFAULT_HAZE_RANGE); - DEFINE_PROPERTY(PROP_HAZE_HAZE_ALTITUDE, HazeAltitude, hazeAltitude, float, DEFAULT_HAZE_ALTITUDE); + static const float DEFAULT_HAZE_RANGE; + static const xColor DEFAULT_HAZE_BLEND_IN_COLOR; + static const xColor DEFAULT_HAZE_BLEND_OUT_COLOR; + static const float DEFAULT_LIGHT_BLEND_ANGLE; + + static const float DEFAULT_HAZE_ALTITUDE; + 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; + + // Selects whether haze inherits the mode, is off or the mode (range only, range & altitude...) + DEFINE_PROPERTY(PROP_HAZE_MODE, HazeMode, hazeMode, uint8_t, DEFAULT_HAZE_MODE); + + // Range only parameters + DEFINE_PROPERTY(PROP_HAZE_RANGE, HazeRange, hazeRange, float, DEFAULT_HAZE_RANGE); + DEFINE_PROPERTY_REF(PROP_HAZE_BLEND_IN_COLOR, HazeBlendInColor, hazeBlendInColor, xColor, DEFAULT_HAZE_BLEND_IN_COLOR); + DEFINE_PROPERTY_REF(PROP_HAZE_BLEND_OUT_COLOR, HazeBlendOutColor, hazeBlendOutColor, xColor, DEFAULT_HAZE_BLEND_OUT_COLOR); + DEFINE_PROPERTY(PROP_HAZE_LIGHT_BLEND_ANGLE, HazeLightBlendAngle, hazeLightBlendAngle, float, DEFAULT_LIGHT_BLEND_ANGLE); + + // Range & Altitude parameters + DEFINE_PROPERTY(PROP_HAZE_ALTITUDE, HazeAltitude, hazeAltitude, float, DEFAULT_HAZE_ALTITUDE); + DEFINE_PROPERTY(PROP_HAZE_BASE_REF, HazeBaseRef, hazeBaseRef, float, DEFAULT_HAZE_BASE_REF); + + // Background (skybox) blend value + DEFINE_PROPERTY(PROP_HAZE_BACKGROUND_BLEND, HazeBackgroundBlend, hazeBackgroundBlend, float, DEFAULT_HAZE_BACKGROUND_BLEND); + + // Directional light attenuation + DEFINE_PROPERTY(PROP_HAZE_KEYLIGHT_RANGE, HazeKeyLightRange, hazeKeyLightRange, float, DEFAULT_HAZE_KEYLIGHT_RANGE); + DEFINE_PROPERTY(PROP_HAZE_KEYLIGHT_ALTITUDE, HazeKeyLightAltitude, hazeKeyLightAltitude, float, DEFAULT_HAZE_KEYLIGHT_ALTITUDE); }; #endif // hifi_HazePropertyGroup_h diff --git a/libraries/model/src/model/Haze.h b/libraries/model/src/model/Haze.h index 60fa59a5ba..fee387cd0d 100644 --- a/libraries/model/src/model/Haze.h +++ b/libraries/model/src/model/Haze.h @@ -14,49 +14,51 @@ #include #include "NumericalConstants.h" +const double p_005 = 0.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 +inline float convertHazeRangeToHazeRangeFactor(const float hazeRange_m) { return (float)-log(p_005) / hazeRange_m; } + +inline float convertHazeAltitudeToHazeAltitudeFactor(const float hazeAltitude_m) { + return (float)-log(p_005) / hazeAltitude_m; +} + +// Derivation (s is th 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(0.5) / log(cos(RADIANS_PER_DEGREE * directionalLightAngle)); +} + +const glm::vec3 initialHazeColor{ 0.5, 0.6, 0.7 }; +const float initialDirectionalLightAngle_degs{ 30.0f }; + +const glm::vec3 initialDirectionalLightColor{ 1.0, 0.9, 0.7 }; +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 initialHazeRangeKeyLight_m{ 150.0f }; +const float initialHazeAltitudeKeyLight_m{ 150.0f }; + +const float initialBackgroundBlendValue{ 0.0f }; + +const glm::vec3 initialColorModulationFactor{ + convertHazeRangeToHazeRangeFactor(initialHazeRange_m), + convertHazeRangeToHazeRangeFactor(initialHazeRange_m), + convertHazeRangeToHazeRangeFactor(initialHazeRange_m) +}; + namespace model { - const double p_005 = 0.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 - inline float convertHazeRangeToHazeRangeFactor(const float hazeRange_m) { return (float)-log(p_005) / hazeRange_m; } - - inline float convertHazeAltitudeToHazeAltitudeFactor(const float hazeAltitude_m) { - return (float)-log(p_005) / hazeAltitude_m; - } - - // Derivation (s is th 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(0.5) / log(cos(RADIANS_PER_DEGREE * directionalLightAngle)); - } - - const glm::vec3 initialHazeColor{ 0.5, 0.6, 0.7 }; - const float initialDirectionalLightAngle_degs{ 30.0f }; - - const glm::vec3 initialDirectionalLightColor{ 1.0, 0.9, 0.7 }; - 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 initialHazeRangeKeyLight_m = 150.0f; - const float initialHazeAltitudeKeyLight_m = 150.0f; - - const glm::vec3 initialColorModulationFactor{ - convertHazeRangeToHazeRangeFactor(initialHazeRange_m), - convertHazeRangeToHazeRangeFactor(initialHazeRange_m), - convertHazeRangeToHazeRangeFactor(initialHazeRange_m) - }; - class Haze { public: using UniformBufferView = gpu::BufferView; @@ -80,6 +82,8 @@ namespace model { void setHazeRangeFactorKeyLight(const float hazeRangeKeyLight); void setHazeAltitudeFactorKeyLight(const float hazeAltitudeKeyLight); + void setBackgroundBlendValue(const float backgroundBlendValue); + UniformBufferView getParametersBuffer() const { return _parametersBuffer; } protected: @@ -97,19 +101,21 @@ namespace model { // bit 1 - set to add the effect of altitude to the haze attenuation // bit 2 - set to activate directional light attenuation mode - // The haze attenuation exponents used by both fragment and directional light attenuation + // The haze attenuation exponents used by both fragment and directional light attenuation float hazeRangeFactor{ convertHazeRangeToHazeRangeFactor(initialHazeRange_m) }; float hazeAltitudeFactor{ convertHazeAltitudeToHazeAltitudeFactor(initialHazeAltitude_m) }; float hazeRangeFactorKeyLight{ convertHazeRangeToHazeRangeFactor(initialHazeRangeKeyLight_m) }; float hazeAltitudeFactorKeyLight{ convertHazeAltitudeToHazeAltitudeFactor(initialHazeAltitudeKeyLight_m) }; + float backgroundBlendValue{ initialBackgroundBlendValue }; + Parameters() {} }; UniformBufferView _parametersBuffer; }; - typedef std::shared_ptr HazePointer; + using HazePointer = std::shared_ptr; } #endif // hifi_model_Haze_h diff --git a/libraries/render-utils/src/DrawHaze.cpp b/libraries/render-utils/src/DrawHaze.cpp new file mode 100644 index 0000000000..33db0c1f6c --- /dev/null +++ b/libraries/render-utils/src/DrawHaze.cpp @@ -0,0 +1,151 @@ +// +// DrawHaze.cpp +// libraries/render-utils/src +// +// Created by Nissim Hadar on 9/1/2017. +// Copyright 2015 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 +// + +#include "DrawHaze.h" + +#include +#include + +#include "StencilMaskPass.h" +#include "FramebufferCache.h" + +#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::setDirectionalLightAngle_degs(const float value) { + directionalLightAngle_degs = value; +} + +void HazeConfig::setDirectionalLightColorR(const float value) { + directionalLightColorR = value; +} + +void HazeConfig::setDirectionalLightColorG(const float value) { + directionalLightColorG = value; +} + +void HazeConfig::setDirectionalLightColorB(const float value) { + directionalLightColorB = value; +} + +void HazeConfig::setHazeBaseReference(const float value) { + hazeBaseReference = value; +} + +void HazeConfig::setIsHazeActive(const bool active) { + isHazeActive = active; +} + +void HazeConfig::setIsAltitudeBased(const bool active) { + isAltitudeBased = active; +} + +void HazeConfig::setIsdirectionalLightAttenuationActive(const bool active) { + isDirectionalLightAttenuationActive = active; +} + +void HazeConfig::setIsModulateColorActive(const bool active) { + isModulateColorActive = active; +} + +void HazeConfig::setHazeRange_m(const float value) { + hazeRange_m = value; +} + +void HazeConfig::setHazeAltitude_m(const float value) { + hazeAltitude_m = value; +} + +void HazeConfig::setHazeRangeKeyLight_m(const float value) { + hazeRangeKeyLight_m = value; +} + +void HazeConfig::setHazeAltitudeKeyLight_m(const float value) { + hazeAltitudeKeyLight_m = value; +} + +void HazeConfig::setBackgroundBlendValue(const float value) { + backgroundBlendValue = value; +} + +const int HazeEffect_ParamsSlot = 0; +const int HazeEffect_TransformBufferSlot = 1; + +const int HazeEffect_LightingMapSlot = 2; +const int HazeEffect_LinearDepthMapSlot = 3; + +void DrawHaze::configure(const Config& config) { +} + +void DrawHaze::run(const render::RenderContextPointer& renderContext, const Inputs& inputs) { + const auto haze = inputs.get0(); + const auto inputBuffer = inputs.get1()->getRenderBuffer(0); + const auto framebuffer = inputs.get2(); + const auto transformBuffer = inputs.get3(); + + auto outputBuffer = inputs.get4(); + + auto depthBuffer = framebuffer->getLinearDepthTexture(); + + if (_hazePipeline == nullptr) { + gpu::ShaderPointer ps = gpu::Shader::createPixel(std::string(Haze_frag)); + gpu::ShaderPointer vs = gpu::StandardShaderLib::getDrawViewportQuadTransformTexcoordVS(); + + gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps); + gpu::StatePointer state = gpu::StatePointer(new gpu::State()); + + // Mask out haze on the tablet + PrepareStencil::testMaskNoAA(*state); + + gpu::Shader::BindingSet slotBindings; + slotBindings.insert(gpu::Shader::Binding(std::string("hazeBuffer"), HazeEffect_ParamsSlot)); + slotBindings.insert(gpu::Shader::Binding(std::string("deferredFrameTransformBuffer"), HazeEffect_TransformBufferSlot)); + slotBindings.insert(gpu::Shader::Binding(std::string("colorMap"), HazeEffect_LightingMapSlot)); + slotBindings.insert(gpu::Shader::Binding(std::string("linearDepthMap"), HazeEffect_LinearDepthMapSlot)); + gpu::Shader::makeProgram(*program, slotBindings); + + _hazePipeline = gpu::PipelinePointer(gpu::Pipeline::create(program, state)); + } + + auto sourceFramebufferSize = glm::ivec2(inputBuffer->getDimensions()); + + gpu::doInBatch(renderContext->args->_context, [&](gpu::Batch& batch) { + batch.enableStereo(false); + batch.setFramebuffer(outputBuffer); + + batch.setViewportTransform(renderContext->args->_viewport); + batch.setProjectionTransform(glm::mat4()); + batch.resetViewTransform(); + batch.setModelTransform( + gpu::Framebuffer::evalSubregionTexcoordTransform(sourceFramebufferSize, renderContext->args->_viewport)); + + batch.setPipeline(_hazePipeline); + +//// batch.setUniformBuffer(HazeEffect_ParamsSlot, haze->getParametersBuffer()); + batch.setUniformBuffer(HazeEffect_TransformBufferSlot, transformBuffer->getFrameTransformBuffer()); + + batch.setResourceTexture(HazeEffect_LightingMapSlot, inputBuffer); + batch.setResourceTexture(HazeEffect_LinearDepthMapSlot, depthBuffer); + + batch.draw(gpu::TRIANGLE_STRIP, 4); + }); +} diff --git a/libraries/render-utils/src/DrawHaze.h b/libraries/render-utils/src/DrawHaze.h new file mode 100644 index 0000000000..fc8a9144b3 --- /dev/null +++ b/libraries/render-utils/src/DrawHaze.h @@ -0,0 +1,95 @@ +// +// DrawHaze.h +// libraries/render-utils/src +// +// Created by Nissim Hadar on 9/1/2017. +// Copyright 2015 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_render_utils_DrawHaze_h +#define hifi_render_utils_DrawHaze_h + +#include +#include + +#include +#include +#include +#include + +#include "SurfaceGeometryPass.h" + +#include "model/Haze.h" + +using LinearDepthFramebufferPointer = std::shared_ptr; + +class HazeConfig : public render::Job::Config { +public: + HazeConfig() : render::Job::Config(true) {} + + // attributes + float hazeColorR{ initialHazeColor.r }; + float hazeColorG{ initialHazeColor.g }; + float hazeColorB{ initialHazeColor.b }; + float directionalLightAngle_degs{ initialDirectionalLightAngle_degs }; + + float directionalLightColorR{ initialDirectionalLightColor.r }; + float directionalLightColorG{ initialDirectionalLightColor.g }; + float directionalLightColorB{ initialDirectionalLightColor.b }; + float hazeBaseReference{ initialHazeBaseReference }; + + bool isHazeActive{ false }; // Setting this to true will set haze to on + bool isAltitudeBased{ false }; + bool isDirectionalLightAttenuationActive{ false }; + bool isModulateColorActive{ false }; + + float hazeRange_m{ initialHazeRange_m }; + float hazeAltitude_m{ initialHazeAltitude_m }; + + float hazeRangeKeyLight_m{ initialHazeRangeKeyLight_m }; + float hazeAltitudeKeyLight_m{ initialHazeAltitudeKeyLight_m }; + + float backgroundBlendValue{ initialBackgroundBlendValue }; + + // methods + void setHazeColorR(const float value); + void setHazeColorG(const float value); + void setHazeColorB(const float value); + void setDirectionalLightAngle_degs(const float value); + + void setDirectionalLightColorR(const float value); + void setDirectionalLightColorG(const float value); + void setDirectionalLightColorB(const float value); + void setHazeBaseReference(const float value); + + void setIsHazeActive(const bool active); + void setIsAltitudeBased(const bool active); + void setIsdirectionalLightAttenuationActive(const bool active); + void setIsModulateColorActive(const bool active); + + void setHazeRange_m(const float value); + void setHazeAltitude_m(const float value); + + void setHazeRangeKeyLight_m(const float value); + void setHazeAltitudeKeyLight_m(const float value); + + void setBackgroundBlendValue(const float value); +}; + +class DrawHaze { +public: + using Inputs = render::VaryingSet5; + using Config = HazeConfig; + using JobModel = render::Job::ModelI; + + void configure(const Config& config); + void run(const render::RenderContextPointer& renderContext, const Inputs& inputs); + +private: + gpu::PipelinePointer _hazePipeline; +}; + +#endif // hifi_render_utils_DrawHaze_h diff --git a/libraries/render-utils/src/Haze.slf b/libraries/render-utils/src/Haze.slf new file mode 100644 index 0000000000..b896afde92 --- /dev/null +++ b/libraries/render-utils/src/Haze.slf @@ -0,0 +1,143 @@ +<@include gpu/Config.slh@> +<$VERSION_HEADER$> +// Generated on <$_SCRIBE_DATE$> +// +// Created by Nissim Hadar on 9/5/2107. +// Copyright 2016 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 +// + +<@include DeferredTransform.slh@> +<$declareDeferredFrameTransform()$> + +<@include model/Light.slh@> + +<@include LightingModel.slh@> +<$declareLightBuffer()$> + +<@include LightDirectional.slh@> +<$declareLightingDirectional(_SCRIBE_NULL)$> + +<@include Haze.slh@> + +uniform sampler2D colorMap; + +vec4 unpackPositionFromZeye(vec2 texcoord) { + float Zeye = -texture(linearDepthMap, texcoord).x; + int side = 0; + if (isStereo()) { + if (texcoord.x > 0.5) { + texcoord.x -= 0.5; + side = 1; + } + texcoord.x *= 2.0; + } + return vec4(evalEyePositionFromZeye(side, Zeye, texcoord), 1.0); +} + +in vec2 varTexCoord0; +out vec4 outFragColor; + +void main(void) { + if ((hazeParams.hazeMode & HAZE_MODE_IS_ACTIVE) != HAZE_MODE_IS_ACTIVE) { + discard; + } + + // Distance to fragment + vec4 eyeFragPos = unpackPositionFromZeye(varTexCoord0); + float distance = length(eyeFragPos.xyz); + + vec4 fragColor = texture(colorMap, varTexCoord0); + vec4 hazeColor = vec4(hazeParams.hazeColor, 1.0); + + // Directional light component is a function of the angle from the eye, between the fragment and the sun + DeferredFrameTransform deferredTransform = getDeferredFrameTransform(); + vec4 worldFragPos = getViewInverse() * eyeFragPos; + vec3 eyeFragDir = normalize(worldFragPos.xyz); + + Light light = getLight(); + //vec3 lightDirection = getLightDirection(light); + vec3 lightDirection = normalize(vec3(-1.0, -1.0, -1.0)); + + float directionalLightComponent = max(0.0, dot(eyeFragDir, -lightDirection)); + float power = min(1.0, pow(directionalLightComponent, hazeParams.directionalLightBlend)); + + vec4 directionalLightColor = vec4(hazeParams.directionalLightColor, 1.0); + + vec4 blendedHazeColor = + mix(hazeColor, directionalLightColor, power); + + vec4 potentialFragColor; + + if ((hazeParams.hazeMode & HAZE_MODE_IS_MODULATE_COLOR) == HAZE_MODE_IS_MODULATE_COLOR) { + // Compute separately for reach colour + // Haze is based on both range and altitude + // Taken from www.crytek.com/download/GDC2007_RealtimeAtmoFxInGamesRev.ppt + + // The eyepoint position is in the last column of the matrix + vec3 worldEyePos = getViewInverse()[3].xyz; + + // 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)); + + vec3 hazeIntegral = hazeDensityDistribution * distance; + + const float slopeThreshold = 0.01; + float deltaHeight = worldFragPos.y - worldEyePos.y; + if (abs(deltaHeight) > slopeThreshold) { + float t = hazeParams.hazeAltitudeFactor * deltaHeight; + hazeIntegral *= (1.0 - exp (-t)) / t; + } + + vec3 hazeAmount = 1.0 - exp(-hazeIntegral); + + // Compute color after haze effect + potentialFragColor = mix(fragColor, vec4(1.0, 1.0, 1.0, 1.0), vec4(hazeAmount, 1.0)); + } + else if ((hazeParams.hazeMode & HAZE_MODE_IS_ALTITUDE_BASED) != HAZE_MODE_IS_ALTITUDE_BASED) { + // Haze is based only on range + float hazeAmount = 1.0 - exp(-distance * hazeParams.hazeRangeFactor); + + // Compute color after haze effect + potentialFragColor = mix(fragColor, blendedHazeColor, hazeAmount); + } + else { + // Haze is based on both range and altitude + // Taken from www.crytek.com/download/GDC2007_RealtimeAtmoFxInGamesRev.ppt + + // The eyepoint position is in the last column of the matrix + vec3 worldEyePos = getViewInverse()[3].xyz; + + // 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)); + + float hazeIntegral = hazeDensityDistribution * distance; + + const float slopeThreshold = 0.01; + float deltaHeight = worldFragPos.y - worldEyePos.y; + if (abs(deltaHeight) > slopeThreshold) { + float t = hazeParams.hazeAltitudeFactor * deltaHeight; + hazeIntegral *= (1.0 - exp (-t)) / t; + } + + float hazeAmount = 1.0 - exp(-hazeIntegral); + + // Compute color after haze effect + potentialFragColor = mix(fragColor, blendedHazeColor, hazeAmount); + } + + // Mix with background at far range + if (distance > 32000.0) { + outFragColor = mix(potentialFragColor, fragColor, hazeParams.backgroundBlendValue); + } + else { + outFragColor = potentialFragColor; + } +} + diff --git a/libraries/render-utils/src/Haze.slh b/libraries/render-utils/src/Haze.slh new file mode 100644 index 0000000000..624a859de7 --- /dev/null +++ b/libraries/render-utils/src/Haze.slh @@ -0,0 +1,44 @@ + +<@if not HAZE_SLH@> +<@def HAZE_SLH@> + +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_MODULATE_COLOR = 1 << 3; + +struct HazeParams { + vec3 hazeColor; + float directionalLightBlend; + + vec3 directionalLightColor; + float hazeBaseReference; + + vec3 colorModulationFactor; + int hazeMode; + + float hazeRangeFactor; + float hazeAltitudeFactor; + + float hazeRangeFactorKeyLight; + float hazeAltitudeFactorKeyLight; + + float backgroundBlendValue; +}; + +layout(std140) uniform hazeBuffer { + HazeParams hazeParams; +}; + +uniform sampler2D linearDepthMap; + +<@endif@> + diff --git a/libraries/render-utils/src/HazeStage.cpp b/libraries/render-utils/src/HazeStage.cpp index a72c9d7254..712111f3b3 100644 --- a/libraries/render-utils/src/HazeStage.cpp +++ b/libraries/render-utils/src/HazeStage.cpp @@ -26,7 +26,6 @@ HazeStage::Index HazeStage::findHaze(const HazePointer& haze) const { } HazeStage::Index HazeStage::addHaze(const HazePointer& haze) { - auto found = _hazeMap.find(haze); if (found == _hazeMap.end()) { auto hazeId = _hazes.newElement(haze); @@ -61,3 +60,13 @@ void HazeStageSetup::run(const render::RenderContextPointer& renderContext) { } } +void FetchHazeStage::run(const render::RenderContextPointer& renderContext, model::HazePointer& haze) { + + auto hazeStage = renderContext->_scene->getStage(); + assert(hazeStage); + + if (hazeStage->_currentFrame._hazes.size()) { + auto hazeId = hazeStage->_currentFrame._hazes.front(); + haze = hazeStage->getHaze(hazeId); + } +} diff --git a/libraries/render-utils/src/HazeStage.h b/libraries/render-utils/src/HazeStage.h index 15b65d9ab7..34f2e8b400 100644 --- a/libraries/render-utils/src/HazeStage.h +++ b/libraries/render-utils/src/HazeStage.h @@ -17,7 +17,9 @@ #include #include -#include "LightingModel.h" +#include +#include +#include "model/Haze.h" // Haze stage to set up haze-related rendering tasks class HazeStage : public render::Stage { @@ -35,7 +37,6 @@ public: using HazeIndices = std::vector; - Index findHaze(const HazePointer& haze) const; Index addHaze(const HazePointer& haze); @@ -79,4 +80,13 @@ public: protected: }; +class FetchHazeStage { +public: + using JobModel = render::Job::ModelO; + + void run(const render::RenderContextPointer& renderContext, model::HazePointer& haze); + +private: + gpu::PipelinePointer _hazePipeline; +}; #endif diff --git a/libraries/render-utils/src/RenderDeferredTask.cpp b/libraries/render-utils/src/RenderDeferredTask.cpp index c67a1c7875..d8b030bb4e 100644 --- a/libraries/render-utils/src/RenderDeferredTask.cpp +++ b/libraries/render-utils/src/RenderDeferredTask.cpp @@ -40,6 +40,7 @@ #include "AntialiasingEffect.h" #include "ToneMappingEffect.h" #include "SubsurfaceScattering.h" +#include "DrawHaze.h" #include "OutlineEffect.h" #include @@ -57,6 +58,7 @@ void RenderDeferredTask::configure(const Config& config) { } +#pragma optimize("", off); void RenderDeferredTask::build(JobModel& task, const render::Varying& input, render::Varying& output) { const auto& items = input.get(); auto fadeEffect = DependencyManager::get(); @@ -145,8 +147,10 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren // Create the cluster grid of lights, cpu job for now const auto lightClusteringPassInputs = LightClusteringPass::Inputs(deferredFrameTransform, lightingModel, linearDepthTarget).asVarying(); const auto lightClusters = task.addJob("LightClustering", lightClusteringPassInputs); - - + + // Add haze model + const auto hazeModel = task.addJob("FetchHazeStage"); + // DeferredBuffer is complete, now let's shade it into the LightingBuffer const auto deferredLightingInputs = RenderDeferred::Inputs(deferredFrameTransform, deferredFramebuffer, lightingModel, surfaceGeometryFramebuffer, ambientOcclusionFramebuffer, scatteringResource, lightClusters).asVarying(); @@ -165,7 +169,10 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren const auto debugLightClustersInputs = DebugLightClusters::Inputs(deferredFrameTransform, deferredFramebuffer, lightingModel, linearDepthTarget, lightClusters).asVarying(); task.addJob("DebugLightClusters", debugLightClustersInputs); } - + + const auto drawHazeInputs = render::Varying(DrawHaze::Inputs(hazeModel, lightingFramebuffer, linearDepthTarget, deferredFrameTransform, lightingFramebuffer)); + task.addJob("DrawHaze", drawHazeInputs); + const auto toneAndPostRangeTimer = task.addJob("BeginToneAndPostRangeTimer", "PostToneOverlaysAntialiasing"); // Lighting Buffer ready for tone mapping diff --git a/libraries/render-utils/src/directional_skybox_light.slf b/libraries/render-utils/src/directional_skybox_light.slf index d8a2f44042..d609dd2300 100644 --- a/libraries/render-utils/src/directional_skybox_light.slf +++ b/libraries/render-utils/src/directional_skybox_light.slf @@ -51,7 +51,7 @@ void main(void) { frag.scattering, midNormalCurvature, lowNormalCurvature); - _fragColor = vec4(color, 1.0); + _fragColor = vec4(color, 1.0); } } From 784f9284334d946da9079113a1115c8261a5ea0d Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Wed, 27 Sep 2017 18:46:55 -0700 Subject: [PATCH 15/94] After merge. --- .../entities-renderer/src/RenderableModelEntityItem.cpp | 5 ----- libraries/render-utils/src/DrawHaze.cpp | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp index a93b308d95..d1e47fd906 100644 --- a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp @@ -407,13 +407,8 @@ void RenderableModelEntityItem::computeShapeInfo(ShapeInfo& shapeInfo) { } shapeInfo.setParams(type, dimensions, getCompoundShapeURL()); } else if (type >= SHAPE_TYPE_SIMPLE_HULL && type <= SHAPE_TYPE_STATIC_MESH) { -<<<<<<< HEAD - // should never fall in here when model not fully loaded - ////assert(_model && _model->isLoaded()); -======= // TODO: assert we never fall in here when model not fully loaded //assert(_model && _model->isLoaded()); ->>>>>>> master updateModelBounds(); model->updateGeometry(); diff --git a/libraries/render-utils/src/DrawHaze.cpp b/libraries/render-utils/src/DrawHaze.cpp index 33db0c1f6c..61e0998d91 100644 --- a/libraries/render-utils/src/DrawHaze.cpp +++ b/libraries/render-utils/src/DrawHaze.cpp @@ -114,7 +114,7 @@ void DrawHaze::run(const render::RenderContextPointer& renderContext, const Inpu gpu::StatePointer state = gpu::StatePointer(new gpu::State()); // Mask out haze on the tablet - PrepareStencil::testMaskNoAA(*state); + PrepareStencil::testNoAA(*state); gpu::Shader::BindingSet slotBindings; slotBindings.insert(gpu::Shader::Binding(std::string("hazeBuffer"), HazeEffect_ParamsSlot)); From 9d0cf16c201a223466ab8c9797c6e23c2d8966ea Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Wed, 27 Sep 2017 19:33:04 -0700 Subject: [PATCH 16/94] Fixed Ubuntu warnings. --- libraries/entities-renderer/src/RenderableZoneEntityItem.cpp | 1 - libraries/entities/src/HazePropertyGroup.cpp | 2 +- libraries/render-utils/src/RenderDeferredTask.cpp | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp index 6ee0e86fe8..8b0a7e9f88 100644 --- a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp @@ -60,7 +60,6 @@ void ZoneEntityRenderer::onRemoveFromSceneTyped(const TypedEntityPointer& entity } } -#pragma optimize("", off); void ZoneEntityRenderer::doRender(RenderArgs* args) { #if 0 if (ZoneEntityItem::getDrawZoneBoundaries()) { diff --git a/libraries/entities/src/HazePropertyGroup.cpp b/libraries/entities/src/HazePropertyGroup.cpp index fa7278b2d3..6b26a55481 100644 --- a/libraries/entities/src/HazePropertyGroup.cpp +++ b/libraries/entities/src/HazePropertyGroup.cpp @@ -207,7 +207,7 @@ bool HazePropertyGroup::decodeFromEditPacket(EntityPropertyFlags& propertyFlags, } void HazePropertyGroup::markAllChanged() { - _hazeModeChanged; + _hazeModeChanged = true; _hazeRangeChanged = true; _hazeBlendInColorChanged = true; diff --git a/libraries/render-utils/src/RenderDeferredTask.cpp b/libraries/render-utils/src/RenderDeferredTask.cpp index cd7cb3c7c2..e4f0c31a14 100644 --- a/libraries/render-utils/src/RenderDeferredTask.cpp +++ b/libraries/render-utils/src/RenderDeferredTask.cpp @@ -58,7 +58,6 @@ void RenderDeferredTask::configure(const Config& config) { } -#pragma optimize("", off); void RenderDeferredTask::build(JobModel& task, const render::Varying& input, render::Varying& output) { const auto& items = input.get(); auto fadeEffect = DependencyManager::get(); From 0acf4b9de920185763711b9f427f03f8b33d3662 Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Thu, 28 Sep 2017 23:53:53 -0700 Subject: [PATCH 17/94] Working on adding zone to haze. --- .../src/RenderableZoneEntityItem.cpp | 24 ++++++++++++------- libraries/render-utils/src/DrawHaze.cpp | 2 +- libraries/render-utils/src/HazeStage.cpp | 3 +-- libraries/render-utils/src/ZoneRenderer.cpp | 6 +++++ 4 files changed, 23 insertions(+), 12 deletions(-) diff --git a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp index 8b0a7e9f88..6e08a8a230 100644 --- a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp @@ -146,16 +146,16 @@ void ZoneEntityRenderer::doRender(RenderArgs* args) { } _needBackgroundUpdate = false; } + } - if (_needHazeUpdate) { - if (HazeStage::isIndexInvalid(_hazeIndex)) { - _hazeIndex = _hazeStage->addHaze(_haze); - } - else { - - } - _needHazeUpdate = false; + if (_needHazeUpdate) { + if (HazeStage::isIndexInvalid(_hazeIndex)) { + _hazeIndex = _hazeStage->addHaze(_haze); } + else { + + } + _needHazeUpdate = false; } if (_visible) { @@ -172,6 +172,11 @@ void ZoneEntityRenderer::doRender(RenderArgs* args) { if (_backgroundMode != BACKGROUND_MODE_INHERIT) { _backgroundStage->_currentFrame.pushBackground(_backgroundIndex); } + + // The haze only if the mode is not inherit + if (_hazeMode != HAZE_MODE_INHERIT) { + _hazeStage->_currentFrame.pushHaze(_hazeIndex); + } } } @@ -329,6 +334,8 @@ void ZoneEntityRenderer::updateKeyAmbientFromEntity() { } void ZoneEntityRenderer::updateHazeFromEntity(const TypedEntityPointer& entity) { + setHazeMode(entity->getHazeMode()); + const auto& haze = editHaze(); haze->setIsHazeActive(entity->getHazeMode() == HAZE_MODE_ENABLED); @@ -337,7 +344,6 @@ void ZoneEntityRenderer::updateHazeFromEntity(const TypedEntityPointer& entity) void ZoneEntityRenderer::updateKeyBackgroundFromEntity(const TypedEntityPointer& entity) { editBackground(); setBackgroundMode(entity->getBackgroundMode()); - setHazeMode(entity->getHazeMode()); setSkyboxColor(_skyboxProperties.getColorVec3()); setProceduralUserData(entity->getUserData()); setSkyboxURL(_skyboxProperties.getURL()); diff --git a/libraries/render-utils/src/DrawHaze.cpp b/libraries/render-utils/src/DrawHaze.cpp index 61e0998d91..291ceb73fd 100644 --- a/libraries/render-utils/src/DrawHaze.cpp +++ b/libraries/render-utils/src/DrawHaze.cpp @@ -140,7 +140,7 @@ void DrawHaze::run(const render::RenderContextPointer& renderContext, const Inpu batch.setPipeline(_hazePipeline); -//// batch.setUniformBuffer(HazeEffect_ParamsSlot, haze->getParametersBuffer()); + batch.setUniformBuffer(HazeEffect_ParamsSlot, haze->getParametersBuffer()); batch.setUniformBuffer(HazeEffect_TransformBufferSlot, transformBuffer->getFrameTransformBuffer()); batch.setResourceTexture(HazeEffect_LightingMapSlot, inputBuffer); diff --git a/libraries/render-utils/src/HazeStage.cpp b/libraries/render-utils/src/HazeStage.cpp index 712111f3b3..b0255516ed 100644 --- a/libraries/render-utils/src/HazeStage.cpp +++ b/libraries/render-utils/src/HazeStage.cpp @@ -61,11 +61,10 @@ void HazeStageSetup::run(const render::RenderContextPointer& renderContext) { } void FetchHazeStage::run(const render::RenderContextPointer& renderContext, model::HazePointer& haze) { - auto hazeStage = renderContext->_scene->getStage(); assert(hazeStage); - if (hazeStage->_currentFrame._hazes.size()) { + if (hazeStage->_currentFrame._hazes.size() != 0) { auto hazeId = hazeStage->_currentFrame._hazes.front(); haze = hazeStage->getHaze(hazeId); } diff --git a/libraries/render-utils/src/ZoneRenderer.cpp b/libraries/render-utils/src/ZoneRenderer.cpp index 787ef47282..d59fb6e61c 100644 --- a/libraries/render-utils/src/ZoneRenderer.cpp +++ b/libraries/render-utils/src/ZoneRenderer.cpp @@ -67,6 +67,12 @@ void SetupZones::run(const RenderContextPointer& context, const Inputs& inputs) lightStage->_currentFrame.pushAmbientLight(0); backgroundStage->_currentFrame.pushBackground(0); + + // Haze + auto hazeStage = context->_scene->getStage(); + assert(hazeStage); + hazeStage->_currentFrame.clear(); + hazeStage->_currentFrame.pushHaze(0); } const gpu::PipelinePointer& DebugZoneLighting::getKeyLightPipeline() { From f26345a3f06afb117f37985ce1c41cfdf0b4c04b Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Fri, 29 Sep 2017 15:15:49 -0700 Subject: [PATCH 18/94] Working on adding zone to haze. --- .../src/RenderableZoneEntityItem.cpp | 15 +++ .../entities/src/EntityItemProperties.cpp | 96 ++++++++++++++++- libraries/entities/src/EntityItemProperties.h | 12 +++ libraries/entities/src/HazePropertyGroup.cpp | 2 +- libraries/entities/src/HazePropertyGroup.h | 4 +- libraries/entities/src/ZoneEntityItem.cpp | 98 ++++++++++++++++- libraries/entities/src/ZoneEntityItem.h | 37 ++++++- libraries/gl/src/gl/GLShaders.cpp | 10 +- libraries/model/src/model/Haze.cpp | 22 ++-- libraries/model/src/model/Haze.h | 100 +++++++++--------- libraries/model/src/model/Stage.h | 27 +++++ libraries/render-utils/src/DrawHaze.h | 26 ++--- .../src/SceneScriptingInterface.cpp | 46 +++++++- .../src/SceneScriptingInterface.h | 23 ++++ 14 files changed, 432 insertions(+), 86 deletions(-) diff --git a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp index 6e08a8a230..95c2a9a0df 100644 --- a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp @@ -339,6 +339,21 @@ void ZoneEntityRenderer::updateHazeFromEntity(const TypedEntityPointer& entity) const auto& haze = editHaze(); haze->setIsHazeActive(entity->getHazeMode() == HAZE_MODE_ENABLED); + + haze->setHazeRangeFactor(model::convertHazeRangeToHazeRangeFactor(entity->getHazeRange())); + xColor hazeBlendInColor = entity->getHazeBlendInColor(); + haze->setHazeColor(glm::vec3(hazeBlendInColor.red / 255.0, hazeBlendInColor.green / 255.0, hazeBlendInColor.blue / 255.0)); + xColor hazeBlendOutColor = entity->getHazeBlendOutColor(); + haze->setHazeColor(glm::vec3(hazeBlendOutColor.red / 255.0, hazeBlendOutColor.green / 255.0, hazeBlendOutColor.blue / 255.0)); + haze->setDirectionalLightBlend(model::convertDirectionalLightAngleToPower(entity->getHazeLightBlendAngle())); + + haze->setHazeAltitudeFactor(model::convertHazeAltitudeToHazeAltitudeFactor(entity->getHazeAltitude())); + haze->setHazeBaseReference(entity->getHazeBaseRef()); + + haze->setHazeBackgroundBlendValue(entity->getHazeBackgroundBlend()); + + haze->setHazeKeyLightRangeFactor(model::convertHazeRangeToHazeRangeFactor(entity->getHazeRange())); + haze->setHazeAltitudeFactor(model::convertHazeAltitudeToHazeAltitudeFactor(entity->getHazeAltitude())); } void ZoneEntityRenderer::updateKeyBackgroundFromEntity(const TypedEntityPointer& entity) { diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp index 868f5a6dd7..b75809b2f0 100644 --- a/libraries/entities/src/EntityItemProperties.cpp +++ b/libraries/entities/src/EntityItemProperties.cpp @@ -234,10 +234,12 @@ QString EntityItemProperties::getHazeModeAsString() const { QString EntityItemProperties::getHazeModeString(HazeMode mode) { return HAZE_MODES[mode].second; } + void EntityItemProperties::setHazeModeFromString(const QString& hazeMode) { auto result = std::find_if(HAZE_MODES.begin(), HAZE_MODES.end(), [&](const HazePair& pair) { return (pair.second == hazeMode); }); + if (result != HAZE_MODES.end()) { _hazeMode = result->first; _hazeModeChanged = true; @@ -317,7 +319,20 @@ EntityPropertyFlags EntityItemProperties::getChangedProperties() const { CHECK_PROPERTY_CHANGE(PROP_MARKETPLACE_ID, marketplaceID); CHECK_PROPERTY_CHANGE(PROP_NAME, name); CHECK_PROPERTY_CHANGE(PROP_BACKGROUND_MODE, backgroundMode); - CHECK_PROPERTY_CHANGE(PROP_HAZE_MODE, hazeMode); + + CHECK_PROPERTY_CHANGE(PROP_HAZE_RANGE, hazeRange); + CHECK_PROPERTY_CHANGE(PROP_HAZE_BLEND_IN_COLOR, hazeBlendInColor); + CHECK_PROPERTY_CHANGE(PROP_HAZE_BLEND_OUT_COLOR, hazeBlendOutColor); + CHECK_PROPERTY_CHANGE(PROP_HAZE_LIGHT_BLEND_ANGLE, hazeLightBlendAngle); + + CHECK_PROPERTY_CHANGE(PROP_HAZE_ALTITUDE, hazeAltitude); + CHECK_PROPERTY_CHANGE(PROP_HAZE_BASE_REF, hazeBaseRef); + + CHECK_PROPERTY_CHANGE(PROP_HAZE_BACKGROUND_BLEND, hazeBackgroundBlend); + + CHECK_PROPERTY_CHANGE(PROP_HAZE_KEYLIGHT_RANGE, hazeKeyLightRange); + CHECK_PROPERTY_CHANGE(PROP_HAZE_KEYLIGHT_ALTITUDE, hazeKeyLightAltitude); + CHECK_PROPERTY_CHANGE(PROP_SOURCE_URL, sourceUrl); CHECK_PROPERTY_CHANGE(PROP_VOXEL_VOLUME_SIZE, voxelVolumeSize); CHECK_PROPERTY_CHANGE(PROP_VOXEL_DATA, voxelData); @@ -526,6 +541,7 @@ QScriptValue EntityItemProperties::copyToScriptValue(QScriptEngine* engine, bool _keyLight.copyToScriptValue(_desiredProperties, properties, engine, skipDefaults, defaultEntityProperties); COPY_PROPERTY_TO_QSCRIPTVALUE_GETTER(PROP_BACKGROUND_MODE, backgroundMode, getBackgroundModeAsString()); + COPY_PROPERTY_TO_QSCRIPTVALUE_GETTER(PROP_HAZE_MODE, hazeMode, getHazeModeAsString()); _skybox.copyToScriptValue(_desiredProperties, properties, engine, skipDefaults, defaultEntityProperties); @@ -706,7 +722,22 @@ void EntityItemProperties::copyFromScriptValue(const QScriptValue& object, bool COPY_PROPERTY_FROM_QSCRIPTVALUE(collisionSoundURL, QString, setCollisionSoundURL); COPY_PROPERTY_FROM_QSCRITPTVALUE_ENUM(backgroundMode, BackgroundMode); + COPY_PROPERTY_FROM_QSCRITPTVALUE_ENUM(hazeMode, HazeMode); + + COPY_PROPERTY_FROM_QSCRIPTVALUE(hazeRange, float, setHazeRange); + COPY_PROPERTY_FROM_QSCRIPTVALUE(hazeBlendInColor, xColor, setHazeBlendInColor); + COPY_PROPERTY_FROM_QSCRIPTVALUE(hazeBlendOutColor, xColor, setHazeBlendOutColor); + COPY_PROPERTY_FROM_QSCRIPTVALUE(hazeLightBlendAngle, float, setHazeLightBlendAngle); + + COPY_PROPERTY_FROM_QSCRIPTVALUE(hazeAltitude, float, setHazeAltitude); + COPY_PROPERTY_FROM_QSCRIPTVALUE(hazeBaseRef, float, setHazeBaseRef); + + COPY_PROPERTY_FROM_QSCRIPTVALUE(hazeBackgroundBlend, float, setHazeBackgroundBlend); + + COPY_PROPERTY_FROM_QSCRIPTVALUE(hazeKeyLightRange, float, setHazeKeyLightRange); + COPY_PROPERTY_FROM_QSCRIPTVALUE(hazeKeyLightAltitude, float, setHazeKeyLightAltitude); + COPY_PROPERTY_FROM_QSCRIPTVALUE(sourceUrl, QString, setSourceUrl); COPY_PROPERTY_FROM_QSCRIPTVALUE(voxelVolumeSize, glmVec3, setVoxelVolumeSize); COPY_PROPERTY_FROM_QSCRIPTVALUE(voxelData, QByteArray, setVoxelData); @@ -846,7 +877,22 @@ void EntityItemProperties::merge(const EntityItemProperties& other) { COPY_PROPERTY_IF_CHANGED(collisionSoundURL); COPY_PROPERTY_IF_CHANGED(backgroundMode); + COPY_PROPERTY_IF_CHANGED(hazeMode); + + COPY_PROPERTY_IF_CHANGED(hazeRange); + COPY_PROPERTY_IF_CHANGED(hazeBlendInColor); + COPY_PROPERTY_IF_CHANGED(hazeBlendOutColor); + COPY_PROPERTY_IF_CHANGED(hazeLightBlendAngle); + + COPY_PROPERTY_IF_CHANGED(hazeAltitude); + COPY_PROPERTY_IF_CHANGED(hazeBaseRef); + + COPY_PROPERTY_IF_CHANGED(hazeBackgroundBlend); + + COPY_PROPERTY_IF_CHANGED(hazeKeyLightRange); + COPY_PROPERTY_IF_CHANGED(hazeKeyLightAltitude); + COPY_PROPERTY_IF_CHANGED(sourceUrl); COPY_PROPERTY_IF_CHANGED(voxelVolumeSize); COPY_PROPERTY_IF_CHANGED(voxelData); @@ -1025,7 +1071,6 @@ void EntityItemProperties::entityPropertyFlagsFromScriptValue(const QScriptValue ADD_PROPERTY_TO_MAP(PROP_VOXEL_SURFACE_STYLE, VoxelSurfaceStyle, voxelSurfaceStyle, uint16_t); ADD_PROPERTY_TO_MAP(PROP_NAME, Name, name, QString); ADD_PROPERTY_TO_MAP(PROP_BACKGROUND_MODE, BackgroundMode, backgroundMode, BackgroundMode); - ADD_PROPERTY_TO_MAP(PROP_HAZE_MODE, HazeMode, hazeMode, HazeMode); ADD_PROPERTY_TO_MAP(PROP_SOURCE_URL, SourceUrl, sourceUrl, QString); ADD_PROPERTY_TO_MAP(PROP_LINE_WIDTH, LineWidth, lineWidth, float); ADD_PROPERTY_TO_MAP(PROP_LINE_POINTS, LinePoints, linePoints, QVector); @@ -1073,8 +1118,20 @@ void EntityItemProperties::entityPropertyFlagsFromScriptValue(const QScriptValue ADD_GROUP_PROPERTY_TO_MAP(PROP_SKYBOX_COLOR, Skybox, skybox, Color, color); ADD_GROUP_PROPERTY_TO_MAP(PROP_SKYBOX_URL, Skybox, skybox, URL, url); - ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_RANGE, Haze, haze, HazeRange, hazeRange); + ADD_PROPERTY_TO_MAP(PROP_HAZE_MODE, HazeMode, hazeMode, HazeMode); + + ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_ALTITUDE, Haze, haze, HazeRange, HazeRange, hazeRange); + ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_BLEND_IN_COLOR, Haze, haze, HazeBlendInColor, hazeBlendInColor); + ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_BLEND_OUT_COLOR, Haze, haze, HazeBlendOutColor, hazeBlendOutColor); + ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_LIGHT_BLEND_ANGLE, Haze, haze, HazeLightBlendAngle, hazeLightBlendAngle); + ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_ALTITUDE, Haze, haze, HazeAltitude, hazeAltitude); + ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_BASE_REF, Haze, haze, HazeBaseRef, hazeBaseRef); + + ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_BACKGROUND_BLEND, Haze, haze, HazeBackgroundBlend, hazeBackgroundBlend); + + ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_KEYLIGHT_RANGE, Haze, haze, HazeKeyLightRange, hazeKeyLightRange); + ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_KEYLIGHT_ALTITUDE, Haze, haze, HazeKeyLightAltitude, hazeKeyLightAltitude); ADD_GROUP_PROPERTY_TO_MAP(PROP_STAGE_SUN_MODEL_ENABLED, Stage, stage, SunModelEnabled, sunModelEnabled); ADD_GROUP_PROPERTY_TO_MAP(PROP_STAGE_LATITUDE, Stage, stage, Latitude, latitude); @@ -2105,9 +2162,42 @@ QList EntityItemProperties::listChangedProperties() { if (backgroundModeChanged()) { out += "backgroundMode"; } + if (hazeModeChanged()) { out += "hazeMode"; } + + if (hazeRangeChanged()) { + out += "hazeRange"; + } + if (hazeBlendInColorChanged()) { + out += "hazeBlendInColor"; + } + if (hazeBlendOutColorChanged()) { + out += "hazeBlendOutColor"; + } + if (hazeLightBlendAngleChanged()) { + out += "hazehazeLightBlendAngle"; + } + + if (hazeAltitudeChanged()) { + out += "hazeAltitude"; + } + if (hazeBaseRefChanged()) { + out += "hazeBaseRef"; + } + + if (hazeBackgroundBlendChanged()) { + out += "hazeBackgroundBlend"; + } + + if (hazeKeyLightRangeChanged()) { + out += "hazeKeyLightRange"; + } + if (hazeKeyLightAltitudeChanged()) { + out += "hazeKeyLightAltitude"; + } + if (voxelVolumeSizeChanged()) { out += "voxelVolumeSize"; } diff --git a/libraries/entities/src/EntityItemProperties.h b/libraries/entities/src/EntityItemProperties.h index 25799fcc0c..cdbed6e4d7 100644 --- a/libraries/entities/src/EntityItemProperties.h +++ b/libraries/entities/src/EntityItemProperties.h @@ -180,8 +180,20 @@ public: DEFINE_PROPERTY_REF_ENUM(PROP_BACKGROUND_MODE, BackgroundMode, backgroundMode, BackgroundMode, BACKGROUND_MODE_INHERIT); DEFINE_PROPERTY_REF_ENUM(PROP_HAZE_MODE, HazeMode, hazeMode, HazeMode, HAZE_MODE_INHERIT); + DEFINE_PROPERTY(PROP_HAZE_RANGE, HazeRange, hazeRange, float, HazePropertyGroup::DEFAULT_HAZE_RANGE); + DEFINE_PROPERTY(PROP_HAZE_BLEND_IN_COLOR, HazeBlendInColor, hazeBlendInColor, xColor, HazePropertyGroup::DEFAULT_HAZE_BLEND_IN_COLOR); + DEFINE_PROPERTY(PROP_HAZE_BLEND_OUT_COLOR, HazeBlendOutColor, hazeBlendOutColor, xColor, HazePropertyGroup::DEFAULT_HAZE_BLEND_OUT_COLOR); + DEFINE_PROPERTY(PROP_HAZE_LIGHT_BLEND_ANGLE, HazeLightBlendAngle, hazeLightBlendAngle, float, HazePropertyGroup::DEFAULT_HAZE_ALTITUDE); + DEFINE_PROPERTY(PROP_HAZE_ALTITUDE, HazeAltitude, hazeAltitude, float, HazePropertyGroup::DEFAULT_HAZE_ALTITUDE); + DEFINE_PROPERTY(PROP_HAZE_BASE_REF, HazeBaseRef, hazeBaseRef, float, HazePropertyGroup::DEFAULT_HAZE_ALTITUDE); + + DEFINE_PROPERTY(PROP_HAZE_BACKGROUND_BLEND, HazeBackgroundBlend, hazeBackgroundBlend, float, HazePropertyGroup::DEFAULT_HAZE_ALTITUDE); + + DEFINE_PROPERTY(PROP_HAZE_KEYLIGHT_RANGE, HazeKeyLightRange, hazeKeyLightRange, float, HazePropertyGroup::DEFAULT_HAZE_RANGE); + DEFINE_PROPERTY(PROP_HAZE_KEYLIGHT_ALTITUDE, HazeKeyLightAltitude, hazeKeyLightAltitude, float, HazePropertyGroup::DEFAULT_HAZE_ALTITUDE); + DEFINE_PROPERTY_GROUP(Skybox, skybox, SkyboxPropertyGroup); DEFINE_PROPERTY_GROUP(Haze, haze, HazePropertyGroup); diff --git a/libraries/entities/src/HazePropertyGroup.cpp b/libraries/entities/src/HazePropertyGroup.cpp index 6b26a55481..3bad0cfda3 100644 --- a/libraries/entities/src/HazePropertyGroup.cpp +++ b/libraries/entities/src/HazePropertyGroup.cpp @@ -20,7 +20,7 @@ const uint8_t HazePropertyGroup::DEFAULT_HAZE_MODE{ 0 }; const float HazePropertyGroup::DEFAULT_HAZE_RANGE{ 1000.0f }; const xColor HazePropertyGroup::DEFAULT_HAZE_BLEND_IN_COLOR{ 128, 154, 179 }; // Bluish const xColor HazePropertyGroup::DEFAULT_HAZE_BLEND_OUT_COLOR{ 255, 229, 179 }; // Yellowish -const float HazePropertyGroup::DEFAULT_LIGHT_BLEND_ANGLE{ 20.0 }; +const float HazePropertyGroup::DEFAULT_HAZE_LIGHT_BLEND_ANGLE{ 20.0 }; const float HazePropertyGroup::DEFAULT_HAZE_ALTITUDE{ 200.0f }; const float HazePropertyGroup::DEFAULT_HAZE_BASE_REF{ 0.0f }; diff --git a/libraries/entities/src/HazePropertyGroup.h b/libraries/entities/src/HazePropertyGroup.h index 78cf1d6e46..355dc3b808 100644 --- a/libraries/entities/src/HazePropertyGroup.h +++ b/libraries/entities/src/HazePropertyGroup.h @@ -79,7 +79,7 @@ public: static const float DEFAULT_HAZE_RANGE; static const xColor DEFAULT_HAZE_BLEND_IN_COLOR; static const xColor DEFAULT_HAZE_BLEND_OUT_COLOR; - static const float DEFAULT_LIGHT_BLEND_ANGLE; + static const float DEFAULT_HAZE_LIGHT_BLEND_ANGLE; static const float DEFAULT_HAZE_ALTITUDE; static const float DEFAULT_HAZE_BASE_REF; @@ -96,7 +96,7 @@ public: DEFINE_PROPERTY(PROP_HAZE_RANGE, HazeRange, hazeRange, float, DEFAULT_HAZE_RANGE); DEFINE_PROPERTY_REF(PROP_HAZE_BLEND_IN_COLOR, HazeBlendInColor, hazeBlendInColor, xColor, DEFAULT_HAZE_BLEND_IN_COLOR); DEFINE_PROPERTY_REF(PROP_HAZE_BLEND_OUT_COLOR, HazeBlendOutColor, hazeBlendOutColor, xColor, DEFAULT_HAZE_BLEND_OUT_COLOR); - DEFINE_PROPERTY(PROP_HAZE_LIGHT_BLEND_ANGLE, HazeLightBlendAngle, hazeLightBlendAngle, float, DEFAULT_LIGHT_BLEND_ANGLE); + DEFINE_PROPERTY(PROP_HAZE_LIGHT_BLEND_ANGLE, HazeLightBlendAngle, hazeLightBlendAngle, float, DEFAULT_HAZE_LIGHT_BLEND_ANGLE); // Range & Altitude parameters DEFINE_PROPERTY(PROP_HAZE_ALTITUDE, HazeAltitude, hazeAltitude, float, DEFAULT_HAZE_ALTITUDE); diff --git a/libraries/entities/src/ZoneEntityItem.cpp b/libraries/entities/src/ZoneEntityItem.cpp index 2d2f3c9051..e6af326e46 100644 --- a/libraries/entities/src/ZoneEntityItem.cpp +++ b/libraries/entities/src/ZoneEntityItem.cpp @@ -110,6 +110,19 @@ bool ZoneEntityItem::setSubClassProperties(const EntityItemProperties& propertie SET_ENTITY_PROPERTY_FROM_PROPERTIES(hazeMode, setHazeMode); + SET_ENTITY_PROPERTY_FROM_PROPERTIES(hazeRange, setHazeRange); + SET_ENTITY_PROPERTY_FROM_PROPERTIES(hazeBlendInColor, setHazeBlendInColor); + SET_ENTITY_PROPERTY_FROM_PROPERTIES(hazeBlendInColor, setHazeBlendInColor); + SET_ENTITY_PROPERTY_FROM_PROPERTIES(hazeLightBlendAngle, setHazeLightBlendAngle); + + SET_ENTITY_PROPERTY_FROM_PROPERTIES(hazeAltitude, setHazeAltitude); + SET_ENTITY_PROPERTY_FROM_PROPERTIES(hazeBaseRef, setHazeBaseRef); + + SET_ENTITY_PROPERTY_FROM_PROPERTIES(hazeBackgroundBlend, setHazeBackgroundBlend); + + SET_ENTITY_PROPERTY_FROM_PROPERTIES(hazeKeyLightRange, setHazeKeyLightRange); + SET_ENTITY_PROPERTY_FROM_PROPERTIES(hazeKeyLightAltitude, setHazeKeyLightAltitude); + SET_ENTITY_PROPERTY_FROM_PROPERTIES(flyingAllowed, setFlyingAllowed); SET_ENTITY_PROPERTY_FROM_PROPERTIES(ghostingAllowed, setGhostingAllowed); SET_ENTITY_PROPERTY_FROM_PROPERTIES(filterURL, setFilterURL); @@ -321,12 +334,93 @@ void ZoneEntityItem::resetRenderingPropertiesChanged() { }); } -void ZoneEntityItem::setHazeMode(HazeMode value) { +void ZoneEntityItem::setHazeMode(const HazeMode value) { _hazeMode = value; _hazePropertiesChanged = true; } HazeMode ZoneEntityItem::getHazeMode() const { - return _hazeMode; + return _hazeMode; +} + +void ZoneEntityItem::setHazeRange(const float hazeRange) { + _hazeRange = hazeRange; + _hazePropertiesChanged = true; +} + +float ZoneEntityItem::getHazeRange() const { + return _hazeRange; +} + +void ZoneEntityItem::setHazeBlendInColor(const xColor hazeBlendInColor){ + _hazeBlendInColor = hazeBlendInColor; + _hazePropertiesChanged = true; +} + +xColor ZoneEntityItem::getHazeBlendInColor()const{ + return _hazeBlendInColor; +} + +void ZoneEntityItem::setHazeBlendOutColor(const xColor hazeBlendOutColor){ + _hazeBlendOutColor = hazeBlendOutColor; + _hazePropertiesChanged = true; +} + +xColor ZoneEntityItem::getHazeBlendOutColor()const{ + return _hazeBlendOutColor; +} + +void ZoneEntityItem::setHazeLightBlendAngle(const float hazeLightBlendAngle){ + _hazeLightBlendAngle = hazeLightBlendAngle; + _hazePropertiesChanged = true; +} + +float ZoneEntityItem::getHazeLightBlendAngle()const{ + return _hazeLightBlendAngle; +} + +void ZoneEntityItem::setHazeAltitude(const float hazeAltitude){ + _hazeAltitude = hazeAltitude; + _hazePropertiesChanged = true; +} + +float ZoneEntityItem::getHazeAltitude()const{ + return _hazeAltitude; +} + +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::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 344c9df553..630c9fb83e 100644 --- a/libraries/entities/src/ZoneEntityItem.h +++ b/libraries/entities/src/ZoneEntityItem.h @@ -69,9 +69,31 @@ public: void setBackgroundMode(BackgroundMode value) { _backgroundMode = value; _backgroundPropertiesChanged = true; } BackgroundMode getBackgroundMode() const { return _backgroundMode; } - void setHazeMode(HazeMode value); + void setHazeMode(const HazeMode value); HazeMode getHazeMode() const; + void setHazeRange(const float hazeRange); + float getHazeRange()const; + void setHazeBlendInColor(const xColor hazeBlendInColor); + xColor getHazeBlendInColor()const; + void setHazeBlendOutColor(const xColor hazeBlendOutColor); + xColor getHazeBlendOutColor()const; + void setHazeLightBlendAngle(const float hazeLightBlendAngle); + float getHazeLightBlendAngle()const; + + void setHazeAltitude(const float hazeAltitude); + float getHazeAltitude()const; + void setHazeBaseRef(const float hazeBaseRef); + float getHazeBaseRef()const; + + void setHazeBackgroundBlend(const float hazeBackgroundBlend); + float getHazeBackgroundBlend()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; } @@ -121,6 +143,19 @@ protected: HazeMode _hazeMode{ HAZE_MODE_INHERIT }; + float _hazeRange{ HazePropertyGroup::DEFAULT_HAZE_RANGE }; + xColor _hazeBlendInColor{ HazePropertyGroup::DEFAULT_HAZE_BLEND_IN_COLOR }; + xColor _hazeBlendOutColor{ HazePropertyGroup::DEFAULT_HAZE_BLEND_OUT_COLOR }; + float _hazeLightBlendAngle{ HazePropertyGroup::DEFAULT_HAZE_LIGHT_BLEND_ANGLE }; + + float _hazeAltitude{ HazePropertyGroup::DEFAULT_HAZE_ALTITUDE }; + float _hazeBaseRef{ HazePropertyGroup::DEFAULT_HAZE_BASE_REF }; + + float _hazeBackgroundBlend{ HazePropertyGroup::DEFAULT_HAZE_BACKGROUND_BLEND }; + + float _hazeKeyLightRange{ HazePropertyGroup::DEFAULT_HAZE_KEYLIGHT_RANGE }; + float _hazeKeyLightAltitude{ HazePropertyGroup::DEFAULT_HAZE_KEYLIGHT_ALTITUDE }; + SkyboxPropertyGroup _skyboxProperties; HazePropertyGroup _hazeProperties; StagePropertyGroup _stageProperties; diff --git a/libraries/gl/src/gl/GLShaders.cpp b/libraries/gl/src/gl/GLShaders.cpp index 4b82803d2c..a05b923fb3 100644 --- a/libraries/gl/src/gl/GLShaders.cpp +++ b/libraries/gl/src/gl/GLShaders.cpp @@ -45,9 +45,9 @@ namespace gl { std::ofstream filestream; filestream.open("D:\\debugshader.glsl"); if (filestream.is_open()) { - filestream << srcstr[0]; - filestream << srcstr[1]; - filestream.close(); + filestream << srcstr[0]; + filestream << srcstr[1]; + filestream.close(); } @@ -61,8 +61,8 @@ namespace gl { filestream.open("D:\\debugshader.glsl.info.txt"); if (filestream.is_open()) { - filestream << std::string(temp); - filestream.close(); + filestream << std::string(temp); + filestream.close(); } diff --git a/libraries/model/src/model/Haze.cpp b/libraries/model/src/model/Haze.cpp index 9844579af2..7daca3c77c 100644 --- a/libraries/model/src/model/Haze.cpp +++ b/libraries/model/src/model/Haze.cpp @@ -27,7 +27,6 @@ enum HazeModes { HAZE_MODE_IS_MODULATE_COLOR = 1 << 3 }; - // For color modulated mode, the colour values are used as range values, which are then converted to range factors // This is separate for each colour. // The colour value is converted from [0.0 .. 1.0] to [5.0 .. 3000.0] @@ -139,21 +138,30 @@ void Haze::setHazeAltitudeFactor(const float hazeAltitudeFactor) { } } -void Haze::setHazeRangeFactorKeyLight(const float hazeRangeFactorKeyLight) { +void Haze::setHazeKeyLightRangeFactor(const float hazeKeyLightRangeFactor) { auto& params = _parametersBuffer.get(); - if (params.hazeRangeFactorKeyLight != hazeRangeFactorKeyLight) { - _parametersBuffer.edit().hazeRangeFactorKeyLight = hazeRangeFactorKeyLight; + if (params.hazeKeyLightRangeFactor != hazeKeyLightRangeFactor) { + _parametersBuffer.edit().hazeKeyLightRangeFactor = hazeKeyLightRangeFactor; } } -void Haze::setHazeAltitudeFactorKeyLight(const float hazeAltitudeFactorKeyLight) { +void Haze::setHazeKeyLightAltitudeFactor(const float hazeKeyLightAltitudeFactor) { auto& params = _parametersBuffer.get(); - if (params.hazeAltitudeFactorKeyLight != hazeAltitudeFactorKeyLight) { - _parametersBuffer.edit().hazeAltitudeFactorKeyLight = hazeAltitudeFactorKeyLight; + if (params.hazeKeyLightAltitudeFactor != hazeKeyLightAltitudeFactor) { + _parametersBuffer.edit().hazeKeyLightAltitudeFactor = hazeKeyLightAltitudeFactor; } } + +void Haze::setHazeBackgroundBlendValue(const float hazeBackgroundBlendValue) { + auto& params = _parametersBuffer.get(); + + if (params.hazeBackgroundBlendValue != hazeBackgroundBlendValue) { + _parametersBuffer.edit().hazeBackgroundBlendValue = hazeBackgroundBlendValue; + } +} + void Haze::setHazeBaseReference(const float hazeBaseReference) { auto& params = _parametersBuffer.get(); diff --git a/libraries/model/src/model/Haze.h b/libraries/model/src/model/Haze.h index fee387cd0d..7ba09c86e7 100644 --- a/libraries/model/src/model/Haze.h +++ b/libraries/model/src/model/Haze.h @@ -14,50 +14,49 @@ #include #include "NumericalConstants.h" -const double p_005 = 0.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 -inline float convertHazeRangeToHazeRangeFactor(const float hazeRange_m) { return (float)-log(p_005) / hazeRange_m; } - -inline float convertHazeAltitudeToHazeAltitudeFactor(const float hazeAltitude_m) { - return (float)-log(p_005) / hazeAltitude_m; -} - -// Derivation (s is th 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(0.5) / log(cos(RADIANS_PER_DEGREE * directionalLightAngle)); -} - -const glm::vec3 initialHazeColor{ 0.5, 0.6, 0.7 }; -const float initialDirectionalLightAngle_degs{ 30.0f }; - -const glm::vec3 initialDirectionalLightColor{ 1.0, 0.9, 0.7 }; -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 initialHazeRangeKeyLight_m{ 150.0f }; -const float initialHazeAltitudeKeyLight_m{ 150.0f }; - -const float initialBackgroundBlendValue{ 0.0f }; - -const glm::vec3 initialColorModulationFactor{ - convertHazeRangeToHazeRangeFactor(initialHazeRange_m), - convertHazeRangeToHazeRangeFactor(initialHazeRange_m), - convertHazeRangeToHazeRangeFactor(initialHazeRange_m) -}; - namespace model { + const double p_005 = 0.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 + inline float convertHazeRangeToHazeRangeFactor(const float hazeRange_m) { return (float)-log(p_005) / hazeRange_m; } + + inline float convertHazeAltitudeToHazeAltitudeFactor(const float hazeAltitude_m) { + return (float)-log(p_005) / hazeAltitude_m; + } + + // Derivation (s is th 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(0.5) / log(cos(RADIANS_PER_DEGREE * directionalLightAngle)); + } + + const glm::vec3 initialHazeColor{ 0.5, 0.6, 0.7 }; + const float initialDirectionalLightAngle_degs{ 30.0f }; + + const glm::vec3 initialDirectionalLightColor{ 1.0, 0.9, 0.7 }; + 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 initialBackgroundBlendValue{ 0.0f }; + + const glm::vec3 initialColorModulationFactor{ + convertHazeRangeToHazeRangeFactor(initialHazeRange_m), + convertHazeRangeToHazeRangeFactor(initialHazeRange_m), + convertHazeRangeToHazeRangeFactor(initialHazeRange_m) + }; class Haze { public: @@ -79,10 +78,10 @@ namespace model { void setHazeRangeFactor(const float hazeRange); void setHazeAltitudeFactor(const float hazeAltitude); - void setHazeRangeFactorKeyLight(const float hazeRangeKeyLight); - void setHazeAltitudeFactorKeyLight(const float hazeAltitudeKeyLight); + void setHazeKeyLightRangeFactor(const float hazeKeyLightRange); + void setHazeKeyLightAltitudeFactor(const float hazeKeyLightAltitude); - void setBackgroundBlendValue(const float backgroundBlendValue); + void setHazeBackgroundBlendValue(const float hazeBackgroundBlendValue); UniformBufferView getParametersBuffer() const { return _parametersBuffer; } @@ -101,14 +100,15 @@ namespace model { // bit 1 - set to add the effect of altitude to the haze attenuation // bit 2 - set to activate directional light attenuation mode - // The haze attenuation exponents used by both fragment and directional light attenuation + // The haze attenuation exponents used by both fragment and directional light attenuation float hazeRangeFactor{ convertHazeRangeToHazeRangeFactor(initialHazeRange_m) }; float hazeAltitudeFactor{ convertHazeAltitudeToHazeAltitudeFactor(initialHazeAltitude_m) }; - float hazeRangeFactorKeyLight{ convertHazeRangeToHazeRangeFactor(initialHazeRangeKeyLight_m) }; - float hazeAltitudeFactorKeyLight{ convertHazeAltitudeToHazeAltitudeFactor(initialHazeAltitudeKeyLight_m) }; + float hazeKeyLightRangeFactor{ convertHazeRangeToHazeRangeFactor(initialHazeKeyLightRange_m) }; + float hazeKeyLightAltitudeFactor{ convertHazeAltitudeToHazeAltitudeFactor(initialHazeKeyLightAltitude_m) }; - float backgroundBlendValue{ initialBackgroundBlendValue }; + // Amount of background (skybox) to display, overriding the haze effect for the background + float hazeBackgroundBlendValue{ initialBackgroundBlendValue }; Parameters() {} }; diff --git a/libraries/model/src/model/Stage.h b/libraries/model/src/model/Stage.h index fe5e9e2a78..49eedaccbb 100644 --- a/libraries/model/src/model/Stage.h +++ b/libraries/model/src/model/Stage.h @@ -188,16 +188,43 @@ public: void setHazeRange(float hazeRange) { _hazeRange = hazeRange; } float getHazeRange() const { return _hazeRange; } + void setHazeBlendInColor(const xColor hazeBlendInColor) { _hazeBlendInColor = hazeBlendInColor; } + xColor getHazeBlendInColor() { return _hazeBlendInColor; } + void setHazeBlendOutColor(const xColor hazeBlendOutColor) { _hazeBlendInColor = hazeBlendOutColor; } + xColor getHazeBlendOutColor() const { return _hazeBlendOutColor; } + void setHazeLightBlendAngle(float hazeLightBlendAngle) { _hazeLightBlendAngle = hazeLightBlendAngle; } + float getHazeLightBlendAngle() const { return _hazeLightBlendAngle; } void setHazeAltitude(float hazeAltitude) { _hazeAltitude = hazeAltitude; } float getHazeAltitude() const { return _hazeAltitude; } + void setHazeBaseRef(float hazeBaseRef) { _hazeBaseRef = hazeBaseRef; } + float getHazeBaseRef() const { return _hazeBaseRef; } + + void setHazeBackgroundBlend(float hazeBackgroundBlend) { _hazeBackgroundBlend = hazeBackgroundBlend; } + float getHazeBackgroundBlend() const { return _hazeBackgroundBlend; } + + 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; HazeMode _hazeMode = HAZE_OFF; + float _hazeRange; + xColor _hazeBlendInColor; + xColor _hazeBlendOutColor; + float _hazeLightBlendAngle; + float _hazeAltitude; + float _hazeBaseRef; + + float _hazeBackgroundBlend; + + float _hazeKeyLightRange; + float _hazeKeyLightAltitude; LightPointer _sunLight; mutable SkyboxPointer _skybox; diff --git a/libraries/render-utils/src/DrawHaze.h b/libraries/render-utils/src/DrawHaze.h index fc8a9144b3..a246c3ca87 100644 --- a/libraries/render-utils/src/DrawHaze.h +++ b/libraries/render-utils/src/DrawHaze.h @@ -31,28 +31,28 @@ public: HazeConfig() : render::Job::Config(true) {} // attributes - float hazeColorR{ initialHazeColor.r }; - float hazeColorG{ initialHazeColor.g }; - float hazeColorB{ initialHazeColor.b }; - float directionalLightAngle_degs{ initialDirectionalLightAngle_degs }; + float hazeColorR{ model::initialHazeColor.r }; + float hazeColorG{ model::initialHazeColor.g }; + float hazeColorB{ model::initialHazeColor.b }; + float directionalLightAngle_degs{ model::initialDirectionalLightAngle_degs }; - float directionalLightColorR{ initialDirectionalLightColor.r }; - float directionalLightColorG{ initialDirectionalLightColor.g }; - float directionalLightColorB{ initialDirectionalLightColor.b }; - float hazeBaseReference{ initialHazeBaseReference }; + float directionalLightColorR{ model::initialDirectionalLightColor.r }; + float directionalLightColorG{ model::initialDirectionalLightColor.g }; + float directionalLightColorB{ model::initialDirectionalLightColor.b }; + float hazeBaseReference{ model::initialHazeBaseReference }; bool isHazeActive{ false }; // Setting this to true will set haze to on bool isAltitudeBased{ false }; bool isDirectionalLightAttenuationActive{ false }; bool isModulateColorActive{ false }; - float hazeRange_m{ initialHazeRange_m }; - float hazeAltitude_m{ initialHazeAltitude_m }; + float hazeRange_m{ model::initialHazeRange_m }; + float hazeAltitude_m{ model::initialHazeAltitude_m }; - float hazeRangeKeyLight_m{ initialHazeRangeKeyLight_m }; - float hazeAltitudeKeyLight_m{ initialHazeAltitudeKeyLight_m }; + float hazeRangeKeyLight_m{ model::initialHazeKeyLightRange_m }; + float hazeAltitudeKeyLight_m{ model::initialHazeKeyLightAltitude_m }; - float backgroundBlendValue{ initialBackgroundBlendValue }; + float backgroundBlendValue{ model::initialBackgroundBlendValue }; // methods void setHazeColorR(const float value); diff --git a/libraries/script-engine/src/SceneScriptingInterface.cpp b/libraries/script-engine/src/SceneScriptingInterface.cpp index 953fafcd23..7f788f11e3 100644 --- a/libraries/script-engine/src/SceneScriptingInterface.cpp +++ b/libraries/script-engine/src/SceneScriptingInterface.cpp @@ -153,18 +153,60 @@ QString SceneScripting::Stage::getHazeMode() const { void SceneScripting::Stage::setHazeRange(const float hazeRange) { _skyStage->setHazeRange(hazeRange); } - float SceneScripting::Stage::getHazeRange() const { return _skyStage->getHazeRange(); } +void SceneScripting::Stage::setHazeBlendInColor(const xColor hazeBlendInColor) { + _skyStage->setHazeBlendInColor(hazeBlendInColor); +} +xColor SceneScripting::Stage::getHazeBlendInColor() const { + return _skyStage->getHazeBlendInColor(); +} +void SceneScripting::Stage::setHazeBlendOutColor(const xColor hazeBlendOutColor) { + _skyStage->setHazeBlendOutColor(hazeBlendOutColor); +} +xColor SceneScripting::Stage::getHazeBlendOutColor() const { + return _skyStage->getHazeBlendOutColor(); +} +void SceneScripting::Stage::setHazeLightBlendAngle(const float hazeLightBlendAngle) { + _skyStage->setHazeLightBlendAngle(hazeLightBlendAngle); +} +float SceneScripting::Stage::getHazeLightBlendAngle() const { + return _skyStage->getHazeLightBlendAngle(); +} void SceneScripting::Stage::setHazeAltitude(const float hazeAltitude) { _skyStage->setHazeAltitude(hazeAltitude); } - float SceneScripting::Stage::getHazeAltitude() const { return _skyStage->getHazeAltitude(); } +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::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 diff --git a/libraries/script-engine/src/SceneScriptingInterface.h b/libraries/script-engine/src/SceneScriptingInterface.h index 342f2c548c..d0ff6b32b9 100644 --- a/libraries/script-engine/src/SceneScriptingInterface.h +++ b/libraries/script-engine/src/SceneScriptingInterface.h @@ -128,10 +128,33 @@ namespace SceneScripting { Q_PROPERTY(float hazeRange READ getHazeRange WRITE setHazeRange) void setHazeRange(float value); float getHazeRange() const; + Q_PROPERTY(xColor hazeBlendInColor READ getHazeBlendInColor WRITE setHazeBlendInColor) + void setHazeBlendInColor(xColor value); + xColor getHazeBlendInColor() const; + Q_PROPERTY(xColor hazeBlendOutColor READ getHazeBlendOutColor WRITE setHazeBlendOutColor) + void setHazeBlendOutColor(xColor value); + xColor getHazeBlendOutColor() const; + Q_PROPERTY(float hazeLightBlendAngle READ getHazeLightBlendAngle WRITE setHazeLightBlendAngle) + void setHazeLightBlendAngle(float value); + float getHazeLightBlendAngle() const; Q_PROPERTY(float hazeAltitude READ getHazeAltitude WRITE setHazeAltitude) void setHazeAltitude(float value); float getHazeAltitude() 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(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; From 951ce247a2a13ec13fdc6598be52437aa98cabd9 Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Fri, 29 Sep 2017 17:36:14 -0700 Subject: [PATCH 19/94] Working on adding zone to haze. --- .../entities/src/EntityItemProperties.cpp | 20 +++++++++---------- libraries/entities/src/HazePropertyGroup.cpp | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp index b75809b2f0..30b5cdc870 100644 --- a/libraries/entities/src/EntityItemProperties.cpp +++ b/libraries/entities/src/EntityItemProperties.cpp @@ -1118,20 +1118,20 @@ void EntityItemProperties::entityPropertyFlagsFromScriptValue(const QScriptValue ADD_GROUP_PROPERTY_TO_MAP(PROP_SKYBOX_COLOR, Skybox, skybox, Color, color); ADD_GROUP_PROPERTY_TO_MAP(PROP_SKYBOX_URL, Skybox, skybox, URL, url); - ADD_PROPERTY_TO_MAP(PROP_HAZE_MODE, HazeMode, hazeMode, HazeMode); + ADD_PROPERTY_TO_MAP(PROP_HAZE_MODE, HazeMode, hazeMode, uint8_t); - ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_ALTITUDE, Haze, haze, HazeRange, HazeRange, hazeRange); - ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_BLEND_IN_COLOR, Haze, haze, HazeBlendInColor, hazeBlendInColor); - ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_BLEND_OUT_COLOR, Haze, haze, HazeBlendOutColor, hazeBlendOutColor); - ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_LIGHT_BLEND_ANGLE, Haze, haze, HazeLightBlendAngle, hazeLightBlendAngle); + ADD_PROPERTY_TO_MAP(PROP_HAZE_ALTITUDE, HazeRange, hazeRange, float); + ADD_PROPERTY_TO_MAP(PROP_HAZE_BLEND_IN_COLOR, HazeBlendInColor, hazeBlendInColor, xColor); + ADD_PROPERTY_TO_MAP(PROP_HAZE_BLEND_OUT_COLOR, HazeBlendOutColor, hazeBlendOutColor, xColor); + ADD_PROPERTY_TO_MAP(PROP_HAZE_LIGHT_BLEND_ANGLE, HazeLightBlendAngle, hazeLightBlendAngle, float); - ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_ALTITUDE, Haze, haze, HazeAltitude, hazeAltitude); - ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_BASE_REF, Haze, haze, HazeBaseRef, hazeBaseRef); + ADD_PROPERTY_TO_MAP(PROP_HAZE_ALTITUDE, HazeAltitude, hazeAltitude, float); + ADD_PROPERTY_TO_MAP(PROP_HAZE_BASE_REF, HazeBaseRef, hazeBaseRef, float); - ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_BACKGROUND_BLEND, Haze, haze, HazeBackgroundBlend, hazeBackgroundBlend); + ADD_PROPERTY_TO_MAP(PROP_HAZE_BACKGROUND_BLEND, HazeBackgroundBlend, hazeBackgroundBlend, float); - ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_KEYLIGHT_RANGE, Haze, haze, HazeKeyLightRange, hazeKeyLightRange); - ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_KEYLIGHT_ALTITUDE, Haze, haze, HazeKeyLightAltitude, hazeKeyLightAltitude); + ADD_PROPERTY_TO_MAP(PROP_HAZE_KEYLIGHT_RANGE, HazeKeyLightRange, hazeKeyLightRange, float); + ADD_PROPERTY_TO_MAP(PROP_HAZE_KEYLIGHT_ALTITUDE, HazeKeyLightAltitude, hazeKeyLightAltitude, float); ADD_GROUP_PROPERTY_TO_MAP(PROP_STAGE_SUN_MODEL_ENABLED, Stage, stage, SunModelEnabled, sunModelEnabled); ADD_GROUP_PROPERTY_TO_MAP(PROP_STAGE_LATITUDE, Stage, stage, Latitude, latitude); diff --git a/libraries/entities/src/HazePropertyGroup.cpp b/libraries/entities/src/HazePropertyGroup.cpp index 3bad0cfda3..57bd5c0739 100644 --- a/libraries/entities/src/HazePropertyGroup.cpp +++ b/libraries/entities/src/HazePropertyGroup.cpp @@ -33,7 +33,7 @@ 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_MODE, Haze, haze, HazeMode, hazeMode); - COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_BLEND_IN_COLOR, Haze, haze, HazeRange, hazeRange); + COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_RANGE, Haze, haze, HazeRange, hazeRange); COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_BLEND_IN_COLOR, Haze, haze, HazeBlendInColor, hazeBlendIncolor); COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_BLEND_OUT_COLOR, Haze, haze, HazeBlendOutColor, hazeBlendOutcolor); COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_LIGHT_BLEND_ANGLE, Haze, haze, HazeLightBlendAngle, hazeLightBlendAngle); @@ -184,7 +184,7 @@ bool HazePropertyGroup::decodeFromEditPacket(EntityPropertyFlags& propertyFlags, READ_ENTITY_PROPERTY(PROP_HAZE_KEYLIGHT_RANGE, float, setHazeKeyLightRange); READ_ENTITY_PROPERTY(PROP_HAZE_KEYLIGHT_ALTITUDE, float, setHazeKeyLightAltitude); - DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_RANGE, HazeMode); + DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_MODE, HazeMode); DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_RANGE, HazeRange); DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_BLEND_IN_COLOR, HazeBlendInColor); From 95f8f1ffc5e86316881bc4898791f54a4524bd01 Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Fri, 29 Sep 2017 18:05:48 -0700 Subject: [PATCH 20/94] Added Varying8 --- libraries/render/src/task/Task.h | 1 + libraries/render/src/task/Varying.h | 37 ++++++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/libraries/render/src/task/Task.h b/libraries/render/src/task/Task.h index e99b33305c..a8137fd239 100644 --- a/libraries/render/src/task/Task.h +++ b/libraries/render/src/task/Task.h @@ -325,6 +325,7 @@ protected: template < typename T0, typename T1, typename T2, typename T3, typename T4 > using VaryingSet5 = task::VaryingSet5; \ template < typename T0, typename T1, typename T2, typename T3, typename T4, typename T5 > using VaryingSet6 = task::VaryingSet6; \ template < typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6 > using VaryingSet7 = task::VaryingSet7; \ + template < typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7 > using VaryingSet8 = task::VaryingSet8; \ template < class T, int NUM > using VaryingArray = task::VaryingArray; #endif // hifi_task_Task_h diff --git a/libraries/render/src/task/Varying.h b/libraries/render/src/task/Varying.h index 9ce234061e..7b7b9907fb 100644 --- a/libraries/render/src/task/Varying.h +++ b/libraries/render/src/task/Varying.h @@ -292,7 +292,42 @@ public: Varying asVarying() const { return Varying((*this)); } }; - +template +class VaryingSet8 : public std::tuple { +public: + using Parent = std::tuple; + + VaryingSet8() : Parent(Varying(T0()), Varying(T1()), Varying(T2()), Varying(T3()), Varying(T4()), Varying(T5()), Varying(T6()), Varying(T7())) {} + VaryingSet8(const VaryingSet8& src) : Parent(std::get<0>(src), std::get<1>(src), std::get<2>(src), std::get<3>(src), std::get<4>(src), std::get<5>(src), std::get<6>(src), std::get<7>(src)) {} + VaryingSet8(const Varying& first, const Varying& second, const Varying& third, const Varying& fourth, const Varying& fifth, const Varying& sixth, const Varying& seventh, const Varying& eighth) : Parent(first, second, third, fourth, fifth, sixth, seventh, eighth) {} + + const T0& get0() const { return std::get<0>((*this)).template get(); } + T0& edit0() { return std::get<0>((*this)).template edit(); } + + const T1& get1() const { return std::get<1>((*this)).template get(); } + T1& edit1() { return std::get<1>((*this)).template edit(); } + + const T2& get2() const { return std::get<2>((*this)).template get(); } + T2& edit2() { return std::get<2>((*this)).template edit(); } + + const T3& get3() const { return std::get<3>((*this)).template get(); } + T3& edit3() { return std::get<3>((*this)).template edit(); } + + const T4& get4() const { return std::get<4>((*this)).template get(); } + T4& edit4() { return std::get<4>((*this)).template edit(); } + + const T5& get5() const { return std::get<5>((*this)).template get(); } + T5& edit5() { return std::get<5>((*this)).template edit(); } + + const T6& get6() const { return std::get<6>((*this)).template get(); } + T6& edit6() { return std::get<6>((*this)).template edit(); } + + const T7& get7() const { return std::get<7>((*this)).template get(); } + T7& edit7() { return std::get<7>((*this)).template edit(); } + + Varying asVarying() const { return Varying((*this)); } +}; + template < class T, int NUM > class VaryingArray : public std::array { public: From 5a7fed022cca3d291d71907283231b7a4e4da4d0 Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Sat, 30 Sep 2017 00:04:28 -0700 Subject: [PATCH 21/94] Merging haze branch. --- .../render-utils/src/DeferredGlobalLight.slh | 51 ++++++++++++++++++- .../src/DeferredLightingEffect.cpp | 19 +++++-- .../render-utils/src/DeferredLightingEffect.h | 6 ++- .../render-utils/src/RenderDeferredTask.cpp | 2 +- libraries/render/src/task/Varying.h | 4 +- 5 files changed, 72 insertions(+), 10 deletions(-) diff --git a/libraries/render-utils/src/DeferredGlobalLight.slh b/libraries/render-utils/src/DeferredGlobalLight.slh index 57ca33eaca..ae560686e1 100644 --- a/libraries/render-utils/src/DeferredGlobalLight.slh +++ b/libraries/render-utils/src/DeferredGlobalLight.slh @@ -101,6 +101,8 @@ vec3 albedo, vec3 fresnel, float metallic, float roughness <$declareDeferredCurvature()$> <@endif@> +<@include Haze.slh@> + vec3 evalSkyboxGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 position, vec3 normal, vec3 albedo, vec3 fresnel, float metallic, float roughness <@if supportScattering@> @@ -120,7 +122,6 @@ vec3 evalSkyboxGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscu color += ambientDiffuse; color += ambientSpecular; - // Directional vec3 directionalDiffuse; vec3 directionalSpecular; @@ -132,6 +133,54 @@ vec3 evalSkyboxGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscu color += directionalDiffuse; color += directionalSpecular; + // Attenuate the light if haze effect selected + if ((hazeParams.hazeMode & HAZE_MODE_IS_DIRECTIONAL_LIGHT_ATTENUATED) == HAZE_MODE_IS_DIRECTIONAL_LIGHT_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 + // + // The distance is computed from the height and the directional light orientation + // The distance is limited to height * 1,000, which gives an angle of ~0.057 degrees + + // Get directional light + Light light = getLight(); + vec3 lightDirection = getLightDirection(light); + + // Height at which haze density is reduced by 95% + float height_95p = -log(0.05) / hazeParams.hazeAltitudeFactorKeyLight; + + // Note that the sine will always be positive + float sin_pitch = sqrt(1.0 - lightDirection.y * lightDirection.y); + + float distance; + const float minimumSinPitch = 0.001; + if (sin_pitch < minimumSinPitch) { + distance = height_95p / minimumSinPitch; + } + else { + distance = height_95p / sin_pitch; + } + + // Position of fragment in world coordinates + vec4 worldFragPos = invViewMat * vec4(position, 0.0); + + // 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)); + + float hazeIntegral = hazeDensityDistribution * distance; + + // Note that t is constant and equal to -log(0.05) + // float t = hazeParams.hazeAltitudeFactor * height_95p; + // hazeIntegral *= (1.0 - exp (-t)) / t; + hazeIntegral *= 0.3171178; + + float hazeAmount = 1.0 - exp(-hazeIntegral); + + color = mix(color, vec3(0.0, 0.0, 0.0), hazeAmount); + } + return color; } diff --git a/libraries/render-utils/src/DeferredLightingEffect.cpp b/libraries/render-utils/src/DeferredLightingEffect.cpp index 201cec5b2d..20292af679 100644 --- a/libraries/render-utils/src/DeferredLightingEffect.cpp +++ b/libraries/render-utils/src/DeferredLightingEffect.cpp @@ -76,7 +76,7 @@ enum DeferredShader_BufferSlot { LIGHT_CLUSTER_GRID_FRUSTUM_GRID_SLOT, LIGHT_CLUSTER_GRID_CLUSTER_GRID_SLOT, LIGHT_CLUSTER_GRID_CLUSTER_CONTENT_SLOT, - + HAZE_MODEL_BUFFER_SLOT }; static void loadLightProgram(const char* vertSource, const char* fragSource, bool lightVolume, gpu::PipelinePointer& program, LightLocationsPtr& locations); @@ -169,6 +169,7 @@ static gpu::ShaderPointer makeLightProgram(const char* vertSource, const char* f slotBindings.insert(gpu::Shader::Binding(std::string("cameraCorrectionBuffer"), CAMERA_CORRECTION_BUFFER_SLOT)); slotBindings.insert(gpu::Shader::Binding(std::string("deferredFrameTransformBuffer"), DEFERRED_FRAME_TRANSFORM_BUFFER_SLOT)); slotBindings.insert(gpu::Shader::Binding(std::string("lightingModelBuffer"), LIGHTING_MODEL_BUFFER_SLOT)); + slotBindings.insert(gpu::Shader::Binding(std::string("hazeBuffer"), HAZE_MODEL_BUFFER_SLOT)); slotBindings.insert(gpu::Shader::Binding(std::string("subsurfaceScatteringParametersBuffer"), SCATTERING_PARAMETERS_BUFFER_SLOT)); slotBindings.insert(gpu::Shader::Binding(std::string("lightBuffer"), LIGHT_GPU_SLOT)); slotBindings.insert(gpu::Shader::Binding(std::string("lightAmbientBuffer"), LIGHT_AMBIENT_SLOT)); @@ -438,6 +439,7 @@ void RenderDeferredSetup::run(const render::RenderContextPointer& renderContext, const DeferredFrameTransformPointer& frameTransform, const DeferredFramebufferPointer& deferredFramebuffer, const LightingModelPointer& lightingModel, + const model::HazePointer& haze, const SurfaceGeometryFramebufferPointer& surfaceGeometryFramebuffer, const AmbientOcclusionFramebufferPointer& ambientOcclusionFramebuffer, const SubsurfaceScatteringResourcePointer& subsurfaceScatteringResource) { @@ -538,6 +540,7 @@ void RenderDeferredSetup::run(const render::RenderContextPointer& renderContext, batch.setUniformBuffer(locations->shadowTransformBuffer, globalShadow->getBuffer()); } } + batch.setPipeline(program); } @@ -547,7 +550,10 @@ void RenderDeferredSetup::run(const render::RenderContextPointer& renderContext, // Setup the global lighting deferredLightingEffect->setupKeyLightBatch(args, batch, locations->lightBufferUnit, locations->ambientBufferUnit, SKYBOX_MAP_UNIT); - + + // Haze + batch.setUniformBuffer(HAZE_MODEL_BUFFER_SLOT, haze->getParametersBuffer()); + batch.draw(gpu::TRIANGLE_STRIP, 4); deferredLightingEffect->unsetKeyLightBatch(batch, locations->lightBufferUnit, locations->ambientBufferUnit, SKYBOX_MAP_UNIT); @@ -566,7 +572,8 @@ void RenderDeferredLocals::run(const render::RenderContextPointer& renderContext const DeferredFrameTransformPointer& frameTransform, const DeferredFramebufferPointer& deferredFramebuffer, const LightingModelPointer& lightingModel, - const SurfaceGeometryFramebufferPointer& surfaceGeometryFramebuffer, const LightClustersPointer& lightClusters) { + const SurfaceGeometryFramebufferPointer& surfaceGeometryFramebuffer, + const LightClustersPointer& lightClusters) { bool points = lightingModel->isPointLightEnabled(); bool spots = lightingModel->isSpotLightEnabled(); @@ -675,6 +682,8 @@ void RenderDeferred::run(const RenderContextPointer& renderContext, const Inputs auto lightClusters = inputs.get6(); auto args = renderContext->args; + const auto haze = inputs.get7(); + if (!_gpuTimer) { _gpuTimer = std::make_shared < gpu::RangeTimer>(__FUNCTION__); } @@ -684,7 +693,7 @@ void RenderDeferred::run(const RenderContextPointer& renderContext, const Inputs args->_batch = &batch; _gpuTimer->begin(batch); - setupJob.run(renderContext, deferredTransform, deferredFramebuffer, lightingModel, surfaceGeometryFramebuffer, ssaoFramebuffer, subsurfaceScatteringResource); + setupJob.run(renderContext, deferredTransform, deferredFramebuffer, lightingModel, haze, surfaceGeometryFramebuffer, ssaoFramebuffer, subsurfaceScatteringResource); lightsJob.run(renderContext, deferredTransform, deferredFramebuffer, lightingModel, surfaceGeometryFramebuffer, lightClusters); @@ -720,7 +729,7 @@ void DefaultLightingSetup::run(const RenderContextPointer& renderContext) { } auto lightStage = renderContext->_scene->getStage(); - if (lightStage) { + if (lightStage) { // Allocate a default global light directional and ambient auto lp = std::make_shared(); diff --git a/libraries/render-utils/src/DeferredLightingEffect.h b/libraries/render-utils/src/DeferredLightingEffect.h index 1f8ba88e27..4266efc7b8 100644 --- a/libraries/render-utils/src/DeferredLightingEffect.h +++ b/libraries/render-utils/src/DeferredLightingEffect.h @@ -121,6 +121,7 @@ public: const DeferredFrameTransformPointer& frameTransform, const DeferredFramebufferPointer& deferredFramebuffer, const LightingModelPointer& lightingModel, + const model::HazePointer& haze, const SurfaceGeometryFramebufferPointer& surfaceGeometryFramebuffer, const AmbientOcclusionFramebufferPointer& ambientOcclusionFramebuffer, const SubsurfaceScatteringResourcePointer& subsurfaceScatteringResource); @@ -155,7 +156,10 @@ using RenderDeferredConfig = render::GPUJobConfig; class RenderDeferred { public: - using Inputs = render::VaryingSet7 < DeferredFrameTransformPointer, DeferredFramebufferPointer, LightingModelPointer, SurfaceGeometryFramebufferPointer, AmbientOcclusionFramebufferPointer, SubsurfaceScatteringResourcePointer, LightClustersPointer>; + using Inputs = render::VaryingSet8 < + DeferredFrameTransformPointer, DeferredFramebufferPointer, LightingModelPointer, SurfaceGeometryFramebufferPointer, + AmbientOcclusionFramebufferPointer, SubsurfaceScatteringResourcePointer, LightClustersPointer, model::HazePointer>; + using Config = RenderDeferredConfig; using JobModel = render::Job::ModelI; diff --git a/libraries/render-utils/src/RenderDeferredTask.cpp b/libraries/render-utils/src/RenderDeferredTask.cpp index e4f0c31a14..e3029c453c 100644 --- a/libraries/render-utils/src/RenderDeferredTask.cpp +++ b/libraries/render-utils/src/RenderDeferredTask.cpp @@ -152,7 +152,7 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren // DeferredBuffer is complete, now let's shade it into the LightingBuffer const auto deferredLightingInputs = RenderDeferred::Inputs(deferredFrameTransform, deferredFramebuffer, lightingModel, - surfaceGeometryFramebuffer, ambientOcclusionFramebuffer, scatteringResource, lightClusters).asVarying(); + surfaceGeometryFramebuffer, ambientOcclusionFramebuffer, scatteringResource, lightClusters, hazeModel).asVarying(); task.addJob("RenderDeferred", deferredLightingInputs); diff --git a/libraries/render/src/task/Varying.h b/libraries/render/src/task/Varying.h index 7b7b9907fb..cd2f9a2d2f 100644 --- a/libraries/render/src/task/Varying.h +++ b/libraries/render/src/task/Varying.h @@ -285,10 +285,10 @@ public: const T5& get5() const { return std::get<5>((*this)).template get(); } T5& edit5() { return std::get<5>((*this)).template edit(); } - + const T6& get6() const { return std::get<6>((*this)).template get(); } T6& edit6() { return std::get<6>((*this)).template edit(); } - + Varying asVarying() const { return Varying((*this)); } }; From ffecf42ebb4a0f266c5d1261257338f5967424ff Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Sun, 1 Oct 2017 21:12:29 -0700 Subject: [PATCH 22/94] Some clean-up. --- libraries/model/src/model/Haze.cpp | 16 ++++++++-------- libraries/model/src/model/Haze.h | 4 ++-- libraries/render-utils/src/DrawHaze.cpp | 2 +- libraries/render-utils/src/DrawHaze.h | 2 +- libraries/render/src/task/Varying.h | 4 ++-- libraries/shared/src/HazeMode.h | 2 +- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/libraries/model/src/model/Haze.cpp b/libraries/model/src/model/Haze.cpp index 7daca3c77c..946850747e 100644 --- a/libraries/model/src/model/Haze.cpp +++ b/libraries/model/src/model/Haze.cpp @@ -154,14 +154,6 @@ void Haze::setHazeKeyLightAltitudeFactor(const float hazeKeyLightAltitudeFactor) } } -void Haze::setHazeBackgroundBlendValue(const float hazeBackgroundBlendValue) { - auto& params = _parametersBuffer.get(); - - if (params.hazeBackgroundBlendValue != hazeBackgroundBlendValue) { - _parametersBuffer.edit().hazeBackgroundBlendValue = hazeBackgroundBlendValue; - } -} - void Haze::setHazeBaseReference(const float hazeBaseReference) { auto& params = _parametersBuffer.get(); @@ -169,3 +161,11 @@ void Haze::setHazeBaseReference(const float hazeBaseReference) { _parametersBuffer.edit().hazeBaseReference = hazeBaseReference; } } + +void Haze::setHazeBackgroundBlendValue(const float hazeBackgroundBlendValue) { + auto& params = _parametersBuffer.get(); + + if (params.hazeBackgroundBlendValue != hazeBackgroundBlendValue) { + _parametersBuffer.edit().hazeBackgroundBlendValue = hazeBackgroundBlendValue; + } +} diff --git a/libraries/model/src/model/Haze.h b/libraries/model/src/model/Haze.h index 7ba09c86e7..320f3a0148 100644 --- a/libraries/model/src/model/Haze.h +++ b/libraries/model/src/model/Haze.h @@ -50,7 +50,7 @@ namespace model { const float initialHazeKeyLightRange_m{ 150.0f }; const float initialHazeKeyLightAltitude_m{ 150.0f }; - const float initialBackgroundBlendValue{ 0.0f }; + const float initialHazeBackgroundBlendValue{ 0.0f }; const glm::vec3 initialColorModulationFactor{ convertHazeRangeToHazeRangeFactor(initialHazeRange_m), @@ -108,7 +108,7 @@ namespace model { float hazeKeyLightAltitudeFactor{ convertHazeAltitudeToHazeAltitudeFactor(initialHazeKeyLightAltitude_m) }; // Amount of background (skybox) to display, overriding the haze effect for the background - float hazeBackgroundBlendValue{ initialBackgroundBlendValue }; + float hazeBackgroundBlendValue{ initialHazeBackgroundBlendValue }; Parameters() {} }; diff --git a/libraries/render-utils/src/DrawHaze.cpp b/libraries/render-utils/src/DrawHaze.cpp index 291ceb73fd..d0fa667519 100644 --- a/libraries/render-utils/src/DrawHaze.cpp +++ b/libraries/render-utils/src/DrawHaze.cpp @@ -84,7 +84,7 @@ void HazeConfig::setHazeAltitudeKeyLight_m(const float value) { } void HazeConfig::setBackgroundBlendValue(const float value) { - backgroundBlendValue = value; + hazeBackgroundBlendValue = value; } const int HazeEffect_ParamsSlot = 0; diff --git a/libraries/render-utils/src/DrawHaze.h b/libraries/render-utils/src/DrawHaze.h index a246c3ca87..bd6e44c977 100644 --- a/libraries/render-utils/src/DrawHaze.h +++ b/libraries/render-utils/src/DrawHaze.h @@ -52,7 +52,7 @@ public: float hazeRangeKeyLight_m{ model::initialHazeKeyLightRange_m }; float hazeAltitudeKeyLight_m{ model::initialHazeKeyLightAltitude_m }; - float backgroundBlendValue{ model::initialBackgroundBlendValue }; + float hazeBackgroundBlendValue{ model::initialHazeBackgroundBlendValue }; // methods void setHazeColorR(const float value); diff --git a/libraries/render/src/task/Varying.h b/libraries/render/src/task/Varying.h index cd2f9a2d2f..7b7b9907fb 100644 --- a/libraries/render/src/task/Varying.h +++ b/libraries/render/src/task/Varying.h @@ -285,10 +285,10 @@ public: const T5& get5() const { return std::get<5>((*this)).template get(); } T5& edit5() { return std::get<5>((*this)).template edit(); } - + const T6& get6() const { return std::get<6>((*this)).template get(); } T6& edit6() { return std::get<6>((*this)).template edit(); } - + Varying asVarying() const { return Varying((*this)); } }; diff --git a/libraries/shared/src/HazeMode.h b/libraries/shared/src/HazeMode.h index 18f67bdf31..0c0af013cd 100644 --- a/libraries/shared/src/HazeMode.h +++ b/libraries/shared/src/HazeMode.h @@ -2,7 +2,7 @@ // HazeMode.h // libraries/entities/src // -// Created by Nissim hadar on 9/21/17. +// Created by Nissim Hadar on 9/21/17. // Copyright 2013 High Fidelity, Inc. // // Distributed under the Apache License, Version 2.0. From bdd469cec460871ee8c7d8d865a0333c42e0391b Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Sun, 1 Oct 2017 21:52:34 -0700 Subject: [PATCH 23/94] Integrated haze shader into this branch. --- libraries/entities/src/HazePropertyGroup.h | 2 +- libraries/model/src/model/Haze.cpp | 20 ++-- libraries/render-utils/src/DrawHaze.cpp | 39 ++++++- libraries/render-utils/src/DrawHaze.h | 104 +++++++++++++++++- .../render-utils/src/RenderDeferredTask.cpp | 3 +- 5 files changed, 146 insertions(+), 22 deletions(-) diff --git a/libraries/entities/src/HazePropertyGroup.h b/libraries/entities/src/HazePropertyGroup.h index 355dc3b808..136c11080e 100644 --- a/libraries/entities/src/HazePropertyGroup.h +++ b/libraries/entities/src/HazePropertyGroup.h @@ -105,7 +105,7 @@ public: // Background (skybox) blend value DEFINE_PROPERTY(PROP_HAZE_BACKGROUND_BLEND, HazeBackgroundBlend, hazeBackgroundBlend, float, DEFAULT_HAZE_BACKGROUND_BLEND); - // Directional light attenuation + // hazeDirectional light attenuation DEFINE_PROPERTY(PROP_HAZE_KEYLIGHT_RANGE, HazeKeyLightRange, hazeKeyLightRange, float, DEFAULT_HAZE_KEYLIGHT_RANGE); DEFINE_PROPERTY(PROP_HAZE_KEYLIGHT_ALTITUDE, HazeKeyLightAltitude, hazeKeyLightAltitude, float, DEFAULT_HAZE_KEYLIGHT_ALTITUDE); }; diff --git a/libraries/model/src/model/Haze.cpp b/libraries/model/src/model/Haze.cpp index 946850747e..7500bec102 100644 --- a/libraries/model/src/model/Haze.cpp +++ b/libraries/model/src/model/Haze.cpp @@ -57,25 +57,25 @@ void Haze::setHazeColor(const glm::vec3 hazeColor) { } } -void Haze::setDirectionalLightBlend(const float directionalLightBlend) { +void Haze::setDirectionalLightBlend(const float hazeDirectionalLightBlend) { auto& params = _parametersBuffer.get(); - if (params.directionalLightBlend != directionalLightBlend) { - _parametersBuffer.edit().directionalLightBlend = directionalLightBlend; + if (params.directionalLightBlend != hazeDirectionalLightBlend) { + _parametersBuffer.edit().directionalLightBlend = hazeDirectionalLightBlend; } } -void Haze::setDirectionalLightColor(const glm::vec3 directionalLightColor) { +void Haze::setDirectionalLightColor(const glm::vec3 hazeDirectionalLightColor) { auto& params = _parametersBuffer.get(); - if (params.directionalLightColor.r != directionalLightColor.r) { - _parametersBuffer.edit().directionalLightColor.r = directionalLightColor.r; + if (params.directionalLightColor.r != hazeDirectionalLightColor.r) { + _parametersBuffer.edit().directionalLightColor.r = hazeDirectionalLightColor.r; } - if (params.directionalLightColor.g != directionalLightColor.g) { - _parametersBuffer.edit().directionalLightColor.g = directionalLightColor.g; + if (params.directionalLightColor.g != hazeDirectionalLightColor.g) { + _parametersBuffer.edit().directionalLightColor.g = hazeDirectionalLightColor.g; } - if (params.directionalLightColor.b != directionalLightColor.b) { - _parametersBuffer.edit().directionalLightColor.b = directionalLightColor.b; + if (params.directionalLightColor.b != hazeDirectionalLightColor.b) { + _parametersBuffer.edit().directionalLightColor.b = hazeDirectionalLightColor.b; } } void Haze::setIsHazeActive(const bool isHazeActive) { diff --git a/libraries/render-utils/src/DrawHaze.cpp b/libraries/render-utils/src/DrawHaze.cpp index d0fa667519..cc984c2875 100644 --- a/libraries/render-utils/src/DrawHaze.cpp +++ b/libraries/render-utils/src/DrawHaze.cpp @@ -32,19 +32,19 @@ void HazeConfig::setHazeColorB(const float value) { } void HazeConfig::setDirectionalLightAngle_degs(const float value) { - directionalLightAngle_degs = value; + hazeDirectionalLightAngle_degs = value; } void HazeConfig::setDirectionalLightColorR(const float value) { - directionalLightColorR = value; + hazeDirectionalLightColorR = value; } void HazeConfig::setDirectionalLightColorG(const float value) { - directionalLightColorG = value; + hazeDirectionalLightColorG = value; } void HazeConfig::setDirectionalLightColorB(const float value) { - directionalLightColorB = value; + hazeDirectionalLightColorB = value; } void HazeConfig::setHazeBaseReference(const float value) { @@ -83,10 +83,39 @@ void HazeConfig::setHazeAltitudeKeyLight_m(const float value) { hazeAltitudeKeyLight_m = value; } -void HazeConfig::setBackgroundBlendValue(const float value) { +void HazeConfig::setHazeBackgroundBlendValue(const float value) { hazeBackgroundBlendValue = value; } +MakeHaze::MakeHaze() { + _haze = std::make_shared(); +} + +void MakeHaze::configure(const Config& config) { + _haze->setHazeColor(glm::vec3(config.hazeColorR, config.hazeColorG, config.hazeColorB)); + _haze->setDirectionalLightBlend(model::convertDirectionalLightAngleToPower(config.hazeDirectionalLightAngle_degs)); + + _haze->setDirectionalLightColor(glm::vec3(config.hazeDirectionalLightColorR, config.hazeDirectionalLightColorG, config.hazeDirectionalLightColorB)); + _haze->setHazeBaseReference(config.hazeBaseReference); + + _haze->setIsHazeActive(config.isHazeActive); + _haze->setIsAltitudeBased(config.isAltitudeBased); + _haze->setIsDirectionaLightAttenuationActive(config.isDirectionaLightAttenuationActive); + _haze->setIsModulateColorActive(config.isModulateColorActive); + + _haze->setHazeRangeFactor(model::convertHazeRangeToHazeRangeFactor(config.hazeRange_m)); + _haze->setHazeAltitudeFactor(model::convertHazeAltitudeToHazeAltitudeFactor(config.hazeAltitude_m)); + + _haze->setHazeKeyLightRangeFactor(model::convertHazeRangeToHazeRangeFactor(config.hazeKeyLightRange_m)); + _haze->setHazeKeyLightAltitudeFactor(model::convertHazeAltitudeToHazeAltitudeFactor(config.hazeKeyLightAltitude_m)); + + _haze->setHazeBackgroundBlendValue(config.hazeBackgroundBlendValue); +} + +void MakeHaze::run(const render::RenderContextPointer& renderContext, model::HazePointer& haze) { + haze = _haze; +} + const int HazeEffect_ParamsSlot = 0; const int HazeEffect_TransformBufferSlot = 1; diff --git a/libraries/render-utils/src/DrawHaze.h b/libraries/render-utils/src/DrawHaze.h index bd6e44c977..7022ea4b22 100644 --- a/libraries/render-utils/src/DrawHaze.h +++ b/libraries/render-utils/src/DrawHaze.h @@ -26,6 +26,100 @@ 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(float hazeDirectionalLightAngle_degs MEMBER hazeDirectionalLightAngle_degs WRITE setDirectionalLightAngle_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(bool isHazeActive MEMBER isHazeActive WRITE setIsHazeActive NOTIFY dirty); + Q_PROPERTY(bool isAltitudeBased MEMBER isAltitudeBased WRITE setIsAltitudeBased NOTIFY dirty); + Q_PROPERTY(bool isDirectionaLightAttenuationActive MEMBER isDirectionaLightAttenuationActive WRITE setIsDirectionaLightAttenuationActive NOTIFY dirty); + Q_PROPERTY(bool isModulateColorActive MEMBER isModulateColorActive WRITE setIsModulateColorActive 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 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); + +public: + MakeHazeConfig() : render::Job::Config() {} + + float hazeColorR{ model::initialHazeColor.r }; + float hazeColorG{ model::initialHazeColor.g }; + float hazeColorB{ model::initialHazeColor.b }; + float hazeDirectionalLightAngle_degs{ model::initialDirectionalLightAngle_degs }; + + float hazeDirectionalLightColorR{ model::initialDirectionalLightColor.r }; + float hazeDirectionalLightColorG{ model::initialDirectionalLightColor.g }; + float hazeDirectionalLightColorB{ model::initialDirectionalLightColor.b }; + float hazeBaseReference{ model::initialHazeBaseReference }; + + bool isHazeActive{ false }; + bool isAltitudeBased{ false }; + bool isDirectionaLightAttenuationActive{ false }; + bool isModulateColorActive{ false }; + + float hazeRange_m{ model::initialHazeRange_m }; + float hazeAltitude_m{ model::initialHazeAltitude_m }; + + float hazeKeyLightRange_m{ model::initialHazeKeyLightRange_m }; + float hazeKeyLightAltitude_m{ model::initialHazeKeyLightAltitude_m }; + + float hazeBackgroundBlendValue{ model::initialHazeBackgroundBlendValue }; + +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 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 setIsHazeActive(const bool active) { isHazeActive = active; emit dirty(); } + void setIsAltitudeBased(const bool active) { isAltitudeBased = active; emit dirty(); } + void setIsDirectionaLightAttenuationActive(const bool active) { isDirectionaLightAttenuationActive = active; emit dirty(); } + void setIsModulateColorActive(const bool active) { isModulateColorActive = 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 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(); } + +signals: + void dirty(); +}; + +class MakeHaze { +public: + using Config = MakeHazeConfig; + using JobModel = render::Job::ModelO; + + MakeHaze(); + + void configure(const Config& config); + void run(const render::RenderContextPointer& renderContext, model::HazePointer& haze); + +private: + model::HazePointer _haze; +}; + class HazeConfig : public render::Job::Config { public: HazeConfig() : render::Job::Config(true) {} @@ -34,11 +128,11 @@ public: float hazeColorR{ model::initialHazeColor.r }; float hazeColorG{ model::initialHazeColor.g }; float hazeColorB{ model::initialHazeColor.b }; - float directionalLightAngle_degs{ model::initialDirectionalLightAngle_degs }; + float hazeDirectionalLightAngle_degs{ model::initialDirectionalLightAngle_degs }; - float directionalLightColorR{ model::initialDirectionalLightColor.r }; - float directionalLightColorG{ model::initialDirectionalLightColor.g }; - float directionalLightColorB{ model::initialDirectionalLightColor.b }; + float hazeDirectionalLightColorR{ model::initialDirectionalLightColor.r }; + float hazeDirectionalLightColorG{ model::initialDirectionalLightColor.g }; + float hazeDirectionalLightColorB{ model::initialDirectionalLightColor.b }; float hazeBaseReference{ model::initialHazeBaseReference }; bool isHazeActive{ false }; // Setting this to true will set haze to on @@ -76,7 +170,7 @@ public: void setHazeRangeKeyLight_m(const float value); void setHazeAltitudeKeyLight_m(const float value); - void setBackgroundBlendValue(const float value); + void setHazeBackgroundBlendValue(const float value); }; class DrawHaze { diff --git a/libraries/render-utils/src/RenderDeferredTask.cpp b/libraries/render-utils/src/RenderDeferredTask.cpp index e3029c453c..ea5380aac0 100644 --- a/libraries/render-utils/src/RenderDeferredTask.cpp +++ b/libraries/render-utils/src/RenderDeferredTask.cpp @@ -148,7 +148,8 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren const auto lightClusters = task.addJob("LightClustering", lightClusteringPassInputs); // Add haze model - const auto hazeModel = task.addJob("FetchHazeStage"); + const auto hazeModel = task.addJob("HazeModel"); + ////const auto hazeModel = task.addJob("FetchHazeStage"); // DeferredBuffer is complete, now let's shade it into the LightingBuffer const auto deferredLightingInputs = RenderDeferred::Inputs(deferredFrameTransform, deferredFramebuffer, lightingModel, From 97756146b1d49af41cf01ae92debc7a68c8adb67 Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Mon, 2 Oct 2017 09:09:36 -0700 Subject: [PATCH 24/94] Attempt to add qml configuration --- libraries/render-utils/src/HazeStage.cpp | 25 ++++++ libraries/render-utils/src/HazeStage.h | 87 ++++++++++++++++++- .../render-utils/src/RenderDeferredTask.cpp | 4 +- 3 files changed, 113 insertions(+), 3 deletions(-) diff --git a/libraries/render-utils/src/HazeStage.cpp b/libraries/render-utils/src/HazeStage.cpp index b0255516ed..7bb73c0127 100644 --- a/libraries/render-utils/src/HazeStage.cpp +++ b/libraries/render-utils/src/HazeStage.cpp @@ -15,6 +15,31 @@ std::string HazeStage::_stageName { "HAZE_STAGE"}; +FetchHazeStage::FetchHazeStage() { + _haze = std::make_shared(); +} + +void FetchHazeStage::configure(const Config& config) { + _haze->setHazeColor(glm::vec3(config.hazeColorR, config.hazeColorG, config.hazeColorB)); + _haze->setDirectionalLightBlend(model::convertDirectionalLightAngleToPower(config.hazeDirectionalLightAngle_degs)); + + _haze->setDirectionalLightColor(glm::vec3(config.hazeDirectionalLightColorR, config.hazeDirectionalLightColorG, config.hazeDirectionalLightColorB)); + _haze->setHazeBaseReference(config.hazeBaseReference); + + _haze->setIsHazeActive(config.isHazeActive); + _haze->setIsAltitudeBased(config.isAltitudeBased); + _haze->setIsDirectionaLightAttenuationActive(config.isDirectionaLightAttenuationActive); + _haze->setIsModulateColorActive(config.isModulateColorActive); + + _haze->setHazeRangeFactor(model::convertHazeRangeToHazeRangeFactor(config.hazeRange_m)); + _haze->setHazeAltitudeFactor(model::convertHazeAltitudeToHazeAltitudeFactor(config.hazeAltitude_m)); + + _haze->setHazeKeyLightRangeFactor(model::convertHazeRangeToHazeRangeFactor(config.hazeKeyLightRange_m)); + _haze->setHazeKeyLightAltitudeFactor(model::convertHazeAltitudeToHazeAltitudeFactor(config.hazeKeyLightAltitude_m)); + + _haze->setHazeBackgroundBlendValue(config.hazeBackgroundBlendValue); +} + HazeStage::Index HazeStage::findHaze(const HazePointer& haze) const { auto found = _hazeMap.find(haze); if (found != _hazeMap.end()) { diff --git a/libraries/render-utils/src/HazeStage.h b/libraries/render-utils/src/HazeStage.h index 34f2e8b400..1fd111c404 100644 --- a/libraries/render-utils/src/HazeStage.h +++ b/libraries/render-utils/src/HazeStage.h @@ -80,13 +80,98 @@ public: 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(float hazeDirectionalLightAngle_degs MEMBER hazeDirectionalLightAngle_degs WRITE setDirectionalLightAngle_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(bool isHazeActive MEMBER isHazeActive WRITE setIsHazeActive NOTIFY dirty); + Q_PROPERTY(bool isAltitudeBased MEMBER isAltitudeBased WRITE setIsAltitudeBased NOTIFY dirty); + Q_PROPERTY(bool isDirectionaLightAttenuationActive MEMBER isDirectionaLightAttenuationActive WRITE setIsDirectionaLightAttenuationActive NOTIFY dirty); + Q_PROPERTY(bool isModulateColorActive MEMBER isModulateColorActive WRITE setIsModulateColorActive 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 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); + +public: + FetchHazeConfig() : render::Job::Config() {} + + float hazeColorR{ model::initialHazeColor.r }; + float hazeColorG{ model::initialHazeColor.g }; + float hazeColorB{ model::initialHazeColor.b }; + float hazeDirectionalLightAngle_degs{ model::initialDirectionalLightAngle_degs }; + + float hazeDirectionalLightColorR{ model::initialDirectionalLightColor.r }; + float hazeDirectionalLightColorG{ model::initialDirectionalLightColor.g }; + float hazeDirectionalLightColorB{ model::initialDirectionalLightColor.b }; + float hazeBaseReference{ model::initialHazeBaseReference }; + + bool isHazeActive{ false }; + bool isAltitudeBased{ false }; + bool isDirectionaLightAttenuationActive{ false }; + bool isModulateColorActive{ false }; + + float hazeRange_m{ model::initialHazeRange_m }; + float hazeAltitude_m{ model::initialHazeAltitude_m }; + + float hazeKeyLightRange_m{ model::initialHazeKeyLightRange_m }; + float hazeKeyLightAltitude_m{ model::initialHazeKeyLightAltitude_m }; + + float hazeBackgroundBlendValue{ model::initialHazeBackgroundBlendValue }; + + 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 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 setIsHazeActive(const bool active) { isHazeActive = active; emit dirty(); } + void setIsAltitudeBased(const bool active) { isAltitudeBased = active; emit dirty(); } + void setIsDirectionaLightAttenuationActive(const bool active) { isDirectionaLightAttenuationActive = active; emit dirty(); } + void setIsModulateColorActive(const bool active) { isModulateColorActive = 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 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(); } + +signals: + void dirty(); +}; + class FetchHazeStage { public: - using JobModel = render::Job::ModelO; + using Config = FetchHazeConfig; + using JobModel = render::Job::ModelO; + FetchHazeStage(); + + void configure(const Config& config); void run(const render::RenderContextPointer& renderContext, model::HazePointer& haze); private: + model::HazePointer _haze; gpu::PipelinePointer _hazePipeline; }; #endif diff --git a/libraries/render-utils/src/RenderDeferredTask.cpp b/libraries/render-utils/src/RenderDeferredTask.cpp index ea5380aac0..50bd3d6dc0 100644 --- a/libraries/render-utils/src/RenderDeferredTask.cpp +++ b/libraries/render-utils/src/RenderDeferredTask.cpp @@ -148,8 +148,8 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren const auto lightClusters = task.addJob("LightClustering", lightClusteringPassInputs); // Add haze model - const auto hazeModel = task.addJob("HazeModel"); - ////const auto hazeModel = task.addJob("FetchHazeStage"); + ////const auto hazeModel = task.addJob("HazeModel"); + const auto hazeModel = task.addJob("FetchHazeStage"); // DeferredBuffer is complete, now let's shade it into the LightingBuffer const auto deferredLightingInputs = RenderDeferred::Inputs(deferredFrameTransform, deferredFramebuffer, lightingModel, From d1488ebfad341aab9e1272365ca1ac358b902ed9 Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Mon, 2 Oct 2017 10:10:29 -0700 Subject: [PATCH 25/94] Added .qml and .js for debug --- scripts/developer/debugging/debugHaze.qml | 185 ++++++++++++++++++ .../debugging/surfaceGeometryPass.qml | 64 ++++++ 2 files changed, 249 insertions(+) create mode 100644 scripts/developer/debugging/debugHaze.qml create mode 100644 scripts/developer/debugging/surfaceGeometryPass.qml diff --git a/scripts/developer/debugging/debugHaze.qml b/scripts/developer/debugging/debugHaze.qml new file mode 100644 index 0000000000..e197050efd --- /dev/null +++ b/scripts/developer/debugging/debugHaze.qml @@ -0,0 +1,185 @@ +// +// haze.qml +// developer/utilities/render +// +// Nissim Hadar, created on 9/8/2017. +// Copyright 2017 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or https://www.apache.org/licenses/LICENSE-2.0.html +// +import QtQuick 2.5 +import QtQuick.Controls 1.4 +import "../utilities/render/configSlider" + +Item { + id: root + property var hazeModel: Render.getConfig("RenderMainView.HazeModel") + + Column { + spacing: 8 + + Row { + CheckBox { + text: "Haze Active" + checked: root.hazeModel["isHazeActive"] + onCheckedChanged: { + root.hazeModel["isHazeActive"] = checked; + } + } + + CheckBox { + text: "Modulated Color" + checked: root.hazeModel["isModulateColorActive"] + onCheckedChanged: { + root.hazeModel["isModulateColorActive"] = checked; + } + } + } + CheckBox { + text: "Altitude Based" + checked: root.hazeModel["isAltitudeBased"] + onCheckedChanged: { + root.hazeModel["isAltitudeBased"] = checked; + } + } + + ConfigSlider { + label: "Range" + integral: false + config: root.hazeModel + property: "hazeRange_m" + max: 10000 + min: 5 + width: 280 + } + + ConfigSlider { + label: "Altitude" + integral: false + config: root.hazeModel + property: "hazeAltitude_m" + max: 2000 + min: 5 + width: 280 + } + + ConfigSlider { + label: "Haze Color R" + integral: false + config: root.hazeModel + property: "hazeColorR" + max: 1.0 + min: 0.0 + width: 280 + } + + ConfigSlider { + label: "Haze Color G" + integral: false + config: root.hazeModel + property: "hazeColorG" + max: 1.0 + min: 0.0 + width: 280 + } + + ConfigSlider { + label: "Haze Color B" + integral: false + config: root.hazeModel + property: "hazeColorB" + max: 1.0 + min: 0.0 + width: 280 + } + + ConfigSlider { + label: "Sun R" + integral: false + config: root.hazeModel + property: "hazeDirectionalLightColorR" + max: 1.0 + min: 0.0 + width: 280 + } + + ConfigSlider { + label: "Sun G" + integral: false + config: root.hazeModel + property: "hazeDirectionalLightColorG" + max: 1.0 + min: 0.0 + width: 280 + } + + ConfigSlider { + label: "Sun B" + integral: false + config: root.hazeModel + property: "hazeDirectionalLightColorB" + max: 1.0 + min: 0.0 + width: 280 + } + + ConfigSlider { + label: "Sun glare angle" + integral: false + config: root.hazeModel + property: "hazeDirectionalLightAngle_degs" + max: 70.0 + min: 0.0 + width: 280 + } + + ConfigSlider { + label: "Base" + integral: false + config: root.hazeModel + property: "hazeBaseReference" + max: 500.0 + min: -500.0 + width: 280 + } + + ConfigSlider { + label: "BG Blend" + integral: false + config: root.hazeModel + property: "hazeBackgroundBlendValue" + max: 1.0 + min: 0.0 + width: 280 + } + + CheckBox { + text: "Keylight Attenuation" + checked: root.hazeModel["isDirectionaLightAttenuationActive"] + onCheckedChanged: { + root.hazeModel["isDirectionaLightAttenuationActive"] = checked; + } + } + + ConfigSlider { + label: "Range" + integral: false + config: root.hazeModel + property: "hazeKeyLightRange_m" + max: 10000 + min: 5 + width: 280 + } + + ConfigSlider { + label: "Altitude" + integral: false + config: root.hazeModel + property: "hazeKeyLightAltitude_m" + max: 2000 + min: 5 + width: 280 + } + } +} diff --git a/scripts/developer/debugging/surfaceGeometryPass.qml b/scripts/developer/debugging/surfaceGeometryPass.qml new file mode 100644 index 0000000000..ba1db66d16 --- /dev/null +++ b/scripts/developer/debugging/surfaceGeometryPass.qml @@ -0,0 +1,64 @@ +// +// surfaceGeometryPass.qml +// +// Created by Sam Gateau on 6/6/2016 +// Copyright 2016 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or https://www.apache.org/licenses/LICENSE-2.0.html +// +import QtQuick 2.5 +import QtQuick.Controls 1.4 +import "configSlider" + +Column { + spacing: 8 + Column { + id: surfaceGeometry + spacing: 10 + + Column{ + ConfigSlider { + label: qsTr("Depth Threshold [cm]") + integral: false + config: Render.getConfig("RenderMainView.SurfaceGeometry") + property: "depthThreshold" + max: 5.0 + min: 0.0 + } + Repeater { + model: [ + "Basis Scale:basisScale:2.0:false", + "Curvature Scale:curvatureScale:100.0:false", + ] + ConfigSlider { + label: qsTr(modelData.split(":")[0]) + integral: (modelData.split(":")[3] == 'true') + config: Render.getConfig("RenderMainView.SurfaceGeometry") + property: modelData.split(":")[1] + max: modelData.split(":")[2] + min: 0.0 + } + } + CheckBox { + text: "Half Resolution" + checked: Render.getConfig("RenderMainView.SurfaceGeometry")["resolutionLevel"] + onCheckedChanged: { Render.getConfig("RenderMainView.SurfaceGeometry")["resolutionLevel"] = checked } + } + + Repeater { + model: [ "Diffusion Scale:RenderMainView.SurfaceGeometry:diffuseFilterScale:2.0", + "Diffusion Depth Threshold:RenderMainView.SurfaceGeometry:diffuseDepthThreshold:1.0" + ] + ConfigSlider { + label: qsTr(modelData.split(":")[0]) + integral: false + config: Render.getConfig(modelData.split(":")[1]) + property: modelData.split(":")[2] + max: modelData.split(":")[3] + min: 0.0 + } + } + } + } +} From 20a42d6fbda8c68b9c9ae7755e6f2b9b863319e4 Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Mon, 2 Oct 2017 10:11:34 -0700 Subject: [PATCH 26/94] Fixed model name string --- libraries/render-utils/src/RenderDeferredTask.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/render-utils/src/RenderDeferredTask.cpp b/libraries/render-utils/src/RenderDeferredTask.cpp index 50bd3d6dc0..41ded3a4f4 100644 --- a/libraries/render-utils/src/RenderDeferredTask.cpp +++ b/libraries/render-utils/src/RenderDeferredTask.cpp @@ -149,7 +149,7 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren // Add haze model ////const auto hazeModel = task.addJob("HazeModel"); - const auto hazeModel = task.addJob("FetchHazeStage"); + const auto hazeModel = task.addJob("HazeModel"); // DeferredBuffer is complete, now let's shade it into the LightingBuffer const auto deferredLightingInputs = RenderDeferred::Inputs(deferredFrameTransform, deferredFramebuffer, lightingModel, From 48fb7522c063259c41a6d827c6fb1a3ddcd4e4f8 Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Mon, 2 Oct 2017 11:42:04 -0700 Subject: [PATCH 27/94] Removed blank line --- libraries/render-utils/src/HazeStage.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/libraries/render-utils/src/HazeStage.cpp b/libraries/render-utils/src/HazeStage.cpp index 7bb73c0127..75003db4f4 100644 --- a/libraries/render-utils/src/HazeStage.cpp +++ b/libraries/render-utils/src/HazeStage.cpp @@ -47,7 +47,6 @@ HazeStage::Index HazeStage::findHaze(const HazePointer& haze) const { } else { return (*found).second; } - } HazeStage::Index HazeStage::addHaze(const HazePointer& haze) { From 93bc3bec5295fe55fe99b144ac4c46de4e21bcc5 Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Mon, 2 Oct 2017 12:14:21 -0700 Subject: [PATCH 28/94] Removed (unused) _haze. --- libraries/model/src/model/Stage.cpp | 3 +-- libraries/model/src/model/Stage.h | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/libraries/model/src/model/Stage.cpp b/libraries/model/src/model/Stage.cpp index d09323d07b..ab441efb2f 100644 --- a/libraries/model/src/model/Stage.cpp +++ b/libraries/model/src/model/Stage.cpp @@ -139,8 +139,7 @@ const float NUM_HOURS_PER_HALF_DAY = NUM_HOURS_PER_DAY * 0.5f; SunSkyStage::SunSkyStage() : _sunLight(std::make_shared()), - _skybox(std::make_shared()), - _haze(std::make_shared()) + _skybox(std::make_shared()) { _sunLight->setType(Light::SUN); // Default ambient sphere (for lack of skybox) diff --git a/libraries/model/src/model/Stage.h b/libraries/model/src/model/Stage.h index 49eedaccbb..fb4ac88f8f 100644 --- a/libraries/model/src/model/Stage.h +++ b/libraries/model/src/model/Stage.h @@ -228,7 +228,6 @@ protected: LightPointer _sunLight; mutable SkyboxPointer _skybox; - mutable HazePointer _haze; float _dayTime = 12.0f; int _yearTime = 0; From 29d5e772d499be72b6486f8a66547177a6775910 Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Mon, 2 Oct 2017 12:42:46 -0700 Subject: [PATCH 29/94] Removed "..Is.." from various methods. --- .../src/RenderableZoneEntityItem.cpp | 2 +- libraries/model/src/model/Haze.cpp | 8 +++---- libraries/model/src/model/Haze.h | 8 +++---- .../src/DeferredLightingEffect.cpp | 1 - libraries/render-utils/src/DrawHaze.cpp | 14 ++++++------ libraries/render-utils/src/DrawHaze.h | 22 +++++++++---------- libraries/render-utils/src/HazeStage.cpp | 8 +++---- libraries/render-utils/src/HazeStage.h | 16 +++++++------- 8 files changed, 39 insertions(+), 40 deletions(-) diff --git a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp index 95c2a9a0df..6d0ca1e4fd 100644 --- a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp @@ -338,7 +338,7 @@ void ZoneEntityRenderer::updateHazeFromEntity(const TypedEntityPointer& entity) const auto& haze = editHaze(); - haze->setIsHazeActive(entity->getHazeMode() == HAZE_MODE_ENABLED); + haze->setHazeActive(entity->getHazeMode() == HAZE_MODE_ENABLED); haze->setHazeRangeFactor(model::convertHazeRangeToHazeRangeFactor(entity->getHazeRange())); xColor hazeBlendInColor = entity->getHazeBlendInColor(); diff --git a/libraries/model/src/model/Haze.cpp b/libraries/model/src/model/Haze.cpp index 7500bec102..e03c3e0f65 100644 --- a/libraries/model/src/model/Haze.cpp +++ b/libraries/model/src/model/Haze.cpp @@ -78,7 +78,7 @@ void Haze::setDirectionalLightColor(const glm::vec3 hazeDirectionalLightColor) { _parametersBuffer.edit().directionalLightColor.b = hazeDirectionalLightColor.b; } } -void Haze::setIsHazeActive(const bool isHazeActive) { +void Haze::setHazeActive(const bool isHazeActive) { auto& params = _parametersBuffer.get(); if (((params.hazeMode & HAZE_MODE_IS_ACTIVE) == HAZE_MODE_IS_ACTIVE )&& !isHazeActive) { @@ -89,7 +89,7 @@ void Haze::setIsHazeActive(const bool isHazeActive) { } } -void Haze::setIsAltitudeBased(const bool isAltitudeBased) { +void Haze::setAltitudeBased(const bool isAltitudeBased) { auto& params = _parametersBuffer.get(); if (((params.hazeMode & HAZE_MODE_IS_ALTITUDE_BASED) == HAZE_MODE_IS_ALTITUDE_BASED )&& !isAltitudeBased) { @@ -100,7 +100,7 @@ void Haze::setIsAltitudeBased(const bool isAltitudeBased) { } } -void Haze::setIsDirectionaLightAttenuationActive(const bool isDirectionaLightAttenuationActive) { +void Haze::setDirectionaLightAttenuationActive(const bool isDirectionaLightAttenuationActive) { auto& params = _parametersBuffer.get(); if (((params.hazeMode & HAZE_MODE_IS_DIRECTIONAL_LIGHT_ATTENUATED) == HAZE_MODE_IS_DIRECTIONAL_LIGHT_ATTENUATED ) && !isDirectionaLightAttenuationActive) { @@ -111,7 +111,7 @@ void Haze::setIsDirectionaLightAttenuationActive(const bool isDirectionaLightAtt } } -void Haze::setIsModulateColorActive(const bool isModulateColorActive) { +void Haze::setModulateColorActive(const bool isModulateColorActive) { auto& params = _parametersBuffer.get(); if (((params.hazeMode & HAZE_MODE_IS_MODULATE_COLOR) == HAZE_MODE_IS_MODULATE_COLOR ) && !isModulateColorActive) { diff --git a/libraries/model/src/model/Haze.h b/libraries/model/src/model/Haze.h index 320f3a0148..0e65f19285 100644 --- a/libraries/model/src/model/Haze.h +++ b/libraries/model/src/model/Haze.h @@ -70,10 +70,10 @@ namespace model { void setDirectionalLightColor(const glm::vec3 directionalLightColor); void setHazeBaseReference(const float hazeBaseReference); - void setIsHazeActive(const bool isHazeActive); - void setIsAltitudeBased(const bool isAltitudeBased); - void setIsDirectionaLightAttenuationActive(const bool isDirectionaLightAttenuationActive); - void setIsModulateColorActive(const bool isModulateColorActive); + void setHazeActive(const bool isHazeActive); + void setAltitudeBased(const bool isAltitudeBased); + void setDirectionaLightAttenuationActive(const bool isDirectionaLightAttenuationActive); + void setModulateColorActive(const bool isModulateColorActive); void setHazeRangeFactor(const float hazeRange); void setHazeAltitudeFactor(const float hazeAltitude); diff --git a/libraries/render-utils/src/DeferredLightingEffect.cpp b/libraries/render-utils/src/DeferredLightingEffect.cpp index 20292af679..56681459d1 100644 --- a/libraries/render-utils/src/DeferredLightingEffect.cpp +++ b/libraries/render-utils/src/DeferredLightingEffect.cpp @@ -774,7 +774,6 @@ void DefaultLightingSetup::run(const RenderContextPointer& renderContext) { if (hazeStage) { auto haze = std::make_shared(); - haze->setIsHazeActive(false); _defaultHaze = haze; _defaultHazeID = hazeStage->addHaze(_defaultHaze); diff --git a/libraries/render-utils/src/DrawHaze.cpp b/libraries/render-utils/src/DrawHaze.cpp index cc984c2875..bd51836c8a 100644 --- a/libraries/render-utils/src/DrawHaze.cpp +++ b/libraries/render-utils/src/DrawHaze.cpp @@ -51,11 +51,11 @@ void HazeConfig::setHazeBaseReference(const float value) { hazeBaseReference = value; } -void HazeConfig::setIsHazeActive(const bool active) { +void HazeConfig::setHazeActive(const bool active) { isHazeActive = active; } -void HazeConfig::setIsAltitudeBased(const bool active) { +void HazeConfig::setAltitudeBased(const bool active) { isAltitudeBased = active; } @@ -63,7 +63,7 @@ void HazeConfig::setIsdirectionalLightAttenuationActive(const bool active) { isDirectionalLightAttenuationActive = active; } -void HazeConfig::setIsModulateColorActive(const bool active) { +void HazeConfig::setModulateColorActive(const bool active) { isModulateColorActive = active; } @@ -98,10 +98,10 @@ void MakeHaze::configure(const Config& config) { _haze->setDirectionalLightColor(glm::vec3(config.hazeDirectionalLightColorR, config.hazeDirectionalLightColorG, config.hazeDirectionalLightColorB)); _haze->setHazeBaseReference(config.hazeBaseReference); - _haze->setIsHazeActive(config.isHazeActive); - _haze->setIsAltitudeBased(config.isAltitudeBased); - _haze->setIsDirectionaLightAttenuationActive(config.isDirectionaLightAttenuationActive); - _haze->setIsModulateColorActive(config.isModulateColorActive); + _haze->setHazeActive(config.isHazeActive); + _haze->setAltitudeBased(config.isAltitudeBased); + _haze->setDirectionaLightAttenuationActive(config.isDirectionaLightAttenuationActive); + _haze->setModulateColorActive(config.isModulateColorActive); _haze->setHazeRangeFactor(model::convertHazeRangeToHazeRangeFactor(config.hazeRange_m)); _haze->setHazeAltitudeFactor(model::convertHazeAltitudeToHazeAltitudeFactor(config.hazeAltitude_m)); diff --git a/libraries/render-utils/src/DrawHaze.h b/libraries/render-utils/src/DrawHaze.h index 7022ea4b22..8ebfff4b29 100644 --- a/libraries/render-utils/src/DrawHaze.h +++ b/libraries/render-utils/src/DrawHaze.h @@ -39,10 +39,10 @@ class MakeHazeConfig : public render::Job::Config { Q_PROPERTY(float hazeDirectionalLightColorB MEMBER hazeDirectionalLightColorB WRITE setDirectionalLightColorB NOTIFY dirty); Q_PROPERTY(float hazeBaseReference MEMBER hazeBaseReference WRITE setHazeBaseReference NOTIFY dirty); - Q_PROPERTY(bool isHazeActive MEMBER isHazeActive WRITE setIsHazeActive NOTIFY dirty); - Q_PROPERTY(bool isAltitudeBased MEMBER isAltitudeBased WRITE setIsAltitudeBased NOTIFY dirty); - Q_PROPERTY(bool isDirectionaLightAttenuationActive MEMBER isDirectionaLightAttenuationActive WRITE setIsDirectionaLightAttenuationActive NOTIFY dirty); - Q_PROPERTY(bool isModulateColorActive MEMBER isModulateColorActive WRITE setIsModulateColorActive NOTIFY dirty); + Q_PROPERTY(bool isHazeActive MEMBER isHazeActive WRITE setHazeActive NOTIFY dirty); + Q_PROPERTY(bool isAltitudeBased MEMBER isAltitudeBased WRITE setAltitudeBased NOTIFY dirty); + Q_PROPERTY(bool isDirectionaLightAttenuationActive MEMBER isDirectionaLightAttenuationActive WRITE setDirectionaLightAttenuationActive NOTIFY dirty); + Q_PROPERTY(bool isModulateColorActive MEMBER isModulateColorActive WRITE setModulateColorActive 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); @@ -89,10 +89,10 @@ public slots: void setDirectionalLightColorB(const float value) { hazeDirectionalLightColorB = value; emit dirty(); } void setHazeBaseReference(const float value) { hazeBaseReference = value; ; emit dirty(); } - void setIsHazeActive(const bool active) { isHazeActive = active; emit dirty(); } - void setIsAltitudeBased(const bool active) { isAltitudeBased = active; emit dirty(); } - void setIsDirectionaLightAttenuationActive(const bool active) { isDirectionaLightAttenuationActive = active; emit dirty(); } - void setIsModulateColorActive(const bool active) { isModulateColorActive = active; emit dirty(); } + void setHazeActive(const bool active) { isHazeActive = active; emit dirty(); } + void setAltitudeBased(const bool active) { isAltitudeBased = active; emit dirty(); } + void setDirectionaLightAttenuationActive(const bool active) { isDirectionaLightAttenuationActive = active; emit dirty(); } + void setModulateColorActive(const bool active) { isModulateColorActive = 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(); } @@ -159,10 +159,10 @@ public: void setDirectionalLightColorB(const float value); void setHazeBaseReference(const float value); - void setIsHazeActive(const bool active); - void setIsAltitudeBased(const bool active); + void setHazeActive(const bool active); + void setAltitudeBased(const bool active); void setIsdirectionalLightAttenuationActive(const bool active); - void setIsModulateColorActive(const bool active); + void setModulateColorActive(const bool active); void setHazeRange_m(const float value); void setHazeAltitude_m(const float value); diff --git a/libraries/render-utils/src/HazeStage.cpp b/libraries/render-utils/src/HazeStage.cpp index 75003db4f4..f5405d01d3 100644 --- a/libraries/render-utils/src/HazeStage.cpp +++ b/libraries/render-utils/src/HazeStage.cpp @@ -26,10 +26,10 @@ void FetchHazeStage::configure(const Config& config) { _haze->setDirectionalLightColor(glm::vec3(config.hazeDirectionalLightColorR, config.hazeDirectionalLightColorG, config.hazeDirectionalLightColorB)); _haze->setHazeBaseReference(config.hazeBaseReference); - _haze->setIsHazeActive(config.isHazeActive); - _haze->setIsAltitudeBased(config.isAltitudeBased); - _haze->setIsDirectionaLightAttenuationActive(config.isDirectionaLightAttenuationActive); - _haze->setIsModulateColorActive(config.isModulateColorActive); + _haze->setHazeActive(config.isHazeActive); + _haze->setAltitudeBased(config.isAltitudeBased); + _haze->setDirectionaLightAttenuationActive(config.isDirectionaLightAttenuationActive); + _haze->setModulateColorActive(config.isModulateColorActive); _haze->setHazeRangeFactor(model::convertHazeRangeToHazeRangeFactor(config.hazeRange_m)); _haze->setHazeAltitudeFactor(model::convertHazeAltitudeToHazeAltitudeFactor(config.hazeAltitude_m)); diff --git a/libraries/render-utils/src/HazeStage.h b/libraries/render-utils/src/HazeStage.h index 1fd111c404..4f3760fb40 100644 --- a/libraries/render-utils/src/HazeStage.h +++ b/libraries/render-utils/src/HazeStage.h @@ -93,10 +93,10 @@ class FetchHazeConfig : public render::Job::Config { Q_PROPERTY(float hazeDirectionalLightColorB MEMBER hazeDirectionalLightColorB WRITE setDirectionalLightColorB NOTIFY dirty); Q_PROPERTY(float hazeBaseReference MEMBER hazeBaseReference WRITE setHazeBaseReference NOTIFY dirty); - Q_PROPERTY(bool isHazeActive MEMBER isHazeActive WRITE setIsHazeActive NOTIFY dirty); - Q_PROPERTY(bool isAltitudeBased MEMBER isAltitudeBased WRITE setIsAltitudeBased NOTIFY dirty); - Q_PROPERTY(bool isDirectionaLightAttenuationActive MEMBER isDirectionaLightAttenuationActive WRITE setIsDirectionaLightAttenuationActive NOTIFY dirty); - Q_PROPERTY(bool isModulateColorActive MEMBER isModulateColorActive WRITE setIsModulateColorActive NOTIFY dirty); + Q_PROPERTY(bool isHazeActive MEMBER isHazeActive WRITE setHazeActive NOTIFY dirty); + Q_PROPERTY(bool isAltitudeBased MEMBER isAltitudeBased WRITE setAltitudeBased NOTIFY dirty); + Q_PROPERTY(bool isDirectionaLightAttenuationActive MEMBER isDirectionaLightAttenuationActive WRITE setDirectionaLightAttenuationActive NOTIFY dirty); + Q_PROPERTY(bool isModulateColorActive MEMBER isModulateColorActive WRITE setModulateColorActive 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); @@ -143,10 +143,10 @@ public: void setDirectionalLightColorB(const float value) { hazeDirectionalLightColorB = value; emit dirty(); } void setHazeBaseReference(const float value) { hazeBaseReference = value; ; emit dirty(); } - void setIsHazeActive(const bool active) { isHazeActive = active; emit dirty(); } - void setIsAltitudeBased(const bool active) { isAltitudeBased = active; emit dirty(); } - void setIsDirectionaLightAttenuationActive(const bool active) { isDirectionaLightAttenuationActive = active; emit dirty(); } - void setIsModulateColorActive(const bool active) { isModulateColorActive = active; emit dirty(); } + void setHazeActive(const bool active) { isHazeActive = active; emit dirty(); } + void setAltitudeBased(const bool active) { isAltitudeBased = active; emit dirty(); } + void setDirectionaLightAttenuationActive(const bool active) { isDirectionaLightAttenuationActive = active; emit dirty(); } + void setModulateColorActive(const bool active) { isModulateColorActive = 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(); } From 1fa7e151327825b5efe896c1fa459efb33e63343 Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Mon, 2 Oct 2017 14:36:26 -0700 Subject: [PATCH 30/94] Added 'HIFI_DISABLE_WATCHDOG' code. --- interface/src/Application.cpp | 11 ++++++++--- interface/src/Application.h | 2 -- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 36e5b3d859..4aa9645323 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -289,6 +289,10 @@ static QTimer locationUpdateTimer; static QTimer identityPacketTimer; static QTimer pingTimer; +static const QString DISABLE_WATCHDOG_FLAG("HIFI_DISABLE_WATCHDOG"); +static bool DISABLE_WATCHDOG = QProcessEnvironment::systemEnvironment().contains(DISABLE_WATCHDOG_FLAG); + + static const int MAX_CONCURRENT_RESOURCE_DOWNLOADS = 16; // For processing on QThreadPool, we target a number of threads after reserving some @@ -805,8 +809,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo nodeList->startThread(); // Set up a watchdog thread to intentionally crash the application on deadlocks - _deadlockWatchdogThread = new DeadlockWatchdogThread(); - _deadlockWatchdogThread->start(); + if (!DISABLE_WATCHDOG) { + (new DeadlockWatchdogThread())->start(); + } if (steamClient) { qCDebug(interfaceapp) << "[VERSION] SteamVR buildID:" << steamClient->getSteamVRBuildID(); @@ -1933,7 +1938,7 @@ void Application::showCursor(const Cursor::Icon& cursor) { } void Application::updateHeartbeat() const { - static_cast(_deadlockWatchdogThread)->updateHeartbeat(); + DeadlockWatchdogThread::updateHeartbeat(); } void Application::onAboutToQuit() { diff --git a/interface/src/Application.h b/interface/src/Application.h index a706ce2b63..b0cac6bb87 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -650,8 +650,6 @@ private: Qt::CursorShape _desiredCursor{ Qt::BlankCursor }; bool _cursorNeedsChanging { false }; - QThread* _deadlockWatchdogThread; - std::map> _postUpdateLambdas; std::mutex _postUpdateLambdasLock; From ca4c5969d98fbe210f1c2ac00d21cf344c3d2fd2 Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Mon, 2 Oct 2017 14:36:45 -0700 Subject: [PATCH 31/94] Clean-up. --- libraries/render-utils/src/DeferredLightingEffect.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/render-utils/src/DeferredLightingEffect.h b/libraries/render-utils/src/DeferredLightingEffect.h index 4266efc7b8..212d17db12 100644 --- a/libraries/render-utils/src/DeferredLightingEffect.h +++ b/libraries/render-utils/src/DeferredLightingEffect.h @@ -187,8 +187,8 @@ protected: model::LightPointer _defaultLight; LightStage::Index _defaultLightID{ LightStage::INVALID_INDEX }; model::SunSkyStagePointer _defaultBackground; - model::HazePointer _defaultHaze{ nullptr }; BackgroundStage::Index _defaultBackgroundID{ BackgroundStage::INVALID_INDEX }; + model::HazePointer _defaultHaze{ nullptr }; HazeStage::Index _defaultHazeID{ HazeStage::INVALID_INDEX }; model::SkyboxPointer _defaultSkybox { new ProceduralSkybox() }; gpu::TexturePointer _defaultSkyboxTexture; From cdbf067a24cae6d633c202c3263c11b8dee3fd1f Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Mon, 2 Oct 2017 16:54:02 -0700 Subject: [PATCH 32/94] Rename (haze)getParametersBuffer to getHazeParametersBuffer. Add corrections from Sam --- .../entities-renderer/src/RenderableZoneEntityItem.cpp | 1 + libraries/model/src/model/Haze.h | 2 +- libraries/render-utils/src/DeferredLightingEffect.cpp | 6 ++++-- libraries/render-utils/src/DrawHaze.cpp | 7 ++++++- libraries/render-utils/src/HazeStage.cpp | 2 ++ libraries/render-utils/src/ZoneRenderer.cpp | 1 - 6 files changed, 14 insertions(+), 5 deletions(-) diff --git a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp index 6d0ca1e4fd..b03dfe89db 100644 --- a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp @@ -60,6 +60,7 @@ void ZoneEntityRenderer::onRemoveFromSceneTyped(const TypedEntityPointer& entity } } +#pragma optimize("", off); void ZoneEntityRenderer::doRender(RenderArgs* args) { #if 0 if (ZoneEntityItem::getDrawZoneBoundaries()) { diff --git a/libraries/model/src/model/Haze.h b/libraries/model/src/model/Haze.h index 0e65f19285..9ab4ec845f 100644 --- a/libraries/model/src/model/Haze.h +++ b/libraries/model/src/model/Haze.h @@ -83,7 +83,7 @@ namespace model { void setHazeBackgroundBlendValue(const float hazeBackgroundBlendValue); - UniformBufferView getParametersBuffer() const { return _parametersBuffer; } + UniformBufferView getHazeParametersBuffer() const { return _parametersBuffer; } protected: class Parameters { diff --git a/libraries/render-utils/src/DeferredLightingEffect.cpp b/libraries/render-utils/src/DeferredLightingEffect.cpp index 56681459d1..6cd3cb1dca 100644 --- a/libraries/render-utils/src/DeferredLightingEffect.cpp +++ b/libraries/render-utils/src/DeferredLightingEffect.cpp @@ -552,8 +552,10 @@ void RenderDeferredSetup::run(const render::RenderContextPointer& renderContext, deferredLightingEffect->setupKeyLightBatch(args, batch, locations->lightBufferUnit, locations->ambientBufferUnit, SKYBOX_MAP_UNIT); // Haze - batch.setUniformBuffer(HAZE_MODEL_BUFFER_SLOT, haze->getParametersBuffer()); - + if (haze != nullptr) { + batch.setUniformBuffer(HAZE_MODEL_BUFFER_SLOT, haze->getHazeParametersBuffer()); + } + batch.draw(gpu::TRIANGLE_STRIP, 4); deferredLightingEffect->unsetKeyLightBatch(batch, locations->lightBufferUnit, locations->ambientBufferUnit, SKYBOX_MAP_UNIT); diff --git a/libraries/render-utils/src/DrawHaze.cpp b/libraries/render-utils/src/DrawHaze.cpp index bd51836c8a..763507f8f8 100644 --- a/libraries/render-utils/src/DrawHaze.cpp +++ b/libraries/render-utils/src/DrawHaze.cpp @@ -125,8 +125,13 @@ const int HazeEffect_LinearDepthMapSlot = 3; void DrawHaze::configure(const Config& config) { } +#pragma optimize("", off) void DrawHaze::run(const render::RenderContextPointer& renderContext, const Inputs& inputs) { const auto haze = inputs.get0(); + if (haze == nullptr) { + return; + } + const auto inputBuffer = inputs.get1()->getRenderBuffer(0); const auto framebuffer = inputs.get2(); const auto transformBuffer = inputs.get3(); @@ -169,7 +174,7 @@ void DrawHaze::run(const render::RenderContextPointer& renderContext, const Inpu batch.setPipeline(_hazePipeline); - batch.setUniformBuffer(HazeEffect_ParamsSlot, haze->getParametersBuffer()); + batch.setUniformBuffer(HazeEffect_ParamsSlot, haze->getHazeParametersBuffer()); batch.setUniformBuffer(HazeEffect_TransformBufferSlot, transformBuffer->getFrameTransformBuffer()); batch.setResourceTexture(HazeEffect_LightingMapSlot, inputBuffer); diff --git a/libraries/render-utils/src/HazeStage.cpp b/libraries/render-utils/src/HazeStage.cpp index f5405d01d3..4acc5d534c 100644 --- a/libraries/render-utils/src/HazeStage.cpp +++ b/libraries/render-utils/src/HazeStage.cpp @@ -84,10 +84,12 @@ void HazeStageSetup::run(const render::RenderContextPointer& renderContext) { } } +#pragma optimize("", off) void FetchHazeStage::run(const render::RenderContextPointer& renderContext, model::HazePointer& haze) { auto hazeStage = renderContext->_scene->getStage(); assert(hazeStage); + haze = nullptr; if (hazeStage->_currentFrame._hazes.size() != 0) { auto hazeId = hazeStage->_currentFrame._hazes.front(); haze = hazeStage->getHaze(hazeId); diff --git a/libraries/render-utils/src/ZoneRenderer.cpp b/libraries/render-utils/src/ZoneRenderer.cpp index d59fb6e61c..a3268b7ac1 100644 --- a/libraries/render-utils/src/ZoneRenderer.cpp +++ b/libraries/render-utils/src/ZoneRenderer.cpp @@ -72,7 +72,6 @@ void SetupZones::run(const RenderContextPointer& context, const Inputs& inputs) auto hazeStage = context->_scene->getStage(); assert(hazeStage); hazeStage->_currentFrame.clear(); - hazeStage->_currentFrame.pushHaze(0); } const gpu::PipelinePointer& DebugZoneLighting::getKeyLightPipeline() { From 93a2776cb5fe443c16aec85f7463d89b3ccc5e49 Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Mon, 2 Oct 2017 18:13:23 -0700 Subject: [PATCH 33/94] Changes for debug --- interface/src/Application.cpp | 2 +- libraries/entities-renderer/src/RenderableZoneEntityItem.cpp | 2 +- libraries/entities/src/ZoneEntityItem.cpp | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index a61c149b9c..a6661965e3 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -433,7 +433,7 @@ public: // Don't actually crash in debug builds, in case this apparent deadlock is simply from // the developer actively debugging code #ifdef NDEBUG - deadlockDetectionCrash(); + ////deadlockDetectionCrash(); #endif } } diff --git a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp index b03dfe89db..3dbcdd6fb0 100644 --- a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp @@ -60,7 +60,7 @@ void ZoneEntityRenderer::onRemoveFromSceneTyped(const TypedEntityPointer& entity } } -#pragma optimize("", off); +#pragma optimize("", off) void ZoneEntityRenderer::doRender(RenderArgs* args) { #if 0 if (ZoneEntityItem::getDrawZoneBoundaries()) { diff --git a/libraries/entities/src/ZoneEntityItem.cpp b/libraries/entities/src/ZoneEntityItem.cpp index e6af326e46..daa5dc0106 100644 --- a/libraries/entities/src/ZoneEntityItem.cpp +++ b/libraries/entities/src/ZoneEntityItem.cpp @@ -334,6 +334,7 @@ void ZoneEntityItem::resetRenderingPropertiesChanged() { }); } +#pragma optimize("", off) void ZoneEntityItem::setHazeMode(const HazeMode value) { _hazeMode = value; _hazePropertiesChanged = true; From 1cf7f5a73243f23a4cde17dfae179af242766b9d Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Tue, 3 Oct 2017 09:54:44 -0700 Subject: [PATCH 34/94] For testing. --- .../src/RenderableZoneEntityItem.cpp | 19 +++++++++++-------- .../render-utils/src/BackgroundStage.cpp | 4 ++-- libraries/render-utils/src/BackgroundStage.h | 6 +++--- libraries/render-utils/src/DrawHaze.cpp | 17 ++++++++++++----- libraries/render-utils/src/HazeStage.cpp | 4 ++-- libraries/render-utils/src/HazeStage.h | 6 +++--- libraries/render-utils/src/ZoneRenderer.cpp | 10 +++++----- 7 files changed, 38 insertions(+), 28 deletions(-) diff --git a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp index 3dbcdd6fb0..2e5b791a84 100644 --- a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp @@ -149,14 +149,16 @@ void ZoneEntityRenderer::doRender(RenderArgs* args) { } } - if (_needHazeUpdate) { - if (HazeStage::isIndexInvalid(_hazeIndex)) { - _hazeIndex = _hazeStage->addHaze(_haze); - } - else { + { + if (_needHazeUpdate) { + if (HazeStage::isIndexInvalid(_hazeIndex)) { + _hazeIndex = _hazeStage->addHaze(_haze); + } + else { + } + _needHazeUpdate = false; } - _needHazeUpdate = false; } if (_visible) { @@ -171,12 +173,12 @@ void ZoneEntityRenderer::doRender(RenderArgs* args) { // The background only if the mode is not inherit if (_backgroundMode != BACKGROUND_MODE_INHERIT) { - _backgroundStage->_currentFrame.pushBackground(_backgroundIndex); + _backgroundStage->_currentBackgroundFrame.pushBackground(_backgroundIndex); } // The haze only if the mode is not inherit if (_hazeMode != HAZE_MODE_INHERIT) { - _hazeStage->_currentFrame.pushHaze(_hazeIndex); + _hazeStage->_currentHazeFrame.pushHaze(_hazeIndex); } } } @@ -466,6 +468,7 @@ void ZoneEntityRenderer::updateSkyboxMap() { void ZoneEntityRenderer::setBackgroundMode(BackgroundMode mode) { _backgroundMode = mode; } + void ZoneEntityRenderer::setHazeMode(HazeMode mode) { _hazeMode = mode; } diff --git a/libraries/render-utils/src/BackgroundStage.cpp b/libraries/render-utils/src/BackgroundStage.cpp index 2ea3683c4a..1e530769e7 100644 --- a/libraries/render-utils/src/BackgroundStage.cpp +++ b/libraries/render-utils/src/BackgroundStage.cpp @@ -65,8 +65,8 @@ void DrawBackgroundStage::run(const render::RenderContextPointer& renderContext, model::SunSkyStagePointer background; model::SkyboxPointer skybox; - if (backgroundStage->_currentFrame._backgrounds.size()) { - auto backgroundId = backgroundStage->_currentFrame._backgrounds.front(); + if (backgroundStage->_currentBackgroundFrame._backgrounds.size()) { + auto backgroundId = backgroundStage->_currentBackgroundFrame._backgrounds.front(); auto background = backgroundStage->getBackground(backgroundId); if (background) { skybox = background->getSkybox(); diff --git a/libraries/render-utils/src/BackgroundStage.h b/libraries/render-utils/src/BackgroundStage.h index eab7c94f0d..7f60139880 100644 --- a/libraries/render-utils/src/BackgroundStage.h +++ b/libraries/render-utils/src/BackgroundStage.h @@ -55,9 +55,9 @@ public: Backgrounds _backgrounds; BackgroundMap _backgroundMap; - class Frame { + class BackgroundFrame { public: - Frame() {} + BackgroundFrame() {} void clear() { _backgrounds.clear(); } @@ -66,7 +66,7 @@ public: BackgroundStage::BackgroundIndices _backgrounds; }; - Frame _currentFrame; + BackgroundFrame _currentBackgroundFrame; }; using BackgroundStagePointer = std::shared_ptr; diff --git a/libraries/render-utils/src/DrawHaze.cpp b/libraries/render-utils/src/DrawHaze.cpp index 763507f8f8..57d2163878 100644 --- a/libraries/render-utils/src/DrawHaze.cpp +++ b/libraries/render-utils/src/DrawHaze.cpp @@ -16,6 +16,7 @@ #include "StencilMaskPass.h" #include "FramebufferCache.h" +#include "HazeStage.h" #include "Haze_frag.h" @@ -140,6 +141,8 @@ void DrawHaze::run(const render::RenderContextPointer& renderContext, const Inpu auto depthBuffer = framebuffer->getLinearDepthTexture(); + RenderArgs* args = renderContext->args; + if (_hazePipeline == nullptr) { gpu::ShaderPointer ps = gpu::Shader::createPixel(std::string(Haze_frag)); gpu::ShaderPointer vs = gpu::StandardShaderLib::getDrawViewportQuadTransformTexcoordVS(); @@ -162,19 +165,23 @@ void DrawHaze::run(const render::RenderContextPointer& renderContext, const Inpu auto sourceFramebufferSize = glm::ivec2(inputBuffer->getDimensions()); - gpu::doInBatch(renderContext->args->_context, [&](gpu::Batch& batch) { + gpu::doInBatch(args->_context, [&](gpu::Batch& batch) { batch.enableStereo(false); batch.setFramebuffer(outputBuffer); - batch.setViewportTransform(renderContext->args->_viewport); + batch.setViewportTransform(args->_viewport); batch.setProjectionTransform(glm::mat4()); batch.resetViewTransform(); - batch.setModelTransform( - gpu::Framebuffer::evalSubregionTexcoordTransform(sourceFramebufferSize, renderContext->args->_viewport)); + batch.setModelTransform(gpu::Framebuffer::evalSubregionTexcoordTransform(sourceFramebufferSize, args->_viewport)); batch.setPipeline(_hazePipeline); - batch.setUniformBuffer(HazeEffect_ParamsSlot, haze->getHazeParametersBuffer()); + auto hazeStage = args->_scene->getStage(); + if (hazeStage && hazeStage->_currentHazeFrame._hazes.size() > 0) { + model::HazePointer hazePointer = hazeStage->getHaze(hazeStage->_currentHazeFrame._hazes.front()); + batch.setUniformBuffer(HazeEffect_ParamsSlot, hazePointer->getHazeParametersBuffer()); + } + batch.setUniformBuffer(HazeEffect_TransformBufferSlot, transformBuffer->getFrameTransformBuffer()); batch.setResourceTexture(HazeEffect_LightingMapSlot, inputBuffer); diff --git a/libraries/render-utils/src/HazeStage.cpp b/libraries/render-utils/src/HazeStage.cpp index 4acc5d534c..96823521ab 100644 --- a/libraries/render-utils/src/HazeStage.cpp +++ b/libraries/render-utils/src/HazeStage.cpp @@ -90,8 +90,8 @@ void FetchHazeStage::run(const render::RenderContextPointer& renderContext, mode assert(hazeStage); haze = nullptr; - if (hazeStage->_currentFrame._hazes.size() != 0) { - auto hazeId = hazeStage->_currentFrame._hazes.front(); + if (hazeStage->_currentHazeFrame._hazes.size() != 0) { + auto hazeId = hazeStage->_currentHazeFrame._hazes.front(); haze = hazeStage->getHaze(hazeId); } } diff --git a/libraries/render-utils/src/HazeStage.h b/libraries/render-utils/src/HazeStage.h index 4f3760fb40..1d070ae972 100644 --- a/libraries/render-utils/src/HazeStage.h +++ b/libraries/render-utils/src/HazeStage.h @@ -55,9 +55,9 @@ public: Hazes _hazes; HazeMap _hazeMap; - class Frame { + class HazeFrame { public: - Frame() {} + HazeFrame() {} void clear() { _hazes.clear(); } @@ -66,7 +66,7 @@ public: HazeStage::HazeIndices _hazes; }; - Frame _currentFrame; + HazeFrame _currentHazeFrame; }; using HazeStagePointer = std::shared_ptr; diff --git a/libraries/render-utils/src/ZoneRenderer.cpp b/libraries/render-utils/src/ZoneRenderer.cpp index a3268b7ac1..46fa21c6d8 100644 --- a/libraries/render-utils/src/ZoneRenderer.cpp +++ b/libraries/render-utils/src/ZoneRenderer.cpp @@ -54,7 +54,7 @@ void ZoneRendererTask::build(JobModel& task, const Varying& input, Varying& oupu void SetupZones::run(const RenderContextPointer& context, const Inputs& inputs) { auto backgroundStage = context->_scene->getStage(); assert(backgroundStage); - backgroundStage->_currentFrame.clear(); + backgroundStage->_currentBackgroundFrame.clear(); // call render in the correct order first... render::renderItems(context, inputs); @@ -66,12 +66,12 @@ void SetupZones::run(const RenderContextPointer& context, const Inputs& inputs) lightStage->_currentFrame.pushSunLight(0); lightStage->_currentFrame.pushAmbientLight(0); - backgroundStage->_currentFrame.pushBackground(0); + backgroundStage->_currentBackgroundFrame.pushBackground(0); // Haze auto hazeStage = context->_scene->getStage(); assert(hazeStage); - hazeStage->_currentFrame.clear(); + hazeStage->_currentHazeFrame.clear(); } const gpu::PipelinePointer& DebugZoneLighting::getKeyLightPipeline() { @@ -160,8 +160,8 @@ void DebugZoneLighting::run(const render::RenderContextPointer& context, const I auto backgroundStage = context->_scene->getStage(BackgroundStage::getName()); std::vector skyboxStack; - if (backgroundStage && backgroundStage->_currentFrame._backgrounds.size()) { - for (auto index : backgroundStage->_currentFrame._backgrounds) { + if (backgroundStage && backgroundStage->_currentBackgroundFrame._backgrounds.size()) { + for (auto index : backgroundStage->_currentBackgroundFrame._backgrounds) { auto background = backgroundStage->getBackground(index); if (background) { skyboxStack.push_back(background->getSkybox()); From 48e5b9d1bcfea9a7f061381e6790f55e18429e46 Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Tue, 3 Oct 2017 17:42:04 -0700 Subject: [PATCH 35/94] Haze enable/disable from UI works. --- .../src/RenderableZoneEntityItem.cpp | 10 ++-------- libraries/render-utils/src/BackgroundStage.cpp | 4 ++-- libraries/render-utils/src/BackgroundStage.h | 6 +++--- libraries/render-utils/src/DrawHaze.cpp | 4 ++-- libraries/render-utils/src/HazeStage.cpp | 4 ++-- libraries/render-utils/src/HazeStage.h | 6 +++--- libraries/render-utils/src/ZoneRenderer.cpp | 18 +++++++++--------- 7 files changed, 23 insertions(+), 29 deletions(-) diff --git a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp index 2e5b791a84..27e4d35f14 100644 --- a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp @@ -141,9 +141,6 @@ void ZoneEntityRenderer::doRender(RenderArgs* args) { if (_needBackgroundUpdate) { if (BackgroundStage::isIndexInvalid(_backgroundIndex)) { _backgroundIndex = _backgroundStage->addBackground(_background); - } - else { - } _needBackgroundUpdate = false; } @@ -153,9 +150,6 @@ void ZoneEntityRenderer::doRender(RenderArgs* args) { if (_needHazeUpdate) { if (HazeStage::isIndexInvalid(_hazeIndex)) { _hazeIndex = _hazeStage->addHaze(_haze); - } - else { - } _needHazeUpdate = false; } @@ -173,12 +167,12 @@ void ZoneEntityRenderer::doRender(RenderArgs* args) { // The background only if the mode is not inherit if (_backgroundMode != BACKGROUND_MODE_INHERIT) { - _backgroundStage->_currentBackgroundFrame.pushBackground(_backgroundIndex); + _backgroundStage->_currentFrame.pushBackground(_backgroundIndex); } // The haze only if the mode is not inherit if (_hazeMode != HAZE_MODE_INHERIT) { - _hazeStage->_currentHazeFrame.pushHaze(_hazeIndex); + _hazeStage->_currentFrame.pushHaze(_hazeIndex); } } } diff --git a/libraries/render-utils/src/BackgroundStage.cpp b/libraries/render-utils/src/BackgroundStage.cpp index 1e530769e7..2ea3683c4a 100644 --- a/libraries/render-utils/src/BackgroundStage.cpp +++ b/libraries/render-utils/src/BackgroundStage.cpp @@ -65,8 +65,8 @@ void DrawBackgroundStage::run(const render::RenderContextPointer& renderContext, model::SunSkyStagePointer background; model::SkyboxPointer skybox; - if (backgroundStage->_currentBackgroundFrame._backgrounds.size()) { - auto backgroundId = backgroundStage->_currentBackgroundFrame._backgrounds.front(); + if (backgroundStage->_currentFrame._backgrounds.size()) { + auto backgroundId = backgroundStage->_currentFrame._backgrounds.front(); auto background = backgroundStage->getBackground(backgroundId); if (background) { skybox = background->getSkybox(); diff --git a/libraries/render-utils/src/BackgroundStage.h b/libraries/render-utils/src/BackgroundStage.h index 7f60139880..eab7c94f0d 100644 --- a/libraries/render-utils/src/BackgroundStage.h +++ b/libraries/render-utils/src/BackgroundStage.h @@ -55,9 +55,9 @@ public: Backgrounds _backgrounds; BackgroundMap _backgroundMap; - class BackgroundFrame { + class Frame { public: - BackgroundFrame() {} + Frame() {} void clear() { _backgrounds.clear(); } @@ -66,7 +66,7 @@ public: BackgroundStage::BackgroundIndices _backgrounds; }; - BackgroundFrame _currentBackgroundFrame; + Frame _currentFrame; }; using BackgroundStagePointer = std::shared_ptr; diff --git a/libraries/render-utils/src/DrawHaze.cpp b/libraries/render-utils/src/DrawHaze.cpp index 57d2163878..1c65e1b905 100644 --- a/libraries/render-utils/src/DrawHaze.cpp +++ b/libraries/render-utils/src/DrawHaze.cpp @@ -177,8 +177,8 @@ void DrawHaze::run(const render::RenderContextPointer& renderContext, const Inpu batch.setPipeline(_hazePipeline); auto hazeStage = args->_scene->getStage(); - if (hazeStage && hazeStage->_currentHazeFrame._hazes.size() > 0) { - model::HazePointer hazePointer = hazeStage->getHaze(hazeStage->_currentHazeFrame._hazes.front()); + if (hazeStage && hazeStage->_currentFrame._hazes.size() > 0) { + model::HazePointer hazePointer = hazeStage->getHaze(hazeStage->_currentFrame._hazes.front()); batch.setUniformBuffer(HazeEffect_ParamsSlot, hazePointer->getHazeParametersBuffer()); } diff --git a/libraries/render-utils/src/HazeStage.cpp b/libraries/render-utils/src/HazeStage.cpp index 96823521ab..4acc5d534c 100644 --- a/libraries/render-utils/src/HazeStage.cpp +++ b/libraries/render-utils/src/HazeStage.cpp @@ -90,8 +90,8 @@ void FetchHazeStage::run(const render::RenderContextPointer& renderContext, mode assert(hazeStage); haze = nullptr; - if (hazeStage->_currentHazeFrame._hazes.size() != 0) { - auto hazeId = hazeStage->_currentHazeFrame._hazes.front(); + if (hazeStage->_currentFrame._hazes.size() != 0) { + auto hazeId = hazeStage->_currentFrame._hazes.front(); haze = hazeStage->getHaze(hazeId); } } diff --git a/libraries/render-utils/src/HazeStage.h b/libraries/render-utils/src/HazeStage.h index 1d070ae972..4f3760fb40 100644 --- a/libraries/render-utils/src/HazeStage.h +++ b/libraries/render-utils/src/HazeStage.h @@ -55,9 +55,9 @@ public: Hazes _hazes; HazeMap _hazeMap; - class HazeFrame { + class Frame { public: - HazeFrame() {} + Frame() {} void clear() { _hazes.clear(); } @@ -66,7 +66,7 @@ public: HazeStage::HazeIndices _hazes; }; - HazeFrame _currentHazeFrame; + Frame _currentFrame; }; using HazeStagePointer = std::shared_ptr; diff --git a/libraries/render-utils/src/ZoneRenderer.cpp b/libraries/render-utils/src/ZoneRenderer.cpp index 46fa21c6d8..3d1fe33267 100644 --- a/libraries/render-utils/src/ZoneRenderer.cpp +++ b/libraries/render-utils/src/ZoneRenderer.cpp @@ -54,7 +54,12 @@ void ZoneRendererTask::build(JobModel& task, const Varying& input, Varying& oupu void SetupZones::run(const RenderContextPointer& context, const Inputs& inputs) { auto backgroundStage = context->_scene->getStage(); assert(backgroundStage); - backgroundStage->_currentBackgroundFrame.clear(); + backgroundStage->_currentFrame.clear(); + + // Haze + auto hazeStage = context->_scene->getStage(); + assert(hazeStage); + hazeStage->_currentFrame.clear(); // call render in the correct order first... render::renderItems(context, inputs); @@ -66,12 +71,7 @@ void SetupZones::run(const RenderContextPointer& context, const Inputs& inputs) lightStage->_currentFrame.pushSunLight(0); lightStage->_currentFrame.pushAmbientLight(0); - backgroundStage->_currentBackgroundFrame.pushBackground(0); - - // Haze - auto hazeStage = context->_scene->getStage(); - assert(hazeStage); - hazeStage->_currentHazeFrame.clear(); + backgroundStage->_currentFrame.pushBackground(0); } const gpu::PipelinePointer& DebugZoneLighting::getKeyLightPipeline() { @@ -160,8 +160,8 @@ void DebugZoneLighting::run(const render::RenderContextPointer& context, const I auto backgroundStage = context->_scene->getStage(BackgroundStage::getName()); std::vector skyboxStack; - if (backgroundStage && backgroundStage->_currentBackgroundFrame._backgrounds.size()) { - for (auto index : backgroundStage->_currentBackgroundFrame._backgrounds) { + if (backgroundStage && backgroundStage->_currentFrame._backgrounds.size()) { + for (auto index : backgroundStage->_currentFrame._backgrounds) { auto background = backgroundStage->getBackground(index); if (background) { skyboxStack.push_back(background->getSkybox()); From c1f4735468f138563ab3a20edf03a635517db435 Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Tue, 3 Oct 2017 19:39:34 -0700 Subject: [PATCH 36/94] Replaced HazeMode with uint8_t in transport protocol. --- .../entities-renderer/src/RenderableZoneEntityItem.cpp | 2 +- libraries/entities/src/EntityItemProperties.cpp | 2 +- libraries/entities/src/EntityItemProperties.h | 4 ++-- libraries/entities/src/ZoneEntityItem.cpp | 6 +++--- libraries/entities/src/ZoneEntityItem.h | 6 +++--- libraries/model/src/model/Stage.cpp | 2 +- libraries/model/src/model/Stage.h | 6 +++--- libraries/octree/src/OctreePacketData.h | 1 - 8 files changed, 14 insertions(+), 15 deletions(-) diff --git a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp index 27e4d35f14..21a9f677ce 100644 --- a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp @@ -331,7 +331,7 @@ void ZoneEntityRenderer::updateKeyAmbientFromEntity() { } void ZoneEntityRenderer::updateHazeFromEntity(const TypedEntityPointer& entity) { - setHazeMode(entity->getHazeMode()); + setHazeMode((HazeMode)entity->getHazeMode()); const auto& haze = editHaze(); diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp index 25874d8979..4b9bdf49c8 100644 --- a/libraries/entities/src/EntityItemProperties.cpp +++ b/libraries/entities/src/EntityItemProperties.cpp @@ -231,7 +231,7 @@ QString EntityItemProperties::getHazeModeAsString() const { return HAZE_MODES[_hazeMode].second; } -QString EntityItemProperties::getHazeModeString(HazeMode mode) { +QString EntityItemProperties::getHazeModeString(uint8_t mode) { return HAZE_MODES[mode].second; } diff --git a/libraries/entities/src/EntityItemProperties.h b/libraries/entities/src/EntityItemProperties.h index 09bc572ca2..ae3010d46a 100644 --- a/libraries/entities/src/EntityItemProperties.h +++ b/libraries/entities/src/EntityItemProperties.h @@ -178,7 +178,7 @@ public: DEFINE_PROPERTY_REF(PROP_NAME, Name, name, QString, ENTITY_ITEM_DEFAULT_NAME); DEFINE_PROPERTY_REF_ENUM(PROP_BACKGROUND_MODE, BackgroundMode, backgroundMode, BackgroundMode, BACKGROUND_MODE_INHERIT); - DEFINE_PROPERTY_REF_ENUM(PROP_HAZE_MODE, HazeMode, hazeMode, HazeMode, HAZE_MODE_INHERIT); + DEFINE_PROPERTY_REF_ENUM(PROP_HAZE_MODE, HazeMode, hazeMode, uint8_t, (uint8_t)HAZE_MODE_INHERIT); DEFINE_PROPERTY(PROP_HAZE_RANGE, HazeRange, hazeRange, float, HazePropertyGroup::DEFAULT_HAZE_RANGE); DEFINE_PROPERTY(PROP_HAZE_BLEND_IN_COLOR, HazeBlendInColor, hazeBlendInColor, xColor, HazePropertyGroup::DEFAULT_HAZE_BLEND_IN_COLOR); @@ -258,7 +258,7 @@ public: DEFINE_PROPERTY_REF(PROP_SERVER_SCRIPTS, ServerScripts, serverScripts, QString, ENTITY_ITEM_DEFAULT_SERVER_SCRIPTS); static QString getBackgroundModeString(BackgroundMode mode); - static QString getHazeModeString(HazeMode mode); + static QString getHazeModeString(uint8_t mode); public: diff --git a/libraries/entities/src/ZoneEntityItem.cpp b/libraries/entities/src/ZoneEntityItem.cpp index daa5dc0106..727fbf5275 100644 --- a/libraries/entities/src/ZoneEntityItem.cpp +++ b/libraries/entities/src/ZoneEntityItem.cpp @@ -164,7 +164,7 @@ int ZoneEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data, READ_ENTITY_PROPERTY(PROP_COMPOUND_SHAPE_URL, QString, setCompoundShapeURL); READ_ENTITY_PROPERTY(PROP_BACKGROUND_MODE, BackgroundMode, setBackgroundMode); - READ_ENTITY_PROPERTY(PROP_BACKGROUND_MODE, HazeMode, setHazeMode); + READ_ENTITY_PROPERTY(PROP_BACKGROUND_MODE, uint8_t, setHazeMode); int bytesFromSkybox; withWriteLock([&] { @@ -335,12 +335,12 @@ void ZoneEntityItem::resetRenderingPropertiesChanged() { } #pragma optimize("", off) -void ZoneEntityItem::setHazeMode(const HazeMode value) { +void ZoneEntityItem::setHazeMode(const uint8_t value) { _hazeMode = value; _hazePropertiesChanged = true; } -HazeMode ZoneEntityItem::getHazeMode() const { +uint8_t ZoneEntityItem::getHazeMode() const { return _hazeMode; } diff --git a/libraries/entities/src/ZoneEntityItem.h b/libraries/entities/src/ZoneEntityItem.h index 675a1feeb7..0bf7e63afd 100644 --- a/libraries/entities/src/ZoneEntityItem.h +++ b/libraries/entities/src/ZoneEntityItem.h @@ -69,8 +69,8 @@ public: void setBackgroundMode(BackgroundMode value) { _backgroundMode = value; _backgroundPropertiesChanged = true; } BackgroundMode getBackgroundMode() const { return _backgroundMode; } - void setHazeMode(const HazeMode value); - HazeMode getHazeMode() const; + void setHazeMode(const uint8_t value); + uint8_t getHazeMode() const; void setHazeRange(const float hazeRange); float getHazeRange()const; @@ -141,7 +141,7 @@ protected: BackgroundMode _backgroundMode = BACKGROUND_MODE_INHERIT; - HazeMode _hazeMode{ HAZE_MODE_INHERIT }; + uint8_t _hazeMode{ (uint8_t)HAZE_MODE_INHERIT }; float _hazeRange{ HazePropertyGroup::DEFAULT_HAZE_RANGE }; xColor _hazeBlendInColor{ HazePropertyGroup::DEFAULT_HAZE_BLEND_IN_COLOR }; diff --git a/libraries/model/src/model/Stage.cpp b/libraries/model/src/model/Stage.cpp index ab441efb2f..3080122181 100644 --- a/libraries/model/src/model/Stage.cpp +++ b/libraries/model/src/model/Stage.cpp @@ -257,7 +257,7 @@ void SunSkyStage::setSkybox(const SkyboxPointer& skybox) { } // Haze -void SunSkyStage::setHazeMode(HazeMode mode) { +void SunSkyStage::setHazeMode(uint8_t mode) { _hazeMode = mode; invalidate(); } diff --git a/libraries/model/src/model/Stage.h b/libraries/model/src/model/Stage.h index fb4ac88f8f..ad1210c5c0 100644 --- a/libraries/model/src/model/Stage.h +++ b/libraries/model/src/model/Stage.h @@ -183,8 +183,8 @@ public: NUM_HAZE_MODES }; - void setHazeMode(HazeMode mode); - HazeMode getHazeMode() const { return _hazeMode; } + void setHazeMode(uint8_t mode); + uint8_t getHazeMode() const { return _hazeMode; } void setHazeRange(float hazeRange) { _hazeRange = hazeRange; } float getHazeRange() const { return _hazeRange; } @@ -211,7 +211,7 @@ public: protected: BackgroundMode _backgroundMode = SKY_DEFAULT; - HazeMode _hazeMode = HAZE_OFF; + uint8_t _hazeMode = (uint8_t)HAZE_OFF; float _hazeRange; xColor _hazeBlendInColor; diff --git a/libraries/octree/src/OctreePacketData.h b/libraries/octree/src/OctreePacketData.h index 0b93343b09..d0255d60ab 100644 --- a/libraries/octree/src/OctreePacketData.h +++ b/libraries/octree/src/OctreePacketData.h @@ -259,7 +259,6 @@ public: static int unpackDataFromBytes(const unsigned char* dataBytes, glm::quat& result) { int bytes = unpackOrientationQuatFromBytes(dataBytes, result); return bytes; } static int unpackDataFromBytes(const unsigned char* dataBytes, ShapeType& result) { memcpy(&result, dataBytes, sizeof(result)); return sizeof(result); } static int unpackDataFromBytes(const unsigned char* dataBytes, BackgroundMode& result) { memcpy(&result, dataBytes, sizeof(result)); return sizeof(result); } - static int unpackDataFromBytes(const unsigned char* dataBytes, HazeMode& result) { memcpy(&result, dataBytes, sizeof(result)); return sizeof(result); } static int unpackDataFromBytes(const unsigned char* dataBytes, QString& result); static int unpackDataFromBytes(const unsigned char* dataBytes, QUuid& result); static int unpackDataFromBytes(const unsigned char* dataBytes, xColor& result); From 89381e7c8e5eab8a7146632f521b62cef9a5c425 Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Tue, 3 Oct 2017 19:43:35 -0700 Subject: [PATCH 37/94] Moved _hazeProperties.getProperties(properties); into the ReadLock --- libraries/entities/src/ZoneEntityItem.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libraries/entities/src/ZoneEntityItem.cpp b/libraries/entities/src/ZoneEntityItem.cpp index 727fbf5275..d90c391f33 100644 --- a/libraries/entities/src/ZoneEntityItem.cpp +++ b/libraries/entities/src/ZoneEntityItem.cpp @@ -65,10 +65,9 @@ EntityItemProperties ZoneEntityItem::getProperties(EntityPropertyFlags desiredPr // Contains a QString property, must be synchronized withReadLock([&] { _skyboxProperties.getProperties(properties); + _hazeProperties.getProperties(properties); }); - _hazeProperties.getProperties(properties); - COPY_ENTITY_PROPERTY_TO_PROPERTIES(flyingAllowed, getFlyingAllowed); COPY_ENTITY_PROPERTY_TO_PROPERTIES(ghostingAllowed, getGhostingAllowed); COPY_ENTITY_PROPERTY_TO_PROPERTIES(filterURL, getFilterURL); From 16a10a8a0cb17941acc9ce9d22d3c3e908312764 Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Tue, 3 Oct 2017 20:57:56 -0700 Subject: [PATCH 38/94] WIP - working on byte order in server messages. --- libraries/entities/src/ZoneEntityItem.cpp | 27 +++++++++++++---------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/libraries/entities/src/ZoneEntityItem.cpp b/libraries/entities/src/ZoneEntityItem.cpp index d90c391f33..a8e2de25ac 100644 --- a/libraries/entities/src/ZoneEntityItem.cpp +++ b/libraries/entities/src/ZoneEntityItem.cpp @@ -59,19 +59,22 @@ EntityItemProperties ZoneEntityItem::getProperties(EntityPropertyFlags desiredPr COPY_ENTITY_PROPERTY_TO_PROPERTIES(shapeType, getShapeType); COPY_ENTITY_PROPERTY_TO_PROPERTIES(compoundShapeURL, getCompoundShapeURL); COPY_ENTITY_PROPERTY_TO_PROPERTIES(backgroundMode, getBackgroundMode); - - COPY_ENTITY_PROPERTY_TO_PROPERTIES(hazeMode, getHazeMode); // Contains a QString property, must be synchronized withReadLock([&] { _skyboxProperties.getProperties(properties); - _hazeProperties.getProperties(properties); }); COPY_ENTITY_PROPERTY_TO_PROPERTIES(flyingAllowed, getFlyingAllowed); COPY_ENTITY_PROPERTY_TO_PROPERTIES(ghostingAllowed, getGhostingAllowed); COPY_ENTITY_PROPERTY_TO_PROPERTIES(filterURL, getFilterURL); + COPY_ENTITY_PROPERTY_TO_PROPERTIES(hazeMode, getHazeMode); + // Contains a QString property, must be synchronized + withReadLock([&] { + _hazeProperties.getProperties(properties); + }); + return properties; } @@ -107,6 +110,15 @@ bool ZoneEntityItem::setSubClassProperties(const EntityItemProperties& propertie SET_ENTITY_PROPERTY_FROM_PROPERTIES(compoundShapeURL, setCompoundShapeURL); SET_ENTITY_PROPERTY_FROM_PROPERTIES(backgroundMode, setBackgroundMode); + // Contains a QString property, must be synchronized + withWriteLock([&] { + _skyboxPropertiesChanged = _skyboxProperties.setProperties(properties); + }); + + SET_ENTITY_PROPERTY_FROM_PROPERTIES(flyingAllowed, setFlyingAllowed); + SET_ENTITY_PROPERTY_FROM_PROPERTIES(ghostingAllowed, setGhostingAllowed); + SET_ENTITY_PROPERTY_FROM_PROPERTIES(filterURL, setFilterURL); + SET_ENTITY_PROPERTY_FROM_PROPERTIES(hazeMode, setHazeMode); SET_ENTITY_PROPERTY_FROM_PROPERTIES(hazeRange, setHazeRange); @@ -122,15 +134,6 @@ bool ZoneEntityItem::setSubClassProperties(const EntityItemProperties& propertie SET_ENTITY_PROPERTY_FROM_PROPERTIES(hazeKeyLightRange, setHazeKeyLightRange); SET_ENTITY_PROPERTY_FROM_PROPERTIES(hazeKeyLightAltitude, setHazeKeyLightAltitude); - SET_ENTITY_PROPERTY_FROM_PROPERTIES(flyingAllowed, setFlyingAllowed); - SET_ENTITY_PROPERTY_FROM_PROPERTIES(ghostingAllowed, setGhostingAllowed); - SET_ENTITY_PROPERTY_FROM_PROPERTIES(filterURL, setFilterURL); - - // Contains a QString property, must be synchronized - withWriteLock([&] { - _skyboxPropertiesChanged = _skyboxProperties.setProperties(properties); - }); - somethingChanged = somethingChanged || _keyLightPropertiesChanged || _stagePropertiesChanged || _skyboxPropertiesChanged || _hazePropertiesChanged; return somethingChanged; From 3505fedc004e131fbcc9f9efc8649ca2d8b0cde0 Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Tue, 3 Oct 2017 21:34:21 -0700 Subject: [PATCH 39/94] WIP - working on byte order in server messages. --- libraries/entities/src/ZoneEntityItem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/entities/src/ZoneEntityItem.cpp b/libraries/entities/src/ZoneEntityItem.cpp index a8e2de25ac..589b3bd478 100644 --- a/libraries/entities/src/ZoneEntityItem.cpp +++ b/libraries/entities/src/ZoneEntityItem.cpp @@ -166,7 +166,7 @@ int ZoneEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data, READ_ENTITY_PROPERTY(PROP_COMPOUND_SHAPE_URL, QString, setCompoundShapeURL); READ_ENTITY_PROPERTY(PROP_BACKGROUND_MODE, BackgroundMode, setBackgroundMode); - READ_ENTITY_PROPERTY(PROP_BACKGROUND_MODE, uint8_t, setHazeMode); + READ_ENTITY_PROPERTY(PROP_HAZE_MODE, uint8_t, setHazeMode); int bytesFromSkybox; withWriteLock([&] { From 4019c3bc1073b24e0ebd3df075086cdf7b2eb650 Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Tue, 3 Oct 2017 21:36:20 -0700 Subject: [PATCH 40/94] WIP - working on byte order in server messages. --- libraries/entities/src/ZoneEntityItem.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libraries/entities/src/ZoneEntityItem.cpp b/libraries/entities/src/ZoneEntityItem.cpp index 589b3bd478..1619816215 100644 --- a/libraries/entities/src/ZoneEntityItem.cpp +++ b/libraries/entities/src/ZoneEntityItem.cpp @@ -166,8 +166,6 @@ int ZoneEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data, READ_ENTITY_PROPERTY(PROP_COMPOUND_SHAPE_URL, QString, setCompoundShapeURL); READ_ENTITY_PROPERTY(PROP_BACKGROUND_MODE, BackgroundMode, setBackgroundMode); - READ_ENTITY_PROPERTY(PROP_HAZE_MODE, uint8_t, setHazeMode); - int bytesFromSkybox; withWriteLock([&] { bytesFromSkybox = _skyboxProperties.readEntitySubclassDataFromBuffer(dataAt, (bytesLeftToRead - bytesRead), args, @@ -177,6 +175,12 @@ int ZoneEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data, bytesRead += bytesFromSkybox; dataAt += bytesFromSkybox; + READ_ENTITY_PROPERTY(PROP_FLYING_ALLOWED, bool, setFlyingAllowed); + READ_ENTITY_PROPERTY(PROP_GHOSTING_ALLOWED, bool, setGhostingAllowed); + READ_ENTITY_PROPERTY(PROP_FILTER_URL, QString, setFilterURL); + + READ_ENTITY_PROPERTY(PROP_HAZE_MODE, uint8_t, setHazeMode); + int bytesFromHaze; withWriteLock([&] { bytesFromHaze = _hazeProperties.readEntitySubclassDataFromBuffer(dataAt, (bytesLeftToRead - bytesRead), args, @@ -186,10 +190,6 @@ int ZoneEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data, bytesRead += bytesFromHaze; dataAt += bytesFromHaze; - READ_ENTITY_PROPERTY(PROP_FLYING_ALLOWED, bool, setFlyingAllowed); - READ_ENTITY_PROPERTY(PROP_GHOSTING_ALLOWED, bool, setGhostingAllowed); - READ_ENTITY_PROPERTY(PROP_FILTER_URL, QString, setFilterURL); - return bytesRead; } From 75509b9ecb99705fee8d69aef26cd2d8a260ab33 Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Tue, 3 Oct 2017 21:39:41 -0700 Subject: [PATCH 41/94] WIP - working on byte order in server messages. --- libraries/entities/src/ZoneEntityItem.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libraries/entities/src/ZoneEntityItem.cpp b/libraries/entities/src/ZoneEntityItem.cpp index 1619816215..cebad4e774 100644 --- a/libraries/entities/src/ZoneEntityItem.cpp +++ b/libraries/entities/src/ZoneEntityItem.cpp @@ -210,13 +210,15 @@ EntityPropertyFlags ZoneEntityItem::getEntityProperties(EncodeBitstreamParams& p withReadLock([&] { requestedProperties += _skyboxProperties.getEntityProperties(params); }); - withReadLock([&] { - requestedProperties += _hazeProperties.getEntityProperties(params); - }); requestedProperties += PROP_FLYING_ALLOWED; requestedProperties += PROP_GHOSTING_ALLOWED; requestedProperties += PROP_FILTER_URL; + requestedProperties += PROP_HAZE_MODE; + withReadLock([&] { + requestedProperties += _hazeProperties.getEntityProperties(params); + }); + return requestedProperties; } From 76f843c741b106985c2bdf25c424296872935c63 Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Tue, 3 Oct 2017 21:46:50 -0700 Subject: [PATCH 42/94] WIP - working on byte order in server messages. --- libraries/entities/src/ZoneEntityItem.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/libraries/entities/src/ZoneEntityItem.cpp b/libraries/entities/src/ZoneEntityItem.cpp index cebad4e774..64c463c16f 100644 --- a/libraries/entities/src/ZoneEntityItem.cpp +++ b/libraries/entities/src/ZoneEntityItem.cpp @@ -243,17 +243,16 @@ void ZoneEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBits APPEND_ENTITY_PROPERTY(PROP_COMPOUND_SHAPE_URL, getCompoundShapeURL()); APPEND_ENTITY_PROPERTY(PROP_BACKGROUND_MODE, (uint32_t)getBackgroundMode()); // could this be a uint16?? - APPEND_ENTITY_PROPERTY(PROP_HAZE_MODE, (uint32_t)getHazeMode()); - _skyboxProperties.appendSubclassData(packetData, params, modelTreeElementExtraEncodeData, requestedProperties, propertyFlags, propertiesDidntFit, propertyCount, appendState); - _hazeProperties.appendSubclassData(packetData, params, modelTreeElementExtraEncodeData, requestedProperties, - propertyFlags, propertiesDidntFit, propertyCount, appendState); - APPEND_ENTITY_PROPERTY(PROP_FLYING_ALLOWED, getFlyingAllowed()); APPEND_ENTITY_PROPERTY(PROP_GHOSTING_ALLOWED, getGhostingAllowed()); APPEND_ENTITY_PROPERTY(PROP_FILTER_URL, getFilterURL()); + + APPEND_ENTITY_PROPERTY(PROP_HAZE_MODE, (uint32_t)getHazeMode()); + _hazeProperties.appendSubclassData(packetData, params, modelTreeElementExtraEncodeData, requestedProperties, + propertyFlags, propertiesDidntFit, propertyCount, appendState); } void ZoneEntityItem::debugDump() const { From 8c430d36fab46c65494606d609ef1d3b92bee4e6 Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Tue, 3 Oct 2017 21:59:40 -0700 Subject: [PATCH 43/94] WIP - working on byte order in server messages. --- libraries/entities/src/HazePropertyGroup.cpp | 33 -------------------- libraries/entities/src/HazePropertyGroup.h | 5 --- libraries/entities/src/ZoneEntityItem.cpp | 1 - 3 files changed, 39 deletions(-) diff --git a/libraries/entities/src/HazePropertyGroup.cpp b/libraries/entities/src/HazePropertyGroup.cpp index 57bd5c0739..9c6fe34fb1 100644 --- a/libraries/entities/src/HazePropertyGroup.cpp +++ b/libraries/entities/src/HazePropertyGroup.cpp @@ -15,8 +15,6 @@ #include "EntityItemProperties.h" #include "EntityItemPropertiesMacros.h" -const uint8_t HazePropertyGroup::DEFAULT_HAZE_MODE{ 0 }; - const float HazePropertyGroup::DEFAULT_HAZE_RANGE{ 1000.0f }; const xColor HazePropertyGroup::DEFAULT_HAZE_BLEND_IN_COLOR{ 128, 154, 179 }; // Bluish const xColor HazePropertyGroup::DEFAULT_HAZE_BLEND_OUT_COLOR{ 255, 229, 179 }; // Yellowish @@ -31,8 +29,6 @@ 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_MODE, Haze, haze, HazeMode, hazeMode); - COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_RANGE, Haze, haze, HazeRange, hazeRange); COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_BLEND_IN_COLOR, Haze, haze, HazeBlendInColor, hazeBlendIncolor); COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_BLEND_OUT_COLOR, Haze, haze, HazeBlendOutColor, hazeBlendOutcolor); @@ -48,8 +44,6 @@ void HazePropertyGroup::copyToScriptValue(const EntityPropertyFlags& desiredProp } void HazePropertyGroup::copyFromScriptValue(const QScriptValue& object, bool& _defaultSettings) { - COPY_PROPERTY_FROM_QSCRIPTVALUE_GETTER(hazeMode, uint8_t, setHazeMode, getHazeMode); - COPY_PROPERTY_FROM_QSCRIPTVALUE_GETTER(hazeHazeRange, float, setHazeRange, getHazeRange); COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(haze, hazeBlendInColor, xColor, setHazeBlendInColor); COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(haze, hazeBlendOutColor, xColor, setHazeBlendOutColor); @@ -65,8 +59,6 @@ void HazePropertyGroup::copyFromScriptValue(const QScriptValue& object, bool& _d } void HazePropertyGroup::merge(const HazePropertyGroup& other) { - COPY_PROPERTY_IF_CHANGED(hazeMode); - COPY_PROPERTY_IF_CHANGED(hazeRange); COPY_PROPERTY_IF_CHANGED(hazeBlendInColor); COPY_PROPERTY_IF_CHANGED(hazeBlendOutColor); @@ -83,7 +75,6 @@ void HazePropertyGroup::merge(const HazePropertyGroup& other) { void HazePropertyGroup::debugDump() const { qCDebug(entities) << " HazePropertyGroup: ---------------------------------------------"; - qCDebug(entities) << " _hazeMode:" << _hazeMode; qCDebug(entities) << " _hazeRange:" << _hazeRange; qCDebug(entities) << " _hazeBlendInColor:" << _hazeBlendInColor; @@ -100,10 +91,6 @@ void HazePropertyGroup::debugDump() const { } void HazePropertyGroup::listChangedProperties(QList& out) { - if (hazeModeChanged()) { - out << "haze-mode"; - } - if (hazeRangeChanged()) { out << "haze-range"; } @@ -145,8 +132,6 @@ bool HazePropertyGroup::appendToEditPacket(OctreePacketData* packetData, bool successPropertyFits = true; - APPEND_ENTITY_PROPERTY(PROP_HAZE_MODE, getHazeMode()); - APPEND_ENTITY_PROPERTY(PROP_HAZE_RANGE, getHazeRange()); APPEND_ENTITY_PROPERTY(PROP_HAZE_BLEND_IN_COLOR, getHazeBlendInColor()); APPEND_ENTITY_PROPERTY(PROP_HAZE_BLEND_OUT_COLOR, getHazeBlendOutColor()); @@ -169,8 +154,6 @@ bool HazePropertyGroup::decodeFromEditPacket(EntityPropertyFlags& propertyFlags, bool overwriteLocalData = true; bool somethingChanged = false; - READ_ENTITY_PROPERTY(PROP_HAZE_MODE, uint8_t, setHazeMode); - READ_ENTITY_PROPERTY(PROP_HAZE_RANGE, float, setHazeRange); READ_ENTITY_PROPERTY(PROP_HAZE_BLEND_IN_COLOR, xColor, setHazeBlendInColor); READ_ENTITY_PROPERTY(PROP_HAZE_BLEND_OUT_COLOR, xColor, setHazeBlendOutColor); @@ -184,8 +167,6 @@ bool HazePropertyGroup::decodeFromEditPacket(EntityPropertyFlags& propertyFlags, READ_ENTITY_PROPERTY(PROP_HAZE_KEYLIGHT_RANGE, float, setHazeKeyLightRange); READ_ENTITY_PROPERTY(PROP_HAZE_KEYLIGHT_ALTITUDE, float, setHazeKeyLightAltitude); - DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_MODE, HazeMode); - DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_RANGE, HazeRange); DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_BLEND_IN_COLOR, HazeBlendInColor); DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_BLEND_OUT_COLOR, HazeBlendOutColor); @@ -207,8 +188,6 @@ bool HazePropertyGroup::decodeFromEditPacket(EntityPropertyFlags& propertyFlags, } void HazePropertyGroup::markAllChanged() { - _hazeModeChanged = true; - _hazeRangeChanged = true; _hazeBlendInColorChanged = true; _hazeBlendOutColorChanged = true; @@ -226,8 +205,6 @@ void HazePropertyGroup::markAllChanged() { EntityPropertyFlags HazePropertyGroup::getChangedProperties() const { EntityPropertyFlags changedProperties; - CHECK_PROPERTY_CHANGE(PROP_HAZE_MODE, hazeMode); - CHECK_PROPERTY_CHANGE(PROP_HAZE_RANGE, hazeRange); CHECK_PROPERTY_CHANGE(PROP_HAZE_BLEND_IN_COLOR, hazeBlendInColor); CHECK_PROPERTY_CHANGE(PROP_HAZE_BLEND_OUT_COLOR, hazeBlendOutColor); @@ -245,8 +222,6 @@ EntityPropertyFlags HazePropertyGroup::getChangedProperties() const { } void HazePropertyGroup::getProperties(EntityItemProperties& properties) const { - COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Haze, HazeMode, getHazeMode); - COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Haze, HazeRange, getHazeRange); COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Haze, HazeBlendInColor, getHazeBlendInColor); COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Haze, HazeBlendOutColor, getHazeBlendOutColor); @@ -264,8 +239,6 @@ void HazePropertyGroup::getProperties(EntityItemProperties& properties) const { bool HazePropertyGroup::setProperties(const EntityItemProperties& properties) { bool somethingChanged = false; - SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Haze, HazeMode, hazeMode, setHazeMode); - SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Haze, HazeRange, hazeRange, setHazeRange); SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Haze, HazeBlendInColor, hazeBlendInColor, setHazeBlendInColor); SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Haze, HazeBlendOutColor, hazeBlendOutColor, setHazeBlendOutColor); @@ -285,8 +258,6 @@ bool HazePropertyGroup::setProperties(const EntityItemProperties& properties) { EntityPropertyFlags HazePropertyGroup::getEntityProperties(EncodeBitstreamParams& params) const { EntityPropertyFlags requestedProperties; - requestedProperties += PROP_HAZE_MODE; - requestedProperties += PROP_HAZE_RANGE; requestedProperties += PROP_HAZE_BLEND_IN_COLOR; requestedProperties += PROP_HAZE_BLEND_OUT_COLOR; @@ -313,8 +284,6 @@ void HazePropertyGroup::appendSubclassData(OctreePacketData* packetData, EncodeB bool successPropertyFits = true; - APPEND_ENTITY_PROPERTY(PROP_HAZE_MODE, getHazeMode()); - APPEND_ENTITY_PROPERTY(PROP_HAZE_RANGE, getHazeRange()); APPEND_ENTITY_PROPERTY(PROP_HAZE_BLEND_IN_COLOR, getHazeBlendInColor()); APPEND_ENTITY_PROPERTY(PROP_HAZE_BLEND_OUT_COLOR, getHazeBlendOutColor()); @@ -337,8 +306,6 @@ int HazePropertyGroup::readEntitySubclassDataFromBuffer(const unsigned char* dat int bytesRead = 0; const unsigned char* dataAt = data; - READ_ENTITY_PROPERTY(PROP_HAZE_MODE, uint8_t, setHazeMode); - READ_ENTITY_PROPERTY(PROP_HAZE_RANGE, float, setHazeRange); READ_ENTITY_PROPERTY(PROP_HAZE_BLEND_IN_COLOR, xColor, setHazeBlendInColor); READ_ENTITY_PROPERTY(PROP_HAZE_BLEND_OUT_COLOR, xColor, setHazeBlendOutColor); diff --git a/libraries/entities/src/HazePropertyGroup.h b/libraries/entities/src/HazePropertyGroup.h index 136c11080e..dd57ec0528 100644 --- a/libraries/entities/src/HazePropertyGroup.h +++ b/libraries/entities/src/HazePropertyGroup.h @@ -74,8 +74,6 @@ public: EntityPropertyFlags& propertyFlags, bool overwriteLocalData, bool& somethingChanged) override; - static const uint8_t DEFAULT_HAZE_MODE; - static const float DEFAULT_HAZE_RANGE; static const xColor DEFAULT_HAZE_BLEND_IN_COLOR; static const xColor DEFAULT_HAZE_BLEND_OUT_COLOR; @@ -89,9 +87,6 @@ public: static const float DEFAULT_HAZE_KEYLIGHT_RANGE; static const float DEFAULT_HAZE_KEYLIGHT_ALTITUDE; - // Selects whether haze inherits the mode, is off or the mode (range only, range & altitude...) - DEFINE_PROPERTY(PROP_HAZE_MODE, HazeMode, hazeMode, uint8_t, DEFAULT_HAZE_MODE); - // Range only parameters DEFINE_PROPERTY(PROP_HAZE_RANGE, HazeRange, hazeRange, float, DEFAULT_HAZE_RANGE); DEFINE_PROPERTY_REF(PROP_HAZE_BLEND_IN_COLOR, HazeBlendInColor, hazeBlendInColor, xColor, DEFAULT_HAZE_BLEND_IN_COLOR); diff --git a/libraries/entities/src/ZoneEntityItem.cpp b/libraries/entities/src/ZoneEntityItem.cpp index 64c463c16f..f6350699e7 100644 --- a/libraries/entities/src/ZoneEntityItem.cpp +++ b/libraries/entities/src/ZoneEntityItem.cpp @@ -337,7 +337,6 @@ void ZoneEntityItem::resetRenderingPropertiesChanged() { }); } -#pragma optimize("", off) void ZoneEntityItem::setHazeMode(const uint8_t value) { _hazeMode = value; _hazePropertiesChanged = true; From 3f677ec7c9fafb560754dc8ee18bad96f0cbb2a1 Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Wed, 4 Oct 2017 10:23:59 -0700 Subject: [PATCH 44/94] WIP - working on byte order in server messages. --- .../entities/src/EntityItemProperties.cpp | 100 ++++-------------- libraries/entities/src/HazePropertyGroup.cpp | 32 +++--- libraries/entities/src/ZoneEntityItem.cpp | 26 +---- 3 files changed, 39 insertions(+), 119 deletions(-) diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp index 4b9bdf49c8..d0b0fbb944 100644 --- a/libraries/entities/src/EntityItemProperties.cpp +++ b/libraries/entities/src/EntityItemProperties.cpp @@ -332,18 +332,7 @@ EntityPropertyFlags EntityItemProperties::getChangedProperties() const { CHECK_PROPERTY_CHANGE(PROP_NAME, name); CHECK_PROPERTY_CHANGE(PROP_BACKGROUND_MODE, backgroundMode); - CHECK_PROPERTY_CHANGE(PROP_HAZE_RANGE, hazeRange); - CHECK_PROPERTY_CHANGE(PROP_HAZE_BLEND_IN_COLOR, hazeBlendInColor); - CHECK_PROPERTY_CHANGE(PROP_HAZE_BLEND_OUT_COLOR, hazeBlendOutColor); - CHECK_PROPERTY_CHANGE(PROP_HAZE_LIGHT_BLEND_ANGLE, hazeLightBlendAngle); - - CHECK_PROPERTY_CHANGE(PROP_HAZE_ALTITUDE, hazeAltitude); - CHECK_PROPERTY_CHANGE(PROP_HAZE_BASE_REF, hazeBaseRef); - - CHECK_PROPERTY_CHANGE(PROP_HAZE_BACKGROUND_BLEND, hazeBackgroundBlend); - - CHECK_PROPERTY_CHANGE(PROP_HAZE_KEYLIGHT_RANGE, hazeKeyLightRange); - CHECK_PROPERTY_CHANGE(PROP_HAZE_KEYLIGHT_ALTITUDE, hazeKeyLightAltitude); + CHECK_PROPERTY_CHANGE(PROP_HAZE_MODE, hazeMode); CHECK_PROPERTY_CHANGE(PROP_SOURCE_URL, sourceUrl); CHECK_PROPERTY_CHANGE(PROP_VOXEL_VOLUME_SIZE, voxelVolumeSize); @@ -391,8 +380,8 @@ EntityPropertyFlags EntityItemProperties::getChangedProperties() const { changedProperties += _animation.getChangedProperties(); changedProperties += _keyLight.getChangedProperties(); changedProperties += _skybox.getChangedProperties(); - changedProperties += _haze.getChangedProperties(); changedProperties += _stage.getChangedProperties(); + changedProperties += _haze.getChangedProperties(); return changedProperties; } @@ -563,18 +552,20 @@ QScriptValue EntityItemProperties::copyToScriptValue(QScriptEngine* engine, bool // Zones only if (_type == EntityTypes::Zone) { _keyLight.copyToScriptValue(_desiredProperties, properties, engine, skipDefaults, defaultEntityProperties); + _stage.copyToScriptValue(_desiredProperties, properties, engine, skipDefaults, defaultEntityProperties); - COPY_PROPERTY_TO_QSCRIPTVALUE_GETTER(PROP_BACKGROUND_MODE, backgroundMode, getBackgroundModeAsString()); - - COPY_PROPERTY_TO_QSCRIPTVALUE_GETTER(PROP_HAZE_MODE, hazeMode, getHazeModeAsString()); + COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_SHAPE_TYPE, shapeType); + COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_COMPOUND_SHAPE_URL, compoundShapeURL); + COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_BACKGROUND_MODE, backgroundMode, backgroundMode); _skybox.copyToScriptValue(_desiredProperties, properties, engine, skipDefaults, defaultEntityProperties); - _haze.copyToScriptValue(_desiredProperties, properties, engine, skipDefaults, defaultEntityProperties); - _stage.copyToScriptValue(_desiredProperties, properties, engine, skipDefaults, defaultEntityProperties); COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_FLYING_ALLOWED, flyingAllowed); COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_GHOSTING_ALLOWED, ghostingAllowed); COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_FILTER_URL, filterURL); + + COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_MODE, hazeMode); + _haze.copyToScriptValue(_desiredProperties, properties, engine, skipDefaults, defaultEntityProperties); } // Web only @@ -761,19 +752,6 @@ void EntityItemProperties::copyFromScriptValue(const QScriptValue& object, bool COPY_PROPERTY_FROM_QSCRITPTVALUE_ENUM(hazeMode, HazeMode); - COPY_PROPERTY_FROM_QSCRIPTVALUE(hazeRange, float, setHazeRange); - COPY_PROPERTY_FROM_QSCRIPTVALUE(hazeBlendInColor, xColor, setHazeBlendInColor); - COPY_PROPERTY_FROM_QSCRIPTVALUE(hazeBlendOutColor, xColor, setHazeBlendOutColor); - COPY_PROPERTY_FROM_QSCRIPTVALUE(hazeLightBlendAngle, float, setHazeLightBlendAngle); - - COPY_PROPERTY_FROM_QSCRIPTVALUE(hazeAltitude, float, setHazeAltitude); - COPY_PROPERTY_FROM_QSCRIPTVALUE(hazeBaseRef, float, setHazeBaseRef); - - COPY_PROPERTY_FROM_QSCRIPTVALUE(hazeBackgroundBlend, float, setHazeBackgroundBlend); - - COPY_PROPERTY_FROM_QSCRIPTVALUE(hazeKeyLightRange, float, setHazeKeyLightRange); - COPY_PROPERTY_FROM_QSCRIPTVALUE(hazeKeyLightAltitude, float, setHazeKeyLightAltitude); - COPY_PROPERTY_FROM_QSCRIPTVALUE(sourceUrl, QString, setSourceUrl); COPY_PROPERTY_FROM_QSCRIPTVALUE(voxelVolumeSize, glmVec3, setVoxelVolumeSize); COPY_PROPERTY_FROM_QSCRIPTVALUE(voxelData, QByteArray, setVoxelData); @@ -800,8 +778,8 @@ void EntityItemProperties::copyFromScriptValue(const QScriptValue& object, bool _animation.copyFromScriptValue(object, _defaultSettings); _keyLight.copyFromScriptValue(object, _defaultSettings); _skybox.copyFromScriptValue(object, _defaultSettings); - _haze.copyFromScriptValue(object, _defaultSettings); _stage.copyFromScriptValue(object, _defaultSettings); + _haze.copyFromScriptValue(object, _defaultSettings); COPY_PROPERTY_FROM_QSCRIPTVALUE(xTextureURL, QString, setXTextureURL); COPY_PROPERTY_FROM_QSCRIPTVALUE(yTextureURL, QString, setYTextureURL); @@ -928,19 +906,6 @@ void EntityItemProperties::merge(const EntityItemProperties& other) { COPY_PROPERTY_IF_CHANGED(hazeMode); - COPY_PROPERTY_IF_CHANGED(hazeRange); - COPY_PROPERTY_IF_CHANGED(hazeBlendInColor); - COPY_PROPERTY_IF_CHANGED(hazeBlendOutColor); - COPY_PROPERTY_IF_CHANGED(hazeLightBlendAngle); - - COPY_PROPERTY_IF_CHANGED(hazeAltitude); - COPY_PROPERTY_IF_CHANGED(hazeBaseRef); - - COPY_PROPERTY_IF_CHANGED(hazeBackgroundBlend); - - COPY_PROPERTY_IF_CHANGED(hazeKeyLightRange); - COPY_PROPERTY_IF_CHANGED(hazeKeyLightAltitude); - COPY_PROPERTY_IF_CHANGED(sourceUrl); COPY_PROPERTY_IF_CHANGED(voxelVolumeSize); COPY_PROPERTY_IF_CHANGED(voxelData); @@ -958,8 +923,8 @@ void EntityItemProperties::merge(const EntityItemProperties& other) { _animation.merge(other._animation); _keyLight.merge(other._keyLight); _skybox.merge(other._skybox); - _haze.merge(other._haze); _stage.merge(other._stage); + _haze.merge(other._haze); COPY_PROPERTY_IF_CHANGED(xTextureURL); COPY_PROPERTY_IF_CHANGED(yTextureURL); @@ -1446,7 +1411,6 @@ bool EntityItemProperties::encodeEntityEditPacket(PacketType command, EntityItem APPEND_ENTITY_PROPERTY(PROP_COMPOUND_SHAPE_URL, properties.getCompoundShapeURL()); APPEND_ENTITY_PROPERTY(PROP_BACKGROUND_MODE, (uint32_t)properties.getBackgroundMode()); - APPEND_ENTITY_PROPERTY(PROP_HAZE_MODE, (uint32_t)properties.getHazeMode()); _staticSkybox.setProperties(properties); _staticSkybox.appendToEditPacket(packetData, requestedProperties, propertyFlags, propertiesDidntFit, propertyCount, appendState); @@ -1455,6 +1419,7 @@ bool EntityItemProperties::encodeEntityEditPacket(PacketType command, EntityItem APPEND_ENTITY_PROPERTY(PROP_GHOSTING_ALLOWED, properties.getGhostingAllowed()); APPEND_ENTITY_PROPERTY(PROP_FILTER_URL, properties.getFilterURL()); + APPEND_ENTITY_PROPERTY(PROP_HAZE_MODE, (uint32_t)properties.getHazeMode()); _staticHaze.setProperties(properties); _staticHaze.appendToEditPacket(packetData, requestedProperties, propertyFlags, propertiesDidntFit, propertyCount, appendState); } @@ -1759,13 +1724,15 @@ bool EntityItemProperties::decodeEntityEditPacket(const unsigned char* data, int READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_COMPOUND_SHAPE_URL, QString, setCompoundShapeURL); READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_BACKGROUND_MODE, BackgroundMode, setBackgroundMode); - properties.getHaze().decodeFromEditPacket(propertyFlags, dataAt, processedBytes); properties.getSkybox().decodeFromEditPacket(propertyFlags, dataAt, processedBytes); READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_FLYING_ALLOWED, bool, setFlyingAllowed); READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_GHOSTING_ALLOWED, bool, setGhostingAllowed); READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_FILTER_URL, QString, setFilterURL); - } + + READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_HAZE_MODE, uint8_t, setHazeMode); + properties.getHaze().decodeFromEditPacket(propertyFlags, dataAt, processedBytes); + } if (properties.getType() == EntityTypes::PolyVox) { READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_VOXEL_VOLUME_SIZE, glm::vec3, setVoxelVolumeSize); @@ -1948,8 +1915,8 @@ void EntityItemProperties::markAllChanged() { _animation.markAllChanged(); _skybox.markAllChanged(); - _haze.markAllChanged(); _stage.markAllChanged(); + _haze.markAllChanged(); _sourceUrlChanged = true; _voxelVolumeSizeChanged = true; @@ -2289,37 +2256,6 @@ QList EntityItemProperties::listChangedProperties() { out += "hazeMode"; } - if (hazeRangeChanged()) { - out += "hazeRange"; - } - if (hazeBlendInColorChanged()) { - out += "hazeBlendInColor"; - } - if (hazeBlendOutColorChanged()) { - out += "hazeBlendOutColor"; - } - if (hazeLightBlendAngleChanged()) { - out += "hazehazeLightBlendAngle"; - } - - if (hazeAltitudeChanged()) { - out += "hazeAltitude"; - } - if (hazeBaseRefChanged()) { - out += "hazeBaseRef"; - } - - if (hazeBackgroundBlendChanged()) { - out += "hazeBackgroundBlend"; - } - - if (hazeKeyLightRangeChanged()) { - out += "hazeKeyLightRange"; - } - if (hazeKeyLightAltitudeChanged()) { - out += "hazeKeyLightAltitude"; - } - if (voxelVolumeSizeChanged()) { out += "voxelVolumeSize"; } @@ -2414,8 +2350,8 @@ QList EntityItemProperties::listChangedProperties() { getAnimation().listChangedProperties(out); getKeyLight().listChangedProperties(out); getSkybox().listChangedProperties(out); - getHaze().listChangedProperties(out); getStage().listChangedProperties(out); + getHaze().listChangedProperties(out); return out; } diff --git a/libraries/entities/src/HazePropertyGroup.cpp b/libraries/entities/src/HazePropertyGroup.cpp index 9c6fe34fb1..93da9913a8 100644 --- a/libraries/entities/src/HazePropertyGroup.cpp +++ b/libraries/entities/src/HazePropertyGroup.cpp @@ -44,18 +44,18 @@ void HazePropertyGroup::copyToScriptValue(const EntityPropertyFlags& desiredProp } void HazePropertyGroup::copyFromScriptValue(const QScriptValue& object, bool& _defaultSettings) { - COPY_PROPERTY_FROM_QSCRIPTVALUE_GETTER(hazeHazeRange, float, setHazeRange, getHazeRange); + COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(haze, hazeRange, float, setHazeRange); COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(haze, hazeBlendInColor, xColor, setHazeBlendInColor); COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(haze, hazeBlendOutColor, xColor, setHazeBlendOutColor); - COPY_PROPERTY_FROM_QSCRIPTVALUE_GETTER(hazeHazeLightBlendAngle, float, setHazeLightBlendAngle, getHazeLightBlendAngle); + COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(haze, hazeLightBlendAngle, float, setHazeLightBlendAngle); - COPY_PROPERTY_FROM_QSCRIPTVALUE_GETTER(hazeHazeAltitude, float, setHazeAltitude, getHazeAltitude); - COPY_PROPERTY_FROM_QSCRIPTVALUE_GETTER(hazeHazeBaseRef, float, setHazeBaseRef, getHazeBaseRef); + COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(haze, hazeAltitude, float, setHazeAltitude); + COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(haze, hazeBaseRef, float, setHazeBaseRef); - COPY_PROPERTY_FROM_QSCRIPTVALUE_GETTER(hazeHazeBackgroundBlend, float, setHazeBackgroundBlend, getHazeBackgroundBlend); + COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(haze, hazeBackgroundBlend, float, setHazeBackgroundBlend); - COPY_PROPERTY_FROM_QSCRIPTVALUE_GETTER(hazeHazeKeyLightRange, float, setHazeKeyLightRange, getHazeKeyLightRange); - COPY_PROPERTY_FROM_QSCRIPTVALUE_GETTER(hazeHazeKeyLightAltitude, float, setHazeKeyLightAltitude, getHazeKeyLightAltitude); + COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(haze, hazeKeyLightRange, float, setHazeKeyLightRange); + COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(haze, hazeKeyLightAltitude, float, setHazeKeyLightAltitude); } void HazePropertyGroup::merge(const HazePropertyGroup& other) { @@ -92,34 +92,34 @@ void HazePropertyGroup::debugDump() const { void HazePropertyGroup::listChangedProperties(QList& out) { if (hazeRangeChanged()) { - out << "haze-range"; + out << "haze-hazeRange"; } if (hazeBlendInColorChanged()) { - out << "haze-blendInColor"; + out << "haze-hazeBlendInColor"; } if (hazeBlendOutColorChanged()) { - out << "haze-blendOutColor"; + out << "haze-hazeBlendOutColor"; } if (hazeLightBlendAngleChanged()) { - out << "haze-lightBlendAngle"; + out << "haze-hazeLightBlendAngle"; } if (hazeAltitudeChanged()) { - out << "haze-altitude"; + out << "haze-hazeAltitude"; } if (hazeBaseRefChanged()) { - out << "haze-baseRef"; + out << "haze-hazeBaseRef"; } if (hazeBackgroundBlendChanged()) { - out << "haze-backgroundBlend"; + out << "haze-hazeBackgroundBlend"; } if (hazeKeyLightRangeChanged()) { - out << "haze-keyLightRange"; + out << "haze-hazeKeyLightRange"; } if (hazeKeyLightAltitudeChanged()) { - out << "haze-keyLightAltitude"; + out << "haze-hazeKeyLightAltitude"; } } diff --git a/libraries/entities/src/ZoneEntityItem.cpp b/libraries/entities/src/ZoneEntityItem.cpp index f6350699e7..723f4103eb 100644 --- a/libraries/entities/src/ZoneEntityItem.cpp +++ b/libraries/entities/src/ZoneEntityItem.cpp @@ -120,19 +120,7 @@ bool ZoneEntityItem::setSubClassProperties(const EntityItemProperties& propertie SET_ENTITY_PROPERTY_FROM_PROPERTIES(filterURL, setFilterURL); SET_ENTITY_PROPERTY_FROM_PROPERTIES(hazeMode, setHazeMode); - - SET_ENTITY_PROPERTY_FROM_PROPERTIES(hazeRange, setHazeRange); - SET_ENTITY_PROPERTY_FROM_PROPERTIES(hazeBlendInColor, setHazeBlendInColor); - SET_ENTITY_PROPERTY_FROM_PROPERTIES(hazeBlendInColor, setHazeBlendInColor); - SET_ENTITY_PROPERTY_FROM_PROPERTIES(hazeLightBlendAngle, setHazeLightBlendAngle); - - SET_ENTITY_PROPERTY_FROM_PROPERTIES(hazeAltitude, setHazeAltitude); - SET_ENTITY_PROPERTY_FROM_PROPERTIES(hazeBaseRef, setHazeBaseRef); - - SET_ENTITY_PROPERTY_FROM_PROPERTIES(hazeBackgroundBlend, setHazeBackgroundBlend); - - SET_ENTITY_PROPERTY_FROM_PROPERTIES(hazeKeyLightRange, setHazeKeyLightRange); - SET_ENTITY_PROPERTY_FROM_PROPERTIES(hazeKeyLightAltitude, setHazeKeyLightAltitude); + _hazePropertiesChanged = _hazeProperties.setProperties(properties); somethingChanged = somethingChanged || _keyLightPropertiesChanged || _stagePropertiesChanged || _skyboxPropertiesChanged || _hazePropertiesChanged; @@ -181,11 +169,9 @@ int ZoneEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data, READ_ENTITY_PROPERTY(PROP_HAZE_MODE, uint8_t, setHazeMode); - int bytesFromHaze; - withWriteLock([&] { - bytesFromHaze = _hazeProperties.readEntitySubclassDataFromBuffer(dataAt, (bytesLeftToRead - bytesRead), args, - propertyFlags, overwriteLocalData, _hazePropertiesChanged); - }); + int bytesFromHaze = _hazeProperties.readEntitySubclassDataFromBuffer(dataAt, (bytesLeftToRead - bytesRead), args, + propertyFlags, overwriteLocalData, _hazePropertiesChanged); + somethingChanged = somethingChanged || _hazePropertiesChanged; bytesRead += bytesFromHaze; dataAt += bytesFromHaze; @@ -215,9 +201,7 @@ EntityPropertyFlags ZoneEntityItem::getEntityProperties(EncodeBitstreamParams& p requestedProperties += PROP_FILTER_URL; requestedProperties += PROP_HAZE_MODE; - withReadLock([&] { - requestedProperties += _hazeProperties.getEntityProperties(params); - }); + requestedProperties += _hazeProperties.getEntityProperties(params); return requestedProperties; } From 2ce86ebfae99b75d9579b23c22b5878350bdf686 Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Wed, 4 Oct 2017 11:56:35 -0700 Subject: [PATCH 45/94] WIP - working on byte order in server messages. --- .../src/RenderableZoneEntityItem.cpp | 4 +- .../src/RenderableZoneEntityItem.h | 4 +- .../entities/src/EntityItemProperties.cpp | 37 +++++++++---------- libraries/entities/src/EntityItemProperties.h | 2 +- libraries/entities/src/ZoneEntityItem.cpp | 15 +++----- libraries/entities/src/ZoneEntityItem.h | 1 + libraries/gl/src/gl/GLShaders.cpp | 25 ++++++------- libraries/octree/src/OctreePacketData.h | 1 - .../src/SceneScriptingInterface.cpp | 3 +- 9 files changed, 43 insertions(+), 49 deletions(-) diff --git a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp index 21a9f677ce..ddc5b409eb 100644 --- a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp @@ -141,6 +141,8 @@ void ZoneEntityRenderer::doRender(RenderArgs* args) { if (_needBackgroundUpdate) { if (BackgroundStage::isIndexInvalid(_backgroundIndex)) { _backgroundIndex = _backgroundStage->addBackground(_background); + } else { + } _needBackgroundUpdate = false; } @@ -170,7 +172,7 @@ void ZoneEntityRenderer::doRender(RenderArgs* args) { _backgroundStage->_currentFrame.pushBackground(_backgroundIndex); } - // The haze only if the mode is not inherit + // Haze only if the mode is not inherit if (_hazeMode != HAZE_MODE_INHERIT) { _hazeStage->_currentFrame.pushHaze(_hazeIndex); } diff --git a/libraries/entities-renderer/src/RenderableZoneEntityItem.h b/libraries/entities-renderer/src/RenderableZoneEntityItem.h index 26403a2483..d8c451d2a1 100644 --- a/libraries/entities-renderer/src/RenderableZoneEntityItem.h +++ b/libraries/entities-renderer/src/RenderableZoneEntityItem.h @@ -21,6 +21,8 @@ #include #include #include "RenderableEntityItem.h" +#include + #if 0 #include #endif @@ -101,9 +103,9 @@ private: bool _needHazeUpdate{ true }; KeyLightPropertyGroup _keyLightProperties; - SkyboxPropertyGroup _skyboxProperties; HazePropertyGroup _hazeProperties; StagePropertyGroup _stageProperties; + SkyboxPropertyGroup _skyboxProperties; // More attributes used for rendering: QString _ambientTextureURL; diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp index d0b0fbb944..c9ad530ca7 100644 --- a/libraries/entities/src/EntityItemProperties.cpp +++ b/libraries/entities/src/EntityItemProperties.cpp @@ -552,19 +552,17 @@ QScriptValue EntityItemProperties::copyToScriptValue(QScriptEngine* engine, bool // Zones only if (_type == EntityTypes::Zone) { _keyLight.copyToScriptValue(_desiredProperties, properties, engine, skipDefaults, defaultEntityProperties); + + COPY_PROPERTY_TO_QSCRIPTVALUE_GETTER(PROP_BACKGROUND_MODE, backgroundMode, getBackgroundModeAsString()); + _stage.copyToScriptValue(_desiredProperties, properties, engine, skipDefaults, defaultEntityProperties); - - COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_SHAPE_TYPE, shapeType); - COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_COMPOUND_SHAPE_URL, compoundShapeURL); - COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_BACKGROUND_MODE, backgroundMode, backgroundMode); - _skybox.copyToScriptValue(_desiredProperties, properties, engine, skipDefaults, defaultEntityProperties); COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_FLYING_ALLOWED, flyingAllowed); COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_GHOSTING_ALLOWED, ghostingAllowed); COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_FILTER_URL, filterURL); - COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_MODE, hazeMode); + COPY_PROPERTY_TO_QSCRIPTVALUE_GETTER(PROP_HAZE_MODE, hazeMode, getHazeModeAsString()); _haze.copyToScriptValue(_desiredProperties, properties, engine, skipDefaults, defaultEntityProperties); } @@ -1143,6 +1141,18 @@ void EntityItemProperties::entityPropertyFlagsFromScriptValue(const QScriptValue ADD_GROUP_PROPERTY_TO_MAP(PROP_SKYBOX_COLOR, Skybox, skybox, Color, color); ADD_GROUP_PROPERTY_TO_MAP(PROP_SKYBOX_URL, Skybox, skybox, URL, url); + ADD_GROUP_PROPERTY_TO_MAP(PROP_STAGE_SUN_MODEL_ENABLED, Stage, stage, SunModelEnabled, sunModelEnabled); + ADD_GROUP_PROPERTY_TO_MAP(PROP_STAGE_LATITUDE, Stage, stage, Latitude, latitude); + ADD_GROUP_PROPERTY_TO_MAP(PROP_STAGE_LONGITUDE, Stage, stage, Longitude, longitude); + ADD_GROUP_PROPERTY_TO_MAP(PROP_STAGE_ALTITUDE, Stage, stage, Altitude, altitude); + ADD_GROUP_PROPERTY_TO_MAP(PROP_STAGE_DAY, Stage, stage, Day, day); + ADD_GROUP_PROPERTY_TO_MAP(PROP_STAGE_HOUR, Stage, stage, Hour, hour); + ADD_GROUP_PROPERTY_TO_MAP(PROP_STAGE_AUTOMATIC_HOURDAY, Stage, stage, AutomaticHourDay, automaticHourDay); + + ADD_PROPERTY_TO_MAP(PROP_FLYING_ALLOWED, FlyingAllowed, flyingAllowed, bool); + ADD_PROPERTY_TO_MAP(PROP_GHOSTING_ALLOWED, GhostingAllowed, ghostingAllowed, bool); + ADD_PROPERTY_TO_MAP(PROP_FILTER_URL, FilterURL, filterURL, QString); + ADD_PROPERTY_TO_MAP(PROP_HAZE_MODE, HazeMode, hazeMode, uint8_t); ADD_PROPERTY_TO_MAP(PROP_HAZE_ALTITUDE, HazeRange, hazeRange, float); @@ -1158,18 +1168,6 @@ void EntityItemProperties::entityPropertyFlagsFromScriptValue(const QScriptValue ADD_PROPERTY_TO_MAP(PROP_HAZE_KEYLIGHT_RANGE, HazeKeyLightRange, hazeKeyLightRange, float); ADD_PROPERTY_TO_MAP(PROP_HAZE_KEYLIGHT_ALTITUDE, HazeKeyLightAltitude, hazeKeyLightAltitude, float); - ADD_GROUP_PROPERTY_TO_MAP(PROP_STAGE_SUN_MODEL_ENABLED, Stage, stage, SunModelEnabled, sunModelEnabled); - ADD_GROUP_PROPERTY_TO_MAP(PROP_STAGE_LATITUDE, Stage, stage, Latitude, latitude); - ADD_GROUP_PROPERTY_TO_MAP(PROP_STAGE_LONGITUDE, Stage, stage, Longitude, longitude); - ADD_GROUP_PROPERTY_TO_MAP(PROP_STAGE_ALTITUDE, Stage, stage, Altitude, altitude); - ADD_GROUP_PROPERTY_TO_MAP(PROP_STAGE_DAY, Stage, stage, Day, day); - ADD_GROUP_PROPERTY_TO_MAP(PROP_STAGE_HOUR, Stage, stage, Hour, hour); - ADD_GROUP_PROPERTY_TO_MAP(PROP_STAGE_AUTOMATIC_HOURDAY, Stage, stage, AutomaticHourDay, automaticHourDay); - - ADD_PROPERTY_TO_MAP(PROP_FLYING_ALLOWED, FlyingAllowed, flyingAllowed, bool); - ADD_PROPERTY_TO_MAP(PROP_GHOSTING_ALLOWED, GhostingAllowed, ghostingAllowed, bool); - ADD_PROPERTY_TO_MAP(PROP_FILTER_URL, FilterURL, filterURL, QString); - ADD_PROPERTY_TO_MAP(PROP_DPI, DPI, dpi, uint16_t); // FIXME - these are not yet handled @@ -1723,8 +1721,7 @@ bool EntityItemProperties::decodeEntityEditPacket(const unsigned char* data, int READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_SHAPE_TYPE, ShapeType, setShapeType); READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_COMPOUND_SHAPE_URL, QString, setCompoundShapeURL); READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_BACKGROUND_MODE, BackgroundMode, setBackgroundMode); - - properties.getSkybox().decodeFromEditPacket(propertyFlags, dataAt, processedBytes); + properties.getSkybox().decodeFromEditPacket(propertyFlags, dataAt , processedBytes); READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_FLYING_ALLOWED, bool, setFlyingAllowed); READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_GHOSTING_ALLOWED, bool, setGhostingAllowed); diff --git a/libraries/entities/src/EntityItemProperties.h b/libraries/entities/src/EntityItemProperties.h index ae3010d46a..6f6b6cc13a 100644 --- a/libraries/entities/src/EntityItemProperties.h +++ b/libraries/entities/src/EntityItemProperties.h @@ -177,6 +177,7 @@ public: DEFINE_PROPERTY_REF(PROP_VOXEL_SURFACE_STYLE, VoxelSurfaceStyle, voxelSurfaceStyle, uint16_t, PolyVoxEntityItem::DEFAULT_VOXEL_SURFACE_STYLE); DEFINE_PROPERTY_REF(PROP_NAME, Name, name, QString, ENTITY_ITEM_DEFAULT_NAME); DEFINE_PROPERTY_REF_ENUM(PROP_BACKGROUND_MODE, BackgroundMode, backgroundMode, BackgroundMode, BACKGROUND_MODE_INHERIT); + DEFINE_PROPERTY_GROUP(Stage, stage, StagePropertyGroup); DEFINE_PROPERTY_REF_ENUM(PROP_HAZE_MODE, HazeMode, hazeMode, uint8_t, (uint8_t)HAZE_MODE_INHERIT); @@ -196,7 +197,6 @@ public: DEFINE_PROPERTY_GROUP(Skybox, skybox, SkyboxPropertyGroup); DEFINE_PROPERTY_GROUP(Haze, haze, HazePropertyGroup); - DEFINE_PROPERTY_GROUP(Stage, stage, StagePropertyGroup); DEFINE_PROPERTY_GROUP(Animation, animation, AnimationPropertyGroup); DEFINE_PROPERTY_REF(PROP_SOURCE_URL, SourceUrl, sourceUrl, QString, ""); DEFINE_PROPERTY(PROP_LINE_WIDTH, LineWidth, lineWidth, float, LineEntityItem::DEFAULT_LINE_WIDTH); diff --git a/libraries/entities/src/ZoneEntityItem.cpp b/libraries/entities/src/ZoneEntityItem.cpp index 723f4103eb..5a2f5bd765 100644 --- a/libraries/entities/src/ZoneEntityItem.cpp +++ b/libraries/entities/src/ZoneEntityItem.cpp @@ -70,10 +70,7 @@ EntityItemProperties ZoneEntityItem::getProperties(EntityPropertyFlags desiredPr COPY_ENTITY_PROPERTY_TO_PROPERTIES(filterURL, getFilterURL); COPY_ENTITY_PROPERTY_TO_PROPERTIES(hazeMode, getHazeMode); - // Contains a QString property, must be synchronized - withReadLock([&] { - _hazeProperties.getProperties(properties); - }); + _hazeProperties.getProperties(properties); return properties; } @@ -110,15 +107,15 @@ bool ZoneEntityItem::setSubClassProperties(const EntityItemProperties& propertie SET_ENTITY_PROPERTY_FROM_PROPERTIES(compoundShapeURL, setCompoundShapeURL); SET_ENTITY_PROPERTY_FROM_PROPERTIES(backgroundMode, setBackgroundMode); - // Contains a QString property, must be synchronized - withWriteLock([&] { - _skyboxPropertiesChanged = _skyboxProperties.setProperties(properties); - }); - SET_ENTITY_PROPERTY_FROM_PROPERTIES(flyingAllowed, setFlyingAllowed); SET_ENTITY_PROPERTY_FROM_PROPERTIES(ghostingAllowed, setGhostingAllowed); SET_ENTITY_PROPERTY_FROM_PROPERTIES(filterURL, setFilterURL); + // Contains a QString property, must be synchronized + withWriteLock([&] { + _skyboxPropertiesChanged = _skyboxProperties.setProperties(properties); + }); + SET_ENTITY_PROPERTY_FROM_PROPERTIES(hazeMode, setHazeMode); _hazePropertiesChanged = _hazeProperties.setProperties(properties); diff --git a/libraries/entities/src/ZoneEntityItem.h b/libraries/entities/src/ZoneEntityItem.h index 0bf7e63afd..cb1d065843 100644 --- a/libraries/entities/src/ZoneEntityItem.h +++ b/libraries/entities/src/ZoneEntityItem.h @@ -18,6 +18,7 @@ #include "SkyboxPropertyGroup.h" #include "HazePropertyGroup.h" #include "StagePropertyGroup.h" +#include class ZoneEntityItem : public EntityItem { public: diff --git a/libraries/gl/src/gl/GLShaders.cpp b/libraries/gl/src/gl/GLShaders.cpp index a05b923fb3..8ef0198676 100644 --- a/libraries/gl/src/gl/GLShaders.cpp +++ b/libraries/gl/src/gl/GLShaders.cpp @@ -2,9 +2,6 @@ #include "GLLogging.h" -#include -#include - namespace gl { @@ -41,15 +38,15 @@ namespace gl { if (!compiled) { // save the source code to a temp file so we can debug easily - + /* std::ofstream filestream; - filestream.open("D:\\debugshader.glsl"); + filestream.open("debugshader.glsl"); if (filestream.is_open()) { - filestream << srcstr[0]; - filestream << srcstr[1]; - filestream.close(); + filestream << srcstr[0]; + filestream << srcstr[1]; + filestream.close(); } - + */ GLint infoLength = 0; glGetShaderiv(glshader, GL_INFO_LOG_LENGTH, &infoLength); @@ -58,13 +55,13 @@ namespace gl { glGetShaderInfoLog(glshader, infoLength, NULL, temp); - - filestream.open("D:\\debugshader.glsl.info.txt"); + /* + filestream.open("debugshader.glsl.info.txt"); if (filestream.is_open()) { - filestream << std::string(temp); - filestream.close(); + filestream << std::string(temp); + filestream.close(); } - + */ qCWarning(glLogging) << "GLShader::compileShader - failed to compile the gl shader object:"; for (auto s : srcstr) { diff --git a/libraries/octree/src/OctreePacketData.h b/libraries/octree/src/OctreePacketData.h index d0255d60ab..ed6a49941b 100644 --- a/libraries/octree/src/OctreePacketData.h +++ b/libraries/octree/src/OctreePacketData.h @@ -29,7 +29,6 @@ #include #include -#include #include #include #include diff --git a/libraries/script-engine/src/SceneScriptingInterface.cpp b/libraries/script-engine/src/SceneScriptingInterface.cpp index 7f788f11e3..096cd58ab6 100644 --- a/libraries/script-engine/src/SceneScriptingInterface.cpp +++ b/libraries/script-engine/src/SceneScriptingInterface.cpp @@ -113,8 +113,7 @@ bool SceneScripting::Stage::isSunModelEnabled() const { void SceneScripting::Stage::setBackgroundMode(const QString& mode) { if (mode == QString("inherit")) { _skyStage->setBackgroundMode(model::SunSkyStage::NO_BACKGROUND); - } - else if (mode == QString("skybox")) { + } else if (mode == QString("skybox")) { _skyStage->setBackgroundMode(model::SunSkyStage::SKY_BOX); } } From 62cfaaaf380b6a5dc1d256a6f2f764be07decf33 Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Wed, 4 Oct 2017 12:56:14 -0700 Subject: [PATCH 46/94] Sam's corrections. --- .../entities/src/EntityItemProperties.cpp | 18 +++++++++--------- libraries/entities/src/EntityItemProperties.h | 14 -------------- libraries/entities/src/ZoneEntityItem.cpp | 12 +++++++----- 3 files changed, 16 insertions(+), 28 deletions(-) diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp index c9ad530ca7..9338bfd773 100644 --- a/libraries/entities/src/EntityItemProperties.cpp +++ b/libraries/entities/src/EntityItemProperties.cpp @@ -1155,18 +1155,18 @@ void EntityItemProperties::entityPropertyFlagsFromScriptValue(const QScriptValue ADD_PROPERTY_TO_MAP(PROP_HAZE_MODE, HazeMode, hazeMode, uint8_t); - ADD_PROPERTY_TO_MAP(PROP_HAZE_ALTITUDE, HazeRange, hazeRange, float); - ADD_PROPERTY_TO_MAP(PROP_HAZE_BLEND_IN_COLOR, HazeBlendInColor, hazeBlendInColor, xColor); - ADD_PROPERTY_TO_MAP(PROP_HAZE_BLEND_OUT_COLOR, HazeBlendOutColor, hazeBlendOutColor, xColor); - ADD_PROPERTY_TO_MAP(PROP_HAZE_LIGHT_BLEND_ANGLE, HazeLightBlendAngle, hazeLightBlendAngle, float); + ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_ALTITUDE, Haze, haze, HazeRange, hazeRange); + ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_BLEND_IN_COLOR, Haze, haze, HazeBlendInColor, hazeBlendInColor); + ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_BLEND_OUT_COLOR, Haze, haze, HazeBlendOutColor, hazeBlendOutColor); + ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_LIGHT_BLEND_ANGLE, Haze, haze, HazeLightBlendAngle, hazeLightBlendAngle); - ADD_PROPERTY_TO_MAP(PROP_HAZE_ALTITUDE, HazeAltitude, hazeAltitude, float); - ADD_PROPERTY_TO_MAP(PROP_HAZE_BASE_REF, HazeBaseRef, hazeBaseRef, float); + ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_ALTITUDE, Haze, haze, HazeAltitude, hazeAltitude); + ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_BASE_REF, Haze, haze, HazeBaseRef, hazeBaseRef); - ADD_PROPERTY_TO_MAP(PROP_HAZE_BACKGROUND_BLEND, HazeBackgroundBlend, hazeBackgroundBlend, float); + ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_BACKGROUND_BLEND, Haze, haze, HazeBackgroundBlend, hazeBackgroundBlend); - ADD_PROPERTY_TO_MAP(PROP_HAZE_KEYLIGHT_RANGE, HazeKeyLightRange, hazeKeyLightRange, float); - ADD_PROPERTY_TO_MAP(PROP_HAZE_KEYLIGHT_ALTITUDE, HazeKeyLightAltitude, hazeKeyLightAltitude, float); + ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_KEYLIGHT_RANGE, Haze, haze, HazeKeyLightRange, hazeKeyLightRange); + ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_KEYLIGHT_ALTITUDE, Haze, haze, HazeKeyLightAltitude, hazeKeyLightAltitude); ADD_PROPERTY_TO_MAP(PROP_DPI, DPI, dpi, uint16_t); diff --git a/libraries/entities/src/EntityItemProperties.h b/libraries/entities/src/EntityItemProperties.h index 6f6b6cc13a..6909ffd264 100644 --- a/libraries/entities/src/EntityItemProperties.h +++ b/libraries/entities/src/EntityItemProperties.h @@ -181,20 +181,6 @@ public: DEFINE_PROPERTY_REF_ENUM(PROP_HAZE_MODE, HazeMode, hazeMode, uint8_t, (uint8_t)HAZE_MODE_INHERIT); - DEFINE_PROPERTY(PROP_HAZE_RANGE, HazeRange, hazeRange, float, HazePropertyGroup::DEFAULT_HAZE_RANGE); - DEFINE_PROPERTY(PROP_HAZE_BLEND_IN_COLOR, HazeBlendInColor, hazeBlendInColor, xColor, HazePropertyGroup::DEFAULT_HAZE_BLEND_IN_COLOR); - DEFINE_PROPERTY(PROP_HAZE_BLEND_OUT_COLOR, HazeBlendOutColor, hazeBlendOutColor, xColor, HazePropertyGroup::DEFAULT_HAZE_BLEND_OUT_COLOR); - DEFINE_PROPERTY(PROP_HAZE_LIGHT_BLEND_ANGLE, HazeLightBlendAngle, hazeLightBlendAngle, float, HazePropertyGroup::DEFAULT_HAZE_ALTITUDE); - - DEFINE_PROPERTY(PROP_HAZE_ALTITUDE, HazeAltitude, hazeAltitude, float, HazePropertyGroup::DEFAULT_HAZE_ALTITUDE); - DEFINE_PROPERTY(PROP_HAZE_BASE_REF, HazeBaseRef, hazeBaseRef, float, HazePropertyGroup::DEFAULT_HAZE_ALTITUDE); - - DEFINE_PROPERTY(PROP_HAZE_BACKGROUND_BLEND, HazeBackgroundBlend, hazeBackgroundBlend, float, HazePropertyGroup::DEFAULT_HAZE_ALTITUDE); - - DEFINE_PROPERTY(PROP_HAZE_KEYLIGHT_RANGE, HazeKeyLightRange, hazeKeyLightRange, float, HazePropertyGroup::DEFAULT_HAZE_RANGE); - DEFINE_PROPERTY(PROP_HAZE_KEYLIGHT_ALTITUDE, HazeKeyLightAltitude, hazeKeyLightAltitude, float, HazePropertyGroup::DEFAULT_HAZE_ALTITUDE); - - DEFINE_PROPERTY_GROUP(Skybox, skybox, SkyboxPropertyGroup); DEFINE_PROPERTY_GROUP(Haze, haze, HazePropertyGroup); DEFINE_PROPERTY_GROUP(Animation, animation, AnimationPropertyGroup); diff --git a/libraries/entities/src/ZoneEntityItem.cpp b/libraries/entities/src/ZoneEntityItem.cpp index 5a2f5bd765..5b95b1ffce 100644 --- a/libraries/entities/src/ZoneEntityItem.cpp +++ b/libraries/entities/src/ZoneEntityItem.cpp @@ -107,14 +107,14 @@ bool ZoneEntityItem::setSubClassProperties(const EntityItemProperties& propertie SET_ENTITY_PROPERTY_FROM_PROPERTIES(compoundShapeURL, setCompoundShapeURL); SET_ENTITY_PROPERTY_FROM_PROPERTIES(backgroundMode, setBackgroundMode); - SET_ENTITY_PROPERTY_FROM_PROPERTIES(flyingAllowed, setFlyingAllowed); - SET_ENTITY_PROPERTY_FROM_PROPERTIES(ghostingAllowed, setGhostingAllowed); - SET_ENTITY_PROPERTY_FROM_PROPERTIES(filterURL, setFilterURL); - // Contains a QString property, must be synchronized withWriteLock([&] { _skyboxPropertiesChanged = _skyboxProperties.setProperties(properties); }); + + SET_ENTITY_PROPERTY_FROM_PROPERTIES(flyingAllowed, setFlyingAllowed); + SET_ENTITY_PROPERTY_FROM_PROPERTIES(ghostingAllowed, setGhostingAllowed); + SET_ENTITY_PROPERTY_FROM_PROPERTIES(filterURL, setFilterURL); SET_ENTITY_PROPERTY_FROM_PROPERTIES(hazeMode, setHazeMode); _hazePropertiesChanged = _hazeProperties.setProperties(properties); @@ -185,14 +185,16 @@ EntityPropertyFlags ZoneEntityItem::getEntityProperties(EncodeBitstreamParams& p requestedProperties += _keyLightProperties.getEntityProperties(params); }); + requestedProperties += _stageProperties.getEntityProperties(params); + requestedProperties += PROP_SHAPE_TYPE; requestedProperties += PROP_COMPOUND_SHAPE_URL; requestedProperties += PROP_BACKGROUND_MODE; - requestedProperties += _stageProperties.getEntityProperties(params); withReadLock([&] { requestedProperties += _skyboxProperties.getEntityProperties(params); }); + requestedProperties += PROP_FLYING_ALLOWED; requestedProperties += PROP_GHOSTING_ALLOWED; requestedProperties += PROP_FILTER_URL; From eef778a46394cf7b88b302b8da02fe5b7b1178b4 Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Wed, 4 Oct 2017 13:47:13 -0700 Subject: [PATCH 47/94] Replaced uint8_t with uint32_t in server packet. --- libraries/entities/src/EntityItemProperties.cpp | 6 +++--- libraries/entities/src/EntityItemProperties.h | 4 ++-- libraries/entities/src/ZoneEntityItem.cpp | 6 +++--- libraries/entities/src/ZoneEntityItem.h | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp index 9338bfd773..cf6fcaae87 100644 --- a/libraries/entities/src/EntityItemProperties.cpp +++ b/libraries/entities/src/EntityItemProperties.cpp @@ -231,7 +231,7 @@ QString EntityItemProperties::getHazeModeAsString() const { return HAZE_MODES[_hazeMode].second; } -QString EntityItemProperties::getHazeModeString(uint8_t mode) { +QString EntityItemProperties::getHazeModeString(uint32_t mode) { return HAZE_MODES[mode].second; } @@ -1153,7 +1153,7 @@ void EntityItemProperties::entityPropertyFlagsFromScriptValue(const QScriptValue ADD_PROPERTY_TO_MAP(PROP_GHOSTING_ALLOWED, GhostingAllowed, ghostingAllowed, bool); ADD_PROPERTY_TO_MAP(PROP_FILTER_URL, FilterURL, filterURL, QString); - ADD_PROPERTY_TO_MAP(PROP_HAZE_MODE, HazeMode, hazeMode, uint8_t); + ADD_PROPERTY_TO_MAP(PROP_HAZE_MODE, HazeMode, hazeMode, uint32_t); ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_ALTITUDE, Haze, haze, HazeRange, hazeRange); ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_BLEND_IN_COLOR, Haze, haze, HazeBlendInColor, hazeBlendInColor); @@ -1727,7 +1727,7 @@ bool EntityItemProperties::decodeEntityEditPacket(const unsigned char* data, int READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_GHOSTING_ALLOWED, bool, setGhostingAllowed); READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_FILTER_URL, QString, setFilterURL); - READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_HAZE_MODE, uint8_t, setHazeMode); + READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_HAZE_MODE, uint32_t, setHazeMode); properties.getHaze().decodeFromEditPacket(propertyFlags, dataAt, processedBytes); } diff --git a/libraries/entities/src/EntityItemProperties.h b/libraries/entities/src/EntityItemProperties.h index 6909ffd264..599d919792 100644 --- a/libraries/entities/src/EntityItemProperties.h +++ b/libraries/entities/src/EntityItemProperties.h @@ -179,7 +179,7 @@ public: DEFINE_PROPERTY_REF_ENUM(PROP_BACKGROUND_MODE, BackgroundMode, backgroundMode, BackgroundMode, BACKGROUND_MODE_INHERIT); DEFINE_PROPERTY_GROUP(Stage, stage, StagePropertyGroup); - DEFINE_PROPERTY_REF_ENUM(PROP_HAZE_MODE, HazeMode, hazeMode, uint8_t, (uint8_t)HAZE_MODE_INHERIT); + DEFINE_PROPERTY_REF_ENUM(PROP_HAZE_MODE, HazeMode, hazeMode, uint32_t, (uint32_t)HAZE_MODE_INHERIT); DEFINE_PROPERTY_GROUP(Skybox, skybox, SkyboxPropertyGroup); DEFINE_PROPERTY_GROUP(Haze, haze, HazePropertyGroup); @@ -244,7 +244,7 @@ public: DEFINE_PROPERTY_REF(PROP_SERVER_SCRIPTS, ServerScripts, serverScripts, QString, ENTITY_ITEM_DEFAULT_SERVER_SCRIPTS); static QString getBackgroundModeString(BackgroundMode mode); - static QString getHazeModeString(uint8_t mode); + static QString getHazeModeString(uint32_t mode); public: diff --git a/libraries/entities/src/ZoneEntityItem.cpp b/libraries/entities/src/ZoneEntityItem.cpp index 5b95b1ffce..3e6c2d66ea 100644 --- a/libraries/entities/src/ZoneEntityItem.cpp +++ b/libraries/entities/src/ZoneEntityItem.cpp @@ -164,7 +164,7 @@ int ZoneEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data, READ_ENTITY_PROPERTY(PROP_GHOSTING_ALLOWED, bool, setGhostingAllowed); READ_ENTITY_PROPERTY(PROP_FILTER_URL, QString, setFilterURL); - READ_ENTITY_PROPERTY(PROP_HAZE_MODE, uint8_t, setHazeMode); + READ_ENTITY_PROPERTY(PROP_HAZE_MODE, uint32_t, setHazeMode); int bytesFromHaze = _hazeProperties.readEntitySubclassDataFromBuffer(dataAt, (bytesLeftToRead - bytesRead), args, propertyFlags, overwriteLocalData, _hazePropertiesChanged); @@ -320,12 +320,12 @@ void ZoneEntityItem::resetRenderingPropertiesChanged() { }); } -void ZoneEntityItem::setHazeMode(const uint8_t value) { +void ZoneEntityItem::setHazeMode(const uint32_t value) { _hazeMode = value; _hazePropertiesChanged = true; } -uint8_t ZoneEntityItem::getHazeMode() const { +uint32_t ZoneEntityItem::getHazeMode() const { return _hazeMode; } diff --git a/libraries/entities/src/ZoneEntityItem.h b/libraries/entities/src/ZoneEntityItem.h index cb1d065843..8f64cc79c6 100644 --- a/libraries/entities/src/ZoneEntityItem.h +++ b/libraries/entities/src/ZoneEntityItem.h @@ -70,8 +70,8 @@ public: void setBackgroundMode(BackgroundMode value) { _backgroundMode = value; _backgroundPropertiesChanged = true; } BackgroundMode getBackgroundMode() const { return _backgroundMode; } - void setHazeMode(const uint8_t value); - uint8_t getHazeMode() const; + void setHazeMode(const uint32_t value); + uint32_t getHazeMode() const; void setHazeRange(const float hazeRange); float getHazeRange()const; From 97f775f6f1cb353f7a116f080bc27293a4acf9b6 Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Wed, 4 Oct 2017 21:36:42 -0700 Subject: [PATCH 48/94] Clean-up. --- libraries/render-utils/src/HazeStage.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/render-utils/src/HazeStage.h b/libraries/render-utils/src/HazeStage.h index 4f3760fb40..26d7cb2abb 100644 --- a/libraries/render-utils/src/HazeStage.h +++ b/libraries/render-utils/src/HazeStage.h @@ -132,7 +132,7 @@ public: float hazeBackgroundBlendValue{ model::initialHazeBackgroundBlendValue }; - public slots: +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(); } From 6dcd8b7b57db722e2c683ba28bd5616d2bc3cd9f Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Wed, 4 Oct 2017 21:47:20 -0700 Subject: [PATCH 49/94] Haze Range works. --- .../src/RenderableZoneEntityItem.cpp | 19 +++++++++---------- libraries/entities/src/HazePropertyGroup.h | 12 ++++++------ libraries/model/src/model/Stage.cpp | 2 +- libraries/model/src/model/Stage.h | 4 ++-- libraries/render-utils/src/DrawHaze.cpp | 1 - libraries/render-utils/src/HazeStage.cpp | 1 - 6 files changed, 18 insertions(+), 21 deletions(-) diff --git a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp index ddc5b409eb..244a2e9a61 100644 --- a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp @@ -60,7 +60,6 @@ void ZoneEntityRenderer::onRemoveFromSceneTyped(const TypedEntityPointer& entity } } -#pragma optimize("", off) void ZoneEntityRenderer::doRender(RenderArgs* args) { #if 0 if (ZoneEntityItem::getDrawZoneBoundaries()) { @@ -339,20 +338,20 @@ void ZoneEntityRenderer::updateHazeFromEntity(const TypedEntityPointer& entity) haze->setHazeActive(entity->getHazeMode() == HAZE_MODE_ENABLED); - haze->setHazeRangeFactor(model::convertHazeRangeToHazeRangeFactor(entity->getHazeRange())); - xColor hazeBlendInColor = entity->getHazeBlendInColor(); + haze->setHazeRangeFactor(model::convertHazeRangeToHazeRangeFactor(_hazeProperties.getHazeRange())); + xColor hazeBlendInColor = _hazeProperties.getHazeBlendInColor(); haze->setHazeColor(glm::vec3(hazeBlendInColor.red / 255.0, hazeBlendInColor.green / 255.0, hazeBlendInColor.blue / 255.0)); - xColor hazeBlendOutColor = entity->getHazeBlendOutColor(); + xColor hazeBlendOutColor = _hazeProperties.getHazeBlendOutColor(); haze->setHazeColor(glm::vec3(hazeBlendOutColor.red / 255.0, hazeBlendOutColor.green / 255.0, hazeBlendOutColor.blue / 255.0)); - haze->setDirectionalLightBlend(model::convertDirectionalLightAngleToPower(entity->getHazeLightBlendAngle())); + haze->setDirectionalLightBlend(model::convertDirectionalLightAngleToPower(_hazeProperties.getHazeLightBlendAngle())); - haze->setHazeAltitudeFactor(model::convertHazeAltitudeToHazeAltitudeFactor(entity->getHazeAltitude())); - haze->setHazeBaseReference(entity->getHazeBaseRef()); + haze->setHazeAltitudeFactor(model::convertHazeAltitudeToHazeAltitudeFactor(_hazeProperties.getHazeAltitude())); + haze->setHazeBaseReference(_hazeProperties.getHazeBaseRef()); - haze->setHazeBackgroundBlendValue(entity->getHazeBackgroundBlend()); + haze->setHazeBackgroundBlendValue(_hazeProperties.getHazeBackgroundBlend()); - haze->setHazeKeyLightRangeFactor(model::convertHazeRangeToHazeRangeFactor(entity->getHazeRange())); - haze->setHazeAltitudeFactor(model::convertHazeAltitudeToHazeAltitudeFactor(entity->getHazeAltitude())); + haze->setHazeKeyLightRangeFactor(model::convertHazeRangeToHazeRangeFactor(_hazeProperties.getHazeKeyLightRange())); + haze->setHazeAltitudeFactor(model::convertHazeAltitudeToHazeAltitudeFactor(_hazeProperties.getHazeAltitude())); } void ZoneEntityRenderer::updateKeyBackgroundFromEntity(const TypedEntityPointer& entity) { diff --git a/libraries/entities/src/HazePropertyGroup.h b/libraries/entities/src/HazePropertyGroup.h index dd57ec0528..982e857010 100644 --- a/libraries/entities/src/HazePropertyGroup.h +++ b/libraries/entities/src/HazePropertyGroup.h @@ -91,18 +91,18 @@ public: DEFINE_PROPERTY(PROP_HAZE_RANGE, HazeRange, hazeRange, float, DEFAULT_HAZE_RANGE); DEFINE_PROPERTY_REF(PROP_HAZE_BLEND_IN_COLOR, HazeBlendInColor, hazeBlendInColor, xColor, DEFAULT_HAZE_BLEND_IN_COLOR); DEFINE_PROPERTY_REF(PROP_HAZE_BLEND_OUT_COLOR, HazeBlendOutColor, hazeBlendOutColor, xColor, DEFAULT_HAZE_BLEND_OUT_COLOR); - DEFINE_PROPERTY(PROP_HAZE_LIGHT_BLEND_ANGLE, HazeLightBlendAngle, hazeLightBlendAngle, float, DEFAULT_HAZE_LIGHT_BLEND_ANGLE); + DEFINE_PROPERTY_REF(PROP_HAZE_LIGHT_BLEND_ANGLE, HazeLightBlendAngle, hazeLightBlendAngle, float, DEFAULT_HAZE_LIGHT_BLEND_ANGLE); // Range & Altitude parameters - DEFINE_PROPERTY(PROP_HAZE_ALTITUDE, HazeAltitude, hazeAltitude, float, DEFAULT_HAZE_ALTITUDE); - DEFINE_PROPERTY(PROP_HAZE_BASE_REF, HazeBaseRef, hazeBaseRef, float, DEFAULT_HAZE_BASE_REF); + DEFINE_PROPERTY_REF(PROP_HAZE_ALTITUDE, HazeAltitude, hazeAltitude, float, DEFAULT_HAZE_ALTITUDE); + DEFINE_PROPERTY_REF(PROP_HAZE_BASE_REF, HazeBaseRef, hazeBaseRef, float, DEFAULT_HAZE_BASE_REF); // Background (skybox) blend value - DEFINE_PROPERTY(PROP_HAZE_BACKGROUND_BLEND, HazeBackgroundBlend, hazeBackgroundBlend, float, DEFAULT_HAZE_BACKGROUND_BLEND); + DEFINE_PROPERTY_REF(PROP_HAZE_BACKGROUND_BLEND, HazeBackgroundBlend, hazeBackgroundBlend, float, DEFAULT_HAZE_BACKGROUND_BLEND); // hazeDirectional light attenuation - DEFINE_PROPERTY(PROP_HAZE_KEYLIGHT_RANGE, HazeKeyLightRange, hazeKeyLightRange, float, DEFAULT_HAZE_KEYLIGHT_RANGE); - DEFINE_PROPERTY(PROP_HAZE_KEYLIGHT_ALTITUDE, HazeKeyLightAltitude, hazeKeyLightAltitude, float, DEFAULT_HAZE_KEYLIGHT_ALTITUDE); + 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); }; #endif // hifi_HazePropertyGroup_h diff --git a/libraries/model/src/model/Stage.cpp b/libraries/model/src/model/Stage.cpp index 3080122181..75a94f0cea 100644 --- a/libraries/model/src/model/Stage.cpp +++ b/libraries/model/src/model/Stage.cpp @@ -257,7 +257,7 @@ void SunSkyStage::setSkybox(const SkyboxPointer& skybox) { } // Haze -void SunSkyStage::setHazeMode(uint8_t mode) { +void SunSkyStage::setHazeMode(uint32_t mode) { _hazeMode = mode; invalidate(); } diff --git a/libraries/model/src/model/Stage.h b/libraries/model/src/model/Stage.h index ad1210c5c0..4ed7c6887c 100644 --- a/libraries/model/src/model/Stage.h +++ b/libraries/model/src/model/Stage.h @@ -183,8 +183,8 @@ public: NUM_HAZE_MODES }; - void setHazeMode(uint8_t mode); - uint8_t getHazeMode() const { return _hazeMode; } + void setHazeMode(uint32_t mode); + uint32_t getHazeMode() const { return _hazeMode; } void setHazeRange(float hazeRange) { _hazeRange = hazeRange; } float getHazeRange() const { return _hazeRange; } diff --git a/libraries/render-utils/src/DrawHaze.cpp b/libraries/render-utils/src/DrawHaze.cpp index 1c65e1b905..fe6745090c 100644 --- a/libraries/render-utils/src/DrawHaze.cpp +++ b/libraries/render-utils/src/DrawHaze.cpp @@ -126,7 +126,6 @@ const int HazeEffect_LinearDepthMapSlot = 3; void DrawHaze::configure(const Config& config) { } -#pragma optimize("", off) void DrawHaze::run(const render::RenderContextPointer& renderContext, const Inputs& inputs) { const auto haze = inputs.get0(); if (haze == nullptr) { diff --git a/libraries/render-utils/src/HazeStage.cpp b/libraries/render-utils/src/HazeStage.cpp index 4acc5d534c..a883344e02 100644 --- a/libraries/render-utils/src/HazeStage.cpp +++ b/libraries/render-utils/src/HazeStage.cpp @@ -84,7 +84,6 @@ void HazeStageSetup::run(const render::RenderContextPointer& renderContext) { } } -#pragma optimize("", off) void FetchHazeStage::run(const render::RenderContextPointer& renderContext, model::HazePointer& haze) { auto hazeStage = renderContext->_scene->getStage(); assert(hazeStage); From 8b72e3044a83daabb13eab7a121e046e16694109 Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Wed, 4 Oct 2017 22:26:53 -0700 Subject: [PATCH 50/94] WIP - implementing range+altitude mode. --- libraries/entities-renderer/src/RenderableZoneEntityItem.cpp | 4 +++- libraries/entities/src/EntityItemProperties.cpp | 3 ++- libraries/entities/src/HazePropertyGroup.cpp | 2 +- libraries/shared/src/HazeMode.h | 3 ++- scripts/system/html/entityProperties.html | 3 ++- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp index 244a2e9a61..c59100c0c7 100644 --- a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp @@ -336,7 +336,9 @@ void ZoneEntityRenderer::updateHazeFromEntity(const TypedEntityPointer& entity) const auto& haze = editHaze(); - haze->setHazeActive(entity->getHazeMode() == HAZE_MODE_ENABLED); + uint32_t hazeMode = entity->getHazeMode(); + haze->setHazeActive((hazeMode == HAZE_MODE_RANGE_ONLY) || (hazeMode == HAZE_MODE_RANGE_ALTITUDE)); + haze->setAltitudeBased(hazeMode == HAZE_MODE_RANGE_ALTITUDE); haze->setHazeRangeFactor(model::convertHazeRangeToHazeRangeFactor(_hazeProperties.getHazeRange())); xColor hazeBlendInColor = _hazeProperties.getHazeBlendInColor(); diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp index cf6fcaae87..c587fa4a07 100644 --- a/libraries/entities/src/EntityItemProperties.cpp +++ b/libraries/entities/src/EntityItemProperties.cpp @@ -224,7 +224,8 @@ using HazePair = std::pair; const std::array HAZE_MODES = { { HazePair{ HAZE_MODE_INHERIT,{ "inherit" } }, HazePair{ HAZE_MODE_DISABLED,{ "disabled" } }, - HazePair{ HAZE_MODE_ENABLED,{ "enabled" } } + HazePair{ HAZE_MODE_RANGE_ONLY,{ "range only" } }, + HazePair{ HAZE_MODE_RANGE_ALTITUDE,{ "range+altitude" } } } }; QString EntityItemProperties::getHazeModeAsString() const { diff --git a/libraries/entities/src/HazePropertyGroup.cpp b/libraries/entities/src/HazePropertyGroup.cpp index 93da9913a8..80879e24e3 100644 --- a/libraries/entities/src/HazePropertyGroup.cpp +++ b/libraries/entities/src/HazePropertyGroup.cpp @@ -199,7 +199,7 @@ void HazePropertyGroup::markAllChanged() { _hazeBackgroundBlendChanged = true; _hazeKeyLightRangeChanged = true; - _hazeAltitudeChanged = true; + _hazeKeyLightAltitudeChanged = true; } EntityPropertyFlags HazePropertyGroup::getChangedProperties() const { diff --git a/libraries/shared/src/HazeMode.h b/libraries/shared/src/HazeMode.h index 0c0af013cd..c5deeed9a3 100644 --- a/libraries/shared/src/HazeMode.h +++ b/libraries/shared/src/HazeMode.h @@ -15,7 +15,8 @@ enum HazeMode { HAZE_MODE_INHERIT, HAZE_MODE_DISABLED, - HAZE_MODE_ENABLED, + HAZE_MODE_RANGE_ONLY, + HAZE_MODE_RANGE_ALTITUDE, HAZE_MODE_ITEM_COUNT }; diff --git a/scripts/system/html/entityProperties.html b/scripts/system/html/entityProperties.html index 5859733f86..e13b17a697 100644 --- a/scripts/system/html/entityProperties.html +++ b/scripts/system/html/entityProperties.html @@ -552,7 +552,8 @@
From ad03301df80ac93b00f8a84898ea2f38b5b55119 Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Wed, 4 Oct 2017 23:03:21 -0700 Subject: [PATCH 51/94] WIP - implementing range+altitude mode. --- .../entities-renderer/src/RenderableZoneEntityItem.cpp | 2 +- libraries/entities/src/EntityItemProperties.cpp | 2 +- libraries/render-utils/src/DrawHaze.cpp | 8 ++++---- libraries/render-utils/src/DrawHaze.h | 8 ++++---- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp index c59100c0c7..850ce73620 100644 --- a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp @@ -353,7 +353,7 @@ void ZoneEntityRenderer::updateHazeFromEntity(const TypedEntityPointer& entity) haze->setHazeBackgroundBlendValue(_hazeProperties.getHazeBackgroundBlend()); haze->setHazeKeyLightRangeFactor(model::convertHazeRangeToHazeRangeFactor(_hazeProperties.getHazeKeyLightRange())); - haze->setHazeAltitudeFactor(model::convertHazeAltitudeToHazeAltitudeFactor(_hazeProperties.getHazeAltitude())); + haze->setHazeKeyLightAltitudeFactor(model::convertHazeAltitudeToHazeAltitudeFactor(_hazeProperties.getHazeKeyLightAltitude())); } void ZoneEntityRenderer::updateKeyBackgroundFromEntity(const TypedEntityPointer& entity) { diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp index c587fa4a07..436b1e12cd 100644 --- a/libraries/entities/src/EntityItemProperties.cpp +++ b/libraries/entities/src/EntityItemProperties.cpp @@ -1156,7 +1156,7 @@ void EntityItemProperties::entityPropertyFlagsFromScriptValue(const QScriptValue ADD_PROPERTY_TO_MAP(PROP_HAZE_MODE, HazeMode, hazeMode, uint32_t); - ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_ALTITUDE, Haze, haze, HazeRange, hazeRange); + ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_RANGE, Haze, haze, HazeRange, hazeRange); ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_BLEND_IN_COLOR, Haze, haze, HazeBlendInColor, hazeBlendInColor); ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_BLEND_OUT_COLOR, Haze, haze, HazeBlendOutColor, hazeBlendOutColor); ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_LIGHT_BLEND_ANGLE, Haze, haze, HazeLightBlendAngle, hazeLightBlendAngle); diff --git a/libraries/render-utils/src/DrawHaze.cpp b/libraries/render-utils/src/DrawHaze.cpp index fe6745090c..0b8872ea9f 100644 --- a/libraries/render-utils/src/DrawHaze.cpp +++ b/libraries/render-utils/src/DrawHaze.cpp @@ -76,12 +76,12 @@ void HazeConfig::setHazeAltitude_m(const float value) { hazeAltitude_m = value; } -void HazeConfig::setHazeRangeKeyLight_m(const float value) { - hazeRangeKeyLight_m = value; +void HazeConfig::setHazeKeyLightRange_m(const float value) { + hazeKeyLightRange_m = value; } -void HazeConfig::setHazeAltitudeKeyLight_m(const float value) { - hazeAltitudeKeyLight_m = value; +void HazeConfig::setHazeKeyLightAltitude_m(const float value) { + hazeKeyLightAltitude_m = value; } void HazeConfig::setHazeBackgroundBlendValue(const float value) { diff --git a/libraries/render-utils/src/DrawHaze.h b/libraries/render-utils/src/DrawHaze.h index 8ebfff4b29..4634df0147 100644 --- a/libraries/render-utils/src/DrawHaze.h +++ b/libraries/render-utils/src/DrawHaze.h @@ -143,8 +143,8 @@ public: float hazeRange_m{ model::initialHazeRange_m }; float hazeAltitude_m{ model::initialHazeAltitude_m }; - float hazeRangeKeyLight_m{ model::initialHazeKeyLightRange_m }; - float hazeAltitudeKeyLight_m{ model::initialHazeKeyLightAltitude_m }; + float hazeKeyLightRange_m{ model::initialHazeKeyLightRange_m }; + float hazeKeyLightAltitude_m{ model::initialHazeKeyLightAltitude_m }; float hazeBackgroundBlendValue{ model::initialHazeBackgroundBlendValue }; @@ -167,8 +167,8 @@ public: void setHazeRange_m(const float value); void setHazeAltitude_m(const float value); - void setHazeRangeKeyLight_m(const float value); - void setHazeAltitudeKeyLight_m(const float value); + void setHazeKeyLightRange_m(const float value); + void setHazeKeyLightAltitude_m(const float value); void setHazeBackgroundBlendValue(const float value); }; From b7af6a58a627107d44ad2de6ce0aad22be7fd695 Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Thu, 5 Oct 2017 09:16:14 -0700 Subject: [PATCH 52/94] WIP - adding background blend --- scripts/system/html/entityProperties.html | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/system/html/entityProperties.html b/scripts/system/html/entityProperties.html index e13b17a697..8c93bb379e 100644 --- a/scripts/system/html/entityProperties.html +++ b/scripts/system/html/entityProperties.html @@ -556,12 +556,17 @@ -
+
+
+
+
+
+
From 595530161ac856acfa7aaadd1ff1a547e37af62b Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Thu, 5 Oct 2017 09:28:55 -0700 Subject: [PATCH 53/94] WIP - adding background blend. Haze altitude works. --- scripts/system/html/js/entityProperties.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts/system/html/js/entityProperties.js b/scripts/system/html/js/entityProperties.js index 9b5c3eed17..0ffce873e4 100644 --- a/scripts/system/html/js/entityProperties.js +++ b/scripts/system/html/js/entityProperties.js @@ -658,7 +658,10 @@ function loaded() { var elZoneKeyLightAmbientURL = document.getElementById("property-zone-key-ambient-url"); var elZoneHazeMode = document.getElementById("property-zone-haze-mode"); + var elZoneHazeRange = document.getElementById("property-zone-haze-range"); + var elZoneHazeBackgroundBlend = document.getElementById("property-zone-haze-background-blend"); + var elZoneHazeAltitude = document.getElementById("property-zone-haze-altitude"); var elZoneStageLatitude = document.getElementById("property-zone-stage-latitude"); @@ -1002,6 +1005,8 @@ function loaded() { setDropdownText(elZoneHazeMode); elZoneHazeRange.value = properties.haze.hazeRange.toFixed(2); + elZoneHazeBackgroundBlend.value = properties.haze.hazeBackgroundBlend; + elZoneHazeAltitude.value = properties.haze.hazeAltitude.toFixed(2); elZoneStageLatitude.value = properties.stage.latitude.toFixed(2); @@ -1399,8 +1404,11 @@ function loaded() { elZoneKeyLightDirectionY.addEventListener('change', zoneKeyLightDirectionChangeFunction); elZoneHazeMode.addEventListener('change', createEmitTextPropertyUpdateFunction('hazeMode')); + elZoneHazeRange.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('haze', 'hazeRange')); - elZoneStageLatitude.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('haze', 'hazeAltitude')); + elZoneHazeBackgroundBlend.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('haze', 'hazeBackgroundBlend')); + + elZoneHazeAltitude.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('haze', 'hazeAltitude')); elZoneStageLatitude.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('stage', 'latitude')); elZoneStageLongitude.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('stage', 'longitude')); From 1e2bd23c0b2b7c529d1cf4f1b9e9ab932d5671c6 Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Thu, 5 Oct 2017 11:31:08 -0700 Subject: [PATCH 54/94] Fixed typo in variable name. --- libraries/entities/src/HazePropertyGroup.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/entities/src/HazePropertyGroup.cpp b/libraries/entities/src/HazePropertyGroup.cpp index 80879e24e3..5a7f2b02f6 100644 --- a/libraries/entities/src/HazePropertyGroup.cpp +++ b/libraries/entities/src/HazePropertyGroup.cpp @@ -30,8 +30,8 @@ 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_BLEND_IN_COLOR, Haze, haze, HazeBlendInColor, hazeBlendIncolor); - COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_BLEND_OUT_COLOR, Haze, haze, HazeBlendOutColor, hazeBlendOutcolor); + COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_BLEND_IN_COLOR, Haze, haze, HazeBlendInColor, hazeBlendInColor); + COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_BLEND_OUT_COLOR, Haze, haze, HazeBlendOutColor, hazeBlendOutColor); COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_LIGHT_BLEND_ANGLE, Haze, haze, HazeLightBlendAngle, hazeLightBlendAngle); COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_ALTITUDE, Haze, haze, HazeAltitude, hazeAltitude); From 512b469dc6a2e3a3abe197414108a104a15bf0b3 Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Thu, 5 Oct 2017 11:31:49 -0700 Subject: [PATCH 55/94] Added haze colour selector. --- scripts/system/html/entityProperties.html | 9 ++++++ scripts/system/html/js/entityProperties.js | 33 ++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/scripts/system/html/entityProperties.html b/scripts/system/html/entityProperties.html index 8c93bb379e..5a063af5cb 100644 --- a/scripts/system/html/entityProperties.html +++ b/scripts/system/html/entityProperties.html @@ -567,6 +567,15 @@
+
+
+ Haze Blend In Color +
+
+
+
+
+
diff --git a/scripts/system/html/js/entityProperties.js b/scripts/system/html/js/entityProperties.js index 0ffce873e4..8816e84597 100644 --- a/scripts/system/html/js/entityProperties.js +++ b/scripts/system/html/js/entityProperties.js @@ -660,6 +660,10 @@ function loaded() { var elZoneHazeMode = document.getElementById("property-zone-haze-mode"); var elZoneHazeRange = document.getElementById("property-zone-haze-range"); + var elZoneHazeBlendInColor = document.getElementById("property-zone-haze-blend-in-color"); + var elZoneHazeBlendInColorRed = document.getElementById("property-zone-haze-blend-in-color-red"); + var elZoneHazeBlendInColorGreen = document.getElementById("property-zone-haze-blend-in-color-green"); + var elZoneHazeBlendInColorBlue = document.getElementById("property-zone-haze-blend-in-color-blue"); var elZoneHazeBackgroundBlend = document.getElementById("property-zone-haze-background-blend"); var elZoneHazeAltitude = document.getElementById("property-zone-haze-altitude"); @@ -1005,6 +1009,11 @@ function loaded() { setDropdownText(elZoneHazeMode); elZoneHazeRange.value = properties.haze.hazeRange.toFixed(2); + elZoneHazeBlendInColor.style.backgroundColor = "rgb(" + properties.haze.hazeBlendInColor.red + "," + properties.haze.hazeBlendInColor.green + "," + properties.haze.hazeBlendInColor.blue + ")"; + + elZoneHazeBlendInColorRed.value = properties.haze.hazeBlendInColor.red; + elZoneHazeBlendInColorGreen.value = properties.haze.hazeBlendInColor.green; + elZoneHazeBlendInColorBlue.value = properties.haze.hazeBlendInColor.blue; elZoneHazeBackgroundBlend.value = properties.haze.hazeBackgroundBlend; elZoneHazeAltitude.value = properties.haze.hazeAltitude.toFixed(2); @@ -1406,6 +1415,30 @@ function loaded() { elZoneHazeMode.addEventListener('change', createEmitTextPropertyUpdateFunction('hazeMode')); elZoneHazeRange.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('haze', 'hazeRange')); + colorPickers.push($('#property-zone-haze-blend-in-color').colpick({ + colorScheme: 'dark', + layout: 'hex', + color: '000000', + onShow: function(colpick) { + $('#property-zone-haze-blend-in-color').attr('active', 'true'); + }, + onHide: function(colpick) { + $('#property-zone-haze-blend-in-color').attr('active', 'false'); + }, + onSubmit: function(hsb, hex, rgb, el) { + $(el).css('background-color', '#' + hex); + $(el).colpickHide(); + emitColorPropertyUpdate('color', rgb.r, rgb.g, rgb.b, 'hazeBlendIn'); + } + })); + var zoneHazeBlendInColorChangeFunction = createEmitGroupColorPropertyUpdateFunction('hazeBlendIn', 'color', + elZoneHazeBlendInColorRed, + elZoneHazeBlendInColorGreen, + elZoneHazeBlendInColorBlue); + + elZoneHazeBlendInColorRed.addEventListener('change', zoneHazeBlendInColorChangeFunction); + elZoneHazeBlendInColorGreen.addEventListener('change', zoneHazeBlendInColorChangeFunction); + elZoneHazeBlendInColorBlue.addEventListener('change', zoneKeyHazeBlendInColorChangeFunction); elZoneHazeBackgroundBlend.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('haze', 'hazeBackgroundBlend')); elZoneHazeAltitude.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('haze', 'hazeAltitude')); From 395d9cbd6bd54abf4cbfe64fb5c6bbb9c90100ca Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Thu, 5 Oct 2017 12:13:37 -0700 Subject: [PATCH 56/94] WIP - haze colour. --- libraries/model/src/model/Stage.h | 2 +- scripts/system/html/entityProperties.html | 6 +----- scripts/system/html/js/entityProperties.js | 15 +++++++++------ 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/libraries/model/src/model/Stage.h b/libraries/model/src/model/Stage.h index 4ed7c6887c..e070404456 100644 --- a/libraries/model/src/model/Stage.h +++ b/libraries/model/src/model/Stage.h @@ -190,7 +190,7 @@ public: float getHazeRange() const { return _hazeRange; } void setHazeBlendInColor(const xColor hazeBlendInColor) { _hazeBlendInColor = hazeBlendInColor; } xColor getHazeBlendInColor() { return _hazeBlendInColor; } - void setHazeBlendOutColor(const xColor hazeBlendOutColor) { _hazeBlendInColor = hazeBlendOutColor; } + void setHazeBlendOutColor(const xColor hazeBlendOutColor) { _hazeBlendOutColor = hazeBlendOutColor; } xColor getHazeBlendOutColor() const { return _hazeBlendOutColor; } void setHazeLightBlendAngle(float hazeLightBlendAngle) { _hazeLightBlendAngle = hazeLightBlendAngle; } float getHazeLightBlendAngle() const { return _hazeLightBlendAngle; } diff --git a/scripts/system/html/entityProperties.html b/scripts/system/html/entityProperties.html index 5a063af5cb..84d1e4748f 100644 --- a/scripts/system/html/entityProperties.html +++ b/scripts/system/html/entityProperties.html @@ -560,11 +560,7 @@
-
-
-
-
-
+
diff --git a/scripts/system/html/js/entityProperties.js b/scripts/system/html/js/entityProperties.js index 8816e84597..29c69acc83 100644 --- a/scripts/system/html/js/entityProperties.js +++ b/scripts/system/html/js/entityProperties.js @@ -1008,15 +1008,18 @@ function loaded() { elZoneHazeMode.value = properties.hazeMode; setDropdownText(elZoneHazeMode); - elZoneHazeRange.value = properties.haze.hazeRange.toFixed(2); - elZoneHazeBlendInColor.style.backgroundColor = "rgb(" + properties.haze.hazeBlendInColor.red + "," + properties.haze.hazeBlendInColor.green + "," + properties.haze.hazeBlendInColor.blue + ")"; + elZoneHazeRange.value = properties.haze.hazeRange.toFixed(0); + elZoneHazeBlendInColor.style.backgroundColor = "rgb(" + + properties.haze.hazeBlendInColor.red + "," + + properties.haze.hazeBlendInColor.green + "," + + properties.haze.hazeBlendInColor.blue + ")"; elZoneHazeBlendInColorRed.value = properties.haze.hazeBlendInColor.red; elZoneHazeBlendInColorGreen.value = properties.haze.hazeBlendInColor.green; elZoneHazeBlendInColorBlue.value = properties.haze.hazeBlendInColor.blue; - elZoneHazeBackgroundBlend.value = properties.haze.hazeBackgroundBlend; + elZoneHazeBackgroundBlend.value = properties.haze.hazeBackgroundBlend.toFixed(2); - elZoneHazeAltitude.value = properties.haze.hazeAltitude.toFixed(2); + elZoneHazeAltitude.value = properties.haze.hazeAltitude.toFixed(0); elZoneStageLatitude.value = properties.stage.latitude.toFixed(2); elZoneStageLongitude.value = properties.stage.longitude.toFixed(2); @@ -1431,14 +1434,14 @@ function loaded() { emitColorPropertyUpdate('color', rgb.r, rgb.g, rgb.b, 'hazeBlendIn'); } })); - var zoneHazeBlendInColorChangeFunction = createEmitGroupColorPropertyUpdateFunction('hazeBlendIn', 'color', + var zoneHazeBlendInColorChangeFunction = createEmitGroupColorPropertyUpdateFunction('haze', 'hazeBlendInColor', elZoneHazeBlendInColorRed, elZoneHazeBlendInColorGreen, elZoneHazeBlendInColorBlue); elZoneHazeBlendInColorRed.addEventListener('change', zoneHazeBlendInColorChangeFunction); elZoneHazeBlendInColorGreen.addEventListener('change', zoneHazeBlendInColorChangeFunction); - elZoneHazeBlendInColorBlue.addEventListener('change', zoneKeyHazeBlendInColorChangeFunction); + elZoneHazeBlendInColorBlue.addEventListener('change', zoneHazeBlendInColorChangeFunction); elZoneHazeBackgroundBlend.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('haze', 'hazeBackgroundBlend')); elZoneHazeAltitude.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('haze', 'hazeAltitude')); From cbaae2c79b49e707920e7900de670573ec363c96 Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Thu, 5 Oct 2017 12:59:56 -0700 Subject: [PATCH 57/94] WIP - haze colour. --- libraries/entities/src/HazePropertyGroup.cpp | 2 +- scripts/system/html/js/entityProperties.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/entities/src/HazePropertyGroup.cpp b/libraries/entities/src/HazePropertyGroup.cpp index 5a7f2b02f6..11bb7f3f6c 100644 --- a/libraries/entities/src/HazePropertyGroup.cpp +++ b/libraries/entities/src/HazePropertyGroup.cpp @@ -78,7 +78,7 @@ void HazePropertyGroup::debugDump() const { qCDebug(entities) << " _hazeRange:" << _hazeRange; qCDebug(entities) << " _hazeBlendInColor:" << _hazeBlendInColor; - qCDebug(entities) << " _hazeBlendOutColor:" << _hazeBlendInColor; + qCDebug(entities) << " _hazeBlendOutColor:" << _hazeBlendOutColor; qCDebug(entities) << " _hazeLightBlendAngle:" << _hazeLightBlendAngle; qCDebug(entities) << " _hazeAltitude:" << _hazeAltitude; diff --git a/scripts/system/html/js/entityProperties.js b/scripts/system/html/js/entityProperties.js index 29c69acc83..28f3d5896f 100644 --- a/scripts/system/html/js/entityProperties.js +++ b/scripts/system/html/js/entityProperties.js @@ -1431,7 +1431,7 @@ function loaded() { onSubmit: function(hsb, hex, rgb, el) { $(el).css('background-color', '#' + hex); $(el).colpickHide(); - emitColorPropertyUpdate('color', rgb.r, rgb.g, rgb.b, 'hazeBlendIn'); + emitColorPropertyUpdate('color', rgb.r, rgb.g, rgb.b, 'hazeBlendInColor'); } })); var zoneHazeBlendInColorChangeFunction = createEmitGroupColorPropertyUpdateFunction('haze', 'hazeBlendInColor', From 2e2364e03fdd60f11a35b870b2c4e83ff74a2df2 Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Thu, 5 Oct 2017 13:20:21 -0700 Subject: [PATCH 58/94] WIP - adding haze blend out colour --- scripts/system/html/entityProperties.html | 21 +++++++++-- scripts/system/html/js/entityProperties.js | 42 ++++++++++++++++++++++ 2 files changed, 60 insertions(+), 3 deletions(-) diff --git a/scripts/system/html/entityProperties.html b/scripts/system/html/entityProperties.html index 84d1e4748f..73dba453c0 100644 --- a/scripts/system/html/entityProperties.html +++ b/scripts/system/html/entityProperties.html @@ -567,9 +567,24 @@
Haze Blend In Color
-
-
-
+
+
+
+
+
+
+
+
+
+
+ Haze Blend Out Color +
+
+
+
+
+
+
diff --git a/scripts/system/html/js/entityProperties.js b/scripts/system/html/js/entityProperties.js index 28f3d5896f..a6a9d532e5 100644 --- a/scripts/system/html/js/entityProperties.js +++ b/scripts/system/html/js/entityProperties.js @@ -664,6 +664,10 @@ function loaded() { var elZoneHazeBlendInColorRed = document.getElementById("property-zone-haze-blend-in-color-red"); var elZoneHazeBlendInColorGreen = document.getElementById("property-zone-haze-blend-in-color-green"); var elZoneHazeBlendInColorBlue = document.getElementById("property-zone-haze-blend-in-color-blue"); + var elZoneHazeBlendOutColor = document.getElementById("property-zone-haze-blend-out-color"); + var elZoneHazeBlendOutColorRed = document.getElementById("property-zone-haze-blend-out-color-red"); + var elZoneHazeBlendOutColorGreen = document.getElementById("property-zone-haze-blend-out-color-green"); + var elZoneHazeBlendOutColorBlue = document.getElementById("property-zone-haze-blend-out-color-blue"); var elZoneHazeBackgroundBlend = document.getElementById("property-zone-haze-background-blend"); var elZoneHazeAltitude = document.getElementById("property-zone-haze-altitude"); @@ -1019,6 +1023,17 @@ function loaded() { elZoneHazeBlendInColorBlue.value = properties.haze.hazeBlendInColor.blue; elZoneHazeBackgroundBlend.value = properties.haze.hazeBackgroundBlend.toFixed(2); + elZoneHazeBlendOutColor.style.backgroundColor = "rgb(" + + properties.haze.hazeBlendOutColor.red + "," + + properties.haze.hazeBlendOutColor.green + "," + + properties.haze.hazeBlendOutColor.blue + ")"; + + elZoneHazeBlendOutColorRed.value = properties.haze.hazeBlendOutColor.red; + elZoneHazeBlendOutColorGreen.value = properties.haze.hazeBlendOutColor.green; + elZoneHazeBlendOutColorBlue.value = properties.haze.hazeBlendOutColor.blue; + + elZoneHazeBackgroundBlend.value = properties.haze.hazeBackgroundBlend.toFixed(2); + elZoneHazeAltitude.value = properties.haze.hazeAltitude.toFixed(0); elZoneStageLatitude.value = properties.stage.latitude.toFixed(2); @@ -1418,6 +1433,7 @@ function loaded() { elZoneHazeMode.addEventListener('change', createEmitTextPropertyUpdateFunction('hazeMode')); elZoneHazeRange.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('haze', 'hazeRange')); + colorPickers.push($('#property-zone-haze-blend-in-color').colpick({ colorScheme: 'dark', layout: 'hex', @@ -1442,6 +1458,32 @@ function loaded() { elZoneHazeBlendInColorRed.addEventListener('change', zoneHazeBlendInColorChangeFunction); elZoneHazeBlendInColorGreen.addEventListener('change', zoneHazeBlendInColorChangeFunction); elZoneHazeBlendInColorBlue.addEventListener('change', zoneHazeBlendInColorChangeFunction); + + colorPickers.push($('#property-zone-haze-blend-out-color').colpick({ + colorScheme: 'dark', + layout: 'hex', + color: '000000', + onShow: function(colpick) { + $('#property-zone-haze-blend-out-color').attr('active', 'true'); + }, + onHide: function(colpick) { + $('#property-zone-haze-blend-out-color').attr('active', 'false'); + }, + onSubmit: function(hsb, hex, rgb, el) { + $(el).css('background-color', '#' + hex); + $(el).colpickHide(); + emitColorPropertyUpdate('color', rgb.r, rgb.g, rgb.b, 'hazeBlendOutColor'); + } + })); + var zoneHazeBlendOutColorChangeFunction = createEmitGroupColorPropertyUpdateFunction('haze', 'hazeBlendOutColor', + elZoneHazeBlendOutColorRed, + elZoneHazeBlendOutColorGreen, + elZoneHazeBlendOutColorBlue); + + elZoneHazeBlendOutColorRed.addEventListener('change', zoneHazeBlendOutColorChangeFunction); + elZoneHazeBlendOutColorGreen.addEventListener('change', zoneHazeBlendOutColorChangeFunction); + elZoneHazeBlendOutColorBlue.addEventListener('change', zoneHazeBlendOutColorChangeFunction); + elZoneHazeBackgroundBlend.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('haze', 'hazeBackgroundBlend')); elZoneHazeAltitude.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('haze', 'hazeAltitude')); From 414cae8df77dd6728568eecd3601c876d2066b5f Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Thu, 5 Oct 2017 13:29:32 -0700 Subject: [PATCH 59/94] Implemented haze colours. --- libraries/entities-renderer/src/RenderableZoneEntityItem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp index 850ce73620..1987b48328 100644 --- a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp @@ -344,7 +344,7 @@ void ZoneEntityRenderer::updateHazeFromEntity(const TypedEntityPointer& entity) xColor hazeBlendInColor = _hazeProperties.getHazeBlendInColor(); haze->setHazeColor(glm::vec3(hazeBlendInColor.red / 255.0, hazeBlendInColor.green / 255.0, hazeBlendInColor.blue / 255.0)); xColor hazeBlendOutColor = _hazeProperties.getHazeBlendOutColor(); - haze->setHazeColor(glm::vec3(hazeBlendOutColor.red / 255.0, hazeBlendOutColor.green / 255.0, hazeBlendOutColor.blue / 255.0)); + haze->setDirectionalLightColor(glm::vec3(hazeBlendOutColor.red / 255.0, hazeBlendOutColor.green / 255.0, hazeBlendOutColor.blue / 255.0)); haze->setDirectionalLightBlend(model::convertDirectionalLightAngleToPower(_hazeProperties.getHazeLightBlendAngle())); haze->setHazeAltitudeFactor(model::convertHazeAltitudeToHazeAltitudeFactor(_hazeProperties.getHazeAltitude())); From e15699192d6edf7776157fc64b7e1a6f8c9244ac Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Thu, 5 Oct 2017 14:18:03 -0700 Subject: [PATCH 60/94] Added blend angle and altitude reference base. --- scripts/system/html/entityProperties.html | 16 ++++++++++++---- scripts/system/html/js/entityProperties.js | 14 ++++++++++---- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/scripts/system/html/entityProperties.html b/scripts/system/html/entityProperties.html index 73dba453c0..599f38a7b0 100644 --- a/scripts/system/html/entityProperties.html +++ b/scripts/system/html/entityProperties.html @@ -558,9 +558,12 @@
-
-
-
+
+
+
+
+
+
@@ -587,7 +590,12 @@
- +
+
+
+
+
+
Stage diff --git a/scripts/system/html/js/entityProperties.js b/scripts/system/html/js/entityProperties.js index a6a9d532e5..aa58906d42 100644 --- a/scripts/system/html/js/entityProperties.js +++ b/scripts/system/html/js/entityProperties.js @@ -669,8 +669,10 @@ function loaded() { var elZoneHazeBlendOutColorGreen = document.getElementById("property-zone-haze-blend-out-color-green"); var elZoneHazeBlendOutColorBlue = document.getElementById("property-zone-haze-blend-out-color-blue"); var elZoneHazeBackgroundBlend = document.getElementById("property-zone-haze-background-blend"); + var elZoneHazeLightBlendAngle = document.getElementById("property-zone-haze-blend-angle"); var elZoneHazeAltitude = document.getElementById("property-zone-haze-altitude"); + var elZoneHazeBaseRef = document.getElementById("property-zone-haze-altitude-base"); var elZoneStageLatitude = document.getElementById("property-zone-stage-latitude"); var elZoneStageLongitude = document.getElementById("property-zone-stage-longitude"); @@ -1031,10 +1033,12 @@ function loaded() { elZoneHazeBlendOutColorRed.value = properties.haze.hazeBlendOutColor.red; elZoneHazeBlendOutColorGreen.value = properties.haze.hazeBlendOutColor.green; elZoneHazeBlendOutColorBlue.value = properties.haze.hazeBlendOutColor.blue; - - elZoneHazeBackgroundBlend.value = properties.haze.hazeBackgroundBlend.toFixed(2); + elZoneHazeLightBlendAngle.value = properties.haze.hazeLightBlendAngle.toFixed(0); elZoneHazeAltitude.value = properties.haze.hazeAltitude.toFixed(0); + elZoneHazeBaseRef.value = properties.haze.hazeBaseRef.toFixed(0); + + elZoneHazeBackgroundBlend.value = properties.haze.hazeBackgroundBlend.toFixed(2); elZoneStageLatitude.value = properties.stage.latitude.toFixed(2); elZoneStageLongitude.value = properties.stage.longitude.toFixed(2); @@ -1483,10 +1487,12 @@ function loaded() { elZoneHazeBlendOutColorRed.addEventListener('change', zoneHazeBlendOutColorChangeFunction); elZoneHazeBlendOutColorGreen.addEventListener('change', zoneHazeBlendOutColorChangeFunction); elZoneHazeBlendOutColorBlue.addEventListener('change', zoneHazeBlendOutColorChangeFunction); - - elZoneHazeBackgroundBlend.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('haze', 'hazeBackgroundBlend')); + elZoneHazeLightBlendAngle.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('haze', 'hazeLightBlendAngle')); elZoneHazeAltitude.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('haze', 'hazeAltitude')); + elZoneHazeBaseRef.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('haze', 'hazeBaseRef')); + + elZoneHazeBackgroundBlend.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('haze', 'hazeBackgroundBlend')); elZoneStageLatitude.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('stage', 'latitude')); elZoneStageLongitude.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('stage', 'longitude')); From f261477aa23ad731ac9deb9bc8b2bba5af58729e Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Thu, 5 Oct 2017 17:55:24 -0700 Subject: [PATCH 61/94] Adding sun attenuation. --- scripts/system/html/entityProperties.html | 8 +++++++- scripts/system/html/js/entityProperties.js | 9 +++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/scripts/system/html/entityProperties.html b/scripts/system/html/entityProperties.html index 599f38a7b0..c2a2422860 100644 --- a/scripts/system/html/entityProperties.html +++ b/scripts/system/html/entityProperties.html @@ -562,7 +562,7 @@
-
+
@@ -595,6 +595,12 @@
+
+
+
+
+
+
diff --git a/scripts/system/html/js/entityProperties.js b/scripts/system/html/js/entityProperties.js index aa58906d42..5eda294eec 100644 --- a/scripts/system/html/js/entityProperties.js +++ b/scripts/system/html/js/entityProperties.js @@ -673,6 +673,9 @@ function loaded() { var elZoneHazeAltitude = document.getElementById("property-zone-haze-altitude"); var elZoneHazeBaseRef = document.getElementById("property-zone-haze-altitude-base"); + + var elZoneHazeKeyLightRange = document.getElementById("property-zone-haze-keylight-range"); + var elZoneHazeKeyLightAltitude = document.getElementById("property-zone-haze-keylight-altitude"); var elZoneStageLatitude = document.getElementById("property-zone-stage-latitude"); var elZoneStageLongitude = document.getElementById("property-zone-stage-longitude"); @@ -1040,6 +1043,9 @@ function loaded() { elZoneHazeBackgroundBlend.value = properties.haze.hazeBackgroundBlend.toFixed(2); + elZoneHazeKeyLightRange.value = properties.haze.hazeKeyLightRange.toFixed(0); + elZoneHazeKeyLightAltitude.value = properties.haze.hazeKeyLightAltitude.toFixed(0); + elZoneStageLatitude.value = properties.stage.latitude.toFixed(2); elZoneStageLongitude.value = properties.stage.longitude.toFixed(2); elZoneStageAltitude.value = properties.stage.altitude.toFixed(2); @@ -1494,6 +1500,9 @@ function loaded() { elZoneHazeBackgroundBlend.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('haze', 'hazeBackgroundBlend')); + elZoneHazeKeyLightRange.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('haze', 'hazeKeyLightRange')); + elZoneHazeKeyLightAltitude.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('haze', 'hazeKeyLightAltitude')); + elZoneStageLatitude.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('stage', 'latitude')); elZoneStageLongitude.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('stage', 'longitude')); elZoneStageAltitude.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('stage', 'altitude')); From 3afab3c1d3f96bded6508c68c6f26d56dcdeb1bd Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Thu, 5 Oct 2017 18:25:02 -0700 Subject: [PATCH 62/94] Keylight attenuation implemented. --- .../entities-renderer/src/RenderableZoneEntityItem.cpp | 8 ++++++-- scripts/system/html/entityProperties.html | 6 ++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp index 1987b48328..846935cc77 100644 --- a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp @@ -336,10 +336,14 @@ void ZoneEntityRenderer::updateHazeFromEntity(const TypedEntityPointer& entity) const auto& haze = editHaze(); - uint32_t hazeMode = entity->getHazeMode(); - haze->setHazeActive((hazeMode == HAZE_MODE_RANGE_ONLY) || (hazeMode == HAZE_MODE_RANGE_ALTITUDE)); + const uint32_t hazeMode = entity->getHazeMode(); + const bool isHazeActive = ((hazeMode == HAZE_MODE_RANGE_ONLY) || (hazeMode == HAZE_MODE_RANGE_ALTITUDE)); + haze->setHazeActive(isHazeActive); haze->setAltitudeBased(hazeMode == HAZE_MODE_RANGE_ALTITUDE); + // Directional light attenuation is set whenever haze is active + haze->setDirectionaLightAttenuationActive(isHazeActive); + haze->setHazeRangeFactor(model::convertHazeRangeToHazeRangeFactor(_hazeProperties.getHazeRange())); xColor hazeBlendInColor = _hazeProperties.getHazeBlendInColor(); haze->setHazeColor(glm::vec3(hazeBlendInColor.red / 255.0, hazeBlendInColor.green / 255.0, hazeBlendInColor.blue / 255.0)); diff --git a/scripts/system/html/entityProperties.html b/scripts/system/html/entityProperties.html index c2a2422860..7b4959f088 100644 --- a/scripts/system/html/entityProperties.html +++ b/scripts/system/html/entityProperties.html @@ -597,8 +597,10 @@
-
-
+
+
From 320c888ce4b29962f1f518313e94d46ccc0a7833 Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Thu, 5 Oct 2017 20:31:45 -0700 Subject: [PATCH 63/94] Added checkbox to allow separate control of keylight attenuation. --- .../src/RenderableZoneEntityItem.cpp | 4 +--- libraries/entities/src/EntityItemProperties.cpp | 2 ++ libraries/entities/src/EntityPropertyFlags.h | 5 +++-- libraries/entities/src/HazePropertyGroup.cpp | 17 +++++++++++++++++ libraries/entities/src/HazePropertyGroup.h | 1 + libraries/entities/src/ZoneEntityItem.cpp | 8 ++++++++ libraries/entities/src/ZoneEntityItem.h | 3 +++ libraries/model/src/model/Haze.cpp | 6 +++--- libraries/model/src/model/Haze.h | 2 +- libraries/model/src/model/Stage.h | 3 +++ libraries/render-utils/src/DrawHaze.cpp | 6 +++--- libraries/render-utils/src/DrawHaze.h | 10 +++++----- libraries/render-utils/src/HazeStage.cpp | 2 +- libraries/render-utils/src/HazeStage.h | 6 +++--- .../src/SceneScriptingInterface.cpp | 6 ++++++ .../script-engine/src/SceneScriptingInterface.h | 3 +++ scripts/system/html/entityProperties.html | 6 +++++- scripts/system/html/js/entityProperties.js | 3 +++ 18 files changed, 71 insertions(+), 22 deletions(-) diff --git a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp index 846935cc77..5089d5a6ea 100644 --- a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp @@ -341,9 +341,6 @@ void ZoneEntityRenderer::updateHazeFromEntity(const TypedEntityPointer& entity) haze->setHazeActive(isHazeActive); haze->setAltitudeBased(hazeMode == HAZE_MODE_RANGE_ALTITUDE); - // Directional light attenuation is set whenever haze is active - haze->setDirectionaLightAttenuationActive(isHazeActive); - haze->setHazeRangeFactor(model::convertHazeRangeToHazeRangeFactor(_hazeProperties.getHazeRange())); xColor hazeBlendInColor = _hazeProperties.getHazeBlendInColor(); haze->setHazeColor(glm::vec3(hazeBlendInColor.red / 255.0, hazeBlendInColor.green / 255.0, hazeBlendInColor.blue / 255.0)); @@ -356,6 +353,7 @@ void ZoneEntityRenderer::updateHazeFromEntity(const TypedEntityPointer& entity) haze->setHazeBackgroundBlendValue(_hazeProperties.getHazeBackgroundBlend()); + haze->setHazeAttenuateKeyLight(_hazeProperties.getHazeAttenuateKeyLight()); haze->setHazeKeyLightRangeFactor(model::convertHazeRangeToHazeRangeFactor(_hazeProperties.getHazeKeyLightRange())); haze->setHazeKeyLightAltitudeFactor(model::convertHazeAltitudeToHazeAltitudeFactor(_hazeProperties.getHazeKeyLightAltitude())); } diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp index 436b1e12cd..fa11c61f56 100644 --- a/libraries/entities/src/EntityItemProperties.cpp +++ b/libraries/entities/src/EntityItemProperties.cpp @@ -1161,11 +1161,13 @@ void EntityItemProperties::entityPropertyFlagsFromScriptValue(const QScriptValue ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_BLEND_OUT_COLOR, Haze, haze, HazeBlendOutColor, hazeBlendOutColor); ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_LIGHT_BLEND_ANGLE, Haze, haze, HazeLightBlendAngle, hazeLightBlendAngle); + ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_ATTENUATE_KEYLIGHT, Haze, haze, HazeAttenuateKeyLight, hazeAttenuateKeyLight); ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_ALTITUDE, Haze, haze, HazeAltitude, hazeAltitude); ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_BASE_REF, Haze, haze, HazeBaseRef, hazeBaseRef); ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_BACKGROUND_BLEND, Haze, haze, HazeBackgroundBlend, hazeBackgroundBlend); + ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_ATTENUATE_KEYLIGHT, Haze, haze, HazeAttenuateKeyLight, hazeAttenuateKeyLight); ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_KEYLIGHT_RANGE, Haze, haze, HazeKeyLightRange, hazeKeyLightRange); ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_KEYLIGHT_ALTITUDE, Haze, haze, HazeKeyLightAltitude, hazeKeyLightAltitude); diff --git a/libraries/entities/src/EntityPropertyFlags.h b/libraries/entities/src/EntityPropertyFlags.h index 0637a0c00a..ecc760e71f 100644 --- a/libraries/entities/src/EntityPropertyFlags.h +++ b/libraries/entities/src/EntityPropertyFlags.h @@ -244,8 +244,9 @@ enum EntityPropertyList { PROP_HAZE_BACKGROUND_BLEND = PROP_SPECULAR_COLOR_UNUSED, - PROP_HAZE_KEYLIGHT_RANGE = PROP_LINEAR_ATTENUATION_UNUSED, - PROP_HAZE_KEYLIGHT_ALTITUDE = PROP_QUADRATIC_ATTENUATION_UNUSED, + PROP_HAZE_ATTENUATE_KEYLIGHT = PROP_LINEAR_ATTENUATION_UNUSED, + PROP_HAZE_KEYLIGHT_RANGE = PROP_QUADRATIC_ATTENUATION_UNUSED, + PROP_HAZE_KEYLIGHT_ALTITUDE = PROP_ANIMATION_FRAME_INDEX, PROP_SKYBOX_COLOR = PROP_ANIMATION_URL, PROP_SKYBOX_URL = PROP_ANIMATION_FPS, diff --git a/libraries/entities/src/HazePropertyGroup.cpp b/libraries/entities/src/HazePropertyGroup.cpp index 11bb7f3f6c..d6bc15805d 100644 --- a/libraries/entities/src/HazePropertyGroup.cpp +++ b/libraries/entities/src/HazePropertyGroup.cpp @@ -39,6 +39,7 @@ void HazePropertyGroup::copyToScriptValue(const EntityPropertyFlags& desiredProp COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_BACKGROUND_BLEND, Haze, haze, HazeBackgroundBlend, hazeBackgroundBlend); + COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_ATTENUATE_KEYLIGHT, Haze, haze, HazeAttenuateKeyLight, hazeAttenuateKeyLight); COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_KEYLIGHT_RANGE, Haze, haze, HazeKeyLightRange, hazeKeyLightRange); COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_KEYLIGHT_ALTITUDE, Haze, haze, HazeKeyLightAltitude, hazeKeyLightAltitude); } @@ -54,6 +55,7 @@ void HazePropertyGroup::copyFromScriptValue(const QScriptValue& object, bool& _d COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(haze, hazeBackgroundBlend, float, setHazeBackgroundBlend); + COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(haze, hazeAttenuateKeyLight, bool, setHazeAttenuateKeyLight); COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(haze, hazeKeyLightRange, float, setHazeKeyLightRange); COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(haze, hazeKeyLightAltitude, float, setHazeKeyLightAltitude); } @@ -69,6 +71,7 @@ void HazePropertyGroup::merge(const HazePropertyGroup& other) { COPY_PROPERTY_IF_CHANGED(hazeBackgroundBlend); + COPY_PROPERTY_IF_CHANGED(hazeAttenuateKeyLight); COPY_PROPERTY_IF_CHANGED(hazeKeyLightRange); COPY_PROPERTY_IF_CHANGED(hazeKeyLightAltitude); } @@ -86,6 +89,7 @@ void HazePropertyGroup::debugDump() const { qCDebug(entities) << " _hazeBackgroundBlend:" << _hazeBackgroundBlend; + qCDebug(entities) << " _hazeAttenuateKeyLight:" << _hazeAttenuateKeyLight; qCDebug(entities) << " _hazeKeyLightRange:" << _hazeKeyLightRange; qCDebug(entities) << " _hazeKeyLightAltitude:" << _hazeKeyLightAltitude; } @@ -115,6 +119,9 @@ void HazePropertyGroup::listChangedProperties(QList& out) { out << "haze-hazeBackgroundBlend"; } + if (hazeAttenuateKeyLightChanged()) { + out << "haze-hazeAttenuateKeyLight"; + } if (hazeKeyLightRangeChanged()) { out << "haze-hazeKeyLightRange"; } @@ -142,6 +149,7 @@ bool HazePropertyGroup::appendToEditPacket(OctreePacketData* packetData, APPEND_ENTITY_PROPERTY(PROP_HAZE_BACKGROUND_BLEND, getHazeBackgroundBlend()); + APPEND_ENTITY_PROPERTY(PROP_HAZE_ATTENUATE_KEYLIGHT, getHazeAttenuateKeyLight()); APPEND_ENTITY_PROPERTY(PROP_HAZE_KEYLIGHT_RANGE, getHazeKeyLightRange()); APPEND_ENTITY_PROPERTY(PROP_HAZE_KEYLIGHT_ALTITUDE, getHazeKeyLightAltitude()); @@ -164,6 +172,7 @@ bool HazePropertyGroup::decodeFromEditPacket(EntityPropertyFlags& propertyFlags, READ_ENTITY_PROPERTY(PROP_HAZE_BACKGROUND_BLEND, float, setHazeBackgroundBlend); + READ_ENTITY_PROPERTY(PROP_HAZE_ATTENUATE_KEYLIGHT, bool, setHazeAttenuateKeyLight); READ_ENTITY_PROPERTY(PROP_HAZE_KEYLIGHT_RANGE, float, setHazeKeyLightRange); READ_ENTITY_PROPERTY(PROP_HAZE_KEYLIGHT_ALTITUDE, float, setHazeKeyLightAltitude); @@ -177,6 +186,7 @@ bool HazePropertyGroup::decodeFromEditPacket(EntityPropertyFlags& propertyFlags, DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_BACKGROUND_BLEND, HazeBackgroundBlend); + DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_ATTENUATE_KEYLIGHT, HazeAttenuateKeyLight); DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_KEYLIGHT_RANGE, HazeKeyLightRange); DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_KEYLIGHT_ALTITUDE, HazeKeyLightAltitude); @@ -198,6 +208,7 @@ void HazePropertyGroup::markAllChanged() { _hazeBackgroundBlendChanged = true; + _hazeAttenuateKeyLightChanged = true; _hazeKeyLightRangeChanged = true; _hazeKeyLightAltitudeChanged = true; } @@ -215,6 +226,7 @@ EntityPropertyFlags HazePropertyGroup::getChangedProperties() const { CHECK_PROPERTY_CHANGE(PROP_HAZE_BACKGROUND_BLEND, hazeBackgroundBlend); + CHECK_PROPERTY_CHANGE(PROP_HAZE_ATTENUATE_KEYLIGHT, hazeAttenuateKeyLight); CHECK_PROPERTY_CHANGE(PROP_HAZE_KEYLIGHT_RANGE, hazeKeyLightRange); CHECK_PROPERTY_CHANGE(PROP_HAZE_KEYLIGHT_ALTITUDE, hazeKeyLightAltitude); @@ -232,6 +244,7 @@ void HazePropertyGroup::getProperties(EntityItemProperties& properties) const { COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Haze, HazeBackgroundBlend, getHazeBackgroundBlend); + COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Haze, HazeAttenuateKeyLight, getHazeAttenuateKeyLight); COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Haze, HazeKeyLightRange, getHazeKeyLightRange); COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Haze, HazeKeyLightAltitude, getHazeKeyLightAltitude); } @@ -249,6 +262,7 @@ bool HazePropertyGroup::setProperties(const EntityItemProperties& properties) { SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Haze, HazeBackgroundBlend, hazeBackgroundBlend, setHazeBackgroundBlend); + SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Haze, HazeAttenuateKeyLight, hazeAttenuateKeyLight, setHazeAttenuateKeyLight); SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Haze, HazeKeyLightRange, hazeKeyLightRange, setHazeKeyLightRange); SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Haze, HazeKeyLightAltitude, hazeKeyLightAltitude, setHazeKeyLightAltitude); @@ -268,6 +282,7 @@ EntityPropertyFlags HazePropertyGroup::getEntityProperties(EncodeBitstreamParams requestedProperties += PROP_HAZE_BACKGROUND_BLEND; + requestedProperties += PROP_HAZE_ATTENUATE_KEYLIGHT; requestedProperties += PROP_HAZE_KEYLIGHT_RANGE; requestedProperties += PROP_HAZE_KEYLIGHT_ALTITUDE; @@ -294,6 +309,7 @@ void HazePropertyGroup::appendSubclassData(OctreePacketData* packetData, EncodeB APPEND_ENTITY_PROPERTY(PROP_HAZE_BACKGROUND_BLEND, getHazeBackgroundBlend()); + APPEND_ENTITY_PROPERTY(PROP_HAZE_ATTENUATE_KEYLIGHT, getHazeAttenuateKeyLight()); APPEND_ENTITY_PROPERTY(PROP_HAZE_KEYLIGHT_RANGE, getHazeKeyLightRange()); APPEND_ENTITY_PROPERTY(PROP_HAZE_KEYLIGHT_ALTITUDE, getHazeKeyLightAltitude()); } @@ -316,6 +332,7 @@ int HazePropertyGroup::readEntitySubclassDataFromBuffer(const unsigned char* dat READ_ENTITY_PROPERTY(PROP_HAZE_BACKGROUND_BLEND, float, setHazeBackgroundBlend); + READ_ENTITY_PROPERTY(PROP_HAZE_ATTENUATE_KEYLIGHT, bool, setHazeAttenuateKeyLight); READ_ENTITY_PROPERTY(PROP_HAZE_KEYLIGHT_RANGE, float, setHazeKeyLightRange); READ_ENTITY_PROPERTY(PROP_HAZE_KEYLIGHT_ALTITUDE, float, setHazeKeyLightAltitude); diff --git a/libraries/entities/src/HazePropertyGroup.h b/libraries/entities/src/HazePropertyGroup.h index 982e857010..cad1647d24 100644 --- a/libraries/entities/src/HazePropertyGroup.h +++ b/libraries/entities/src/HazePropertyGroup.h @@ -101,6 +101,7 @@ public: DEFINE_PROPERTY_REF(PROP_HAZE_BACKGROUND_BLEND, HazeBackgroundBlend, hazeBackgroundBlend, float, DEFAULT_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, DEFAULT_HAZE_KEYLIGHT_RANGE); DEFINE_PROPERTY_REF(PROP_HAZE_KEYLIGHT_ALTITUDE, HazeKeyLightAltitude, hazeKeyLightAltitude, float, DEFAULT_HAZE_KEYLIGHT_ALTITUDE); }; diff --git a/libraries/entities/src/ZoneEntityItem.cpp b/libraries/entities/src/ZoneEntityItem.cpp index 3e6c2d66ea..4a14d6c9be 100644 --- a/libraries/entities/src/ZoneEntityItem.cpp +++ b/libraries/entities/src/ZoneEntityItem.cpp @@ -392,6 +392,14 @@ float ZoneEntityItem::getHazeBackgroundBlend()const{ return _hazeBackgroundBlend; } +void ZoneEntityItem::setHazeAttenuateKeyLight(const bool hazeAttenuateKeyLight) { + _hazeAttenuateKeyLight = hazeAttenuateKeyLight; +} + +bool ZoneEntityItem::getHazeAttenuateKeyLight()const { + return _hazeAttenuateKeyLight; +} + void ZoneEntityItem::setHazeKeyLightRange(const float hazeKeyLightRange){ _hazeKeyLightRange = hazeKeyLightRange; _hazePropertiesChanged = true; diff --git a/libraries/entities/src/ZoneEntityItem.h b/libraries/entities/src/ZoneEntityItem.h index 8f64cc79c6..352f98f5a2 100644 --- a/libraries/entities/src/ZoneEntityItem.h +++ b/libraries/entities/src/ZoneEntityItem.h @@ -90,6 +90,8 @@ public: 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); @@ -154,6 +156,7 @@ protected: float _hazeBackgroundBlend{ HazePropertyGroup::DEFAULT_HAZE_BACKGROUND_BLEND }; + float _hazeAttenuateKeyLight{ false }; float _hazeKeyLightRange{ HazePropertyGroup::DEFAULT_HAZE_KEYLIGHT_RANGE }; float _hazeKeyLightAltitude{ HazePropertyGroup::DEFAULT_HAZE_KEYLIGHT_ALTITUDE }; diff --git a/libraries/model/src/model/Haze.cpp b/libraries/model/src/model/Haze.cpp index e03c3e0f65..6cc9e2b965 100644 --- a/libraries/model/src/model/Haze.cpp +++ b/libraries/model/src/model/Haze.cpp @@ -100,13 +100,13 @@ void Haze::setAltitudeBased(const bool isAltitudeBased) { } } -void Haze::setDirectionaLightAttenuationActive(const bool isDirectionaLightAttenuationActive) { +void Haze::setHazeAttenuateKeyLight(const bool isHazeAttenuateKeyLight) { auto& params = _parametersBuffer.get(); - if (((params.hazeMode & HAZE_MODE_IS_DIRECTIONAL_LIGHT_ATTENUATED) == HAZE_MODE_IS_DIRECTIONAL_LIGHT_ATTENUATED ) && !isDirectionaLightAttenuationActive) { + if (((params.hazeMode & HAZE_MODE_IS_DIRECTIONAL_LIGHT_ATTENUATED) == HAZE_MODE_IS_DIRECTIONAL_LIGHT_ATTENUATED ) && !isHazeAttenuateKeyLight) { _parametersBuffer.edit().hazeMode &= ~HAZE_MODE_IS_DIRECTIONAL_LIGHT_ATTENUATED; } - else if (((params.hazeMode & HAZE_MODE_IS_DIRECTIONAL_LIGHT_ATTENUATED) != HAZE_MODE_IS_DIRECTIONAL_LIGHT_ATTENUATED) && isDirectionaLightAttenuationActive) { + else if (((params.hazeMode & HAZE_MODE_IS_DIRECTIONAL_LIGHT_ATTENUATED) != HAZE_MODE_IS_DIRECTIONAL_LIGHT_ATTENUATED) && isHazeAttenuateKeyLight) { _parametersBuffer.edit().hazeMode |= HAZE_MODE_IS_DIRECTIONAL_LIGHT_ATTENUATED; } } diff --git a/libraries/model/src/model/Haze.h b/libraries/model/src/model/Haze.h index 9ab4ec845f..55ee2c1a5a 100644 --- a/libraries/model/src/model/Haze.h +++ b/libraries/model/src/model/Haze.h @@ -72,7 +72,7 @@ namespace model { void setHazeActive(const bool isHazeActive); void setAltitudeBased(const bool isAltitudeBased); - void setDirectionaLightAttenuationActive(const bool isDirectionaLightAttenuationActive); + void setHazeAttenuateKeyLight(const bool isHazeAttenuateKeyLight); void setModulateColorActive(const bool isModulateColorActive); void setHazeRangeFactor(const float hazeRange); diff --git a/libraries/model/src/model/Stage.h b/libraries/model/src/model/Stage.h index e070404456..797c646e68 100644 --- a/libraries/model/src/model/Stage.h +++ b/libraries/model/src/model/Stage.h @@ -203,6 +203,8 @@ public: 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; } @@ -223,6 +225,7 @@ protected: float _hazeBackgroundBlend; + bool _hazeAttenuateKeyLight; float _hazeKeyLightRange; float _hazeKeyLightAltitude; diff --git a/libraries/render-utils/src/DrawHaze.cpp b/libraries/render-utils/src/DrawHaze.cpp index 0b8872ea9f..fb6428857e 100644 --- a/libraries/render-utils/src/DrawHaze.cpp +++ b/libraries/render-utils/src/DrawHaze.cpp @@ -60,8 +60,8 @@ void HazeConfig::setAltitudeBased(const bool active) { isAltitudeBased = active; } -void HazeConfig::setIsdirectionalLightAttenuationActive(const bool active) { - isDirectionalLightAttenuationActive = active; +void HazeConfig::setHazeAttenuateKeyLight(const bool active) { + isHazeAttenuateKeyLight = active; } void HazeConfig::setModulateColorActive(const bool active) { @@ -101,7 +101,7 @@ void MakeHaze::configure(const Config& config) { _haze->setHazeActive(config.isHazeActive); _haze->setAltitudeBased(config.isAltitudeBased); - _haze->setDirectionaLightAttenuationActive(config.isDirectionaLightAttenuationActive); + _haze->setHazeAttenuateKeyLight(config.isHazeAttenuateKeyLight); _haze->setModulateColorActive(config.isModulateColorActive); _haze->setHazeRangeFactor(model::convertHazeRangeToHazeRangeFactor(config.hazeRange_m)); diff --git a/libraries/render-utils/src/DrawHaze.h b/libraries/render-utils/src/DrawHaze.h index 4634df0147..ad740dd522 100644 --- a/libraries/render-utils/src/DrawHaze.h +++ b/libraries/render-utils/src/DrawHaze.h @@ -41,7 +41,7 @@ class MakeHazeConfig : public render::Job::Config { Q_PROPERTY(bool isHazeActive MEMBER isHazeActive WRITE setHazeActive NOTIFY dirty); Q_PROPERTY(bool isAltitudeBased MEMBER isAltitudeBased WRITE setAltitudeBased NOTIFY dirty); - Q_PROPERTY(bool isDirectionaLightAttenuationActive MEMBER isDirectionaLightAttenuationActive WRITE setDirectionaLightAttenuationActive NOTIFY dirty); + Q_PROPERTY(bool isHazeAttenuateKeyLight MEMBER isHazeAttenuateKeyLight WRITE setHazeAttenuateKeyLight NOTIFY dirty); Q_PROPERTY(bool isModulateColorActive MEMBER isModulateColorActive WRITE setModulateColorActive NOTIFY dirty); Q_PROPERTY(float hazeRange_m MEMBER hazeRange_m WRITE setHazeRange_m NOTIFY dirty); @@ -67,7 +67,7 @@ public: bool isHazeActive{ false }; bool isAltitudeBased{ false }; - bool isDirectionaLightAttenuationActive{ false }; + bool isHazeAttenuateKeyLight{ false }; bool isModulateColorActive{ false }; float hazeRange_m{ model::initialHazeRange_m }; @@ -91,7 +91,7 @@ public slots: void setHazeActive(const bool active) { isHazeActive = active; emit dirty(); } void setAltitudeBased(const bool active) { isAltitudeBased = active; emit dirty(); } - void setDirectionaLightAttenuationActive(const bool active) { isDirectionaLightAttenuationActive = active; emit dirty(); } + void setHazeAttenuateKeyLight(const bool active) { isHazeAttenuateKeyLight = active; emit dirty(); } void setModulateColorActive(const bool active) { isModulateColorActive = active; emit dirty(); } void setHazeRange_m(const float value) { hazeRange_m = value; emit dirty(); } @@ -137,7 +137,7 @@ public: bool isHazeActive{ false }; // Setting this to true will set haze to on bool isAltitudeBased{ false }; - bool isDirectionalLightAttenuationActive{ false }; + bool isHazeAttenuateKeyLight{ false }; bool isModulateColorActive{ false }; float hazeRange_m{ model::initialHazeRange_m }; @@ -161,7 +161,7 @@ public: void setHazeActive(const bool active); void setAltitudeBased(const bool active); - void setIsdirectionalLightAttenuationActive(const bool active); + void setHazeAttenuateKeyLight(const bool active); void setModulateColorActive(const bool active); void setHazeRange_m(const float value); diff --git a/libraries/render-utils/src/HazeStage.cpp b/libraries/render-utils/src/HazeStage.cpp index a883344e02..f2056b5fe5 100644 --- a/libraries/render-utils/src/HazeStage.cpp +++ b/libraries/render-utils/src/HazeStage.cpp @@ -28,7 +28,7 @@ void FetchHazeStage::configure(const Config& config) { _haze->setHazeActive(config.isHazeActive); _haze->setAltitudeBased(config.isAltitudeBased); - _haze->setDirectionaLightAttenuationActive(config.isDirectionaLightAttenuationActive); + _haze->setHazeAttenuateKeyLight(config.isHazeAttenuateKeyLight); _haze->setModulateColorActive(config.isModulateColorActive); _haze->setHazeRangeFactor(model::convertHazeRangeToHazeRangeFactor(config.hazeRange_m)); diff --git a/libraries/render-utils/src/HazeStage.h b/libraries/render-utils/src/HazeStage.h index 26d7cb2abb..e6ba8a52f1 100644 --- a/libraries/render-utils/src/HazeStage.h +++ b/libraries/render-utils/src/HazeStage.h @@ -95,7 +95,7 @@ class FetchHazeConfig : public render::Job::Config { Q_PROPERTY(bool isHazeActive MEMBER isHazeActive WRITE setHazeActive NOTIFY dirty); Q_PROPERTY(bool isAltitudeBased MEMBER isAltitudeBased WRITE setAltitudeBased NOTIFY dirty); - Q_PROPERTY(bool isDirectionaLightAttenuationActive MEMBER isDirectionaLightAttenuationActive WRITE setDirectionaLightAttenuationActive NOTIFY dirty); + Q_PROPERTY(bool isHazeAttenuateKeyLight MEMBER isHazeAttenuateKeyLight WRITE setHazeAttenuateKeyLight NOTIFY dirty); Q_PROPERTY(bool isModulateColorActive MEMBER isModulateColorActive WRITE setModulateColorActive NOTIFY dirty); Q_PROPERTY(float hazeRange_m MEMBER hazeRange_m WRITE setHazeRange_m NOTIFY dirty); @@ -121,7 +121,7 @@ public: bool isHazeActive{ false }; bool isAltitudeBased{ false }; - bool isDirectionaLightAttenuationActive{ false }; + bool isHazeAttenuateKeyLight{ false }; bool isModulateColorActive{ false }; float hazeRange_m{ model::initialHazeRange_m }; @@ -145,7 +145,7 @@ public slots: void setHazeActive(const bool active) { isHazeActive = active; emit dirty(); } void setAltitudeBased(const bool active) { isAltitudeBased = active; emit dirty(); } - void setDirectionaLightAttenuationActive(const bool active) { isDirectionaLightAttenuationActive = active; emit dirty(); } + void setHazeAttenuateKeyLight(const bool active) { isHazeAttenuateKeyLight = active; emit dirty(); } void setModulateColorActive(const bool active) { isModulateColorActive = active; emit dirty(); } void setHazeRange_m(const float value) { hazeRange_m = value; emit dirty(); } diff --git a/libraries/script-engine/src/SceneScriptingInterface.cpp b/libraries/script-engine/src/SceneScriptingInterface.cpp index 096cd58ab6..1c2c38c53c 100644 --- a/libraries/script-engine/src/SceneScriptingInterface.cpp +++ b/libraries/script-engine/src/SceneScriptingInterface.cpp @@ -194,6 +194,12 @@ 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); } diff --git a/libraries/script-engine/src/SceneScriptingInterface.h b/libraries/script-engine/src/SceneScriptingInterface.h index d0ff6b32b9..3be496fce5 100644 --- a/libraries/script-engine/src/SceneScriptingInterface.h +++ b/libraries/script-engine/src/SceneScriptingInterface.h @@ -149,6 +149,9 @@ namespace SceneScripting { void setHazeBackgroundBlend(float value); float getHazeBackgroundBlend() const; + Q_PROPERTY(float 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; diff --git a/scripts/system/html/entityProperties.html b/scripts/system/html/entityProperties.html index 7b4959f088..f7970b969c 100644 --- a/scripts/system/html/entityProperties.html +++ b/scripts/system/html/entityProperties.html @@ -596,8 +596,12 @@
+
+ + +
-
diff --git a/scripts/system/html/js/entityProperties.js b/scripts/system/html/js/entityProperties.js index 5eda294eec..7a88bf61de 100644 --- a/scripts/system/html/js/entityProperties.js +++ b/scripts/system/html/js/entityProperties.js @@ -674,6 +674,7 @@ function loaded() { var elZoneHazeAltitude = document.getElementById("property-zone-haze-altitude"); var elZoneHazeBaseRef = document.getElementById("property-zone-haze-altitude-base"); + var elZoneHazeAttenuateKeyLight = document.getElementById("property-zone-haze-attenuate-keylight"); var elZoneHazeKeyLightRange = document.getElementById("property-zone-haze-keylight-range"); var elZoneHazeKeyLightAltitude = document.getElementById("property-zone-haze-keylight-altitude"); @@ -1043,6 +1044,7 @@ function loaded() { elZoneHazeBackgroundBlend.value = properties.haze.hazeBackgroundBlend.toFixed(2); + elZoneHazeAttenuateKeyLight.checked = properties.haze.hazeAttenuateKeyLight; elZoneHazeKeyLightRange.value = properties.haze.hazeKeyLightRange.toFixed(0); elZoneHazeKeyLightAltitude.value = properties.haze.hazeKeyLightAltitude.toFixed(0); @@ -1500,6 +1502,7 @@ function loaded() { elZoneHazeBackgroundBlend.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('haze', 'hazeBackgroundBlend')); + elZoneHazeAttenuateKeyLight.addEventListener('change', createEmitGroupCheckedPropertyUpdateFunction('haze', 'hazeAttenuateKeyLight')); elZoneHazeKeyLightRange.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('haze', 'hazeKeyLightRange')); elZoneHazeKeyLightAltitude.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('haze', 'hazeKeyLightAltitude')); From 991875706114a50b895206999e1306b31e0341e3 Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Fri, 6 Oct 2017 11:43:57 -0700 Subject: [PATCH 64/94] Initial work on adding keylight direction. --- libraries/render-utils/src/DrawHaze.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libraries/render-utils/src/DrawHaze.cpp b/libraries/render-utils/src/DrawHaze.cpp index fb6428857e..16f5ddc045 100644 --- a/libraries/render-utils/src/DrawHaze.cpp +++ b/libraries/render-utils/src/DrawHaze.cpp @@ -119,9 +119,9 @@ void MakeHaze::run(const render::RenderContextPointer& renderContext, model::Haz const int HazeEffect_ParamsSlot = 0; const int HazeEffect_TransformBufferSlot = 1; - -const int HazeEffect_LightingMapSlot = 2; +const int HazeEffect_ColorMapSlot = 2; const int HazeEffect_LinearDepthMapSlot = 3; +const int HazeEffect_LightingMapSlot = 4; void DrawHaze::configure(const Config& config) { } @@ -155,7 +155,7 @@ void DrawHaze::run(const render::RenderContextPointer& renderContext, const Inpu gpu::Shader::BindingSet slotBindings; slotBindings.insert(gpu::Shader::Binding(std::string("hazeBuffer"), HazeEffect_ParamsSlot)); slotBindings.insert(gpu::Shader::Binding(std::string("deferredFrameTransformBuffer"), HazeEffect_TransformBufferSlot)); - slotBindings.insert(gpu::Shader::Binding(std::string("colorMap"), HazeEffect_LightingMapSlot)); + slotBindings.insert(gpu::Shader::Binding(std::string("colorMap"), HazeEffect_ColorMapSlot)); slotBindings.insert(gpu::Shader::Binding(std::string("linearDepthMap"), HazeEffect_LinearDepthMapSlot)); gpu::Shader::makeProgram(*program, slotBindings); @@ -183,7 +183,7 @@ void DrawHaze::run(const render::RenderContextPointer& renderContext, const Inpu batch.setUniformBuffer(HazeEffect_TransformBufferSlot, transformBuffer->getFrameTransformBuffer()); - batch.setResourceTexture(HazeEffect_LightingMapSlot, inputBuffer); + batch.setResourceTexture(HazeEffect_ColorMapSlot, inputBuffer); batch.setResourceTexture(HazeEffect_LinearDepthMapSlot, depthBuffer); batch.draw(gpu::TRIANGLE_STRIP, 4); From 47a6f2d7c99b705085f933fbb8995b6ad4b1ae48 Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Fri, 6 Oct 2017 12:01:15 -0700 Subject: [PATCH 65/94] Initial work on adding keylight direction. --- libraries/render-utils/src/DrawHaze.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/libraries/render-utils/src/DrawHaze.cpp b/libraries/render-utils/src/DrawHaze.cpp index 16f5ddc045..ca7a59801c 100644 --- a/libraries/render-utils/src/DrawHaze.cpp +++ b/libraries/render-utils/src/DrawHaze.cpp @@ -17,6 +17,7 @@ #include "StencilMaskPass.h" #include "FramebufferCache.h" #include "HazeStage.h" +#include "LightStage.h" #include "Haze_frag.h" @@ -157,6 +158,7 @@ void DrawHaze::run(const render::RenderContextPointer& renderContext, const Inpu slotBindings.insert(gpu::Shader::Binding(std::string("deferredFrameTransformBuffer"), HazeEffect_TransformBufferSlot)); slotBindings.insert(gpu::Shader::Binding(std::string("colorMap"), HazeEffect_ColorMapSlot)); slotBindings.insert(gpu::Shader::Binding(std::string("linearDepthMap"), HazeEffect_LinearDepthMapSlot)); + slotBindings.insert(gpu::Shader::Binding(std::string("lights"), HazeEffect_LightingMapSlot)); gpu::Shader::makeProgram(*program, slotBindings); _hazePipeline = gpu::PipelinePointer(gpu::Pipeline::create(program, state)); @@ -183,6 +185,15 @@ void DrawHaze::run(const render::RenderContextPointer& renderContext, const Inpu batch.setUniformBuffer(HazeEffect_TransformBufferSlot, transformBuffer->getFrameTransformBuffer()); + auto lightStage = args->_scene->getStage(); + if (lightStage && lightStage->_currentFrame._sunLights.size() > 0) { + model::LightPointer keyLight; + keyLight = lightStage->getLight(lightStage->_currentFrame._sunLights.front()); + if (keyLight != nullptr) { + batch.setUniformBuffer(HazeEffect_LightingMapSlot, keyLight->getLightSchemaBuffer()); + } + } + batch.setResourceTexture(HazeEffect_ColorMapSlot, inputBuffer); batch.setResourceTexture(HazeEffect_LinearDepthMapSlot, depthBuffer); From 8fad23aefde624ca18dc888684fae77820c720e9 Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Fri, 6 Oct 2017 12:49:43 -0700 Subject: [PATCH 66/94] Keylight working. --- libraries/render-utils/src/DrawHaze.cpp | 2 +- libraries/render-utils/src/Haze.slf | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/libraries/render-utils/src/DrawHaze.cpp b/libraries/render-utils/src/DrawHaze.cpp index ca7a59801c..9001acc4ed 100644 --- a/libraries/render-utils/src/DrawHaze.cpp +++ b/libraries/render-utils/src/DrawHaze.cpp @@ -158,7 +158,7 @@ void DrawHaze::run(const render::RenderContextPointer& renderContext, const Inpu slotBindings.insert(gpu::Shader::Binding(std::string("deferredFrameTransformBuffer"), HazeEffect_TransformBufferSlot)); slotBindings.insert(gpu::Shader::Binding(std::string("colorMap"), HazeEffect_ColorMapSlot)); slotBindings.insert(gpu::Shader::Binding(std::string("linearDepthMap"), HazeEffect_LinearDepthMapSlot)); - slotBindings.insert(gpu::Shader::Binding(std::string("lights"), HazeEffect_LightingMapSlot)); + slotBindings.insert(gpu::Shader::Binding(std::string("lightBuffer"), HazeEffect_LightingMapSlot)); gpu::Shader::makeProgram(*program, slotBindings); _hazePipeline = gpu::PipelinePointer(gpu::Pipeline::create(program, state)); diff --git a/libraries/render-utils/src/Haze.slf b/libraries/render-utils/src/Haze.slf index b896afde92..58e15f9ae6 100644 --- a/libraries/render-utils/src/Haze.slf +++ b/libraries/render-utils/src/Haze.slf @@ -58,8 +58,7 @@ void main(void) { vec3 eyeFragDir = normalize(worldFragPos.xyz); Light light = getLight(); - //vec3 lightDirection = getLightDirection(light); - vec3 lightDirection = normalize(vec3(-1.0, -1.0, -1.0)); + vec3 lightDirection = getLightDirection(light); float directionalLightComponent = max(0.0, dot(eyeFragDir, -lightDirection)); float power = min(1.0, pow(directionalLightComponent, hazeParams.directionalLightBlend)); From bfdd489682864ec7ff9c207d72a2d56b3a74c4d7 Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Fri, 6 Oct 2017 13:18:12 -0700 Subject: [PATCH 67/94] Fixed color selector bug. --- scripts/system/html/js/entityProperties.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/system/html/js/entityProperties.js b/scripts/system/html/js/entityProperties.js index 7a88bf61de..ae13a10076 100644 --- a/scripts/system/html/js/entityProperties.js +++ b/scripts/system/html/js/entityProperties.js @@ -1459,7 +1459,7 @@ function loaded() { onSubmit: function(hsb, hex, rgb, el) { $(el).css('background-color', '#' + hex); $(el).colpickHide(); - emitColorPropertyUpdate('color', rgb.r, rgb.g, rgb.b, 'hazeBlendInColor'); + emitColorPropertyUpdate('hazeBlendInColor', rgb.r, rgb.g, rgb.b, 'haze'); } })); var zoneHazeBlendInColorChangeFunction = createEmitGroupColorPropertyUpdateFunction('haze', 'hazeBlendInColor', @@ -1484,7 +1484,7 @@ function loaded() { onSubmit: function(hsb, hex, rgb, el) { $(el).css('background-color', '#' + hex); $(el).colpickHide(); - emitColorPropertyUpdate('color', rgb.r, rgb.g, rgb.b, 'hazeBlendOutColor'); + emitColorPropertyUpdate('hazeBlendOutColor', rgb.r, rgb.g, rgb.b, 'haze'); } })); var zoneHazeBlendOutColorChangeFunction = createEmitGroupColorPropertyUpdateFunction('haze', 'hazeBlendOutColor', From e02876f1eac4d1e37f2f0f13009ed6436d207b0e Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Fri, 6 Oct 2017 17:24:20 -0700 Subject: [PATCH 68/94] Zone position/direction sent to haze uniform. --- .../src/RenderableZoneEntityItem.cpp | 3 + libraries/model/src/model/Haze.cpp | 93 +++++++++++-------- libraries/model/src/model/Haze.h | 17 +++- libraries/render-utils/src/Haze.slh | 7 +- 4 files changed, 75 insertions(+), 45 deletions(-) diff --git a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp index 5089d5a6ea..d0fc17e3f6 100644 --- a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp @@ -356,6 +356,9 @@ void ZoneEntityRenderer::updateHazeFromEntity(const TypedEntityPointer& entity) haze->setHazeAttenuateKeyLight(_hazeProperties.getHazeAttenuateKeyLight()); haze->setHazeKeyLightRangeFactor(model::convertHazeRangeToHazeRangeFactor(_hazeProperties.getHazeKeyLightRange())); haze->setHazeKeyLightAltitudeFactor(model::convertHazeAltitudeToHazeAltitudeFactor(_hazeProperties.getHazeKeyLightAltitude())); + + haze->setZoneOrientation(_lastRotation); + haze->setZonePosition(_lastPosition); } void ZoneEntityRenderer::updateKeyBackgroundFromEntity(const TypedEntityPointer& entity) { diff --git a/libraries/model/src/model/Haze.cpp b/libraries/model/src/model/Haze.cpp index 6cc9e2b965..9a3e59dfa7 100644 --- a/libraries/model/src/model/Haze.cpp +++ b/libraries/model/src/model/Haze.cpp @@ -17,7 +17,7 @@ using namespace model; Haze::Haze() { Parameters parameters; - _parametersBuffer = gpu::BufferView(std::make_shared(sizeof(Parameters), (const gpu::Byte*) ¶meters)); + _hazeParametersBuffer = gpu::BufferView(std::make_shared(sizeof(Parameters), (const gpu::Byte*) ¶meters)); } enum HazeModes { @@ -31,141 +31,158 @@ enum HazeModes { // This is separate for each colour. // The colour value is converted from [0.0 .. 1.0] to [5.0 .. 3000.0] void Haze::setHazeColor(const glm::vec3 hazeColor) { - auto& params = _parametersBuffer.get(); + auto& params = _hazeParametersBuffer.get(); if (params.hazeColor.r != hazeColor.r) { - _parametersBuffer.edit().hazeColor.r = hazeColor.r; + _hazeParametersBuffer.edit().hazeColor.r = hazeColor.r; float range = hazeColor.r * 2995.0f + 5.0f; float factor = convertHazeRangeToHazeRangeFactor(range); - _parametersBuffer.edit().colorModulationFactor.r = factor; + _hazeParametersBuffer.edit().colorModulationFactor.r = factor; } if (params.hazeColor.g != hazeColor.g) { - _parametersBuffer.edit().hazeColor.g = hazeColor.g; + _hazeParametersBuffer.edit().hazeColor.g = hazeColor.g; float range = hazeColor.g * 2995.0f + 5.0f; float factor = convertHazeRangeToHazeRangeFactor(range); - _parametersBuffer.edit().colorModulationFactor.g = factor; + _hazeParametersBuffer.edit().colorModulationFactor.g = factor; } if (params.hazeColor.b != hazeColor.b) { - _parametersBuffer.edit().hazeColor.b = hazeColor.b; + _hazeParametersBuffer.edit().hazeColor.b = hazeColor.b; float range = hazeColor.b * 2995.0f + 5.0f; float factor = convertHazeRangeToHazeRangeFactor(range); - _parametersBuffer.edit().colorModulationFactor.b = factor; + _hazeParametersBuffer.edit().colorModulationFactor.b = factor; } } void Haze::setDirectionalLightBlend(const float hazeDirectionalLightBlend) { - auto& params = _parametersBuffer.get(); + auto& params = _hazeParametersBuffer.get(); if (params.directionalLightBlend != hazeDirectionalLightBlend) { - _parametersBuffer.edit().directionalLightBlend = hazeDirectionalLightBlend; + _hazeParametersBuffer.edit().directionalLightBlend = hazeDirectionalLightBlend; } } void Haze::setDirectionalLightColor(const glm::vec3 hazeDirectionalLightColor) { - auto& params = _parametersBuffer.get(); + auto& params = _hazeParametersBuffer.get(); if (params.directionalLightColor.r != hazeDirectionalLightColor.r) { - _parametersBuffer.edit().directionalLightColor.r = hazeDirectionalLightColor.r; + _hazeParametersBuffer.edit().directionalLightColor.r = hazeDirectionalLightColor.r; } if (params.directionalLightColor.g != hazeDirectionalLightColor.g) { - _parametersBuffer.edit().directionalLightColor.g = hazeDirectionalLightColor.g; + _hazeParametersBuffer.edit().directionalLightColor.g = hazeDirectionalLightColor.g; } if (params.directionalLightColor.b != hazeDirectionalLightColor.b) { - _parametersBuffer.edit().directionalLightColor.b = hazeDirectionalLightColor.b; + _hazeParametersBuffer.edit().directionalLightColor.b = hazeDirectionalLightColor.b; } } void Haze::setHazeActive(const bool isHazeActive) { - auto& params = _parametersBuffer.get(); + auto& params = _hazeParametersBuffer.get(); if (((params.hazeMode & HAZE_MODE_IS_ACTIVE) == HAZE_MODE_IS_ACTIVE )&& !isHazeActive) { - _parametersBuffer.edit().hazeMode &= ~HAZE_MODE_IS_ACTIVE; + _hazeParametersBuffer.edit().hazeMode &= ~HAZE_MODE_IS_ACTIVE; } else if (((params.hazeMode & HAZE_MODE_IS_ACTIVE) != HAZE_MODE_IS_ACTIVE) && isHazeActive) { - _parametersBuffer.edit().hazeMode |= HAZE_MODE_IS_ACTIVE; + _hazeParametersBuffer.edit().hazeMode |= HAZE_MODE_IS_ACTIVE; } } void Haze::setAltitudeBased(const bool isAltitudeBased) { - auto& params = _parametersBuffer.get(); + auto& params = _hazeParametersBuffer.get(); if (((params.hazeMode & HAZE_MODE_IS_ALTITUDE_BASED) == HAZE_MODE_IS_ALTITUDE_BASED )&& !isAltitudeBased) { - _parametersBuffer.edit().hazeMode &= ~HAZE_MODE_IS_ALTITUDE_BASED; + _hazeParametersBuffer.edit().hazeMode &= ~HAZE_MODE_IS_ALTITUDE_BASED; } else if (((params.hazeMode & HAZE_MODE_IS_ALTITUDE_BASED) != HAZE_MODE_IS_ALTITUDE_BASED) && isAltitudeBased) { - _parametersBuffer.edit().hazeMode |= HAZE_MODE_IS_ALTITUDE_BASED; + _hazeParametersBuffer.edit().hazeMode |= HAZE_MODE_IS_ALTITUDE_BASED; } } void Haze::setHazeAttenuateKeyLight(const bool isHazeAttenuateKeyLight) { - auto& params = _parametersBuffer.get(); + auto& params = _hazeParametersBuffer.get(); if (((params.hazeMode & HAZE_MODE_IS_DIRECTIONAL_LIGHT_ATTENUATED) == HAZE_MODE_IS_DIRECTIONAL_LIGHT_ATTENUATED ) && !isHazeAttenuateKeyLight) { - _parametersBuffer.edit().hazeMode &= ~HAZE_MODE_IS_DIRECTIONAL_LIGHT_ATTENUATED; + _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) { - _parametersBuffer.edit().hazeMode |= HAZE_MODE_IS_DIRECTIONAL_LIGHT_ATTENUATED; + _hazeParametersBuffer.edit().hazeMode |= HAZE_MODE_IS_DIRECTIONAL_LIGHT_ATTENUATED; } } void Haze::setModulateColorActive(const bool isModulateColorActive) { - auto& params = _parametersBuffer.get(); + auto& params = _hazeParametersBuffer.get(); if (((params.hazeMode & HAZE_MODE_IS_MODULATE_COLOR) == HAZE_MODE_IS_MODULATE_COLOR ) && !isModulateColorActive) { - _parametersBuffer.edit().hazeMode &= ~HAZE_MODE_IS_MODULATE_COLOR; + _hazeParametersBuffer.edit().hazeMode &= ~HAZE_MODE_IS_MODULATE_COLOR; } else if (((params.hazeMode & HAZE_MODE_IS_MODULATE_COLOR) != HAZE_MODE_IS_MODULATE_COLOR) && isModulateColorActive) { - _parametersBuffer.edit().hazeMode |= HAZE_MODE_IS_MODULATE_COLOR; + _hazeParametersBuffer.edit().hazeMode |= HAZE_MODE_IS_MODULATE_COLOR; } } void Haze::setHazeRangeFactor(const float hazeRangeFactor) { - auto& params = _parametersBuffer.get(); + auto& params = _hazeParametersBuffer.get(); if (params.hazeRangeFactor != hazeRangeFactor) { - _parametersBuffer.edit().hazeRangeFactor = hazeRangeFactor; + _hazeParametersBuffer.edit().hazeRangeFactor = hazeRangeFactor; } } void Haze::setHazeAltitudeFactor(const float hazeAltitudeFactor) { - auto& params = _parametersBuffer.get(); + auto& params = _hazeParametersBuffer.get(); if (params.hazeAltitudeFactor != hazeAltitudeFactor) { - _parametersBuffer.edit().hazeAltitudeFactor = hazeAltitudeFactor; + _hazeParametersBuffer.edit().hazeAltitudeFactor = hazeAltitudeFactor; } } void Haze::setHazeKeyLightRangeFactor(const float hazeKeyLightRangeFactor) { - auto& params = _parametersBuffer.get(); + auto& params = _hazeParametersBuffer.get(); if (params.hazeKeyLightRangeFactor != hazeKeyLightRangeFactor) { - _parametersBuffer.edit().hazeKeyLightRangeFactor = hazeKeyLightRangeFactor; + _hazeParametersBuffer.edit().hazeKeyLightRangeFactor = hazeKeyLightRangeFactor; } } void Haze::setHazeKeyLightAltitudeFactor(const float hazeKeyLightAltitudeFactor) { - auto& params = _parametersBuffer.get(); + auto& params = _hazeParametersBuffer.get(); if (params.hazeKeyLightAltitudeFactor != hazeKeyLightAltitudeFactor) { - _parametersBuffer.edit().hazeKeyLightAltitudeFactor = hazeKeyLightAltitudeFactor; + _hazeParametersBuffer.edit().hazeKeyLightAltitudeFactor = hazeKeyLightAltitudeFactor; } } void Haze::setHazeBaseReference(const float hazeBaseReference) { - auto& params = _parametersBuffer.get(); + auto& params = _hazeParametersBuffer.get(); if (params.hazeBaseReference != hazeBaseReference) { - _parametersBuffer.edit().hazeBaseReference = hazeBaseReference; + _hazeParametersBuffer.edit().hazeBaseReference = hazeBaseReference; } } void Haze::setHazeBackgroundBlendValue(const float hazeBackgroundBlendValue) { - auto& params = _parametersBuffer.get(); + auto& params = _hazeParametersBuffer.get(); if (params.hazeBackgroundBlendValue != hazeBackgroundBlendValue) { - _parametersBuffer.edit().hazeBackgroundBlendValue = hazeBackgroundBlendValue; + _hazeParametersBuffer.edit().hazeBackgroundBlendValue = hazeBackgroundBlendValue; + } +} + +void Haze::setZoneOrientation(const glm::quat& zoneOrientation) { + auto& params = _hazeParametersBuffer.get(); + + glm::vec3 zoneDirection = zoneOrientation * glm::vec3(0.0f, 0.0f, -1.0f); + if (params.zoneDirection == zoneDirection) { + _hazeParametersBuffer.edit().zoneDirection = zoneDirection; + } +} + +void Haze::setZonePosition(const glm::vec3& zonePosition) { + auto& params = _hazeParametersBuffer.get(); + + if (params.zonePosition != zonePosition) { + _hazeParametersBuffer.edit().zonePosition = zonePosition; } } diff --git a/libraries/model/src/model/Haze.h b/libraries/model/src/model/Haze.h index 55ee2c1a5a..880b1c6f8c 100644 --- a/libraries/model/src/model/Haze.h +++ b/libraries/model/src/model/Haze.h @@ -12,6 +12,7 @@ #define hifi_model_Haze_h #include +#include "Transform.h" #include "NumericalConstants.h" namespace model { @@ -83,7 +84,10 @@ namespace model { void setHazeBackgroundBlendValue(const float hazeBackgroundBlendValue); - UniformBufferView getHazeParametersBuffer() const { return _parametersBuffer; } + void setZoneOrientation(const glm::quat& zoneOrientation); + void setZonePosition(const glm::vec3& zonePosition); + + UniformBufferView getHazeParametersBuffer() const { return _hazeParametersBuffer; } protected: class Parameters { @@ -100,6 +104,12 @@ namespace model { // bit 1 - set to add the effect of altitude to the haze attenuation // bit 2 - set to activate directional light attenuation mode + glm::vec3 zoneDirection; + + // Amount of background (skybox) to display, overriding the haze effect for the background + float hazeBackgroundBlendValue{ initialHazeBackgroundBlendValue }; + glm::vec3 zonePosition; + // The haze attenuation exponents used by both fragment and directional light attenuation float hazeRangeFactor{ convertHazeRangeToHazeRangeFactor(initialHazeRange_m) }; float hazeAltitudeFactor{ convertHazeAltitudeToHazeAltitudeFactor(initialHazeAltitude_m) }; @@ -107,13 +117,10 @@ namespace model { float hazeKeyLightRangeFactor{ convertHazeRangeToHazeRangeFactor(initialHazeKeyLightRange_m) }; float hazeKeyLightAltitudeFactor{ convertHazeAltitudeToHazeAltitudeFactor(initialHazeKeyLightAltitude_m) }; - // Amount of background (skybox) to display, overriding the haze effect for the background - float hazeBackgroundBlendValue{ initialHazeBackgroundBlendValue }; - Parameters() {} }; - UniformBufferView _parametersBuffer; + UniformBufferView _hazeParametersBuffer; }; using HazePointer = std::shared_ptr; diff --git a/libraries/render-utils/src/Haze.slh b/libraries/render-utils/src/Haze.slh index 624a859de7..42e561f2fe 100644 --- a/libraries/render-utils/src/Haze.slh +++ b/libraries/render-utils/src/Haze.slh @@ -25,13 +25,16 @@ struct HazeParams { vec3 colorModulationFactor; int hazeMode; + vec3 zoneDirection; + float backgroundBlendValue; + + vec3 zonePosition; + float hazeRangeFactor; float hazeAltitudeFactor; float hazeRangeFactorKeyLight; float hazeAltitudeFactorKeyLight; - - float backgroundBlendValue; }; layout(std140) uniform hazeBuffer { From 7d5a887f436d60c970cc3e6db3590d20afaa539b Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Mon, 9 Oct 2017 17:25:19 -0700 Subject: [PATCH 69/94] Refactoring. --- interface/src/Application.cpp | 2 +- .../src/RenderableZoneEntityItem.cpp | 4 +- .../entities/src/EntityItemProperties.cpp | 2 +- libraries/entities/src/EntityPropertyFlags.h | 15 ++++--- libraries/entities/src/HazePropertyGroup.cpp | 17 +++++++ libraries/entities/src/HazePropertyGroup.h | 1 + libraries/entities/src/ZoneEntityItem.cpp | 44 ++++++++++++------- libraries/entities/src/ZoneEntityItem.h | 25 ++++++----- libraries/model/src/model/Haze.cpp | 28 +++++++----- libraries/model/src/model/Haze.h | 8 ++-- libraries/model/src/model/Stage.h | 3 ++ libraries/render-utils/src/DrawHaze.cpp | 5 +++ libraries/render-utils/src/DrawHaze.h | 5 +++ libraries/render-utils/src/Haze.slf | 10 ++++- libraries/render-utils/src/Haze.slh | 5 +-- libraries/render-utils/src/HazeStage.cpp | 1 + libraries/render-utils/src/HazeStage.h | 3 ++ .../render-utils/src/RenderDeferredTask.cpp | 1 - .../src/SceneScriptingInterface.cpp | 6 +++ .../src/SceneScriptingInterface.h | 12 ++++- scripts/system/html/entityProperties.html | 4 ++ scripts/system/html/js/entityProperties.js | 8 +++- 22 files changed, 146 insertions(+), 63 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 1c602c7363..0fc8c46cdc 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -433,7 +433,7 @@ public: // Don't actually crash in debug builds, in case this apparent deadlock is simply from // the developer actively debugging code #ifdef NDEBUG - ////deadlockDetectionCrash(); + deadlockDetectionCrash(); #endif } } diff --git a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp index d0fc17e3f6..3efe991baa 100644 --- a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp @@ -346,6 +346,7 @@ void ZoneEntityRenderer::updateHazeFromEntity(const TypedEntityPointer& entity) haze->setHazeColor(glm::vec3(hazeBlendInColor.red / 255.0, hazeBlendInColor.green / 255.0, hazeBlendInColor.blue / 255.0)); xColor hazeBlendOutColor = _hazeProperties.getHazeBlendOutColor(); haze->setDirectionalLightColor(glm::vec3(hazeBlendOutColor.red / 255.0, hazeBlendOutColor.green / 255.0, hazeBlendOutColor.blue / 255.0)); + haze->setHazeEnableLightBlend(_hazeProperties.getHazeEnableLightBlend()); haze->setDirectionalLightBlend(model::convertDirectionalLightAngleToPower(_hazeProperties.getHazeLightBlendAngle())); haze->setHazeAltitudeFactor(model::convertHazeAltitudeToHazeAltitudeFactor(_hazeProperties.getHazeAltitude())); @@ -357,8 +358,7 @@ void ZoneEntityRenderer::updateHazeFromEntity(const TypedEntityPointer& entity) haze->setHazeKeyLightRangeFactor(model::convertHazeRangeToHazeRangeFactor(_hazeProperties.getHazeKeyLightRange())); haze->setHazeKeyLightAltitudeFactor(model::convertHazeAltitudeToHazeAltitudeFactor(_hazeProperties.getHazeKeyLightAltitude())); - haze->setZoneOrientation(_lastRotation); - haze->setZonePosition(_lastPosition); + haze->setZoneTransform(entity->getTransform().getMatrix()); } void ZoneEntityRenderer::updateKeyBackgroundFromEntity(const TypedEntityPointer& entity) { diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp index fa11c61f56..3f87cb374b 100644 --- a/libraries/entities/src/EntityItemProperties.cpp +++ b/libraries/entities/src/EntityItemProperties.cpp @@ -1159,9 +1159,9 @@ void EntityItemProperties::entityPropertyFlagsFromScriptValue(const QScriptValue ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_RANGE, Haze, haze, HazeRange, hazeRange); ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_BLEND_IN_COLOR, Haze, haze, HazeBlendInColor, hazeBlendInColor); ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_BLEND_OUT_COLOR, Haze, haze, HazeBlendOutColor, hazeBlendOutColor); + ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_ENABLE_LIGHT_BLEND, Haze, haze, HazeEnableLightBlend, hazeEnableLightBlend); ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_LIGHT_BLEND_ANGLE, Haze, haze, HazeLightBlendAngle, hazeLightBlendAngle); - ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_ATTENUATE_KEYLIGHT, Haze, haze, HazeAttenuateKeyLight, hazeAttenuateKeyLight); ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_ALTITUDE, Haze, haze, HazeAltitude, hazeAltitude); ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_BASE_REF, Haze, haze, HazeBaseRef, hazeBaseRef); diff --git a/libraries/entities/src/EntityPropertyFlags.h b/libraries/entities/src/EntityPropertyFlags.h index ecc760e71f..6eded2148f 100644 --- a/libraries/entities/src/EntityPropertyFlags.h +++ b/libraries/entities/src/EntityPropertyFlags.h @@ -237,16 +237,17 @@ enum EntityPropertyList { PROP_HAZE_RANGE = PROP_INTENSITY, PROP_HAZE_BLEND_IN_COLOR = PROP_CUTOFF, PROP_HAZE_BLEND_OUT_COLOR = PROP_EXPONENT, - PROP_HAZE_LIGHT_BLEND_ANGLE = PROP_IS_SPOTLIGHT, + PROP_HAZE_ENABLE_LIGHT_BLEND = PROP_IS_SPOTLIGHT, + PROP_HAZE_LIGHT_BLEND_ANGLE = PROP_DIFFUSE_COLOR, - PROP_HAZE_ALTITUDE = PROP_DIFFUSE_COLOR, - PROP_HAZE_BASE_REF = PROP_AMBIENT_COLOR_UNUSED, + PROP_HAZE_ALTITUDE = PROP_AMBIENT_COLOR_UNUSED, + PROP_HAZE_BASE_REF = PROP_SPECULAR_COLOR_UNUSED, - PROP_HAZE_BACKGROUND_BLEND = PROP_SPECULAR_COLOR_UNUSED, + PROP_HAZE_BACKGROUND_BLEND = PROP_LINEAR_ATTENUATION_UNUSED, - PROP_HAZE_ATTENUATE_KEYLIGHT = PROP_LINEAR_ATTENUATION_UNUSED, - PROP_HAZE_KEYLIGHT_RANGE = PROP_QUADRATIC_ATTENUATION_UNUSED, - PROP_HAZE_KEYLIGHT_ALTITUDE = PROP_ANIMATION_FRAME_INDEX, + PROP_HAZE_ATTENUATE_KEYLIGHT = PROP_QUADRATIC_ATTENUATION_UNUSED, + PROP_HAZE_KEYLIGHT_RANGE = PROP_ANIMATION_FRAME_INDEX, + PROP_HAZE_KEYLIGHT_ALTITUDE = PROP_MODEL_URL, PROP_SKYBOX_COLOR = PROP_ANIMATION_URL, PROP_SKYBOX_URL = PROP_ANIMATION_FPS, diff --git a/libraries/entities/src/HazePropertyGroup.cpp b/libraries/entities/src/HazePropertyGroup.cpp index d6bc15805d..dae2e3c281 100644 --- a/libraries/entities/src/HazePropertyGroup.cpp +++ b/libraries/entities/src/HazePropertyGroup.cpp @@ -32,6 +32,7 @@ void HazePropertyGroup::copyToScriptValue(const EntityPropertyFlags& desiredProp COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_RANGE, Haze, haze, HazeRange, hazeRange); COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_BLEND_IN_COLOR, Haze, haze, HazeBlendInColor, hazeBlendInColor); COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_BLEND_OUT_COLOR, Haze, haze, HazeBlendOutColor, hazeBlendOutColor); + COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_ENABLE_LIGHT_BLEND, Haze, haze, HazeEnableLightBlend, hazeEnableLightBlend); COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_LIGHT_BLEND_ANGLE, Haze, haze, HazeLightBlendAngle, hazeLightBlendAngle); COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_ALTITUDE, Haze, haze, HazeAltitude, hazeAltitude); @@ -48,6 +49,7 @@ void HazePropertyGroup::copyFromScriptValue(const QScriptValue& object, bool& _d COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(haze, hazeRange, float, setHazeRange); COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(haze, hazeBlendInColor, xColor, setHazeBlendInColor); COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(haze, hazeBlendOutColor, xColor, setHazeBlendOutColor); + COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(haze, hazeEnableLightBlend, bool, setHazeEnableLightBlend); COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(haze, hazeLightBlendAngle, float, setHazeLightBlendAngle); COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(haze, hazeAltitude, float, setHazeAltitude); @@ -64,6 +66,7 @@ void HazePropertyGroup::merge(const HazePropertyGroup& other) { COPY_PROPERTY_IF_CHANGED(hazeRange); COPY_PROPERTY_IF_CHANGED(hazeBlendInColor); COPY_PROPERTY_IF_CHANGED(hazeBlendOutColor); + COPY_PROPERTY_IF_CHANGED(hazeEnableLightBlend); COPY_PROPERTY_IF_CHANGED(hazeLightBlendAngle); COPY_PROPERTY_IF_CHANGED(hazeAltitude); @@ -82,6 +85,7 @@ void HazePropertyGroup::debugDump() const { qCDebug(entities) << " _hazeRange:" << _hazeRange; qCDebug(entities) << " _hazeBlendInColor:" << _hazeBlendInColor; qCDebug(entities) << " _hazeBlendOutColor:" << _hazeBlendOutColor; + qCDebug(entities) << " _hazeEnableLightBlend:" << _hazeEnableLightBlend; qCDebug(entities) << " _hazeLightBlendAngle:" << _hazeLightBlendAngle; qCDebug(entities) << " _hazeAltitude:" << _hazeAltitude; @@ -104,6 +108,9 @@ void HazePropertyGroup::listChangedProperties(QList& out) { if (hazeBlendOutColorChanged()) { out << "haze-hazeBlendOutColor"; } + if (hazeEnableLightBlendChanged()) { + out << "haze-hazeEnableLightBlend"; + } if (hazeLightBlendAngleChanged()) { out << "haze-hazeLightBlendAngle"; } @@ -142,6 +149,7 @@ bool HazePropertyGroup::appendToEditPacket(OctreePacketData* packetData, APPEND_ENTITY_PROPERTY(PROP_HAZE_RANGE, getHazeRange()); APPEND_ENTITY_PROPERTY(PROP_HAZE_BLEND_IN_COLOR, getHazeBlendInColor()); APPEND_ENTITY_PROPERTY(PROP_HAZE_BLEND_OUT_COLOR, getHazeBlendOutColor()); + APPEND_ENTITY_PROPERTY(PROP_HAZE_ENABLE_LIGHT_BLEND, getHazeEnableLightBlend()); APPEND_ENTITY_PROPERTY(PROP_HAZE_LIGHT_BLEND_ANGLE, getHazeLightBlendAngle()); APPEND_ENTITY_PROPERTY(PROP_HAZE_ALTITUDE, getHazeAltitude()); @@ -165,6 +173,7 @@ bool HazePropertyGroup::decodeFromEditPacket(EntityPropertyFlags& propertyFlags, READ_ENTITY_PROPERTY(PROP_HAZE_RANGE, float, setHazeRange); READ_ENTITY_PROPERTY(PROP_HAZE_BLEND_IN_COLOR, xColor, setHazeBlendInColor); READ_ENTITY_PROPERTY(PROP_HAZE_BLEND_OUT_COLOR, xColor, setHazeBlendOutColor); + READ_ENTITY_PROPERTY(PROP_HAZE_ENABLE_LIGHT_BLEND, bool, setHazeEnableLightBlend); READ_ENTITY_PROPERTY(PROP_HAZE_LIGHT_BLEND_ANGLE, float, setHazeLightBlendAngle); READ_ENTITY_PROPERTY(PROP_HAZE_ALTITUDE, float, setHazeAltitude); @@ -179,6 +188,7 @@ bool HazePropertyGroup::decodeFromEditPacket(EntityPropertyFlags& propertyFlags, DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_RANGE, HazeRange); DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_BLEND_IN_COLOR, HazeBlendInColor); DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_BLEND_OUT_COLOR, HazeBlendOutColor); + DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_ENABLE_LIGHT_BLEND, HazeEnableLightBlend); DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_LIGHT_BLEND_ANGLE, HazeLightBlendAngle); DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_ALTITUDE, HazeAltitude); @@ -201,6 +211,7 @@ void HazePropertyGroup::markAllChanged() { _hazeRangeChanged = true; _hazeBlendInColorChanged = true; _hazeBlendOutColorChanged = true; + _hazeEnableLightBlendChanged = true; _hazeLightBlendAngleChanged = true; _hazeAltitudeChanged = true; @@ -219,6 +230,7 @@ EntityPropertyFlags HazePropertyGroup::getChangedProperties() const { CHECK_PROPERTY_CHANGE(PROP_HAZE_RANGE, hazeRange); CHECK_PROPERTY_CHANGE(PROP_HAZE_BLEND_IN_COLOR, hazeBlendInColor); CHECK_PROPERTY_CHANGE(PROP_HAZE_BLEND_OUT_COLOR, hazeBlendOutColor); + CHECK_PROPERTY_CHANGE(PROP_HAZE_ENABLE_LIGHT_BLEND, hazeEnableLightBlend); CHECK_PROPERTY_CHANGE(PROP_HAZE_LIGHT_BLEND_ANGLE, hazeLightBlendAngle); CHECK_PROPERTY_CHANGE(PROP_HAZE_ALTITUDE, hazeAltitude); @@ -237,6 +249,7 @@ void HazePropertyGroup::getProperties(EntityItemProperties& properties) const { COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Haze, HazeRange, getHazeRange); COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Haze, HazeBlendInColor, getHazeBlendInColor); COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Haze, HazeBlendOutColor, getHazeBlendOutColor); + COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Haze, HazeEnableLightBlend, getHazeEnableLightBlend); COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Haze, HazeLightBlendAngle, getHazeLightBlendAngle); COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Haze, HazeAltitude, getHazeAltitude); @@ -255,6 +268,7 @@ bool HazePropertyGroup::setProperties(const EntityItemProperties& properties) { SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Haze, HazeRange, hazeRange, setHazeRange); SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Haze, HazeBlendInColor, hazeBlendInColor, setHazeBlendInColor); SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Haze, HazeBlendOutColor, hazeBlendOutColor, setHazeBlendOutColor); + SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Haze, HazeEnableLightBlend, hazeEnableLightBlend, setHazeEnableLightBlend); SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Haze, HazeLightBlendAngle, hazeLightBlendAngle, setHazeLightBlendAngle); SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Haze, HazeAltitude, hazeAltitude, setHazeAltitude); @@ -275,6 +289,7 @@ EntityPropertyFlags HazePropertyGroup::getEntityProperties(EncodeBitstreamParams requestedProperties += PROP_HAZE_RANGE; requestedProperties += PROP_HAZE_BLEND_IN_COLOR; requestedProperties += PROP_HAZE_BLEND_OUT_COLOR; + requestedProperties += PROP_HAZE_ENABLE_LIGHT_BLEND; requestedProperties += PROP_HAZE_LIGHT_BLEND_ANGLE; requestedProperties += PROP_HAZE_ALTITUDE; @@ -302,6 +317,7 @@ void HazePropertyGroup::appendSubclassData(OctreePacketData* packetData, EncodeB APPEND_ENTITY_PROPERTY(PROP_HAZE_RANGE, getHazeRange()); APPEND_ENTITY_PROPERTY(PROP_HAZE_BLEND_IN_COLOR, getHazeBlendInColor()); APPEND_ENTITY_PROPERTY(PROP_HAZE_BLEND_OUT_COLOR, getHazeBlendOutColor()); + APPEND_ENTITY_PROPERTY(PROP_HAZE_ENABLE_LIGHT_BLEND, getHazeEnableLightBlend()); APPEND_ENTITY_PROPERTY(PROP_HAZE_LIGHT_BLEND_ANGLE, getHazeLightBlendAngle()); APPEND_ENTITY_PROPERTY(PROP_HAZE_ALTITUDE, getHazeAltitude()); @@ -325,6 +341,7 @@ int HazePropertyGroup::readEntitySubclassDataFromBuffer(const unsigned char* dat READ_ENTITY_PROPERTY(PROP_HAZE_RANGE, float, setHazeRange); READ_ENTITY_PROPERTY(PROP_HAZE_BLEND_IN_COLOR, xColor, setHazeBlendInColor); READ_ENTITY_PROPERTY(PROP_HAZE_BLEND_OUT_COLOR, xColor, setHazeBlendOutColor); + READ_ENTITY_PROPERTY(PROP_HAZE_ENABLE_LIGHT_BLEND, bool, setHazeEnableLightBlend); READ_ENTITY_PROPERTY(PROP_HAZE_LIGHT_BLEND_ANGLE, float, setHazeLightBlendAngle); READ_ENTITY_PROPERTY(PROP_HAZE_ALTITUDE, float, setHazeAltitude); diff --git a/libraries/entities/src/HazePropertyGroup.h b/libraries/entities/src/HazePropertyGroup.h index cad1647d24..334f82982d 100644 --- a/libraries/entities/src/HazePropertyGroup.h +++ b/libraries/entities/src/HazePropertyGroup.h @@ -91,6 +91,7 @@ public: DEFINE_PROPERTY(PROP_HAZE_RANGE, HazeRange, hazeRange, float, DEFAULT_HAZE_RANGE); DEFINE_PROPERTY_REF(PROP_HAZE_BLEND_IN_COLOR, HazeBlendInColor, hazeBlendInColor, xColor, DEFAULT_HAZE_BLEND_IN_COLOR); DEFINE_PROPERTY_REF(PROP_HAZE_BLEND_OUT_COLOR, HazeBlendOutColor, hazeBlendOutColor, xColor, DEFAULT_HAZE_BLEND_OUT_COLOR); + DEFINE_PROPERTY(PROP_HAZE_ENABLE_LIGHT_BLEND, HazeEnableLightBlend, hazeEnableLightBlend, bool, false); DEFINE_PROPERTY_REF(PROP_HAZE_LIGHT_BLEND_ANGLE, HazeLightBlendAngle, hazeLightBlendAngle, float, DEFAULT_HAZE_LIGHT_BLEND_ANGLE); // Range & Altitude parameters diff --git a/libraries/entities/src/ZoneEntityItem.cpp b/libraries/entities/src/ZoneEntityItem.cpp index 4a14d6c9be..5cd75bf399 100644 --- a/libraries/entities/src/ZoneEntityItem.cpp +++ b/libraries/entities/src/ZoneEntityItem.cpp @@ -338,83 +338,93 @@ float ZoneEntityItem::getHazeRange() const { return _hazeRange; } -void ZoneEntityItem::setHazeBlendInColor(const xColor hazeBlendInColor){ +void ZoneEntityItem::setHazeBlendInColor(const xColor hazeBlendInColor) { _hazeBlendInColor = hazeBlendInColor; _hazePropertiesChanged = true; } -xColor ZoneEntityItem::getHazeBlendInColor()const{ +xColor ZoneEntityItem::getHazeBlendInColor() const { return _hazeBlendInColor; } -void ZoneEntityItem::setHazeBlendOutColor(const xColor hazeBlendOutColor){ +void ZoneEntityItem::setHazeBlendOutColor(const xColor hazeBlendOutColor) { _hazeBlendOutColor = hazeBlendOutColor; _hazePropertiesChanged = true; } -xColor ZoneEntityItem::getHazeBlendOutColor()const{ +xColor ZoneEntityItem::getHazeBlendOutColor()const { return _hazeBlendOutColor; } -void ZoneEntityItem::setHazeLightBlendAngle(const float hazeLightBlendAngle){ +void ZoneEntityItem::setHazeEnableLightBlend(const bool hazeEnableLightBlend) { + _hazeEnableLightBlend = hazeEnableLightBlend; + _hazePropertiesChanged = true; +} + +bool ZoneEntityItem::getHazeEnableLightBlend()const { + return _hazeEnableLightBlend; +} + +void ZoneEntityItem::setHazeLightBlendAngle(const float hazeLightBlendAngle) { _hazeLightBlendAngle = hazeLightBlendAngle; _hazePropertiesChanged = true; } -float ZoneEntityItem::getHazeLightBlendAngle()const{ +float ZoneEntityItem::getHazeLightBlendAngle() const { return _hazeLightBlendAngle; } -void ZoneEntityItem::setHazeAltitude(const float hazeAltitude){ +void ZoneEntityItem::setHazeAltitude(const float hazeAltitude) { _hazeAltitude = hazeAltitude; _hazePropertiesChanged = true; } -float ZoneEntityItem::getHazeAltitude()const{ +float ZoneEntityItem::getHazeAltitude() const { return _hazeAltitude; } -void ZoneEntityItem::setHazeBaseRef(const float hazeBaseRef){ +void ZoneEntityItem::setHazeBaseRef(const float hazeBaseRef) { _hazeBaseRef = hazeBaseRef; _hazePropertiesChanged = true; } -float ZoneEntityItem::getHazeBaseRef()const{ +float ZoneEntityItem::getHazeBaseRef() const { return _hazeBaseRef; } -void ZoneEntityItem::setHazeBackgroundBlend(const float hazeBackgroundBlend){ +void ZoneEntityItem::setHazeBackgroundBlend(const float hazeBackgroundBlend) { _hazeBackgroundBlend = hazeBackgroundBlend; _hazePropertiesChanged = true; } -float ZoneEntityItem::getHazeBackgroundBlend()const{ +float ZoneEntityItem::getHazeBackgroundBlend() const { return _hazeBackgroundBlend; } void ZoneEntityItem::setHazeAttenuateKeyLight(const bool hazeAttenuateKeyLight) { _hazeAttenuateKeyLight = hazeAttenuateKeyLight; + _hazePropertiesChanged = true; } -bool ZoneEntityItem::getHazeAttenuateKeyLight()const { +bool ZoneEntityItem::getHazeAttenuateKeyLight() const { return _hazeAttenuateKeyLight; } -void ZoneEntityItem::setHazeKeyLightRange(const float hazeKeyLightRange){ +void ZoneEntityItem::setHazeKeyLightRange(const float hazeKeyLightRange) { _hazeKeyLightRange = hazeKeyLightRange; _hazePropertiesChanged = true; } -float ZoneEntityItem::getHazeKeyLightRange()const { +float ZoneEntityItem::getHazeKeyLightRange() const { return _hazeKeyLightRange; } -void ZoneEntityItem::setHazeKeyLightAltitude(const float hazeKeyLightAltitude){ +void ZoneEntityItem::setHazeKeyLightAltitude(const float hazeKeyLightAltitude) { _hazeKeyLightAltitude = hazeKeyLightAltitude; _hazePropertiesChanged = true; } -float ZoneEntityItem::getHazeKeyLightAltitude()const{ +float ZoneEntityItem::getHazeKeyLightAltitude() const { return _hazeKeyLightAltitude; } diff --git a/libraries/entities/src/ZoneEntityItem.h b/libraries/entities/src/ZoneEntityItem.h index 352f98f5a2..d73eadebb5 100644 --- a/libraries/entities/src/ZoneEntityItem.h +++ b/libraries/entities/src/ZoneEntityItem.h @@ -74,28 +74,30 @@ public: uint32_t getHazeMode() const; void setHazeRange(const float hazeRange); - float getHazeRange()const; + float getHazeRange() const; void setHazeBlendInColor(const xColor hazeBlendInColor); - xColor getHazeBlendInColor()const; + xColor getHazeBlendInColor() const; void setHazeBlendOutColor(const xColor hazeBlendOutColor); - xColor getHazeBlendOutColor()const; + xColor getHazeBlendOutColor() const; + void setHazeEnableLightBlend(const bool hazeEnableLightBlend); + bool getHazeEnableLightBlend() const; void setHazeLightBlendAngle(const float hazeLightBlendAngle); - float getHazeLightBlendAngle()const; + float getHazeLightBlendAngle() const; void setHazeAltitude(const float hazeAltitude); - float getHazeAltitude()const; + float getHazeAltitude() const; void setHazeBaseRef(const float hazeBaseRef); - float getHazeBaseRef()const; + float getHazeBaseRef() const; void setHazeBackgroundBlend(const float hazeBackgroundBlend); - float getHazeBackgroundBlend()const; + float getHazeBackgroundBlend() const; void setHazeAttenuateKeyLight(const bool hazeAttenuateKeyLight); - bool getHazeAttenuateKeyLight()const; + bool getHazeAttenuateKeyLight() const; void setHazeKeyLightRange(const float hazeKeyLightRange); - float getHazeKeyLightRange()const; + float getHazeKeyLightRange() const; void setHazeKeyLightAltitude(const float hazeKeyLightAltitude); - float getHazeKeyLightAltitude()const; + float getHazeKeyLightAltitude() const; SkyboxPropertyGroup getSkyboxProperties() const { return resultWithReadLock([&] { return _skyboxProperties; }); } @@ -149,6 +151,7 @@ protected: float _hazeRange{ HazePropertyGroup::DEFAULT_HAZE_RANGE }; xColor _hazeBlendInColor{ HazePropertyGroup::DEFAULT_HAZE_BLEND_IN_COLOR }; xColor _hazeBlendOutColor{ HazePropertyGroup::DEFAULT_HAZE_BLEND_OUT_COLOR }; + bool _hazeEnableLightBlend{ false }; float _hazeLightBlendAngle{ HazePropertyGroup::DEFAULT_HAZE_LIGHT_BLEND_ANGLE }; float _hazeAltitude{ HazePropertyGroup::DEFAULT_HAZE_ALTITUDE }; @@ -156,7 +159,7 @@ protected: float _hazeBackgroundBlend{ HazePropertyGroup::DEFAULT_HAZE_BACKGROUND_BLEND }; - float _hazeAttenuateKeyLight{ false }; + bool _hazeAttenuateKeyLight{ false }; float _hazeKeyLightRange{ HazePropertyGroup::DEFAULT_HAZE_KEYLIGHT_RANGE }; float _hazeKeyLightAltitude{ HazePropertyGroup::DEFAULT_HAZE_KEYLIGHT_ALTITUDE }; diff --git a/libraries/model/src/model/Haze.cpp b/libraries/model/src/model/Haze.cpp index 9a3e59dfa7..3654fb3467 100644 --- a/libraries/model/src/model/Haze.cpp +++ b/libraries/model/src/model/Haze.cpp @@ -24,7 +24,8 @@ 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_MODULATE_COLOR = 1 << 3 + HAZE_MODE_IS_MODULATE_COLOR = 1 << 3, + HAZE_MODE_IS_ENABLE_LIGHT_BLEND = 1 << 4 }; // For color modulated mode, the colour values are used as range values, which are then converted to range factors @@ -57,6 +58,17 @@ void Haze::setHazeColor(const glm::vec3 hazeColor) { } } +void Haze::setHazeEnableLightBlend(const bool isHazeEnableLightBlend) { + auto& params = _hazeParametersBuffer.get(); + + if (((params.hazeMode & HAZE_MODE_IS_ENABLE_LIGHT_BLEND) == HAZE_MODE_IS_ENABLE_LIGHT_BLEND) && !isHazeEnableLightBlend) { + _hazeParametersBuffer.edit().hazeMode &= ~HAZE_MODE_IS_ENABLE_LIGHT_BLEND; + } + else if (((params.hazeMode & HAZE_MODE_IS_ENABLE_LIGHT_BLEND) != HAZE_MODE_IS_ENABLE_LIGHT_BLEND) && isHazeEnableLightBlend) { + _hazeParametersBuffer.edit().hazeMode |= HAZE_MODE_IS_ENABLE_LIGHT_BLEND; + } +} + void Haze::setDirectionalLightBlend(const float hazeDirectionalLightBlend) { auto& params = _hazeParametersBuffer.get(); @@ -170,19 +182,11 @@ void Haze::setHazeBackgroundBlendValue(const float hazeBackgroundBlendValue) { } } -void Haze::setZoneOrientation(const glm::quat& zoneOrientation) { +void Haze::setZoneTransform(const glm::mat4& zoneTransform) { auto& params = _hazeParametersBuffer.get(); - glm::vec3 zoneDirection = zoneOrientation * glm::vec3(0.0f, 0.0f, -1.0f); - if (params.zoneDirection == zoneDirection) { - _hazeParametersBuffer.edit().zoneDirection = zoneDirection; + if (params.zoneTransform == zoneTransform) { + _hazeParametersBuffer.edit().zoneTransform = zoneTransform; } } -void Haze::setZonePosition(const glm::vec3& zonePosition) { - auto& params = _hazeParametersBuffer.get(); - - if (params.zonePosition != zonePosition) { - _hazeParametersBuffer.edit().zonePosition = zonePosition; - } -} diff --git a/libraries/model/src/model/Haze.h b/libraries/model/src/model/Haze.h index 880b1c6f8c..7fe8de2735 100644 --- a/libraries/model/src/model/Haze.h +++ b/libraries/model/src/model/Haze.h @@ -75,6 +75,7 @@ namespace model { void setAltitudeBased(const bool isAltitudeBased); void setHazeAttenuateKeyLight(const bool isHazeAttenuateKeyLight); void setModulateColorActive(const bool isModulateColorActive); + void setHazeEnableLightBlend(const bool isHazeEnableLightBlend); void setHazeRangeFactor(const float hazeRange); void setHazeAltitudeFactor(const float hazeAltitude); @@ -84,8 +85,7 @@ namespace model { void setHazeBackgroundBlendValue(const float hazeBackgroundBlendValue); - void setZoneOrientation(const glm::quat& zoneOrientation); - void setZonePosition(const glm::vec3& zonePosition); + void setZoneTransform(const glm::mat4& zoneTransform); UniformBufferView getHazeParametersBuffer() const { return _hazeParametersBuffer; } @@ -103,12 +103,12 @@ namespace model { 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 + // bit 3 - set to blend between blend-in and blend-out colours - glm::vec3 zoneDirection; + glm::mat4 zoneTransform; // Amount of background (skybox) to display, overriding the haze effect for the background float hazeBackgroundBlendValue{ initialHazeBackgroundBlendValue }; - glm::vec3 zonePosition; // The haze attenuation exponents used by both fragment and directional light attenuation float hazeRangeFactor{ convertHazeRangeToHazeRangeFactor(initialHazeRange_m) }; diff --git a/libraries/model/src/model/Stage.h b/libraries/model/src/model/Stage.h index 797c646e68..70012d9b23 100644 --- a/libraries/model/src/model/Stage.h +++ b/libraries/model/src/model/Stage.h @@ -192,6 +192,8 @@ public: xColor getHazeBlendInColor() { return _hazeBlendInColor; } void setHazeBlendOutColor(const xColor hazeBlendOutColor) { _hazeBlendOutColor = hazeBlendOutColor; } xColor getHazeBlendOutColor() const { return _hazeBlendOutColor; } + void setHazeEnableLightBlend(bool hazeEnableLightBlend) { _hazeEnableLightBlend = hazeEnableLightBlend; } + bool getHazeEnableLightBlend() const { return _hazeEnableLightBlend; } void setHazeLightBlendAngle(float hazeLightBlendAngle) { _hazeLightBlendAngle = hazeLightBlendAngle; } float getHazeLightBlendAngle() const { return _hazeLightBlendAngle; } @@ -218,6 +220,7 @@ protected: float _hazeRange; xColor _hazeBlendInColor; xColor _hazeBlendOutColor; + bool _hazeEnableLightBlend; float _hazeLightBlendAngle; float _hazeAltitude; diff --git a/libraries/render-utils/src/DrawHaze.cpp b/libraries/render-utils/src/DrawHaze.cpp index 9001acc4ed..320aa06c6d 100644 --- a/libraries/render-utils/src/DrawHaze.cpp +++ b/libraries/render-utils/src/DrawHaze.cpp @@ -69,6 +69,10 @@ void HazeConfig::setModulateColorActive(const bool active) { isModulateColorActive = active; } +void HazeConfig::setHazeEnableLightBlend(const bool active) { + isHazeEnableLightBlend = active; +} + void HazeConfig::setHazeRange_m(const float value) { hazeRange_m = value; } @@ -104,6 +108,7 @@ void MakeHaze::configure(const Config& config) { _haze->setAltitudeBased(config.isAltitudeBased); _haze->setHazeAttenuateKeyLight(config.isHazeAttenuateKeyLight); _haze->setModulateColorActive(config.isModulateColorActive); + _haze->setHazeEnableLightBlend(config.isHazeEnableLightBlend); _haze->setHazeRangeFactor(model::convertHazeRangeToHazeRangeFactor(config.hazeRange_m)); _haze->setHazeAltitudeFactor(model::convertHazeAltitudeToHazeAltitudeFactor(config.hazeAltitude_m)); diff --git a/libraries/render-utils/src/DrawHaze.h b/libraries/render-utils/src/DrawHaze.h index ad740dd522..919ccdb368 100644 --- a/libraries/render-utils/src/DrawHaze.h +++ b/libraries/render-utils/src/DrawHaze.h @@ -43,6 +43,7 @@ class MakeHazeConfig : public render::Job::Config { Q_PROPERTY(bool isAltitudeBased MEMBER isAltitudeBased WRITE setAltitudeBased NOTIFY dirty); Q_PROPERTY(bool isHazeAttenuateKeyLight MEMBER isHazeAttenuateKeyLight WRITE setHazeAttenuateKeyLight NOTIFY dirty); Q_PROPERTY(bool isModulateColorActive MEMBER isModulateColorActive WRITE setModulateColorActive NOTIFY dirty); + Q_PROPERTY(bool isHazeEnableLightBlend MEMBER isHazeEnableLightBlend WRITE setHazeEnableLightBlend 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); @@ -69,6 +70,7 @@ public: bool isAltitudeBased{ false }; bool isHazeAttenuateKeyLight{ false }; bool isModulateColorActive{ false }; + bool isHazeEnableLightBlend{ false }; float hazeRange_m{ model::initialHazeRange_m }; float hazeAltitude_m{ model::initialHazeAltitude_m }; @@ -93,6 +95,7 @@ public slots: void setAltitudeBased(const bool active) { isAltitudeBased = active; emit dirty(); } void setHazeAttenuateKeyLight(const bool active) { isHazeAttenuateKeyLight = active; emit dirty(); } void setModulateColorActive(const bool active) { isModulateColorActive = active; emit dirty(); } + void setHazeEnableLightBlend(const bool active) { isHazeEnableLightBlend = 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(); } @@ -139,6 +142,7 @@ public: bool isAltitudeBased{ false }; bool isHazeAttenuateKeyLight{ false }; bool isModulateColorActive{ false }; + bool isHazeEnableLightBlend{ false }; float hazeRange_m{ model::initialHazeRange_m }; float hazeAltitude_m{ model::initialHazeAltitude_m }; @@ -163,6 +167,7 @@ public: void setAltitudeBased(const bool active); void setHazeAttenuateKeyLight(const bool active); void setModulateColorActive(const bool active); + void setHazeEnableLightBlend(const bool active); void setHazeRange_m(const float value); void setHazeAltitude_m(const float value); diff --git a/libraries/render-utils/src/Haze.slf b/libraries/render-utils/src/Haze.slf index 58e15f9ae6..5d5d92f96d 100644 --- a/libraries/render-utils/src/Haze.slf +++ b/libraries/render-utils/src/Haze.slf @@ -65,8 +65,14 @@ void main(void) { vec4 directionalLightColor = vec4(hazeParams.directionalLightColor, 1.0); - vec4 blendedHazeColor = - mix(hazeColor, directionalLightColor, power); + // Use the haze colour for the belnd-out 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); + } + else { + blendedHazeColor = hazeColor; + } vec4 potentialFragColor; diff --git a/libraries/render-utils/src/Haze.slh b/libraries/render-utils/src/Haze.slh index 42e561f2fe..614431dce7 100644 --- a/libraries/render-utils/src/Haze.slh +++ b/libraries/render-utils/src/Haze.slh @@ -14,6 +14,7 @@ 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_MODULATE_COLOR = 1 << 3; +const int HAZE_MODE_IS_ENABLE_LIGHT_BLEND = 1 << 4; struct HazeParams { vec3 hazeColor; @@ -25,11 +26,9 @@ struct HazeParams { vec3 colorModulationFactor; int hazeMode; - vec3 zoneDirection; + mat4 zoneTransform; float backgroundBlendValue; - vec3 zonePosition; - float hazeRangeFactor; float hazeAltitudeFactor; diff --git a/libraries/render-utils/src/HazeStage.cpp b/libraries/render-utils/src/HazeStage.cpp index f2056b5fe5..c09fcaa488 100644 --- a/libraries/render-utils/src/HazeStage.cpp +++ b/libraries/render-utils/src/HazeStage.cpp @@ -30,6 +30,7 @@ void FetchHazeStage::configure(const Config& config) { _haze->setAltitudeBased(config.isAltitudeBased); _haze->setHazeAttenuateKeyLight(config.isHazeAttenuateKeyLight); _haze->setModulateColorActive(config.isModulateColorActive); + _haze->setHazeEnableLightBlend(config.isHazeEnableLightBlend); _haze->setHazeRangeFactor(model::convertHazeRangeToHazeRangeFactor(config.hazeRange_m)); _haze->setHazeAltitudeFactor(model::convertHazeAltitudeToHazeAltitudeFactor(config.hazeAltitude_m)); diff --git a/libraries/render-utils/src/HazeStage.h b/libraries/render-utils/src/HazeStage.h index e6ba8a52f1..349985ee3b 100644 --- a/libraries/render-utils/src/HazeStage.h +++ b/libraries/render-utils/src/HazeStage.h @@ -97,6 +97,7 @@ class FetchHazeConfig : public render::Job::Config { Q_PROPERTY(bool isAltitudeBased MEMBER isAltitudeBased WRITE setAltitudeBased NOTIFY dirty); Q_PROPERTY(bool isHazeAttenuateKeyLight MEMBER isHazeAttenuateKeyLight WRITE setHazeAttenuateKeyLight NOTIFY dirty); Q_PROPERTY(bool isModulateColorActive MEMBER isModulateColorActive WRITE setModulateColorActive NOTIFY dirty); + Q_PROPERTY(bool isHazeEnableLightBlend MEMBER isHazeEnableLightBlend WRITE setHazeEnableLightBlend 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); @@ -123,6 +124,7 @@ public: bool isAltitudeBased{ false }; bool isHazeAttenuateKeyLight{ false }; bool isModulateColorActive{ false }; + bool isHazeEnableLightBlend{ false }; float hazeRange_m{ model::initialHazeRange_m }; float hazeAltitude_m{ model::initialHazeAltitude_m }; @@ -147,6 +149,7 @@ public slots: void setAltitudeBased(const bool active) { isAltitudeBased = active; emit dirty(); } void setHazeAttenuateKeyLight(const bool active) { isHazeAttenuateKeyLight = active; emit dirty(); } void setModulateColorActive(const bool active) { isModulateColorActive = active; emit dirty(); } + void setHazeEnableLightBlend(const bool active) { isHazeEnableLightBlend = 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(); } diff --git a/libraries/render-utils/src/RenderDeferredTask.cpp b/libraries/render-utils/src/RenderDeferredTask.cpp index 41ded3a4f4..0901aec5c0 100644 --- a/libraries/render-utils/src/RenderDeferredTask.cpp +++ b/libraries/render-utils/src/RenderDeferredTask.cpp @@ -148,7 +148,6 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren const auto lightClusters = task.addJob("LightClustering", lightClusteringPassInputs); // Add haze model - ////const auto hazeModel = task.addJob("HazeModel"); const auto hazeModel = task.addJob("HazeModel"); // DeferredBuffer is complete, now let's shade it into the LightingBuffer diff --git a/libraries/script-engine/src/SceneScriptingInterface.cpp b/libraries/script-engine/src/SceneScriptingInterface.cpp index 1c2c38c53c..4a9a3b2ac5 100644 --- a/libraries/script-engine/src/SceneScriptingInterface.cpp +++ b/libraries/script-engine/src/SceneScriptingInterface.cpp @@ -167,6 +167,12 @@ void SceneScripting::Stage::setHazeBlendOutColor(const xColor hazeBlendOutColor) xColor SceneScripting::Stage::getHazeBlendOutColor() const { return _skyStage->getHazeBlendOutColor(); } +void SceneScripting::Stage::setHazeEnableLightBlend(const bool hazeEnableLightBlend) { + _skyStage->setHazeEnableLightBlend(hazeEnableLightBlend); +} +bool SceneScripting::Stage::getHazeEnableLightBlend() const { + return _skyStage->getHazeEnableLightBlend(); +} void SceneScripting::Stage::setHazeLightBlendAngle(const float hazeLightBlendAngle) { _skyStage->setHazeLightBlendAngle(hazeLightBlendAngle); } diff --git a/libraries/script-engine/src/SceneScriptingInterface.h b/libraries/script-engine/src/SceneScriptingInterface.h index 3be496fce5..2f02237d75 100644 --- a/libraries/script-engine/src/SceneScriptingInterface.h +++ b/libraries/script-engine/src/SceneScriptingInterface.h @@ -128,12 +128,19 @@ namespace SceneScripting { Q_PROPERTY(float hazeRange READ getHazeRange WRITE setHazeRange) void setHazeRange(float value); float getHazeRange() const; + Q_PROPERTY(xColor hazeBlendInColor READ getHazeBlendInColor WRITE setHazeBlendInColor) void setHazeBlendInColor(xColor value); xColor getHazeBlendInColor() const; + Q_PROPERTY(xColor hazeBlendOutColor READ getHazeBlendOutColor WRITE setHazeBlendOutColor) void setHazeBlendOutColor(xColor value); xColor getHazeBlendOutColor() const; + + Q_PROPERTY(bool hazeEnableLightBlend READ getHazeEnableLightBlend WRITE setHazeEnableLightBlend) + void setHazeEnableLightBlend(bool value); + bool getHazeEnableLightBlend() const; + Q_PROPERTY(float hazeLightBlendAngle READ getHazeLightBlendAngle WRITE setHazeLightBlendAngle) void setHazeLightBlendAngle(float value); float getHazeLightBlendAngle() const; @@ -141,6 +148,7 @@ namespace SceneScripting { Q_PROPERTY(float hazeAltitude READ getHazeAltitude WRITE setHazeAltitude) void setHazeAltitude(float value); float getHazeAltitude() const; + Q_PROPERTY(float hazeBaseRef READ getHazeBaseRef WRITE setHazeBaseRef) void setHazeBaseRef(float value); float getHazeBaseRef() const; @@ -149,12 +157,14 @@ namespace SceneScripting { void setHazeBackgroundBlend(float value); float getHazeBackgroundBlend() const; - Q_PROPERTY(float hazeAttenuateKeyLight READ getHazeAttenuateKeyLight WRITE setHazeAttenuateKeyLight) + 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; diff --git a/scripts/system/html/entityProperties.html b/scripts/system/html/entityProperties.html index f7970b969c..50e4ac01b9 100644 --- a/scripts/system/html/entityProperties.html +++ b/scripts/system/html/entityProperties.html @@ -591,6 +591,10 @@
+
+ + +
diff --git a/scripts/system/html/js/entityProperties.js b/scripts/system/html/js/entityProperties.js index ae13a10076..1c3410999b 100644 --- a/scripts/system/html/js/entityProperties.js +++ b/scripts/system/html/js/entityProperties.js @@ -668,11 +668,13 @@ function loaded() { var elZoneHazeBlendOutColorRed = document.getElementById("property-zone-haze-blend-out-color-red"); var elZoneHazeBlendOutColorGreen = document.getElementById("property-zone-haze-blend-out-color-green"); var elZoneHazeBlendOutColorBlue = document.getElementById("property-zone-haze-blend-out-color-blue"); - var elZoneHazeBackgroundBlend = document.getElementById("property-zone-haze-background-blend"); + var elZoneHazeEnableLightBlend = document.getElementById("property-zone-haze-enable-light-blend"); var elZoneHazeLightBlendAngle = document.getElementById("property-zone-haze-blend-angle"); var elZoneHazeAltitude = document.getElementById("property-zone-haze-altitude"); var elZoneHazeBaseRef = document.getElementById("property-zone-haze-altitude-base"); + + var elZoneHazeBackgroundBlend = document.getElementById("property-zone-haze-background-blend"); var elZoneHazeAttenuateKeyLight = document.getElementById("property-zone-haze-attenuate-keylight"); var elZoneHazeKeyLightRange = document.getElementById("property-zone-haze-keylight-range"); @@ -1037,6 +1039,8 @@ function loaded() { elZoneHazeBlendOutColorRed.value = properties.haze.hazeBlendOutColor.red; elZoneHazeBlendOutColorGreen.value = properties.haze.hazeBlendOutColor.green; elZoneHazeBlendOutColorBlue.value = properties.haze.hazeBlendOutColor.blue; + + elZoneHazeEnableLightBlend.checked = properties.haze.hazeEnableLightBlend; elZoneHazeLightBlendAngle.value = properties.haze.hazeLightBlendAngle.toFixed(0); elZoneHazeAltitude.value = properties.haze.hazeAltitude.toFixed(0); @@ -1495,6 +1499,8 @@ function loaded() { elZoneHazeBlendOutColorRed.addEventListener('change', zoneHazeBlendOutColorChangeFunction); elZoneHazeBlendOutColorGreen.addEventListener('change', zoneHazeBlendOutColorChangeFunction); elZoneHazeBlendOutColorBlue.addEventListener('change', zoneHazeBlendOutColorChangeFunction); + + elZoneHazeEnableLightBlend.addEventListener('change', createEmitGroupCheckedPropertyUpdateFunction('haze', 'hazeEnableLightBlend')); elZoneHazeLightBlendAngle.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('haze', 'hazeLightBlendAngle')); elZoneHazeAltitude.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('haze', 'hazeAltitude')); From 1a932fbaf0b9dff772198e131cd7090a15b5c587 Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Mon, 9 Oct 2017 19:10:30 -0700 Subject: [PATCH 70/94] Corrected error in html. --- scripts/system/html/entityProperties.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/system/html/entityProperties.html b/scripts/system/html/entityProperties.html index 50e4ac01b9..5545be6a1e 100644 --- a/scripts/system/html/entityProperties.html +++ b/scripts/system/html/entityProperties.html @@ -593,7 +593,7 @@
- +
From 3070778b395758d6070bd450d4968d69fa11edca Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Tue, 10 Oct 2017 10:20:04 -0700 Subject: [PATCH 71/94] Fixed typo in comment. --- libraries/render-utils/src/Haze.slf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/render-utils/src/Haze.slf b/libraries/render-utils/src/Haze.slf index 5d5d92f96d..ee552faf63 100644 --- a/libraries/render-utils/src/Haze.slf +++ b/libraries/render-utils/src/Haze.slf @@ -77,7 +77,7 @@ void main(void) { vec4 potentialFragColor; if ((hazeParams.hazeMode & HAZE_MODE_IS_MODULATE_COLOR) == HAZE_MODE_IS_MODULATE_COLOR) { - // Compute separately for reach colour + // Compute separately for each colour // Haze is based on both range and altitude // Taken from www.crytek.com/download/GDC2007_RealtimeAtmoFxInGamesRev.ppt From ea6b9ed28e655cebdadad34669e79f5260a142a1 Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Wed, 11 Oct 2017 18:58:59 -0700 Subject: [PATCH 72/94] Removed ...ALTITUDE_MODE from combo. --- libraries/entities-renderer/src/RenderableZoneEntityItem.cpp | 5 ++--- libraries/entities/src/EntityItemProperties.cpp | 3 +-- libraries/shared/src/HazeMode.h | 1 - scripts/system/html/entityProperties.html | 1 - 4 files changed, 3 insertions(+), 7 deletions(-) diff --git a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp index 3efe991baa..d9eea1f1e5 100644 --- a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp @@ -337,9 +337,8 @@ void ZoneEntityRenderer::updateHazeFromEntity(const TypedEntityPointer& entity) const auto& haze = editHaze(); const uint32_t hazeMode = entity->getHazeMode(); - const bool isHazeActive = ((hazeMode == HAZE_MODE_RANGE_ONLY) || (hazeMode == HAZE_MODE_RANGE_ALTITUDE)); - haze->setHazeActive(isHazeActive); - haze->setAltitudeBased(hazeMode == HAZE_MODE_RANGE_ALTITUDE); + haze->setHazeActive(hazeMode == HAZE_MODE_RANGE_ONLY); +//// haze->setAltitudeBased(hazeMode == HAZE_MODE_RANGE_ALTITUDE); haze->setHazeRangeFactor(model::convertHazeRangeToHazeRangeFactor(_hazeProperties.getHazeRange())); xColor hazeBlendInColor = _hazeProperties.getHazeBlendInColor(); diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp index 3f87cb374b..38b5892117 100644 --- a/libraries/entities/src/EntityItemProperties.cpp +++ b/libraries/entities/src/EntityItemProperties.cpp @@ -224,8 +224,7 @@ using HazePair = std::pair; const std::array HAZE_MODES = { { HazePair{ HAZE_MODE_INHERIT,{ "inherit" } }, HazePair{ HAZE_MODE_DISABLED,{ "disabled" } }, - HazePair{ HAZE_MODE_RANGE_ONLY,{ "range only" } }, - HazePair{ HAZE_MODE_RANGE_ALTITUDE,{ "range+altitude" } } + HazePair{ HAZE_MODE_RANGE_ONLY,{ "range only" } } } }; QString EntityItemProperties::getHazeModeAsString() const { diff --git a/libraries/shared/src/HazeMode.h b/libraries/shared/src/HazeMode.h index c5deeed9a3..f2dedfa4bd 100644 --- a/libraries/shared/src/HazeMode.h +++ b/libraries/shared/src/HazeMode.h @@ -16,7 +16,6 @@ enum HazeMode { HAZE_MODE_INHERIT, HAZE_MODE_DISABLED, HAZE_MODE_RANGE_ONLY, - HAZE_MODE_RANGE_ALTITUDE, HAZE_MODE_ITEM_COUNT }; diff --git a/scripts/system/html/entityProperties.html b/scripts/system/html/entityProperties.html index 5545be6a1e..650e120e6e 100644 --- a/scripts/system/html/entityProperties.html +++ b/scripts/system/html/entityProperties.html @@ -553,7 +553,6 @@ -
From 832f9fb6e3f920b2d930942555282d6db7311a52 Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Wed, 11 Oct 2017 19:10:51 -0700 Subject: [PATCH 73/94] Renamed HAZE_MODE_RANGE_ONLY to HAZE_MODE_ENABLED. --- libraries/entities-renderer/src/RenderableZoneEntityItem.cpp | 2 +- libraries/entities/src/EntityItemProperties.cpp | 2 +- libraries/shared/src/HazeMode.h | 2 +- scripts/system/html/entityProperties.html | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp index d9eea1f1e5..f3468263b6 100644 --- a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp @@ -337,7 +337,7 @@ void ZoneEntityRenderer::updateHazeFromEntity(const TypedEntityPointer& entity) const auto& haze = editHaze(); const uint32_t hazeMode = entity->getHazeMode(); - haze->setHazeActive(hazeMode == HAZE_MODE_RANGE_ONLY); + haze->setHazeActive(hazeMode == HAZE_MODE_ENABLED); //// haze->setAltitudeBased(hazeMode == HAZE_MODE_RANGE_ALTITUDE); haze->setHazeRangeFactor(model::convertHazeRangeToHazeRangeFactor(_hazeProperties.getHazeRange())); diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp index 38b5892117..06d6c8b40b 100644 --- a/libraries/entities/src/EntityItemProperties.cpp +++ b/libraries/entities/src/EntityItemProperties.cpp @@ -224,7 +224,7 @@ using HazePair = std::pair; const std::array HAZE_MODES = { { HazePair{ HAZE_MODE_INHERIT,{ "inherit" } }, HazePair{ HAZE_MODE_DISABLED,{ "disabled" } }, - HazePair{ HAZE_MODE_RANGE_ONLY,{ "range only" } } + HazePair{ HAZE_MODE_ENABLED,{ "range only" } } } }; QString EntityItemProperties::getHazeModeAsString() const { diff --git a/libraries/shared/src/HazeMode.h b/libraries/shared/src/HazeMode.h index f2dedfa4bd..0c0af013cd 100644 --- a/libraries/shared/src/HazeMode.h +++ b/libraries/shared/src/HazeMode.h @@ -15,7 +15,7 @@ enum HazeMode { HAZE_MODE_INHERIT, HAZE_MODE_DISABLED, - HAZE_MODE_RANGE_ONLY, + HAZE_MODE_ENABLED, HAZE_MODE_ITEM_COUNT }; diff --git a/scripts/system/html/entityProperties.html b/scripts/system/html/entityProperties.html index 650e120e6e..282b9d001c 100644 --- a/scripts/system/html/entityProperties.html +++ b/scripts/system/html/entityProperties.html @@ -552,7 +552,7 @@
From 748f97364b04633d305e2894d4645afcb77186c9 Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Wed, 11 Oct 2017 19:20:46 -0700 Subject: [PATCH 74/94] Moved Bakground Blend to end of Haze fields. --- scripts/system/html/entityProperties.html | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/system/html/entityProperties.html b/scripts/system/html/entityProperties.html index 282b9d001c..8d1778f9b8 100644 --- a/scripts/system/html/entityProperties.html +++ b/scripts/system/html/entityProperties.html @@ -558,7 +558,6 @@
-
@@ -610,6 +609,12 @@ min="-1000" max="50000" step="10">
+
+
+ + +
+
From 2f4ddd84f8c5f48888b51ee459f20ba54a64e9bd Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Wed, 11 Oct 2017 19:32:09 -0700 Subject: [PATCH 75/94] Renamed haze colours and moved checkbox for glare. --- 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 8d1778f9b8..b75a54dd95 100644 --- a/scripts/system/html/entityProperties.html +++ b/scripts/system/html/entityProperties.html @@ -565,8 +565,12 @@
+
+ + +
- Haze Blend In Color + Haze Color
@@ -578,7 +582,7 @@
- Haze Blend Out Color + Glare Color
@@ -589,10 +593,6 @@
-
- - -
From 96fd3123e819065fbab1500141b779dd8fc459fa Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Wed, 11 Oct 2017 20:36:24 -0700 Subject: [PATCH 76/94] Changed haze altitude to ceiling. --- .../src/RenderableZoneEntityItem.cpp | 3 +- .../entities/src/EntityItemProperties.cpp | 2 +- libraries/entities/src/HazePropertyGroup.cpp | 32 +++++++++---------- libraries/entities/src/HazePropertyGroup.h | 4 +-- libraries/entities/src/ZoneEntityItem.cpp | 8 ++--- libraries/entities/src/ZoneEntityItem.h | 6 ++-- libraries/model/src/model/Stage.h | 6 ++-- .../src/SceneScriptingInterface.cpp | 8 ++--- .../src/SceneScriptingInterface.h | 6 ++-- scripts/system/html/entityProperties.html | 4 +-- scripts/system/html/js/entityProperties.js | 8 ++--- 11 files changed, 44 insertions(+), 43 deletions(-) diff --git a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp index f3468263b6..08c64f2581 100644 --- a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp @@ -348,7 +348,8 @@ void ZoneEntityRenderer::updateHazeFromEntity(const TypedEntityPointer& entity) haze->setHazeEnableLightBlend(_hazeProperties.getHazeEnableLightBlend()); haze->setDirectionalLightBlend(model::convertDirectionalLightAngleToPower(_hazeProperties.getHazeLightBlendAngle())); - haze->setHazeAltitudeFactor(model::convertHazeAltitudeToHazeAltitudeFactor(_hazeProperties.getHazeAltitude())); + float hazeAltitude = _hazeProperties.getHazeCeiling() - _hazeProperties.getHazeBaseRef(); + haze->setHazeAltitudeFactor(model::convertHazeAltitudeToHazeAltitudeFactor(hazeAltitude)); haze->setHazeBaseReference(_hazeProperties.getHazeBaseRef()); haze->setHazeBackgroundBlendValue(_hazeProperties.getHazeBackgroundBlend()); diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp index 06d6c8b40b..0725c15100 100644 --- a/libraries/entities/src/EntityItemProperties.cpp +++ b/libraries/entities/src/EntityItemProperties.cpp @@ -1161,7 +1161,7 @@ void EntityItemProperties::entityPropertyFlagsFromScriptValue(const QScriptValue ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_ENABLE_LIGHT_BLEND, Haze, haze, HazeEnableLightBlend, hazeEnableLightBlend); ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_LIGHT_BLEND_ANGLE, Haze, haze, HazeLightBlendAngle, hazeLightBlendAngle); - ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_ALTITUDE, Haze, haze, HazeAltitude, hazeAltitude); + ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_ALTITUDE, Haze, haze, HazeCeiling, hazeCeiling); ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_BASE_REF, Haze, haze, HazeBaseRef, hazeBaseRef); ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_BACKGROUND_BLEND, Haze, haze, HazeBackgroundBlend, hazeBackgroundBlend); diff --git a/libraries/entities/src/HazePropertyGroup.cpp b/libraries/entities/src/HazePropertyGroup.cpp index dae2e3c281..c276d35a00 100644 --- a/libraries/entities/src/HazePropertyGroup.cpp +++ b/libraries/entities/src/HazePropertyGroup.cpp @@ -20,7 +20,7 @@ const xColor HazePropertyGroup::DEFAULT_HAZE_BLEND_IN_COLOR{ 128, 154, 179 }; const xColor HazePropertyGroup::DEFAULT_HAZE_BLEND_OUT_COLOR{ 255, 229, 179 }; // Yellowish const float HazePropertyGroup::DEFAULT_HAZE_LIGHT_BLEND_ANGLE{ 20.0 }; -const float HazePropertyGroup::DEFAULT_HAZE_ALTITUDE{ 200.0f }; +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 }; @@ -35,7 +35,7 @@ void HazePropertyGroup::copyToScriptValue(const EntityPropertyFlags& desiredProp COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_ENABLE_LIGHT_BLEND, Haze, haze, HazeEnableLightBlend, hazeEnableLightBlend); COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_LIGHT_BLEND_ANGLE, Haze, haze, HazeLightBlendAngle, hazeLightBlendAngle); - COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_ALTITUDE, Haze, haze, HazeAltitude, hazeAltitude); + COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_ALTITUDE, Haze, haze, HazeCeiling, hazeCeiling); COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_BASE_REF, Haze, haze, HazeBaseRef, hazeBaseRef); COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_BACKGROUND_BLEND, Haze, haze, HazeBackgroundBlend, hazeBackgroundBlend); @@ -52,7 +52,7 @@ void HazePropertyGroup::copyFromScriptValue(const QScriptValue& object, bool& _d COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(haze, hazeEnableLightBlend, bool, setHazeEnableLightBlend); COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(haze, hazeLightBlendAngle, float, setHazeLightBlendAngle); - COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(haze, hazeAltitude, float, setHazeAltitude); + COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(haze, hazeCeiling, float, setHazeCeiling); COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(haze, hazeBaseRef, float, setHazeBaseRef); COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(haze, hazeBackgroundBlend, float, setHazeBackgroundBlend); @@ -69,7 +69,7 @@ void HazePropertyGroup::merge(const HazePropertyGroup& other) { COPY_PROPERTY_IF_CHANGED(hazeEnableLightBlend); COPY_PROPERTY_IF_CHANGED(hazeLightBlendAngle); - COPY_PROPERTY_IF_CHANGED(hazeAltitude); + COPY_PROPERTY_IF_CHANGED(hazeCeiling); COPY_PROPERTY_IF_CHANGED(hazeBaseRef); COPY_PROPERTY_IF_CHANGED(hazeBackgroundBlend); @@ -88,7 +88,7 @@ void HazePropertyGroup::debugDump() const { qCDebug(entities) << " _hazeEnableLightBlend:" << _hazeEnableLightBlend; qCDebug(entities) << " _hazeLightBlendAngle:" << _hazeLightBlendAngle; - qCDebug(entities) << " _hazeAltitude:" << _hazeAltitude; + qCDebug(entities) << " _hazeCeiling:" << _hazeCeiling; qCDebug(entities) << " _hazeBaseRef:" << _hazeBaseRef; qCDebug(entities) << " _hazeBackgroundBlend:" << _hazeBackgroundBlend; @@ -115,8 +115,8 @@ void HazePropertyGroup::listChangedProperties(QList& out) { out << "haze-hazeLightBlendAngle"; } - if (hazeAltitudeChanged()) { - out << "haze-hazeAltitude"; + if (hazeCeilingChanged()) { + out << "haze-hazeCeiling"; } if (hazeBaseRefChanged()) { out << "haze-hazeBaseRef"; @@ -152,7 +152,7 @@ bool HazePropertyGroup::appendToEditPacket(OctreePacketData* packetData, APPEND_ENTITY_PROPERTY(PROP_HAZE_ENABLE_LIGHT_BLEND, getHazeEnableLightBlend()); APPEND_ENTITY_PROPERTY(PROP_HAZE_LIGHT_BLEND_ANGLE, getHazeLightBlendAngle()); - APPEND_ENTITY_PROPERTY(PROP_HAZE_ALTITUDE, getHazeAltitude()); + APPEND_ENTITY_PROPERTY(PROP_HAZE_ALTITUDE, getHazeCeiling()); APPEND_ENTITY_PROPERTY(PROP_HAZE_BASE_REF, getHazeBaseRef()); APPEND_ENTITY_PROPERTY(PROP_HAZE_BACKGROUND_BLEND, getHazeBackgroundBlend()); @@ -176,7 +176,7 @@ bool HazePropertyGroup::decodeFromEditPacket(EntityPropertyFlags& propertyFlags, READ_ENTITY_PROPERTY(PROP_HAZE_ENABLE_LIGHT_BLEND, bool, setHazeEnableLightBlend); READ_ENTITY_PROPERTY(PROP_HAZE_LIGHT_BLEND_ANGLE, float, setHazeLightBlendAngle); - READ_ENTITY_PROPERTY(PROP_HAZE_ALTITUDE, float, setHazeAltitude); + READ_ENTITY_PROPERTY(PROP_HAZE_ALTITUDE, float, setHazeCeiling); READ_ENTITY_PROPERTY(PROP_HAZE_BASE_REF, float, setHazeBaseRef); READ_ENTITY_PROPERTY(PROP_HAZE_BACKGROUND_BLEND, float, setHazeBackgroundBlend); @@ -191,7 +191,7 @@ bool HazePropertyGroup::decodeFromEditPacket(EntityPropertyFlags& propertyFlags, DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_ENABLE_LIGHT_BLEND, HazeEnableLightBlend); DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_LIGHT_BLEND_ANGLE, HazeLightBlendAngle); - DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_ALTITUDE, HazeAltitude); + DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_ALTITUDE, HazeCeiling); DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_BASE_REF, HazeBaseRef); DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_BACKGROUND_BLEND, HazeBackgroundBlend); @@ -214,7 +214,7 @@ void HazePropertyGroup::markAllChanged() { _hazeEnableLightBlendChanged = true; _hazeLightBlendAngleChanged = true; - _hazeAltitudeChanged = true; + _hazeCeilingChanged = true; _hazeBaseRefChanged = true; _hazeBackgroundBlendChanged = true; @@ -233,7 +233,7 @@ EntityPropertyFlags HazePropertyGroup::getChangedProperties() const { CHECK_PROPERTY_CHANGE(PROP_HAZE_ENABLE_LIGHT_BLEND, hazeEnableLightBlend); CHECK_PROPERTY_CHANGE(PROP_HAZE_LIGHT_BLEND_ANGLE, hazeLightBlendAngle); - CHECK_PROPERTY_CHANGE(PROP_HAZE_ALTITUDE, hazeAltitude); + CHECK_PROPERTY_CHANGE(PROP_HAZE_ALTITUDE, hazeCeiling); CHECK_PROPERTY_CHANGE(PROP_HAZE_BASE_REF, hazeBaseRef); CHECK_PROPERTY_CHANGE(PROP_HAZE_BACKGROUND_BLEND, hazeBackgroundBlend); @@ -252,7 +252,7 @@ void HazePropertyGroup::getProperties(EntityItemProperties& properties) const { COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Haze, HazeEnableLightBlend, getHazeEnableLightBlend); COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Haze, HazeLightBlendAngle, getHazeLightBlendAngle); - COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Haze, HazeAltitude, getHazeAltitude); + COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Haze, HazeCeiling, getHazeCeiling); COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Haze, HazeBaseRef, getHazeBaseRef); COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Haze, HazeBackgroundBlend, getHazeBackgroundBlend); @@ -271,7 +271,7 @@ bool HazePropertyGroup::setProperties(const EntityItemProperties& properties) { SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Haze, HazeEnableLightBlend, hazeEnableLightBlend, setHazeEnableLightBlend); SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Haze, HazeLightBlendAngle, hazeLightBlendAngle, setHazeLightBlendAngle); - SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Haze, HazeAltitude, hazeAltitude, setHazeAltitude); + SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Haze, HazeCeiling, hazeCeiling, setHazeCeiling); SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Haze, HazeBaseRef, hazeBaseRef, setHazeBaseRef); SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Haze, HazeBackgroundBlend, hazeBackgroundBlend, setHazeBackgroundBlend); @@ -320,7 +320,7 @@ void HazePropertyGroup::appendSubclassData(OctreePacketData* packetData, EncodeB APPEND_ENTITY_PROPERTY(PROP_HAZE_ENABLE_LIGHT_BLEND, getHazeEnableLightBlend()); APPEND_ENTITY_PROPERTY(PROP_HAZE_LIGHT_BLEND_ANGLE, getHazeLightBlendAngle()); - APPEND_ENTITY_PROPERTY(PROP_HAZE_ALTITUDE, getHazeAltitude()); + APPEND_ENTITY_PROPERTY(PROP_HAZE_ALTITUDE, getHazeCeiling()); APPEND_ENTITY_PROPERTY(PROP_HAZE_BASE_REF, getHazeBaseRef()); APPEND_ENTITY_PROPERTY(PROP_HAZE_BACKGROUND_BLEND, getHazeBackgroundBlend()); @@ -344,7 +344,7 @@ int HazePropertyGroup::readEntitySubclassDataFromBuffer(const unsigned char* dat READ_ENTITY_PROPERTY(PROP_HAZE_ENABLE_LIGHT_BLEND, bool, setHazeEnableLightBlend); READ_ENTITY_PROPERTY(PROP_HAZE_LIGHT_BLEND_ANGLE, float, setHazeLightBlendAngle); - READ_ENTITY_PROPERTY(PROP_HAZE_ALTITUDE, float, setHazeAltitude); + READ_ENTITY_PROPERTY(PROP_HAZE_ALTITUDE, float, setHazeCeiling); READ_ENTITY_PROPERTY(PROP_HAZE_BASE_REF, float, setHazeBaseRef); READ_ENTITY_PROPERTY(PROP_HAZE_BACKGROUND_BLEND, float, setHazeBackgroundBlend); diff --git a/libraries/entities/src/HazePropertyGroup.h b/libraries/entities/src/HazePropertyGroup.h index 334f82982d..97d02f570e 100644 --- a/libraries/entities/src/HazePropertyGroup.h +++ b/libraries/entities/src/HazePropertyGroup.h @@ -79,7 +79,7 @@ public: static const xColor DEFAULT_HAZE_BLEND_OUT_COLOR; static const float DEFAULT_HAZE_LIGHT_BLEND_ANGLE; - static const float DEFAULT_HAZE_ALTITUDE; + static const float DEFAULT_HAZE_CEILING; static const float DEFAULT_HAZE_BASE_REF; static const float DEFAULT_HAZE_BACKGROUND_BLEND; @@ -95,7 +95,7 @@ public: DEFINE_PROPERTY_REF(PROP_HAZE_LIGHT_BLEND_ANGLE, HazeLightBlendAngle, hazeLightBlendAngle, float, DEFAULT_HAZE_LIGHT_BLEND_ANGLE); // Range & Altitude parameters - DEFINE_PROPERTY_REF(PROP_HAZE_ALTITUDE, HazeAltitude, hazeAltitude, float, DEFAULT_HAZE_ALTITUDE); + DEFINE_PROPERTY_REF(PROP_HAZE_ALTITUDE, HazeCeiling, hazeCeiling, float, DEFAULT_HAZE_CEILING); DEFINE_PROPERTY_REF(PROP_HAZE_BASE_REF, HazeBaseRef, hazeBaseRef, float, DEFAULT_HAZE_BASE_REF); // Background (skybox) blend value diff --git a/libraries/entities/src/ZoneEntityItem.cpp b/libraries/entities/src/ZoneEntityItem.cpp index 5cd75bf399..fefdefb6bc 100644 --- a/libraries/entities/src/ZoneEntityItem.cpp +++ b/libraries/entities/src/ZoneEntityItem.cpp @@ -374,13 +374,13 @@ float ZoneEntityItem::getHazeLightBlendAngle() const { return _hazeLightBlendAngle; } -void ZoneEntityItem::setHazeAltitude(const float hazeAltitude) { - _hazeAltitude = hazeAltitude; +void ZoneEntityItem::setHazeCeiling(const float hazeCeiling) { + _hazeCeiling = hazeCeiling; _hazePropertiesChanged = true; } -float ZoneEntityItem::getHazeAltitude() const { - return _hazeAltitude; +float ZoneEntityItem::getHazeCeiling() const { + return _hazeCeiling; } void ZoneEntityItem::setHazeBaseRef(const float hazeBaseRef) { diff --git a/libraries/entities/src/ZoneEntityItem.h b/libraries/entities/src/ZoneEntityItem.h index d73eadebb5..c626789205 100644 --- a/libraries/entities/src/ZoneEntityItem.h +++ b/libraries/entities/src/ZoneEntityItem.h @@ -84,8 +84,8 @@ public: void setHazeLightBlendAngle(const float hazeLightBlendAngle); float getHazeLightBlendAngle() const; - void setHazeAltitude(const float hazeAltitude); - float getHazeAltitude() const; + void setHazeCeiling(const float hazeCeiling); + float getHazeCeiling() const; void setHazeBaseRef(const float hazeBaseRef); float getHazeBaseRef() const; @@ -154,7 +154,7 @@ protected: bool _hazeEnableLightBlend{ false }; float _hazeLightBlendAngle{ HazePropertyGroup::DEFAULT_HAZE_LIGHT_BLEND_ANGLE }; - float _hazeAltitude{ HazePropertyGroup::DEFAULT_HAZE_ALTITUDE }; + float _hazeCeiling{ HazePropertyGroup::DEFAULT_HAZE_CEILING }; float _hazeBaseRef{ HazePropertyGroup::DEFAULT_HAZE_BASE_REF }; float _hazeBackgroundBlend{ HazePropertyGroup::DEFAULT_HAZE_BACKGROUND_BLEND }; diff --git a/libraries/model/src/model/Stage.h b/libraries/model/src/model/Stage.h index 70012d9b23..901c97cfe6 100644 --- a/libraries/model/src/model/Stage.h +++ b/libraries/model/src/model/Stage.h @@ -197,8 +197,8 @@ public: void setHazeLightBlendAngle(float hazeLightBlendAngle) { _hazeLightBlendAngle = hazeLightBlendAngle; } float getHazeLightBlendAngle() const { return _hazeLightBlendAngle; } - void setHazeAltitude(float hazeAltitude) { _hazeAltitude = hazeAltitude; } - float getHazeAltitude() const { return _hazeAltitude; } + void setHazeCeiling(float hazeCeiling) { _hazeCeiling = hazeCeiling; } + float getHazeCeiling() const { return _hazeCeiling; } void setHazeBaseRef(float hazeBaseRef) { _hazeBaseRef = hazeBaseRef; } float getHazeBaseRef() const { return _hazeBaseRef; } @@ -223,7 +223,7 @@ protected: bool _hazeEnableLightBlend; float _hazeLightBlendAngle; - float _hazeAltitude; + float _hazeCeiling; float _hazeBaseRef; float _hazeBackgroundBlend; diff --git a/libraries/script-engine/src/SceneScriptingInterface.cpp b/libraries/script-engine/src/SceneScriptingInterface.cpp index 4a9a3b2ac5..b330b4cf2a 100644 --- a/libraries/script-engine/src/SceneScriptingInterface.cpp +++ b/libraries/script-engine/src/SceneScriptingInterface.cpp @@ -180,11 +180,11 @@ float SceneScripting::Stage::getHazeLightBlendAngle() const { return _skyStage->getHazeLightBlendAngle(); } -void SceneScripting::Stage::setHazeAltitude(const float hazeAltitude) { - _skyStage->setHazeAltitude(hazeAltitude); +void SceneScripting::Stage::setHazeCeiling(const float hazeCeiling) { + _skyStage->setHazeCeiling(hazeCeiling); } -float SceneScripting::Stage::getHazeAltitude() const { - return _skyStage->getHazeAltitude(); +float SceneScripting::Stage::getHazeCeiling() const { + return _skyStage->getHazeCeiling(); } void SceneScripting::Stage::setHazeBaseRef(const float hazeBaseRef) { _skyStage->setHazeBaseRef(hazeBaseRef); diff --git a/libraries/script-engine/src/SceneScriptingInterface.h b/libraries/script-engine/src/SceneScriptingInterface.h index 2f02237d75..4de0f5f894 100644 --- a/libraries/script-engine/src/SceneScriptingInterface.h +++ b/libraries/script-engine/src/SceneScriptingInterface.h @@ -145,9 +145,9 @@ namespace SceneScripting { void setHazeLightBlendAngle(float value); float getHazeLightBlendAngle() const; - Q_PROPERTY(float hazeAltitude READ getHazeAltitude WRITE setHazeAltitude) - void setHazeAltitude(float value); - float getHazeAltitude() 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); diff --git a/scripts/system/html/entityProperties.html b/scripts/system/html/entityProperties.html index b75a54dd95..088055407f 100644 --- a/scripts/system/html/entityProperties.html +++ b/scripts/system/html/entityProperties.html @@ -560,8 +560,8 @@
-
-
+
+
diff --git a/scripts/system/html/js/entityProperties.js b/scripts/system/html/js/entityProperties.js index 1c3410999b..5cd2e22337 100644 --- a/scripts/system/html/js/entityProperties.js +++ b/scripts/system/html/js/entityProperties.js @@ -671,8 +671,8 @@ function loaded() { var elZoneHazeEnableLightBlend = document.getElementById("property-zone-haze-enable-light-blend"); var elZoneHazeLightBlendAngle = document.getElementById("property-zone-haze-blend-angle"); - var elZoneHazeAltitude = document.getElementById("property-zone-haze-altitude"); - var elZoneHazeBaseRef = document.getElementById("property-zone-haze-altitude-base"); + var elZoneHazeBaseRef = document.getElementById("property-zone-haze-base"); + var elZoneHazeCeiling = document.getElementById("property-zone-haze-ceiling"); var elZoneHazeBackgroundBlend = document.getElementById("property-zone-haze-background-blend"); @@ -1043,8 +1043,8 @@ function loaded() { elZoneHazeEnableLightBlend.checked = properties.haze.hazeEnableLightBlend; elZoneHazeLightBlendAngle.value = properties.haze.hazeLightBlendAngle.toFixed(0); - elZoneHazeAltitude.value = properties.haze.hazeAltitude.toFixed(0); elZoneHazeBaseRef.value = properties.haze.hazeBaseRef.toFixed(0); + elZoneHazeCeiling.value = properties.haze.hazeCeiling.toFixed(0); elZoneHazeBackgroundBlend.value = properties.haze.hazeBackgroundBlend.toFixed(2); @@ -1503,7 +1503,7 @@ function loaded() { elZoneHazeEnableLightBlend.addEventListener('change', createEmitGroupCheckedPropertyUpdateFunction('haze', 'hazeEnableLightBlend')); elZoneHazeLightBlendAngle.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('haze', 'hazeLightBlendAngle')); - elZoneHazeAltitude.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('haze', 'hazeAltitude')); + elZoneHazeCeiling.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('haze', 'hazeCeiling')); elZoneHazeBaseRef.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('haze', 'hazeBaseRef')); elZoneHazeBackgroundBlend.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('haze', 'hazeBackgroundBlend')); From 3ec8faa1b942b7635249b8f9a16ea6ceb2704685 Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Wed, 11 Oct 2017 20:47:39 -0700 Subject: [PATCH 77/94] Added checkbox for altitude effect of haze. --- scripts/system/html/entityProperties.html | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/system/html/entityProperties.html b/scripts/system/html/entityProperties.html index 088055407f..0cc343f81a 100644 --- a/scripts/system/html/entityProperties.html +++ b/scripts/system/html/entityProperties.html @@ -559,6 +559,12 @@
+
+
+
+ + +
From a21995db2473a38d89094955374a3c5697674ec5 Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Wed, 11 Oct 2017 22:10:58 -0700 Subject: [PATCH 78/94] Added checkbox for altitude effect. --- .../src/RenderableZoneEntityItem.cpp | 2 +- .../entities/src/EntityItemProperties.cpp | 3 +- libraries/entities/src/EntityPropertyFlags.h | 13 ++++---- libraries/entities/src/HazePropertyGroup.cpp | 32 ++++++++++++++----- libraries/entities/src/HazePropertyGroup.h | 5 +-- libraries/model/src/model/Stage.h | 3 ++ .../src/SceneScriptingInterface.cpp | 6 ++++ .../src/SceneScriptingInterface.h | 4 +++ scripts/system/html/js/entityProperties.js | 3 ++ 9 files changed, 53 insertions(+), 18 deletions(-) diff --git a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp index 08c64f2581..87db66aa7d 100644 --- a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp @@ -338,7 +338,7 @@ void ZoneEntityRenderer::updateHazeFromEntity(const TypedEntityPointer& entity) const uint32_t hazeMode = entity->getHazeMode(); haze->setHazeActive(hazeMode == HAZE_MODE_ENABLED); -//// haze->setAltitudeBased(hazeMode == HAZE_MODE_RANGE_ALTITUDE); + haze->setAltitudeBased(_hazeProperties.getHazeAltitudeEffect()); haze->setHazeRangeFactor(model::convertHazeRangeToHazeRangeFactor(_hazeProperties.getHazeRange())); xColor hazeBlendInColor = _hazeProperties.getHazeBlendInColor(); diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp index 0725c15100..c1eb74cd28 100644 --- a/libraries/entities/src/EntityItemProperties.cpp +++ b/libraries/entities/src/EntityItemProperties.cpp @@ -1161,7 +1161,8 @@ void EntityItemProperties::entityPropertyFlagsFromScriptValue(const QScriptValue ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_ENABLE_LIGHT_BLEND, Haze, haze, HazeEnableLightBlend, hazeEnableLightBlend); ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_LIGHT_BLEND_ANGLE, Haze, haze, HazeLightBlendAngle, hazeLightBlendAngle); - ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_ALTITUDE, Haze, haze, HazeCeiling, hazeCeiling); + ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_ALTITUDE_EFFECT, Haze, haze, HazeAltitudeEffect, hazeAltitudeEfect); + ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_CEILING, Haze, haze, HazeCeiling, hazeCeiling); ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_BASE_REF, Haze, haze, HazeBaseRef, hazeBaseRef); ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_BACKGROUND_BLEND, Haze, haze, HazeBackgroundBlend, hazeBackgroundBlend); diff --git a/libraries/entities/src/EntityPropertyFlags.h b/libraries/entities/src/EntityPropertyFlags.h index 6eded2148f..a1ffe6038f 100644 --- a/libraries/entities/src/EntityPropertyFlags.h +++ b/libraries/entities/src/EntityPropertyFlags.h @@ -240,14 +240,15 @@ enum EntityPropertyList { PROP_HAZE_ENABLE_LIGHT_BLEND = PROP_IS_SPOTLIGHT, PROP_HAZE_LIGHT_BLEND_ANGLE = PROP_DIFFUSE_COLOR, - PROP_HAZE_ALTITUDE = PROP_AMBIENT_COLOR_UNUSED, - PROP_HAZE_BASE_REF = PROP_SPECULAR_COLOR_UNUSED, + 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_LINEAR_ATTENUATION_UNUSED, + PROP_HAZE_BACKGROUND_BLEND = PROP_QUADRATIC_ATTENUATION_UNUSED, - PROP_HAZE_ATTENUATE_KEYLIGHT = PROP_QUADRATIC_ATTENUATION_UNUSED, - PROP_HAZE_KEYLIGHT_RANGE = PROP_ANIMATION_FRAME_INDEX, - PROP_HAZE_KEYLIGHT_ALTITUDE = PROP_MODEL_URL, + 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, diff --git a/libraries/entities/src/HazePropertyGroup.cpp b/libraries/entities/src/HazePropertyGroup.cpp index c276d35a00..5fd7b1e4c1 100644 --- a/libraries/entities/src/HazePropertyGroup.cpp +++ b/libraries/entities/src/HazePropertyGroup.cpp @@ -35,7 +35,8 @@ void HazePropertyGroup::copyToScriptValue(const EntityPropertyFlags& desiredProp COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_ENABLE_LIGHT_BLEND, Haze, haze, HazeEnableLightBlend, hazeEnableLightBlend); COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_LIGHT_BLEND_ANGLE, Haze, haze, HazeLightBlendAngle, hazeLightBlendAngle); - COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_ALTITUDE, Haze, haze, HazeCeiling, hazeCeiling); + COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_ALTITUDE_EFFECT, Haze, haze, HazeAltitudeEffect, hazeAltitudeEffect); + COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_CEILING, Haze, haze, HazeCeiling, hazeCeiling); COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_BASE_REF, Haze, haze, HazeBaseRef, hazeBaseRef); COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_BACKGROUND_BLEND, Haze, haze, HazeBackgroundBlend, hazeBackgroundBlend); @@ -52,6 +53,7 @@ void HazePropertyGroup::copyFromScriptValue(const QScriptValue& object, bool& _d COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(haze, hazeEnableLightBlend, bool, setHazeEnableLightBlend); COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(haze, hazeLightBlendAngle, float, setHazeLightBlendAngle); + COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(haze, hazeAltitudeEffect, bool, setHazeAltitudeEffect); COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(haze, hazeCeiling, float, setHazeCeiling); COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(haze, hazeBaseRef, float, setHazeBaseRef); @@ -69,6 +71,7 @@ void HazePropertyGroup::merge(const HazePropertyGroup& other) { COPY_PROPERTY_IF_CHANGED(hazeEnableLightBlend); COPY_PROPERTY_IF_CHANGED(hazeLightBlendAngle); + COPY_PROPERTY_IF_CHANGED(hazeAltitudeEffect); COPY_PROPERTY_IF_CHANGED(hazeCeiling); COPY_PROPERTY_IF_CHANGED(hazeBaseRef); @@ -88,6 +91,7 @@ void HazePropertyGroup::debugDump() const { qCDebug(entities) << " _hazeEnableLightBlend:" << _hazeEnableLightBlend; qCDebug(entities) << " _hazeLightBlendAngle:" << _hazeLightBlendAngle; + qCDebug(entities) << " _hazeAltitudeEffect:" << _hazeAltitudeEffect; qCDebug(entities) << " _hazeCeiling:" << _hazeCeiling; qCDebug(entities) << " _hazeBaseRef:" << _hazeBaseRef; @@ -115,6 +119,9 @@ void HazePropertyGroup::listChangedProperties(QList& out) { out << "haze-hazeLightBlendAngle"; } + if (hazeAltitudeEffectChanged()) { + out << "haze-hazeAltitudeEffect"; + } if (hazeCeilingChanged()) { out << "haze-hazeCeiling"; } @@ -152,7 +159,8 @@ bool HazePropertyGroup::appendToEditPacket(OctreePacketData* packetData, APPEND_ENTITY_PROPERTY(PROP_HAZE_ENABLE_LIGHT_BLEND, getHazeEnableLightBlend()); APPEND_ENTITY_PROPERTY(PROP_HAZE_LIGHT_BLEND_ANGLE, getHazeLightBlendAngle()); - APPEND_ENTITY_PROPERTY(PROP_HAZE_ALTITUDE, getHazeCeiling()); + APPEND_ENTITY_PROPERTY(PROP_HAZE_ALTITUDE_EFFECT, getHazeAltitudeEffect()); + APPEND_ENTITY_PROPERTY(PROP_HAZE_CEILING, getHazeCeiling()); APPEND_ENTITY_PROPERTY(PROP_HAZE_BASE_REF, getHazeBaseRef()); APPEND_ENTITY_PROPERTY(PROP_HAZE_BACKGROUND_BLEND, getHazeBackgroundBlend()); @@ -176,7 +184,8 @@ bool HazePropertyGroup::decodeFromEditPacket(EntityPropertyFlags& propertyFlags, READ_ENTITY_PROPERTY(PROP_HAZE_ENABLE_LIGHT_BLEND, bool, setHazeEnableLightBlend); READ_ENTITY_PROPERTY(PROP_HAZE_LIGHT_BLEND_ANGLE, float, setHazeLightBlendAngle); - READ_ENTITY_PROPERTY(PROP_HAZE_ALTITUDE, float, setHazeCeiling); + READ_ENTITY_PROPERTY(PROP_HAZE_ALTITUDE_EFFECT, bool, setHazeAltitudeEffect); + READ_ENTITY_PROPERTY(PROP_HAZE_CEILING, float, setHazeCeiling); READ_ENTITY_PROPERTY(PROP_HAZE_BASE_REF, float, setHazeBaseRef); READ_ENTITY_PROPERTY(PROP_HAZE_BACKGROUND_BLEND, float, setHazeBackgroundBlend); @@ -191,7 +200,8 @@ bool HazePropertyGroup::decodeFromEditPacket(EntityPropertyFlags& propertyFlags, DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_ENABLE_LIGHT_BLEND, HazeEnableLightBlend); DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_LIGHT_BLEND_ANGLE, HazeLightBlendAngle); - DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_ALTITUDE, HazeCeiling); + DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_ALTITUDE_EFFECT, HazeAltitudeEffect); + DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_CEILING, HazeCeiling); DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_BASE_REF, HazeBaseRef); DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_BACKGROUND_BLEND, HazeBackgroundBlend); @@ -214,6 +224,7 @@ void HazePropertyGroup::markAllChanged() { _hazeEnableLightBlendChanged = true; _hazeLightBlendAngleChanged = true; + _hazeAltitudeEffectChanged = true; _hazeCeilingChanged = true; _hazeBaseRefChanged = true; @@ -233,7 +244,8 @@ EntityPropertyFlags HazePropertyGroup::getChangedProperties() const { CHECK_PROPERTY_CHANGE(PROP_HAZE_ENABLE_LIGHT_BLEND, hazeEnableLightBlend); CHECK_PROPERTY_CHANGE(PROP_HAZE_LIGHT_BLEND_ANGLE, hazeLightBlendAngle); - CHECK_PROPERTY_CHANGE(PROP_HAZE_ALTITUDE, hazeCeiling); + CHECK_PROPERTY_CHANGE(PROP_HAZE_ALTITUDE_EFFECT, hazeAltitudeEffect); + CHECK_PROPERTY_CHANGE(PROP_HAZE_CEILING, hazeCeiling); CHECK_PROPERTY_CHANGE(PROP_HAZE_BASE_REF, hazeBaseRef); CHECK_PROPERTY_CHANGE(PROP_HAZE_BACKGROUND_BLEND, hazeBackgroundBlend); @@ -252,6 +264,7 @@ void HazePropertyGroup::getProperties(EntityItemProperties& properties) const { COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Haze, HazeEnableLightBlend, getHazeEnableLightBlend); COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Haze, HazeLightBlendAngle, getHazeLightBlendAngle); + COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Haze, HazeAltitudeEffect, getHazeAltitudeEffect); COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Haze, HazeCeiling, getHazeCeiling); COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Haze, HazeBaseRef, getHazeBaseRef); @@ -271,6 +284,7 @@ bool HazePropertyGroup::setProperties(const EntityItemProperties& properties) { SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Haze, HazeEnableLightBlend, hazeEnableLightBlend, setHazeEnableLightBlend); SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Haze, HazeLightBlendAngle, hazeLightBlendAngle, setHazeLightBlendAngle); + SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Haze, HazeAltitudeEffect, hazeAltitudeEffect, setHazeAltitudeEffect); SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Haze, HazeCeiling, hazeCeiling, setHazeCeiling); SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Haze, HazeBaseRef, hazeBaseRef, setHazeBaseRef); @@ -292,7 +306,7 @@ EntityPropertyFlags HazePropertyGroup::getEntityProperties(EncodeBitstreamParams requestedProperties += PROP_HAZE_ENABLE_LIGHT_BLEND; requestedProperties += PROP_HAZE_LIGHT_BLEND_ANGLE; - requestedProperties += PROP_HAZE_ALTITUDE; + requestedProperties += PROP_HAZE_CEILING; requestedProperties += PROP_HAZE_BASE_REF; requestedProperties += PROP_HAZE_BACKGROUND_BLEND; @@ -320,7 +334,8 @@ void HazePropertyGroup::appendSubclassData(OctreePacketData* packetData, EncodeB APPEND_ENTITY_PROPERTY(PROP_HAZE_ENABLE_LIGHT_BLEND, getHazeEnableLightBlend()); APPEND_ENTITY_PROPERTY(PROP_HAZE_LIGHT_BLEND_ANGLE, getHazeLightBlendAngle()); - APPEND_ENTITY_PROPERTY(PROP_HAZE_ALTITUDE, getHazeCeiling()); + APPEND_ENTITY_PROPERTY(PROP_HAZE_ALTITUDE_EFFECT, getHazeAltitudeEffect()); + APPEND_ENTITY_PROPERTY(PROP_HAZE_CEILING, getHazeCeiling()); APPEND_ENTITY_PROPERTY(PROP_HAZE_BASE_REF, getHazeBaseRef()); APPEND_ENTITY_PROPERTY(PROP_HAZE_BACKGROUND_BLEND, getHazeBackgroundBlend()); @@ -344,7 +359,8 @@ int HazePropertyGroup::readEntitySubclassDataFromBuffer(const unsigned char* dat READ_ENTITY_PROPERTY(PROP_HAZE_ENABLE_LIGHT_BLEND, bool, setHazeEnableLightBlend); READ_ENTITY_PROPERTY(PROP_HAZE_LIGHT_BLEND_ANGLE, float, setHazeLightBlendAngle); - READ_ENTITY_PROPERTY(PROP_HAZE_ALTITUDE, float, setHazeCeiling); + READ_ENTITY_PROPERTY(PROP_HAZE_ALTITUDE_EFFECT, bool, setHazeAltitudeEffect); + READ_ENTITY_PROPERTY(PROP_HAZE_CEILING, float, setHazeCeiling); READ_ENTITY_PROPERTY(PROP_HAZE_BASE_REF, float, setHazeBaseRef); READ_ENTITY_PROPERTY(PROP_HAZE_BACKGROUND_BLEND, float, setHazeBackgroundBlend); diff --git a/libraries/entities/src/HazePropertyGroup.h b/libraries/entities/src/HazePropertyGroup.h index 97d02f570e..4ec4a33a24 100644 --- a/libraries/entities/src/HazePropertyGroup.h +++ b/libraries/entities/src/HazePropertyGroup.h @@ -94,8 +94,9 @@ public: DEFINE_PROPERTY(PROP_HAZE_ENABLE_LIGHT_BLEND, HazeEnableLightBlend, hazeEnableLightBlend, bool, false); DEFINE_PROPERTY_REF(PROP_HAZE_LIGHT_BLEND_ANGLE, HazeLightBlendAngle, hazeLightBlendAngle, float, DEFAULT_HAZE_LIGHT_BLEND_ANGLE); - // Range & Altitude parameters - DEFINE_PROPERTY_REF(PROP_HAZE_ALTITUDE, HazeCeiling, hazeCeiling, float, DEFAULT_HAZE_CEILING); + // 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); // Background (skybox) blend value diff --git a/libraries/model/src/model/Stage.h b/libraries/model/src/model/Stage.h index 901c97cfe6..256c25524b 100644 --- a/libraries/model/src/model/Stage.h +++ b/libraries/model/src/model/Stage.h @@ -197,6 +197,8 @@ public: void setHazeLightBlendAngle(float hazeLightBlendAngle) { _hazeLightBlendAngle = hazeLightBlendAngle; } float getHazeLightBlendAngle() const { return _hazeLightBlendAngle; } + 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; } @@ -223,6 +225,7 @@ protected: bool _hazeEnableLightBlend; float _hazeLightBlendAngle; + bool _hazeAltitudeEffect; float _hazeCeiling; float _hazeBaseRef; diff --git a/libraries/script-engine/src/SceneScriptingInterface.cpp b/libraries/script-engine/src/SceneScriptingInterface.cpp index b330b4cf2a..dde06a6785 100644 --- a/libraries/script-engine/src/SceneScriptingInterface.cpp +++ b/libraries/script-engine/src/SceneScriptingInterface.cpp @@ -180,6 +180,12 @@ float SceneScripting::Stage::getHazeLightBlendAngle() const { return _skyStage->getHazeLightBlendAngle(); } +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); } diff --git a/libraries/script-engine/src/SceneScriptingInterface.h b/libraries/script-engine/src/SceneScriptingInterface.h index 4de0f5f894..5e6db82b3d 100644 --- a/libraries/script-engine/src/SceneScriptingInterface.h +++ b/libraries/script-engine/src/SceneScriptingInterface.h @@ -145,6 +145,10 @@ namespace SceneScripting { void setHazeLightBlendAngle(float value); float getHazeLightBlendAngle() 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; diff --git a/scripts/system/html/js/entityProperties.js b/scripts/system/html/js/entityProperties.js index 5cd2e22337..1edd7477a1 100644 --- a/scripts/system/html/js/entityProperties.js +++ b/scripts/system/html/js/entityProperties.js @@ -671,6 +671,7 @@ function loaded() { var elZoneHazeEnableLightBlend = document.getElementById("property-zone-haze-enable-light-blend"); var elZoneHazeLightBlendAngle = document.getElementById("property-zone-haze-blend-angle"); + var elZoneHazeAltitudeEffect = document.getElementById("property-zone-haze-altitude-effect"); var elZoneHazeBaseRef = document.getElementById("property-zone-haze-base"); var elZoneHazeCeiling = document.getElementById("property-zone-haze-ceiling"); @@ -1043,6 +1044,7 @@ function loaded() { elZoneHazeEnableLightBlend.checked = properties.haze.hazeEnableLightBlend; elZoneHazeLightBlendAngle.value = properties.haze.hazeLightBlendAngle.toFixed(0); + elZoneHazeAltitudeEffect.checked = properties.haze.hazeAltitudeEffect; elZoneHazeBaseRef.value = properties.haze.hazeBaseRef.toFixed(0); elZoneHazeCeiling.value = properties.haze.hazeCeiling.toFixed(0); @@ -1503,6 +1505,7 @@ function loaded() { elZoneHazeEnableLightBlend.addEventListener('change', createEmitGroupCheckedPropertyUpdateFunction('haze', 'hazeEnableLightBlend')); elZoneHazeLightBlendAngle.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('haze', 'hazeLightBlendAngle')); + elZoneHazeAltitudeEffect.addEventListener('change', createEmitGroupCheckedPropertyUpdateFunction('haze', 'hazeAltitudeEffect')); elZoneHazeCeiling.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('haze', 'hazeCeiling')); elZoneHazeBaseRef.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('haze', 'hazeBaseRef')); From 00609c95472f68ac16e1c6503b8183fece8fec03 Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Thu, 12 Oct 2017 07:37:44 -0700 Subject: [PATCH 79/94] Name correction. --- scripts/system/html/entityProperties.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/system/html/entityProperties.html b/scripts/system/html/entityProperties.html index 0cc343f81a..e59ce88540 100644 --- a/scripts/system/html/entityProperties.html +++ b/scripts/system/html/entityProperties.html @@ -562,8 +562,8 @@
- - + +
From d0deaa631c029472141826c83cd1fbf0d7de8e08 Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Thu, 12 Oct 2017 07:54:03 -0700 Subject: [PATCH 80/94] Trying to pretty-up. --- scripts/system/html/entityProperties.html | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/scripts/system/html/entityProperties.html b/scripts/system/html/entityProperties.html index e59ce88540..0b6c621405 100644 --- a/scripts/system/html/entityProperties.html +++ b/scripts/system/html/entityProperties.html @@ -565,10 +565,12 @@
-
-
-
-
+
+
+
+
+
+
From dc45c7af75a78cad33583781172ad3e4b3def454 Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Thu, 12 Oct 2017 11:18:18 -0700 Subject: [PATCH 81/94] Implemented radio-buttons. --- .../entities/src/EntityItemProperties.cpp | 2 +- scripts/system/html/entityProperties.html | 23 +++++++------- scripts/system/html/js/entityProperties.js | 30 ++++++++++++++++--- 3 files changed, 37 insertions(+), 18 deletions(-) diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp index c1eb74cd28..543c4a58b5 100644 --- a/libraries/entities/src/EntityItemProperties.cpp +++ b/libraries/entities/src/EntityItemProperties.cpp @@ -224,7 +224,7 @@ using HazePair = std::pair; const std::array HAZE_MODES = { { HazePair{ HAZE_MODE_INHERIT,{ "inherit" } }, HazePair{ HAZE_MODE_DISABLED,{ "disabled" } }, - HazePair{ HAZE_MODE_ENABLED,{ "range only" } } + HazePair{ HAZE_MODE_ENABLED,{ "enabled" } } } }; QString EntityItemProperties::getHazeModeAsString() const { diff --git a/scripts/system/html/entityProperties.html b/scripts/system/html/entityProperties.html index 0b6c621405..2d5dd35e66 100644 --- a/scripts/system/html/entityProperties.html +++ b/scripts/system/html/entityProperties.html @@ -547,14 +547,11 @@ Haze - +
+ Inherit + Off + On +
@@ -573,10 +570,6 @@
-
- - -
Haze Color
@@ -588,6 +581,10 @@
+
+ + +
Glare Color @@ -602,7 +599,7 @@
-
+
diff --git a/scripts/system/html/js/entityProperties.js b/scripts/system/html/js/entityProperties.js index 1edd7477a1..07ce858f86 100644 --- a/scripts/system/html/js/entityProperties.js +++ b/scripts/system/html/js/entityProperties.js @@ -146,6 +146,22 @@ function createEmitTextPropertyUpdateFunction(propertyName) { }; } +function createHazeModeChangedFunction(zoneHazeModeInherit, zoneHazeModeDisabled, zoneHazeModeEnabled) { + return function() { + var hazeMode; + + if (zoneHazeModeInherit.checked) { + hazeMode = 'inherit'; + } else if (zoneHazeModeDisabled.checked) { + hazeMode = 'disabled'; + } else if (zoneHazeModeEnabled.checked) { + hazeMode = 'enabled'; + } + + updateProperty('hazeMode', hazeMode); + } +} + function createEmitGroupTextPropertyUpdateFunction(group, propertyName) { return function() { var properties = {}; @@ -657,7 +673,9 @@ function loaded() { var elZoneKeyLightDirectionZ = document.getElementById("property-zone-key-light-direction-z"); var elZoneKeyLightAmbientURL = document.getElementById("property-zone-key-ambient-url"); - var elZoneHazeMode = document.getElementById("property-zone-haze-mode"); + var elZoneHazeModeInherit = document.getElementById("property-zone-haze-mode-inherit"); + var elZoneHazeModeDisabled = document.getElementById("property-zone-haze-mode-disabled"); + var elZoneHazeModeEnabled = document.getElementById("property-zone-haze-mode-enabled"); var elZoneHazeRange = document.getElementById("property-zone-haze-range"); var elZoneHazeBlendInColor = document.getElementById("property-zone-haze-blend-in-color"); @@ -1018,8 +1036,9 @@ function loaded() { elZoneKeyLightDirectionY.value = properties.keyLight.direction.y.toFixed(2); elZoneKeyLightAmbientURL.value = properties.keyLight.ambientURL; - elZoneHazeMode.value = properties.hazeMode; - setDropdownText(elZoneHazeMode); + elZoneHazeModeInherit.checked = (properties.hazeMode == 'inherit'); + elZoneHazeModeDisabled.checked = (properties.hazeMode == 'disabled'); + elZoneHazeModeEnabled.checked = (properties.hazeMode == 'enabled'); elZoneHazeRange.value = properties.haze.hazeRange.toFixed(0); elZoneHazeBlendInColor.style.backgroundColor = "rgb(" + @@ -1448,7 +1467,10 @@ function loaded() { elZoneKeyLightDirectionX.addEventListener('change', zoneKeyLightDirectionChangeFunction); elZoneKeyLightDirectionY.addEventListener('change', zoneKeyLightDirectionChangeFunction); - elZoneHazeMode.addEventListener('change', createEmitTextPropertyUpdateFunction('hazeMode')); + var hazeModeChanged = createHazeModeChangedFunction(elZoneHazeModeInherit, elZoneHazeModeDisabled, elZoneHazeModeEnabled) + elZoneHazeModeInherit.addEventListener('change', hazeModeChanged); + elZoneHazeModeDisabled.addEventListener('change', hazeModeChanged); + elZoneHazeModeEnabled.addEventListener('change', hazeModeChanged); elZoneHazeRange.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('haze', 'hazeRange')); From 7eb9dade6a68bade5e0d0b1de80e078abc1af615 Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Thu, 12 Oct 2017 17:03:33 -0700 Subject: [PATCH 82/94] Added hazeTestInitialPose.js --- scripts/developer/tests/hazeTestInitialPose.js | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 scripts/developer/tests/hazeTestInitialPose.js diff --git a/scripts/developer/tests/hazeTestInitialPose.js b/scripts/developer/tests/hazeTestInitialPose.js new file mode 100644 index 0000000000..e56fb36bc1 --- /dev/null +++ b/scripts/developer/tests/hazeTestInitialPose.js @@ -0,0 +1,5 @@ +var ORIGIN = {x: -68.7, y: 27.4, z: 487.7}; +var ROT_IDENT = {x: 0, y: 0.901, z: 0, w: 0.434}; + +MyAvatar.position = ORIGIN; +MyAvatar.orientation = ROT_IDENT; \ No newline at end of file From 5bfbaf4860e449dac6ab981ced511416f4bcfbab Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Fri, 13 Oct 2017 11:24:56 -0700 Subject: [PATCH 83/94] Renamed HazeMode to ComponentMode. --- .../src/RenderableZoneEntityItem.cpp | 8 ++++---- .../src/RenderableZoneEntityItem.h | 6 +++--- .../entities/src/EntityItemProperties.cpp | 18 +++++++++--------- libraries/entities/src/EntityItemProperties.h | 2 +- libraries/entities/src/ZoneEntityItem.h | 4 ++-- .../shared/src/{HazeMode.h => ComponentMode.h} | 18 +++++++++--------- 6 files changed, 28 insertions(+), 28 deletions(-) rename libraries/shared/src/{HazeMode.h => ComponentMode.h} (52%) diff --git a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp index 87db66aa7d..a3951daa41 100644 --- a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp @@ -172,7 +172,7 @@ void ZoneEntityRenderer::doRender(RenderArgs* args) { } // Haze only if the mode is not inherit - if (_hazeMode != HAZE_MODE_INHERIT) { + if (_hazeMode != COMPONENT_MODE_INHERIT) { _hazeStage->_currentFrame.pushHaze(_hazeIndex); } } @@ -332,12 +332,12 @@ void ZoneEntityRenderer::updateKeyAmbientFromEntity() { } void ZoneEntityRenderer::updateHazeFromEntity(const TypedEntityPointer& entity) { - setHazeMode((HazeMode)entity->getHazeMode()); + setHazeMode((ComponentMode)entity->getHazeMode()); const auto& haze = editHaze(); const uint32_t hazeMode = entity->getHazeMode(); - haze->setHazeActive(hazeMode == HAZE_MODE_ENABLED); + haze->setHazeActive(hazeMode == COMPONENT_MODE_ENABLED); haze->setAltitudeBased(_hazeProperties.getHazeAltitudeEffect()); haze->setHazeRangeFactor(model::convertHazeRangeToHazeRangeFactor(_hazeProperties.getHazeRange())); @@ -471,7 +471,7 @@ void ZoneEntityRenderer::setBackgroundMode(BackgroundMode mode) { _backgroundMode = mode; } -void ZoneEntityRenderer::setHazeMode(HazeMode mode) { +void ZoneEntityRenderer::setHazeMode(ComponentMode mode) { _hazeMode = mode; } diff --git a/libraries/entities-renderer/src/RenderableZoneEntityItem.h b/libraries/entities-renderer/src/RenderableZoneEntityItem.h index d8c451d2a1..30da96cd9d 100644 --- a/libraries/entities-renderer/src/RenderableZoneEntityItem.h +++ b/libraries/entities-renderer/src/RenderableZoneEntityItem.h @@ -21,7 +21,7 @@ #include #include #include "RenderableEntityItem.h" -#include +#include #if 0 #include @@ -55,7 +55,7 @@ private: void setAmbientURL(const QString& ambientUrl); void setSkyboxURL(const QString& skyboxUrl); void setBackgroundMode(BackgroundMode mode); - void setHazeMode(HazeMode mode); + void setHazeMode(ComponentMode mode); void setSkyboxColor(const glm::vec3& color); void setProceduralUserData(const QString& userData); @@ -85,7 +85,7 @@ private: const model::HazePointer _haze{ std::make_shared() }; BackgroundMode _backgroundMode{ BACKGROUND_MODE_INHERIT }; - HazeMode _hazeMode{ HAZE_MODE_INHERIT }; + ComponentMode _hazeMode{ COMPONENT_MODE_INHERIT }; indexed_container::Index _sunIndex{ LightStage::INVALID_INDEX }; indexed_container::Index _ambientIndex{ LightStage::INVALID_INDEX }; diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp index 543c4a58b5..1c6782ba73 100644 --- a/libraries/entities/src/EntityItemProperties.cpp +++ b/libraries/entities/src/EntityItemProperties.cpp @@ -220,27 +220,27 @@ void EntityItemProperties::setBackgroundModeFromString(const QString& background } } -using HazePair = std::pair; -const std::array HAZE_MODES = { { - HazePair{ HAZE_MODE_INHERIT,{ "inherit" } }, - HazePair{ HAZE_MODE_DISABLED,{ "disabled" } }, - HazePair{ HAZE_MODE_ENABLED,{ "enabled" } } +using ComponentPair = std::pair; +const std::array COMPONENT_MODES = { { + ComponentPair{ COMPONENT_MODE_INHERIT,{ "inherit" } }, + ComponentPair{ COMPONENT_MODE_DISABLED,{ "disabled" } }, + ComponentPair{ COMPONENT_MODE_ENABLED,{ "enabled" } } } }; QString EntityItemProperties::getHazeModeAsString() const { - return HAZE_MODES[_hazeMode].second; + return COMPONENT_MODES[_hazeMode].second; } QString EntityItemProperties::getHazeModeString(uint32_t mode) { - return HAZE_MODES[mode].second; + return COMPONENT_MODES[mode].second; } void EntityItemProperties::setHazeModeFromString(const QString& hazeMode) { - auto result = std::find_if(HAZE_MODES.begin(), HAZE_MODES.end(), [&](const HazePair& pair) { + auto result = std::find_if(COMPONENT_MODES.begin(), COMPONENT_MODES.end(), [&](const ComponentPair& pair) { return (pair.second == hazeMode); }); - if (result != HAZE_MODES.end()) { + if (result != COMPONENT_MODES.end()) { _hazeMode = result->first; _hazeModeChanged = true; } diff --git a/libraries/entities/src/EntityItemProperties.h b/libraries/entities/src/EntityItemProperties.h index 599d919792..654cd1a6af 100644 --- a/libraries/entities/src/EntityItemProperties.h +++ b/libraries/entities/src/EntityItemProperties.h @@ -179,7 +179,7 @@ public: DEFINE_PROPERTY_REF_ENUM(PROP_BACKGROUND_MODE, BackgroundMode, backgroundMode, BackgroundMode, BACKGROUND_MODE_INHERIT); DEFINE_PROPERTY_GROUP(Stage, stage, StagePropertyGroup); - DEFINE_PROPERTY_REF_ENUM(PROP_HAZE_MODE, HazeMode, hazeMode, uint32_t, (uint32_t)HAZE_MODE_INHERIT); + DEFINE_PROPERTY_REF_ENUM(PROP_HAZE_MODE, HazeMode, hazeMode, uint32_t, (uint32_t)COMPONENT_MODE_INHERIT); DEFINE_PROPERTY_GROUP(Skybox, skybox, SkyboxPropertyGroup); DEFINE_PROPERTY_GROUP(Haze, haze, HazePropertyGroup); diff --git a/libraries/entities/src/ZoneEntityItem.h b/libraries/entities/src/ZoneEntityItem.h index c626789205..9c1c9fd9c1 100644 --- a/libraries/entities/src/ZoneEntityItem.h +++ b/libraries/entities/src/ZoneEntityItem.h @@ -18,7 +18,7 @@ #include "SkyboxPropertyGroup.h" #include "HazePropertyGroup.h" #include "StagePropertyGroup.h" -#include +#include class ZoneEntityItem : public EntityItem { public: @@ -146,7 +146,7 @@ protected: BackgroundMode _backgroundMode = BACKGROUND_MODE_INHERIT; - uint8_t _hazeMode{ (uint8_t)HAZE_MODE_INHERIT }; + uint8_t _hazeMode{ (uint8_t)COMPONENT_MODE_INHERIT }; float _hazeRange{ HazePropertyGroup::DEFAULT_HAZE_RANGE }; xColor _hazeBlendInColor{ HazePropertyGroup::DEFAULT_HAZE_BLEND_IN_COLOR }; diff --git a/libraries/shared/src/HazeMode.h b/libraries/shared/src/ComponentMode.h similarity index 52% rename from libraries/shared/src/HazeMode.h rename to libraries/shared/src/ComponentMode.h index 0c0af013cd..03721c6a45 100644 --- a/libraries/shared/src/HazeMode.h +++ b/libraries/shared/src/ComponentMode.h @@ -1,5 +1,5 @@ // -// HazeMode.h +// ComponentMode.h // libraries/entities/src // // Created by Nissim Hadar on 9/21/17. @@ -9,16 +9,16 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef hifi_HazeMode_h -#define hifi_HazeMode_h +#ifndef hifi_ComponentMode_h +#define hifi_ComponentMode_h -enum HazeMode { - HAZE_MODE_INHERIT, - HAZE_MODE_DISABLED, - HAZE_MODE_ENABLED, +enum ComponentMode { + COMPONENT_MODE_INHERIT, + COMPONENT_MODE_DISABLED, + COMPONENT_MODE_ENABLED, - HAZE_MODE_ITEM_COUNT + COMPONENT_MODE_ITEM_COUNT }; -#endif // hifi_HazeMode_h +#endif // hifi_ComponentMode_h From c76229934cfbd4d8430ab72b790fcf49c5ff9dcc Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Fri, 13 Oct 2017 12:21:00 -0700 Subject: [PATCH 84/94] Changed blend-in colour and blend-out colour to colour and glare colour --- .../src/RenderableZoneEntityItem.cpp | 8 +- .../entities/src/EntityItemProperties.cpp | 4 +- libraries/entities/src/EntityPropertyFlags.h | 4 +- libraries/entities/src/HazePropertyGroup.cpp | 68 ++++++++--------- libraries/entities/src/HazePropertyGroup.h | 8 +- libraries/entities/src/ZoneEntityItem.cpp | 16 ++-- libraries/entities/src/ZoneEntityItem.h | 12 +-- libraries/model/src/model/Stage.h | 12 +-- .../src/SceneScriptingInterface.cpp | 16 ++-- .../src/SceneScriptingInterface.h | 12 +-- scripts/system/html/js/entityProperties.js | 76 +++++++++---------- 11 files changed, 118 insertions(+), 118 deletions(-) diff --git a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp index a3951daa41..864b95ba63 100644 --- a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp @@ -341,10 +341,10 @@ void ZoneEntityRenderer::updateHazeFromEntity(const TypedEntityPointer& entity) haze->setAltitudeBased(_hazeProperties.getHazeAltitudeEffect()); haze->setHazeRangeFactor(model::convertHazeRangeToHazeRangeFactor(_hazeProperties.getHazeRange())); - xColor hazeBlendInColor = _hazeProperties.getHazeBlendInColor(); - haze->setHazeColor(glm::vec3(hazeBlendInColor.red / 255.0, hazeBlendInColor.green / 255.0, hazeBlendInColor.blue / 255.0)); - xColor hazeBlendOutColor = _hazeProperties.getHazeBlendOutColor(); - haze->setDirectionalLightColor(glm::vec3(hazeBlendOutColor.red / 255.0, hazeBlendOutColor.green / 255.0, hazeBlendOutColor.blue / 255.0)); + 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->setHazeEnableLightBlend(_hazeProperties.getHazeEnableLightBlend()); haze->setDirectionalLightBlend(model::convertDirectionalLightAngleToPower(_hazeProperties.getHazeLightBlendAngle())); diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp index 1c6782ba73..7098d0a79d 100644 --- a/libraries/entities/src/EntityItemProperties.cpp +++ b/libraries/entities/src/EntityItemProperties.cpp @@ -1156,8 +1156,8 @@ void EntityItemProperties::entityPropertyFlagsFromScriptValue(const QScriptValue ADD_PROPERTY_TO_MAP(PROP_HAZE_MODE, HazeMode, hazeMode, uint32_t); ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_RANGE, Haze, haze, HazeRange, hazeRange); - ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_BLEND_IN_COLOR, Haze, haze, HazeBlendInColor, hazeBlendInColor); - ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_BLEND_OUT_COLOR, Haze, haze, HazeBlendOutColor, hazeBlendOutColor); + ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_COLOR, Haze, haze, HazeColor, hazeColor); + ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_GLARE_COLOR, Haze, haze, HazeGlareColor, hazeGlareColor); ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_ENABLE_LIGHT_BLEND, Haze, haze, HazeEnableLightBlend, hazeEnableLightBlend); ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_LIGHT_BLEND_ANGLE, Haze, haze, HazeLightBlendAngle, hazeLightBlendAngle); diff --git a/libraries/entities/src/EntityPropertyFlags.h b/libraries/entities/src/EntityPropertyFlags.h index a1ffe6038f..4496ba34cb 100644 --- a/libraries/entities/src/EntityPropertyFlags.h +++ b/libraries/entities/src/EntityPropertyFlags.h @@ -235,8 +235,8 @@ enum EntityPropertyList { PROP_HAZE_MODE = PROP_COLOR, PROP_HAZE_RANGE = PROP_INTENSITY, - PROP_HAZE_BLEND_IN_COLOR = PROP_CUTOFF, - PROP_HAZE_BLEND_OUT_COLOR = PROP_EXPONENT, + PROP_HAZE_COLOR = PROP_CUTOFF, + PROP_HAZE_GLARE_COLOR = PROP_EXPONENT, PROP_HAZE_ENABLE_LIGHT_BLEND = PROP_IS_SPOTLIGHT, PROP_HAZE_LIGHT_BLEND_ANGLE = PROP_DIFFUSE_COLOR, diff --git a/libraries/entities/src/HazePropertyGroup.cpp b/libraries/entities/src/HazePropertyGroup.cpp index 5fd7b1e4c1..62e6fd7e84 100644 --- a/libraries/entities/src/HazePropertyGroup.cpp +++ b/libraries/entities/src/HazePropertyGroup.cpp @@ -16,8 +16,8 @@ #include "EntityItemPropertiesMacros.h" const float HazePropertyGroup::DEFAULT_HAZE_RANGE{ 1000.0f }; -const xColor HazePropertyGroup::DEFAULT_HAZE_BLEND_IN_COLOR{ 128, 154, 179 }; // Bluish -const xColor HazePropertyGroup::DEFAULT_HAZE_BLEND_OUT_COLOR{ 255, 229, 179 }; // Yellowish +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_LIGHT_BLEND_ANGLE{ 20.0 }; const float HazePropertyGroup::DEFAULT_HAZE_CEILING{ 200.0f }; @@ -30,8 +30,8 @@ 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_BLEND_IN_COLOR, Haze, haze, HazeBlendInColor, hazeBlendInColor); - COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_BLEND_OUT_COLOR, Haze, haze, HazeBlendOutColor, hazeBlendOutColor); + COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_COLOR, Haze, haze, HazeColor, hazeColor); + COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_GLARE_COLOR, Haze, haze, HazeGlareColor, hazeGlareColor); COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_ENABLE_LIGHT_BLEND, Haze, haze, HazeEnableLightBlend, hazeEnableLightBlend); COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_LIGHT_BLEND_ANGLE, Haze, haze, HazeLightBlendAngle, hazeLightBlendAngle); @@ -48,8 +48,8 @@ void HazePropertyGroup::copyToScriptValue(const EntityPropertyFlags& desiredProp void HazePropertyGroup::copyFromScriptValue(const QScriptValue& object, bool& _defaultSettings) { COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(haze, hazeRange, float, setHazeRange); - COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(haze, hazeBlendInColor, xColor, setHazeBlendInColor); - COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(haze, hazeBlendOutColor, xColor, setHazeBlendOutColor); + COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(haze, hazeColor, xColor, setHazeColor); + COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(haze, hazeGlareColor, xColor, setHazeGlareColor); COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(haze, hazeEnableLightBlend, bool, setHazeEnableLightBlend); COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(haze, hazeLightBlendAngle, float, setHazeLightBlendAngle); @@ -66,8 +66,8 @@ void HazePropertyGroup::copyFromScriptValue(const QScriptValue& object, bool& _d void HazePropertyGroup::merge(const HazePropertyGroup& other) { COPY_PROPERTY_IF_CHANGED(hazeRange); - COPY_PROPERTY_IF_CHANGED(hazeBlendInColor); - COPY_PROPERTY_IF_CHANGED(hazeBlendOutColor); + COPY_PROPERTY_IF_CHANGED(hazeColor); + COPY_PROPERTY_IF_CHANGED(hazeGlareColor); COPY_PROPERTY_IF_CHANGED(hazeEnableLightBlend); COPY_PROPERTY_IF_CHANGED(hazeLightBlendAngle); @@ -86,8 +86,8 @@ void HazePropertyGroup::debugDump() const { qCDebug(entities) << " HazePropertyGroup: ---------------------------------------------"; qCDebug(entities) << " _hazeRange:" << _hazeRange; - qCDebug(entities) << " _hazeBlendInColor:" << _hazeBlendInColor; - qCDebug(entities) << " _hazeBlendOutColor:" << _hazeBlendOutColor; + qCDebug(entities) << " _hazeColor:" << _hazeColor; + qCDebug(entities) << " _hazeGlareColor:" << _hazeGlareColor; qCDebug(entities) << " _hazeEnableLightBlend:" << _hazeEnableLightBlend; qCDebug(entities) << " _hazeLightBlendAngle:" << _hazeLightBlendAngle; @@ -106,11 +106,11 @@ void HazePropertyGroup::listChangedProperties(QList& out) { if (hazeRangeChanged()) { out << "haze-hazeRange"; } - if (hazeBlendInColorChanged()) { - out << "haze-hazeBlendInColor"; + if (hazeColorChanged()) { + out << "haze-hazeColor"; } - if (hazeBlendOutColorChanged()) { - out << "haze-hazeBlendOutColor"; + if (hazeGlareColorChanged()) { + out << "haze-hazeGlareColor"; } if (hazeEnableLightBlendChanged()) { out << "haze-hazeEnableLightBlend"; @@ -154,8 +154,8 @@ bool HazePropertyGroup::appendToEditPacket(OctreePacketData* packetData, bool successPropertyFits = true; APPEND_ENTITY_PROPERTY(PROP_HAZE_RANGE, getHazeRange()); - APPEND_ENTITY_PROPERTY(PROP_HAZE_BLEND_IN_COLOR, getHazeBlendInColor()); - APPEND_ENTITY_PROPERTY(PROP_HAZE_BLEND_OUT_COLOR, getHazeBlendOutColor()); + APPEND_ENTITY_PROPERTY(PROP_HAZE_COLOR, getHazeColor()); + APPEND_ENTITY_PROPERTY(PROP_HAZE_GLARE_COLOR, getHazeGlareColor()); APPEND_ENTITY_PROPERTY(PROP_HAZE_ENABLE_LIGHT_BLEND, getHazeEnableLightBlend()); APPEND_ENTITY_PROPERTY(PROP_HAZE_LIGHT_BLEND_ANGLE, getHazeLightBlendAngle()); @@ -179,8 +179,8 @@ bool HazePropertyGroup::decodeFromEditPacket(EntityPropertyFlags& propertyFlags, bool somethingChanged = false; READ_ENTITY_PROPERTY(PROP_HAZE_RANGE, float, setHazeRange); - READ_ENTITY_PROPERTY(PROP_HAZE_BLEND_IN_COLOR, xColor, setHazeBlendInColor); - READ_ENTITY_PROPERTY(PROP_HAZE_BLEND_OUT_COLOR, xColor, setHazeBlendOutColor); + READ_ENTITY_PROPERTY(PROP_HAZE_COLOR, xColor, setHazeColor); + READ_ENTITY_PROPERTY(PROP_HAZE_GLARE_COLOR, xColor, setHazeGlareColor); READ_ENTITY_PROPERTY(PROP_HAZE_ENABLE_LIGHT_BLEND, bool, setHazeEnableLightBlend); READ_ENTITY_PROPERTY(PROP_HAZE_LIGHT_BLEND_ANGLE, float, setHazeLightBlendAngle); @@ -195,8 +195,8 @@ bool HazePropertyGroup::decodeFromEditPacket(EntityPropertyFlags& propertyFlags, READ_ENTITY_PROPERTY(PROP_HAZE_KEYLIGHT_ALTITUDE, float, setHazeKeyLightAltitude); DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_RANGE, HazeRange); - DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_BLEND_IN_COLOR, HazeBlendInColor); - DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_BLEND_OUT_COLOR, HazeBlendOutColor); + DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_COLOR, HazeColor); + DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_GLARE_COLOR, HazeGlareColor); DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_ENABLE_LIGHT_BLEND, HazeEnableLightBlend); DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_LIGHT_BLEND_ANGLE, HazeLightBlendAngle); @@ -219,8 +219,8 @@ bool HazePropertyGroup::decodeFromEditPacket(EntityPropertyFlags& propertyFlags, void HazePropertyGroup::markAllChanged() { _hazeRangeChanged = true; - _hazeBlendInColorChanged = true; - _hazeBlendOutColorChanged = true; + _hazeColorChanged = true; + _hazeGlareColorChanged = true; _hazeEnableLightBlendChanged = true; _hazeLightBlendAngleChanged = true; @@ -239,8 +239,8 @@ EntityPropertyFlags HazePropertyGroup::getChangedProperties() const { EntityPropertyFlags changedProperties; CHECK_PROPERTY_CHANGE(PROP_HAZE_RANGE, hazeRange); - CHECK_PROPERTY_CHANGE(PROP_HAZE_BLEND_IN_COLOR, hazeBlendInColor); - CHECK_PROPERTY_CHANGE(PROP_HAZE_BLEND_OUT_COLOR, hazeBlendOutColor); + CHECK_PROPERTY_CHANGE(PROP_HAZE_COLOR, hazeColor); + CHECK_PROPERTY_CHANGE(PROP_HAZE_GLARE_COLOR, hazeGlareColor); CHECK_PROPERTY_CHANGE(PROP_HAZE_ENABLE_LIGHT_BLEND, hazeEnableLightBlend); CHECK_PROPERTY_CHANGE(PROP_HAZE_LIGHT_BLEND_ANGLE, hazeLightBlendAngle); @@ -259,8 +259,8 @@ EntityPropertyFlags HazePropertyGroup::getChangedProperties() const { void HazePropertyGroup::getProperties(EntityItemProperties& properties) const { COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Haze, HazeRange, getHazeRange); - COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Haze, HazeBlendInColor, getHazeBlendInColor); - COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Haze, HazeBlendOutColor, getHazeBlendOutColor); + COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Haze, HazeColor, getHazeColor); + COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Haze, HazeGlareColor, getHazeGlareColor); COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Haze, HazeEnableLightBlend, getHazeEnableLightBlend); COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Haze, HazeLightBlendAngle, getHazeLightBlendAngle); @@ -279,8 +279,8 @@ bool HazePropertyGroup::setProperties(const EntityItemProperties& properties) { bool somethingChanged = false; SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Haze, HazeRange, hazeRange, setHazeRange); - SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Haze, HazeBlendInColor, hazeBlendInColor, setHazeBlendInColor); - SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Haze, HazeBlendOutColor, hazeBlendOutColor, setHazeBlendOutColor); + SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Haze, HazeColor, hazeColor, setHazeColor); + SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Haze, HazeGlareColor, hazeGlareColor, setHazeGlareColor); SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Haze, HazeEnableLightBlend, hazeEnableLightBlend, setHazeEnableLightBlend); SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Haze, HazeLightBlendAngle, hazeLightBlendAngle, setHazeLightBlendAngle); @@ -301,8 +301,8 @@ EntityPropertyFlags HazePropertyGroup::getEntityProperties(EncodeBitstreamParams EntityPropertyFlags requestedProperties; requestedProperties += PROP_HAZE_RANGE; - requestedProperties += PROP_HAZE_BLEND_IN_COLOR; - requestedProperties += PROP_HAZE_BLEND_OUT_COLOR; + requestedProperties += PROP_HAZE_COLOR; + requestedProperties += PROP_HAZE_GLARE_COLOR; requestedProperties += PROP_HAZE_ENABLE_LIGHT_BLEND; requestedProperties += PROP_HAZE_LIGHT_BLEND_ANGLE; @@ -329,8 +329,8 @@ void HazePropertyGroup::appendSubclassData(OctreePacketData* packetData, EncodeB bool successPropertyFits = true; APPEND_ENTITY_PROPERTY(PROP_HAZE_RANGE, getHazeRange()); - APPEND_ENTITY_PROPERTY(PROP_HAZE_BLEND_IN_COLOR, getHazeBlendInColor()); - APPEND_ENTITY_PROPERTY(PROP_HAZE_BLEND_OUT_COLOR, getHazeBlendOutColor()); + APPEND_ENTITY_PROPERTY(PROP_HAZE_COLOR, getHazeColor()); + APPEND_ENTITY_PROPERTY(PROP_HAZE_GLARE_COLOR, getHazeGlareColor()); APPEND_ENTITY_PROPERTY(PROP_HAZE_ENABLE_LIGHT_BLEND, getHazeEnableLightBlend()); APPEND_ENTITY_PROPERTY(PROP_HAZE_LIGHT_BLEND_ANGLE, getHazeLightBlendAngle()); @@ -354,8 +354,8 @@ int HazePropertyGroup::readEntitySubclassDataFromBuffer(const unsigned char* dat const unsigned char* dataAt = data; READ_ENTITY_PROPERTY(PROP_HAZE_RANGE, float, setHazeRange); - READ_ENTITY_PROPERTY(PROP_HAZE_BLEND_IN_COLOR, xColor, setHazeBlendInColor); - READ_ENTITY_PROPERTY(PROP_HAZE_BLEND_OUT_COLOR, xColor, setHazeBlendOutColor); + READ_ENTITY_PROPERTY(PROP_HAZE_COLOR, xColor, setHazeColor); + READ_ENTITY_PROPERTY(PROP_HAZE_GLARE_COLOR, xColor, setHazeGlareColor); READ_ENTITY_PROPERTY(PROP_HAZE_ENABLE_LIGHT_BLEND, bool, setHazeEnableLightBlend); READ_ENTITY_PROPERTY(PROP_HAZE_LIGHT_BLEND_ANGLE, float, setHazeLightBlendAngle); diff --git a/libraries/entities/src/HazePropertyGroup.h b/libraries/entities/src/HazePropertyGroup.h index 4ec4a33a24..d1ce32c472 100644 --- a/libraries/entities/src/HazePropertyGroup.h +++ b/libraries/entities/src/HazePropertyGroup.h @@ -75,8 +75,8 @@ public: bool& somethingChanged) override; static const float DEFAULT_HAZE_RANGE; - static const xColor DEFAULT_HAZE_BLEND_IN_COLOR; - static const xColor DEFAULT_HAZE_BLEND_OUT_COLOR; + static const xColor DEFAULT_HAZE_COLOR; + static const xColor DEFAULT_HAZE_GLARE_COLOR; static const float DEFAULT_HAZE_LIGHT_BLEND_ANGLE; static const float DEFAULT_HAZE_CEILING; @@ -89,8 +89,8 @@ public: // Range only parameters DEFINE_PROPERTY(PROP_HAZE_RANGE, HazeRange, hazeRange, float, DEFAULT_HAZE_RANGE); - DEFINE_PROPERTY_REF(PROP_HAZE_BLEND_IN_COLOR, HazeBlendInColor, hazeBlendInColor, xColor, DEFAULT_HAZE_BLEND_IN_COLOR); - DEFINE_PROPERTY_REF(PROP_HAZE_BLEND_OUT_COLOR, HazeBlendOutColor, hazeBlendOutColor, xColor, DEFAULT_HAZE_BLEND_OUT_COLOR); + 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_ENABLE_LIGHT_BLEND, HazeEnableLightBlend, hazeEnableLightBlend, bool, false); DEFINE_PROPERTY_REF(PROP_HAZE_LIGHT_BLEND_ANGLE, HazeLightBlendAngle, hazeLightBlendAngle, float, DEFAULT_HAZE_LIGHT_BLEND_ANGLE); diff --git a/libraries/entities/src/ZoneEntityItem.cpp b/libraries/entities/src/ZoneEntityItem.cpp index fefdefb6bc..6d5e9099d9 100644 --- a/libraries/entities/src/ZoneEntityItem.cpp +++ b/libraries/entities/src/ZoneEntityItem.cpp @@ -338,22 +338,22 @@ float ZoneEntityItem::getHazeRange() const { return _hazeRange; } -void ZoneEntityItem::setHazeBlendInColor(const xColor hazeBlendInColor) { - _hazeBlendInColor = hazeBlendInColor; +void ZoneEntityItem::setHazeColor(const xColor hazeColor) { + _hazeColor = hazeColor; _hazePropertiesChanged = true; } -xColor ZoneEntityItem::getHazeBlendInColor() const { - return _hazeBlendInColor; +xColor ZoneEntityItem::getHazeColor() const { + return _hazeColor; } -void ZoneEntityItem::setHazeBlendOutColor(const xColor hazeBlendOutColor) { - _hazeBlendOutColor = hazeBlendOutColor; +void ZoneEntityItem::setHazeGlareColor(const xColor hazeGlareColor) { + _hazeGlareColor = hazeGlareColor; _hazePropertiesChanged = true; } -xColor ZoneEntityItem::getHazeBlendOutColor()const { - return _hazeBlendOutColor; +xColor ZoneEntityItem::getHazeGlareColor()const { + return _hazeGlareColor; } void ZoneEntityItem::setHazeEnableLightBlend(const bool hazeEnableLightBlend) { diff --git a/libraries/entities/src/ZoneEntityItem.h b/libraries/entities/src/ZoneEntityItem.h index 9c1c9fd9c1..ebfac294b6 100644 --- a/libraries/entities/src/ZoneEntityItem.h +++ b/libraries/entities/src/ZoneEntityItem.h @@ -75,10 +75,10 @@ public: void setHazeRange(const float hazeRange); float getHazeRange() const; - void setHazeBlendInColor(const xColor hazeBlendInColor); - xColor getHazeBlendInColor() const; - void setHazeBlendOutColor(const xColor hazeBlendOutColor); - xColor getHazeBlendOutColor() const; + void setHazeColor(const xColor hazeColor); + xColor getHazeColor() const; + void setHazeGlareColor(const xColor hazeGlareColor); + xColor getHazeGlareColor() const; void setHazeEnableLightBlend(const bool hazeEnableLightBlend); bool getHazeEnableLightBlend() const; void setHazeLightBlendAngle(const float hazeLightBlendAngle); @@ -149,8 +149,8 @@ protected: uint8_t _hazeMode{ (uint8_t)COMPONENT_MODE_INHERIT }; float _hazeRange{ HazePropertyGroup::DEFAULT_HAZE_RANGE }; - xColor _hazeBlendInColor{ HazePropertyGroup::DEFAULT_HAZE_BLEND_IN_COLOR }; - xColor _hazeBlendOutColor{ HazePropertyGroup::DEFAULT_HAZE_BLEND_OUT_COLOR }; + xColor _hazeColor{ HazePropertyGroup::DEFAULT_HAZE_COLOR }; + xColor _hazeGlareColor{ HazePropertyGroup::DEFAULT_HAZE_GLARE_COLOR }; bool _hazeEnableLightBlend{ false }; float _hazeLightBlendAngle{ HazePropertyGroup::DEFAULT_HAZE_LIGHT_BLEND_ANGLE }; diff --git a/libraries/model/src/model/Stage.h b/libraries/model/src/model/Stage.h index 256c25524b..b8f1a3908a 100644 --- a/libraries/model/src/model/Stage.h +++ b/libraries/model/src/model/Stage.h @@ -188,10 +188,10 @@ public: void setHazeRange(float hazeRange) { _hazeRange = hazeRange; } float getHazeRange() const { return _hazeRange; } - void setHazeBlendInColor(const xColor hazeBlendInColor) { _hazeBlendInColor = hazeBlendInColor; } - xColor getHazeBlendInColor() { return _hazeBlendInColor; } - void setHazeBlendOutColor(const xColor hazeBlendOutColor) { _hazeBlendOutColor = hazeBlendOutColor; } - xColor getHazeBlendOutColor() const { return _hazeBlendOutColor; } + void setHazeColor(const xColor hazeColor) { _hazeColor = hazeColor; } + xColor getHazeColor() { return _hazeColor; } + void setHazeGlareColor(const xColor hazeGlareColor) { _hazeGlareColor = hazeGlareColor; } + xColor getHazeGlareColor() const { return _hazeGlareColor; } void setHazeEnableLightBlend(bool hazeEnableLightBlend) { _hazeEnableLightBlend = hazeEnableLightBlend; } bool getHazeEnableLightBlend() const { return _hazeEnableLightBlend; } void setHazeLightBlendAngle(float hazeLightBlendAngle) { _hazeLightBlendAngle = hazeLightBlendAngle; } @@ -220,8 +220,8 @@ protected: uint8_t _hazeMode = (uint8_t)HAZE_OFF; float _hazeRange; - xColor _hazeBlendInColor; - xColor _hazeBlendOutColor; + xColor _hazeColor; + xColor _hazeGlareColor; bool _hazeEnableLightBlend; float _hazeLightBlendAngle; diff --git a/libraries/script-engine/src/SceneScriptingInterface.cpp b/libraries/script-engine/src/SceneScriptingInterface.cpp index dde06a6785..41eb10be19 100644 --- a/libraries/script-engine/src/SceneScriptingInterface.cpp +++ b/libraries/script-engine/src/SceneScriptingInterface.cpp @@ -155,17 +155,17 @@ void SceneScripting::Stage::setHazeRange(const float hazeRange) { float SceneScripting::Stage::getHazeRange() const { return _skyStage->getHazeRange(); } -void SceneScripting::Stage::setHazeBlendInColor(const xColor hazeBlendInColor) { - _skyStage->setHazeBlendInColor(hazeBlendInColor); +void SceneScripting::Stage::setHazeColor(const xColor hazeColor) { + _skyStage->setHazeColor(hazeColor); } -xColor SceneScripting::Stage::getHazeBlendInColor() const { - return _skyStage->getHazeBlendInColor(); +xColor SceneScripting::Stage::getHazeColor() const { + return _skyStage->getHazeColor(); } -void SceneScripting::Stage::setHazeBlendOutColor(const xColor hazeBlendOutColor) { - _skyStage->setHazeBlendOutColor(hazeBlendOutColor); +void SceneScripting::Stage::setHazeGlareColor(const xColor hazeGlareColor) { + _skyStage->setHazeGlareColor(hazeGlareColor); } -xColor SceneScripting::Stage::getHazeBlendOutColor() const { - return _skyStage->getHazeBlendOutColor(); +xColor SceneScripting::Stage::getHazeGlareColor() const { + return _skyStage->getHazeGlareColor(); } void SceneScripting::Stage::setHazeEnableLightBlend(const bool hazeEnableLightBlend) { _skyStage->setHazeEnableLightBlend(hazeEnableLightBlend); diff --git a/libraries/script-engine/src/SceneScriptingInterface.h b/libraries/script-engine/src/SceneScriptingInterface.h index 5e6db82b3d..ed3158848b 100644 --- a/libraries/script-engine/src/SceneScriptingInterface.h +++ b/libraries/script-engine/src/SceneScriptingInterface.h @@ -129,13 +129,13 @@ namespace SceneScripting { void setHazeRange(float value); float getHazeRange() const; - Q_PROPERTY(xColor hazeBlendInColor READ getHazeBlendInColor WRITE setHazeBlendInColor) - void setHazeBlendInColor(xColor value); - xColor getHazeBlendInColor() const; + Q_PROPERTY(xColor hazeColor READ getHazeColor WRITE setHazeColor) + void setHazeColor(xColor value); + xColor getHazeColor() const; - Q_PROPERTY(xColor hazeBlendOutColor READ getHazeBlendOutColor WRITE setHazeBlendOutColor) - void setHazeBlendOutColor(xColor value); - xColor getHazeBlendOutColor() const; + Q_PROPERTY(xColor hazeGlareColor READ getHazeGlareColor WRITE setHazeGlareColor) + void setHazeGlareColor(xColor value); + xColor getHazeGlareColor() const; Q_PROPERTY(bool hazeEnableLightBlend READ getHazeEnableLightBlend WRITE setHazeEnableLightBlend) void setHazeEnableLightBlend(bool value); diff --git a/scripts/system/html/js/entityProperties.js b/scripts/system/html/js/entityProperties.js index 07ce858f86..bbb59cab04 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 elZoneHazeBlendInColor = document.getElementById("property-zone-haze-blend-in-color"); - var elZoneHazeBlendInColorRed = document.getElementById("property-zone-haze-blend-in-color-red"); - var elZoneHazeBlendInColorGreen = document.getElementById("property-zone-haze-blend-in-color-green"); - var elZoneHazeBlendInColorBlue = document.getElementById("property-zone-haze-blend-in-color-blue"); - var elZoneHazeBlendOutColor = document.getElementById("property-zone-haze-blend-out-color"); - var elZoneHazeBlendOutColorRed = document.getElementById("property-zone-haze-blend-out-color-red"); - var elZoneHazeBlendOutColorGreen = document.getElementById("property-zone-haze-blend-out-color-green"); - var elZoneHazeBlendOutColorBlue = document.getElementById("property-zone-haze-blend-out-color-blue"); + 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 elZoneHazeEnableLightBlend = document.getElementById("property-zone-haze-enable-light-blend"); var elZoneHazeLightBlendAngle = document.getElementById("property-zone-haze-blend-angle"); @@ -1041,24 +1041,24 @@ function loaded() { elZoneHazeModeEnabled.checked = (properties.hazeMode == 'enabled'); elZoneHazeRange.value = properties.haze.hazeRange.toFixed(0); - elZoneHazeBlendInColor.style.backgroundColor = "rgb(" + - properties.haze.hazeBlendInColor.red + "," + - properties.haze.hazeBlendInColor.green + "," + - properties.haze.hazeBlendInColor.blue + ")"; + elZoneHazeColor.style.backgroundColor = "rgb(" + + properties.haze.hazeColor.red + "," + + properties.haze.hazeColor.green + "," + + properties.haze.hazeColor.blue + ")"; - elZoneHazeBlendInColorRed.value = properties.haze.hazeBlendInColor.red; - elZoneHazeBlendInColorGreen.value = properties.haze.hazeBlendInColor.green; - elZoneHazeBlendInColorBlue.value = properties.haze.hazeBlendInColor.blue; + elZoneHazeColorRed.value = properties.haze.hazeColor.red; + elZoneHazeColorGreen.value = properties.haze.hazeColor.green; + elZoneHazeColorBlue.value = properties.haze.hazeColor.blue; elZoneHazeBackgroundBlend.value = properties.haze.hazeBackgroundBlend.toFixed(2); - elZoneHazeBlendOutColor.style.backgroundColor = "rgb(" + - properties.haze.hazeBlendOutColor.red + "," + - properties.haze.hazeBlendOutColor.green + "," + - properties.haze.hazeBlendOutColor.blue + ")"; + elZoneHazeGlareColor.style.backgroundColor = "rgb(" + + properties.haze.hazeGlareColor.red + "," + + properties.haze.hazeGlareColor.green + "," + + properties.haze.hazeGlareColor.blue + ")"; - elZoneHazeBlendOutColorRed.value = properties.haze.hazeBlendOutColor.red; - elZoneHazeBlendOutColorGreen.value = properties.haze.hazeBlendOutColor.green; - elZoneHazeBlendOutColorBlue.value = properties.haze.hazeBlendOutColor.blue; + elZoneHazeGlareColorRed.value = properties.haze.hazeGlareColor.red; + elZoneHazeGlareColorGreen.value = properties.haze.hazeGlareColor.green; + elZoneHazeGlareColorBlue.value = properties.haze.hazeGlareColor.blue; elZoneHazeEnableLightBlend.checked = properties.haze.hazeEnableLightBlend; elZoneHazeLightBlendAngle.value = properties.haze.hazeLightBlendAngle.toFixed(0); @@ -1487,17 +1487,17 @@ function loaded() { onSubmit: function(hsb, hex, rgb, el) { $(el).css('background-color', '#' + hex); $(el).colpickHide(); - emitColorPropertyUpdate('hazeBlendInColor', rgb.r, rgb.g, rgb.b, 'haze'); + emitColorPropertyUpdate('hazeColor', rgb.r, rgb.g, rgb.b, 'haze'); } })); - var zoneHazeBlendInColorChangeFunction = createEmitGroupColorPropertyUpdateFunction('haze', 'hazeBlendInColor', - elZoneHazeBlendInColorRed, - elZoneHazeBlendInColorGreen, - elZoneHazeBlendInColorBlue); + var zoneHazeColorChangeFunction = createEmitGroupColorPropertyUpdateFunction('haze', 'hazeColor', + elZoneHazeColorRed, + elZoneHazeColorGreen, + elZoneHazeColorBlue); - elZoneHazeBlendInColorRed.addEventListener('change', zoneHazeBlendInColorChangeFunction); - elZoneHazeBlendInColorGreen.addEventListener('change', zoneHazeBlendInColorChangeFunction); - elZoneHazeBlendInColorBlue.addEventListener('change', zoneHazeBlendInColorChangeFunction); + elZoneHazeColorRed.addEventListener('change', zoneHazeColorChangeFunction); + elZoneHazeColorGreen.addEventListener('change', zoneHazeColorChangeFunction); + elZoneHazeColorBlue.addEventListener('change', zoneHazeColorChangeFunction); colorPickers.push($('#property-zone-haze-blend-out-color').colpick({ colorScheme: 'dark', @@ -1512,17 +1512,17 @@ function loaded() { onSubmit: function(hsb, hex, rgb, el) { $(el).css('background-color', '#' + hex); $(el).colpickHide(); - emitColorPropertyUpdate('hazeBlendOutColor', rgb.r, rgb.g, rgb.b, 'haze'); + emitColorPropertyUpdate('hazeGlareColor', rgb.r, rgb.g, rgb.b, 'haze'); } })); - var zoneHazeBlendOutColorChangeFunction = createEmitGroupColorPropertyUpdateFunction('haze', 'hazeBlendOutColor', - elZoneHazeBlendOutColorRed, - elZoneHazeBlendOutColorGreen, - elZoneHazeBlendOutColorBlue); + var zoneHazeGlareColorChangeFunction = createEmitGroupColorPropertyUpdateFunction('haze', 'hazeGlareColor', + elZoneHazeGlareColorRed, + elZoneHazeGlareColorGreen, + elZoneHazeGlareColorBlue); - elZoneHazeBlendOutColorRed.addEventListener('change', zoneHazeBlendOutColorChangeFunction); - elZoneHazeBlendOutColorGreen.addEventListener('change', zoneHazeBlendOutColorChangeFunction); - elZoneHazeBlendOutColorBlue.addEventListener('change', zoneHazeBlendOutColorChangeFunction); + elZoneHazeGlareColorRed.addEventListener('change', zoneHazeGlareColorChangeFunction); + elZoneHazeGlareColorGreen.addEventListener('change', zoneHazeGlareColorChangeFunction); + elZoneHazeGlareColorBlue.addEventListener('change', zoneHazeGlareColorChangeFunction); elZoneHazeEnableLightBlend.addEventListener('change', createEmitGroupCheckedPropertyUpdateFunction('haze', 'hazeEnableLightBlend')); elZoneHazeLightBlendAngle.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('haze', 'hazeLightBlendAngle')); From 6697d7c93a17cec2ce64f30daa61d7a348a640ed Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Fri, 13 Oct 2017 12:49:38 -0700 Subject: [PATCH 85/94] Simplified setHazeColor. --- libraries/model/src/model/Haze.cpp | 29 ++++++++--------------------- libraries/model/src/model/Haze.h | 23 +++++++++++++++-------- 2 files changed, 23 insertions(+), 29 deletions(-) diff --git a/libraries/model/src/model/Haze.cpp b/libraries/model/src/model/Haze.cpp index 3654fb3467..c98c44b7a2 100644 --- a/libraries/model/src/model/Haze.cpp +++ b/libraries/model/src/model/Haze.cpp @@ -31,32 +31,19 @@ enum HazeModes { // For color modulated mode, the colour values are used as range values, which are then converted to range factors // This is separate for each colour. // The colour value is converted from [0.0 .. 1.0] to [5.0 .. 3000.0] +const float OFFSET = 5.0f; +const float BIAS = (3000.0f - 5.0f) / (1.0f - 0.0f); void Haze::setHazeColor(const glm::vec3 hazeColor) { auto& params = _hazeParametersBuffer.get(); - if (params.hazeColor.r != hazeColor.r) { - _hazeParametersBuffer.edit().hazeColor.r = hazeColor.r; + if (params.hazeColor != hazeColor) { + _hazeParametersBuffer.edit().hazeColor = hazeColor; - float range = hazeColor.r * 2995.0f + 5.0f; - float factor = convertHazeRangeToHazeRangeFactor(range); - _hazeParametersBuffer.edit().colorModulationFactor.r = factor; + glm::vec3 range = hazeColor * BIAS + OFFSET; + glm::vec3 factor = convertHazeRangeToHazeRangeFactor(range); + _hazeParametersBuffer.edit().colorModulationFactor = factor; } - if (params.hazeColor.g != hazeColor.g) { - _hazeParametersBuffer.edit().hazeColor.g = hazeColor.g; - - float range = hazeColor.g * 2995.0f + 5.0f; - float factor = convertHazeRangeToHazeRangeFactor(range); - _hazeParametersBuffer.edit().colorModulationFactor.g = factor; - } - - if (params.hazeColor.b != hazeColor.b) { - _hazeParametersBuffer.edit().hazeColor.b = hazeColor.b; - - float range = hazeColor.b * 2995.0f + 5.0f; - float factor = convertHazeRangeToHazeRangeFactor(range); - _hazeParametersBuffer.edit().colorModulationFactor.b = factor; - } -} + } void Haze::setHazeEnableLightBlend(const bool isHazeEnableLightBlend) { auto& params = _hazeParametersBuffer.get(); diff --git a/libraries/model/src/model/Haze.h b/libraries/model/src/model/Haze.h index 7fe8de2735..2340f2fa05 100644 --- a/libraries/model/src/model/Haze.h +++ b/libraries/model/src/model/Haze.h @@ -22,25 +22,32 @@ namespace model { // f = exp(-d * b) // ln(f) = -d * b // b = -ln(f)/d - inline float convertHazeRangeToHazeRangeFactor(const float hazeRange_m) { return (float)-log(p_005) / hazeRange_m; } - - inline float convertHazeAltitudeToHazeAltitudeFactor(const float hazeAltitude_m) { - return (float)-log(p_005) / hazeAltitude_m; + inline glm::vec3 convertHazeRangeToHazeRangeFactor(const glm::vec3 hazeRange_m) { + return glm::vec3( + (float)(-log(p_005) / hazeRange_m.x), + (float)(-log(p_005) / hazeRange_m.y), + (float)(-log(p_005) / hazeRange_m.z)); } - // Derivation (s is th proportion of sun blend, a is the angle at which the blend is 50%, solve for m = 0.5 + inline float convertHazeRangeToHazeRangeFactor(const float hazeRange_m) { return (float)(-log(p_005) / hazeRange_m); } + + inline float convertHazeAltitudeToHazeAltitudeFactor(const float hazeAltitude_m) { + return (float)(-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 // 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(0.5) / log(cos(RADIANS_PER_DEGREE * directionalLightAngle)); + return (float)(log(0.5) / log(cos(RADIANS_PER_DEGREE * directionalLightAngle))); } - const glm::vec3 initialHazeColor{ 0.5, 0.6, 0.7 }; + const glm::vec3 initialHazeColor{ 0.5f, 0.6f, 0.7f }; const float initialDirectionalLightAngle_degs{ 30.0f }; - const glm::vec3 initialDirectionalLightColor{ 1.0, 0.9, 0.7 }; + 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% From 9c9dfc721146022395402bc3a2eae121ff19bc70 Mon Sep 17 00:00:00 2001 From: Nissim Hadar Date: Fri, 13 Oct 2017 13:36:46 -0700 Subject: [PATCH 86/94] Replace light blend with glare. --- .../src/RenderableZoneEntityItem.cpp | 2 +- .../entities/src/EntityItemProperties.cpp | 2 +- libraries/entities/src/EntityPropertyFlags.h | 2 +- libraries/entities/src/HazePropertyGroup.cpp | 32 +++++++++---------- libraries/entities/src/HazePropertyGroup.h | 2 +- libraries/entities/src/ZoneEntityItem.cpp | 8 ++--- libraries/entities/src/ZoneEntityItem.h | 6 ++-- libraries/model/src/model/Haze.cpp | 6 ++-- libraries/model/src/model/Haze.h | 2 +- libraries/model/src/model/Stage.h | 6 ++-- libraries/render-utils/src/DrawHaze.cpp | 6 ++-- libraries/render-utils/src/DrawHaze.h | 10 +++--- libraries/render-utils/src/HazeStage.cpp | 2 +- libraries/render-utils/src/HazeStage.h | 6 ++-- .../src/SceneScriptingInterface.cpp | 8 ++--- .../src/SceneScriptingInterface.h | 6 ++-- scripts/system/html/js/entityProperties.js | 6 ++-- 17 files changed, 56 insertions(+), 56 deletions(-) diff --git a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp index 864b95ba63..b67342ece4 100644 --- a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp @@ -345,7 +345,7 @@ void ZoneEntityRenderer::updateHazeFromEntity(const TypedEntityPointer& entity) 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->setHazeEnableLightBlend(_hazeProperties.getHazeEnableLightBlend()); + haze->setHazeEnableGlare(_hazeProperties.getHazeEnableGlare()); haze->setDirectionalLightBlend(model::convertDirectionalLightAngleToPower(_hazeProperties.getHazeLightBlendAngle())); float hazeAltitude = _hazeProperties.getHazeCeiling() - _hazeProperties.getHazeBaseRef(); diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp index 7098d0a79d..259b6b4935 100644 --- a/libraries/entities/src/EntityItemProperties.cpp +++ b/libraries/entities/src/EntityItemProperties.cpp @@ -1158,7 +1158,7 @@ void EntityItemProperties::entityPropertyFlagsFromScriptValue(const QScriptValue ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_RANGE, Haze, haze, HazeRange, hazeRange); ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_COLOR, Haze, haze, HazeColor, hazeColor); ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_GLARE_COLOR, Haze, haze, HazeGlareColor, hazeGlareColor); - ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_ENABLE_LIGHT_BLEND, Haze, haze, HazeEnableLightBlend, hazeEnableLightBlend); + ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_ENABLE_GLARE, Haze, haze, HazeEnableGlare, hazeEnableGlare); ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_LIGHT_BLEND_ANGLE, Haze, haze, HazeLightBlendAngle, hazeLightBlendAngle); ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_ALTITUDE_EFFECT, Haze, haze, HazeAltitudeEffect, hazeAltitudeEfect); diff --git a/libraries/entities/src/EntityPropertyFlags.h b/libraries/entities/src/EntityPropertyFlags.h index 4496ba34cb..e9a3b9e9d6 100644 --- a/libraries/entities/src/EntityPropertyFlags.h +++ b/libraries/entities/src/EntityPropertyFlags.h @@ -237,7 +237,7 @@ enum EntityPropertyList { PROP_HAZE_RANGE = PROP_INTENSITY, PROP_HAZE_COLOR = PROP_CUTOFF, PROP_HAZE_GLARE_COLOR = PROP_EXPONENT, - PROP_HAZE_ENABLE_LIGHT_BLEND = PROP_IS_SPOTLIGHT, + PROP_HAZE_ENABLE_GLARE = PROP_IS_SPOTLIGHT, PROP_HAZE_LIGHT_BLEND_ANGLE = PROP_DIFFUSE_COLOR, PROP_HAZE_ALTITUDE_EFFECT = PROP_AMBIENT_COLOR_UNUSED, diff --git a/libraries/entities/src/HazePropertyGroup.cpp b/libraries/entities/src/HazePropertyGroup.cpp index 62e6fd7e84..e21f509489 100644 --- a/libraries/entities/src/HazePropertyGroup.cpp +++ b/libraries/entities/src/HazePropertyGroup.cpp @@ -32,7 +32,7 @@ void HazePropertyGroup::copyToScriptValue(const EntityPropertyFlags& desiredProp COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_RANGE, Haze, haze, HazeRange, hazeRange); COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_COLOR, Haze, haze, HazeColor, hazeColor); COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_GLARE_COLOR, Haze, haze, HazeGlareColor, hazeGlareColor); - COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_ENABLE_LIGHT_BLEND, Haze, haze, HazeEnableLightBlend, hazeEnableLightBlend); + COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_ENABLE_GLARE, Haze, haze, HazeEnableGlare, hazeEnableGlare); COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_LIGHT_BLEND_ANGLE, Haze, haze, HazeLightBlendAngle, hazeLightBlendAngle); COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_ALTITUDE_EFFECT, Haze, haze, HazeAltitudeEffect, hazeAltitudeEffect); @@ -50,7 +50,7 @@ void HazePropertyGroup::copyFromScriptValue(const QScriptValue& object, bool& _d COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(haze, hazeRange, float, setHazeRange); COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(haze, hazeColor, xColor, setHazeColor); COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(haze, hazeGlareColor, xColor, setHazeGlareColor); - COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(haze, hazeEnableLightBlend, bool, setHazeEnableLightBlend); + COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(haze, hazeEnableGlare, bool, setHazeEnableGlare); COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(haze, hazeLightBlendAngle, float, setHazeLightBlendAngle); COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(haze, hazeAltitudeEffect, bool, setHazeAltitudeEffect); @@ -68,7 +68,7 @@ void HazePropertyGroup::merge(const HazePropertyGroup& other) { COPY_PROPERTY_IF_CHANGED(hazeRange); COPY_PROPERTY_IF_CHANGED(hazeColor); COPY_PROPERTY_IF_CHANGED(hazeGlareColor); - COPY_PROPERTY_IF_CHANGED(hazeEnableLightBlend); + COPY_PROPERTY_IF_CHANGED(hazeEnableGlare); COPY_PROPERTY_IF_CHANGED(hazeLightBlendAngle); COPY_PROPERTY_IF_CHANGED(hazeAltitudeEffect); @@ -88,7 +88,7 @@ void HazePropertyGroup::debugDump() const { qCDebug(entities) << " _hazeRange:" << _hazeRange; qCDebug(entities) << " _hazeColor:" << _hazeColor; qCDebug(entities) << " _hazeGlareColor:" << _hazeGlareColor; - qCDebug(entities) << " _hazeEnableLightBlend:" << _hazeEnableLightBlend; + qCDebug(entities) << " _hazeEnableGlare:" << _hazeEnableGlare; qCDebug(entities) << " _hazeLightBlendAngle:" << _hazeLightBlendAngle; qCDebug(entities) << " _hazeAltitudeEffect:" << _hazeAltitudeEffect; @@ -112,8 +112,8 @@ void HazePropertyGroup::listChangedProperties(QList& out) { if (hazeGlareColorChanged()) { out << "haze-hazeGlareColor"; } - if (hazeEnableLightBlendChanged()) { - out << "haze-hazeEnableLightBlend"; + if (hazeEnableGlareChanged()) { + out << "haze-hazeEnableGlare"; } if (hazeLightBlendAngleChanged()) { out << "haze-hazeLightBlendAngle"; @@ -156,7 +156,7 @@ bool HazePropertyGroup::appendToEditPacket(OctreePacketData* packetData, APPEND_ENTITY_PROPERTY(PROP_HAZE_RANGE, getHazeRange()); APPEND_ENTITY_PROPERTY(PROP_HAZE_COLOR, getHazeColor()); APPEND_ENTITY_PROPERTY(PROP_HAZE_GLARE_COLOR, getHazeGlareColor()); - APPEND_ENTITY_PROPERTY(PROP_HAZE_ENABLE_LIGHT_BLEND, getHazeEnableLightBlend()); + APPEND_ENTITY_PROPERTY(PROP_HAZE_ENABLE_GLARE, getHazeEnableGlare()); APPEND_ENTITY_PROPERTY(PROP_HAZE_LIGHT_BLEND_ANGLE, getHazeLightBlendAngle()); APPEND_ENTITY_PROPERTY(PROP_HAZE_ALTITUDE_EFFECT, getHazeAltitudeEffect()); @@ -181,7 +181,7 @@ bool HazePropertyGroup::decodeFromEditPacket(EntityPropertyFlags& propertyFlags, READ_ENTITY_PROPERTY(PROP_HAZE_RANGE, float, setHazeRange); READ_ENTITY_PROPERTY(PROP_HAZE_COLOR, xColor, setHazeColor); READ_ENTITY_PROPERTY(PROP_HAZE_GLARE_COLOR, xColor, setHazeGlareColor); - READ_ENTITY_PROPERTY(PROP_HAZE_ENABLE_LIGHT_BLEND, bool, setHazeEnableLightBlend); + READ_ENTITY_PROPERTY(PROP_HAZE_ENABLE_GLARE, bool, setHazeEnableGlare); READ_ENTITY_PROPERTY(PROP_HAZE_LIGHT_BLEND_ANGLE, float, setHazeLightBlendAngle); READ_ENTITY_PROPERTY(PROP_HAZE_ALTITUDE_EFFECT, bool, setHazeAltitudeEffect); @@ -197,7 +197,7 @@ bool HazePropertyGroup::decodeFromEditPacket(EntityPropertyFlags& propertyFlags, DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_RANGE, HazeRange); DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_COLOR, HazeColor); DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_GLARE_COLOR, HazeGlareColor); - DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_ENABLE_LIGHT_BLEND, HazeEnableLightBlend); + DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_ENABLE_GLARE, HazeEnableGlare); DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_LIGHT_BLEND_ANGLE, HazeLightBlendAngle); DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_ALTITUDE_EFFECT, HazeAltitudeEffect); @@ -221,7 +221,7 @@ void HazePropertyGroup::markAllChanged() { _hazeRangeChanged = true; _hazeColorChanged = true; _hazeGlareColorChanged = true; - _hazeEnableLightBlendChanged = true; + _hazeEnableGlareChanged = true; _hazeLightBlendAngleChanged = true; _hazeAltitudeEffectChanged = true; @@ -241,7 +241,7 @@ EntityPropertyFlags HazePropertyGroup::getChangedProperties() const { CHECK_PROPERTY_CHANGE(PROP_HAZE_RANGE, hazeRange); CHECK_PROPERTY_CHANGE(PROP_HAZE_COLOR, hazeColor); CHECK_PROPERTY_CHANGE(PROP_HAZE_GLARE_COLOR, hazeGlareColor); - CHECK_PROPERTY_CHANGE(PROP_HAZE_ENABLE_LIGHT_BLEND, hazeEnableLightBlend); + CHECK_PROPERTY_CHANGE(PROP_HAZE_ENABLE_GLARE, hazeEnableGlare); CHECK_PROPERTY_CHANGE(PROP_HAZE_LIGHT_BLEND_ANGLE, hazeLightBlendAngle); CHECK_PROPERTY_CHANGE(PROP_HAZE_ALTITUDE_EFFECT, hazeAltitudeEffect); @@ -261,7 +261,7 @@ void HazePropertyGroup::getProperties(EntityItemProperties& properties) const { COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Haze, HazeRange, getHazeRange); COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Haze, HazeColor, getHazeColor); COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Haze, HazeGlareColor, getHazeGlareColor); - COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Haze, HazeEnableLightBlend, getHazeEnableLightBlend); + COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Haze, HazeEnableGlare, getHazeEnableGlare); COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Haze, HazeLightBlendAngle, getHazeLightBlendAngle); COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Haze, HazeAltitudeEffect, getHazeAltitudeEffect); @@ -281,7 +281,7 @@ bool HazePropertyGroup::setProperties(const EntityItemProperties& properties) { SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Haze, HazeRange, hazeRange, setHazeRange); SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Haze, HazeColor, hazeColor, setHazeColor); SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Haze, HazeGlareColor, hazeGlareColor, setHazeGlareColor); - SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Haze, HazeEnableLightBlend, hazeEnableLightBlend, setHazeEnableLightBlend); + SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Haze, HazeEnableGlare, hazeEnableGlare, setHazeEnableGlare); SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Haze, HazeLightBlendAngle, hazeLightBlendAngle, setHazeLightBlendAngle); SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Haze, HazeAltitudeEffect, hazeAltitudeEffect, setHazeAltitudeEffect); @@ -303,7 +303,7 @@ EntityPropertyFlags HazePropertyGroup::getEntityProperties(EncodeBitstreamParams requestedProperties += PROP_HAZE_RANGE; requestedProperties += PROP_HAZE_COLOR; requestedProperties += PROP_HAZE_GLARE_COLOR; - requestedProperties += PROP_HAZE_ENABLE_LIGHT_BLEND; + requestedProperties += PROP_HAZE_ENABLE_GLARE; requestedProperties += PROP_HAZE_LIGHT_BLEND_ANGLE; requestedProperties += PROP_HAZE_CEILING; @@ -331,7 +331,7 @@ void HazePropertyGroup::appendSubclassData(OctreePacketData* packetData, EncodeB APPEND_ENTITY_PROPERTY(PROP_HAZE_RANGE, getHazeRange()); APPEND_ENTITY_PROPERTY(PROP_HAZE_COLOR, getHazeColor()); APPEND_ENTITY_PROPERTY(PROP_HAZE_GLARE_COLOR, getHazeGlareColor()); - APPEND_ENTITY_PROPERTY(PROP_HAZE_ENABLE_LIGHT_BLEND, getHazeEnableLightBlend()); + APPEND_ENTITY_PROPERTY(PROP_HAZE_ENABLE_GLARE, getHazeEnableGlare()); APPEND_ENTITY_PROPERTY(PROP_HAZE_LIGHT_BLEND_ANGLE, getHazeLightBlendAngle()); APPEND_ENTITY_PROPERTY(PROP_HAZE_ALTITUDE_EFFECT, getHazeAltitudeEffect()); @@ -356,7 +356,7 @@ int HazePropertyGroup::readEntitySubclassDataFromBuffer(const unsigned char* dat READ_ENTITY_PROPERTY(PROP_HAZE_RANGE, float, setHazeRange); READ_ENTITY_PROPERTY(PROP_HAZE_COLOR, xColor, setHazeColor); READ_ENTITY_PROPERTY(PROP_HAZE_GLARE_COLOR, xColor, setHazeGlareColor); - READ_ENTITY_PROPERTY(PROP_HAZE_ENABLE_LIGHT_BLEND, bool, setHazeEnableLightBlend); + READ_ENTITY_PROPERTY(PROP_HAZE_ENABLE_GLARE, bool, setHazeEnableGlare); READ_ENTITY_PROPERTY(PROP_HAZE_LIGHT_BLEND_ANGLE, float, setHazeLightBlendAngle); READ_ENTITY_PROPERTY(PROP_HAZE_ALTITUDE_EFFECT, bool, setHazeAltitudeEffect); diff --git a/libraries/entities/src/HazePropertyGroup.h b/libraries/entities/src/HazePropertyGroup.h index d1ce32c472..1afd857e5e 100644 --- a/libraries/entities/src/HazePropertyGroup.h +++ b/libraries/entities/src/HazePropertyGroup.h @@ -91,7 +91,7 @@ public: 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_ENABLE_LIGHT_BLEND, HazeEnableLightBlend, hazeEnableLightBlend, bool, false); + DEFINE_PROPERTY(PROP_HAZE_ENABLE_GLARE, HazeEnableGlare, hazeEnableGlare, bool, false); DEFINE_PROPERTY_REF(PROP_HAZE_LIGHT_BLEND_ANGLE, HazeLightBlendAngle, hazeLightBlendAngle, float, DEFAULT_HAZE_LIGHT_BLEND_ANGLE); // Altitude parameters diff --git a/libraries/entities/src/ZoneEntityItem.cpp b/libraries/entities/src/ZoneEntityItem.cpp index 6d5e9099d9..0ac0a20985 100644 --- a/libraries/entities/src/ZoneEntityItem.cpp +++ b/libraries/entities/src/ZoneEntityItem.cpp @@ -356,13 +356,13 @@ xColor ZoneEntityItem::getHazeGlareColor()const { return _hazeGlareColor; } -void ZoneEntityItem::setHazeEnableLightBlend(const bool hazeEnableLightBlend) { - _hazeEnableLightBlend = hazeEnableLightBlend; +void ZoneEntityItem::setHazeEnableGlare(const bool hazeEnableGlare) { + _hazeEnableGlare = hazeEnableGlare; _hazePropertiesChanged = true; } -bool ZoneEntityItem::getHazeEnableLightBlend()const { - return _hazeEnableLightBlend; +bool ZoneEntityItem::getHazeEnableGlare()const { + return _hazeEnableGlare; } void ZoneEntityItem::setHazeLightBlendAngle(const float hazeLightBlendAngle) { diff --git a/libraries/entities/src/ZoneEntityItem.h b/libraries/entities/src/ZoneEntityItem.h index ebfac294b6..df26b37414 100644 --- a/libraries/entities/src/ZoneEntityItem.h +++ b/libraries/entities/src/ZoneEntityItem.h @@ -79,8 +79,8 @@ public: xColor getHazeColor() const; void setHazeGlareColor(const xColor hazeGlareColor); xColor getHazeGlareColor() const; - void setHazeEnableLightBlend(const bool hazeEnableLightBlend); - bool getHazeEnableLightBlend() const; + void setHazeEnableGlare(const bool hazeEnableGlare); + bool getHazeEnableGlare() const; void setHazeLightBlendAngle(const float hazeLightBlendAngle); float getHazeLightBlendAngle() const; @@ -151,7 +151,7 @@ protected: float _hazeRange{ HazePropertyGroup::DEFAULT_HAZE_RANGE }; xColor _hazeColor{ HazePropertyGroup::DEFAULT_HAZE_COLOR }; xColor _hazeGlareColor{ HazePropertyGroup::DEFAULT_HAZE_GLARE_COLOR }; - bool _hazeEnableLightBlend{ false }; + bool _hazeEnableGlare{ false }; float _hazeLightBlendAngle{ HazePropertyGroup::DEFAULT_HAZE_LIGHT_BLEND_ANGLE }; float _hazeCeiling{ HazePropertyGroup::DEFAULT_HAZE_CEILING }; diff --git a/libraries/model/src/model/Haze.cpp b/libraries/model/src/model/Haze.cpp index c98c44b7a2..f5fc04f55e 100644 --- a/libraries/model/src/model/Haze.cpp +++ b/libraries/model/src/model/Haze.cpp @@ -45,13 +45,13 @@ void Haze::setHazeColor(const glm::vec3 hazeColor) { } } -void Haze::setHazeEnableLightBlend(const bool isHazeEnableLightBlend) { +void Haze::setHazeEnableGlare(const bool isHazeEnableGlare) { auto& params = _hazeParametersBuffer.get(); - if (((params.hazeMode & HAZE_MODE_IS_ENABLE_LIGHT_BLEND) == HAZE_MODE_IS_ENABLE_LIGHT_BLEND) && !isHazeEnableLightBlend) { + if (((params.hazeMode & HAZE_MODE_IS_ENABLE_LIGHT_BLEND) == HAZE_MODE_IS_ENABLE_LIGHT_BLEND) && !isHazeEnableGlare) { _hazeParametersBuffer.edit().hazeMode &= ~HAZE_MODE_IS_ENABLE_LIGHT_BLEND; } - else if (((params.hazeMode & HAZE_MODE_IS_ENABLE_LIGHT_BLEND) != HAZE_MODE_IS_ENABLE_LIGHT_BLEND) && isHazeEnableLightBlend) { + else if (((params.hazeMode & HAZE_MODE_IS_ENABLE_LIGHT_BLEND) != HAZE_MODE_IS_ENABLE_LIGHT_BLEND) && isHazeEnableGlare) { _hazeParametersBuffer.edit().hazeMode |= HAZE_MODE_IS_ENABLE_LIGHT_BLEND; } } diff --git a/libraries/model/src/model/Haze.h b/libraries/model/src/model/Haze.h index 2340f2fa05..1467c9ce77 100644 --- a/libraries/model/src/model/Haze.h +++ b/libraries/model/src/model/Haze.h @@ -82,7 +82,7 @@ namespace model { void setAltitudeBased(const bool isAltitudeBased); void setHazeAttenuateKeyLight(const bool isHazeAttenuateKeyLight); void setModulateColorActive(const bool isModulateColorActive); - void setHazeEnableLightBlend(const bool isHazeEnableLightBlend); + void setHazeEnableGlare(const bool isHazeEnableGlare); void setHazeRangeFactor(const float hazeRange); void setHazeAltitudeFactor(const float hazeAltitude); diff --git a/libraries/model/src/model/Stage.h b/libraries/model/src/model/Stage.h index b8f1a3908a..4f704effa7 100644 --- a/libraries/model/src/model/Stage.h +++ b/libraries/model/src/model/Stage.h @@ -192,8 +192,8 @@ public: xColor getHazeColor() { return _hazeColor; } void setHazeGlareColor(const xColor hazeGlareColor) { _hazeGlareColor = hazeGlareColor; } xColor getHazeGlareColor() const { return _hazeGlareColor; } - void setHazeEnableLightBlend(bool hazeEnableLightBlend) { _hazeEnableLightBlend = hazeEnableLightBlend; } - bool getHazeEnableLightBlend() const { return _hazeEnableLightBlend; } + void setHazeEnableGlare(bool hazeEnableGlare) { _hazeEnableGlare = hazeEnableGlare; } + bool getHazeEnableGlare() const { return _hazeEnableGlare; } void setHazeLightBlendAngle(float hazeLightBlendAngle) { _hazeLightBlendAngle = hazeLightBlendAngle; } float getHazeLightBlendAngle() const { return _hazeLightBlendAngle; } @@ -222,7 +222,7 @@ protected: float _hazeRange; xColor _hazeColor; xColor _hazeGlareColor; - bool _hazeEnableLightBlend; + bool _hazeEnableGlare; float _hazeLightBlendAngle; bool _hazeAltitudeEffect; diff --git a/libraries/render-utils/src/DrawHaze.cpp b/libraries/render-utils/src/DrawHaze.cpp index 320aa06c6d..369f5df5e2 100644 --- a/libraries/render-utils/src/DrawHaze.cpp +++ b/libraries/render-utils/src/DrawHaze.cpp @@ -69,8 +69,8 @@ void HazeConfig::setModulateColorActive(const bool active) { isModulateColorActive = active; } -void HazeConfig::setHazeEnableLightBlend(const bool active) { - isHazeEnableLightBlend = active; +void HazeConfig::setHazeEnableGlare(const bool active) { + isHazeEnableGlare = active; } void HazeConfig::setHazeRange_m(const float value) { @@ -108,7 +108,7 @@ void MakeHaze::configure(const Config& config) { _haze->setAltitudeBased(config.isAltitudeBased); _haze->setHazeAttenuateKeyLight(config.isHazeAttenuateKeyLight); _haze->setModulateColorActive(config.isModulateColorActive); - _haze->setHazeEnableLightBlend(config.isHazeEnableLightBlend); + _haze->setHazeEnableGlare(config.isHazeEnableGlare); _haze->setHazeRangeFactor(model::convertHazeRangeToHazeRangeFactor(config.hazeRange_m)); _haze->setHazeAltitudeFactor(model::convertHazeAltitudeToHazeAltitudeFactor(config.hazeAltitude_m)); diff --git a/libraries/render-utils/src/DrawHaze.h b/libraries/render-utils/src/DrawHaze.h index 919ccdb368..4a7b2135bd 100644 --- a/libraries/render-utils/src/DrawHaze.h +++ b/libraries/render-utils/src/DrawHaze.h @@ -43,7 +43,7 @@ class MakeHazeConfig : public render::Job::Config { Q_PROPERTY(bool isAltitudeBased MEMBER isAltitudeBased WRITE setAltitudeBased NOTIFY dirty); Q_PROPERTY(bool isHazeAttenuateKeyLight MEMBER isHazeAttenuateKeyLight WRITE setHazeAttenuateKeyLight NOTIFY dirty); Q_PROPERTY(bool isModulateColorActive MEMBER isModulateColorActive WRITE setModulateColorActive NOTIFY dirty); - Q_PROPERTY(bool isHazeEnableLightBlend MEMBER isHazeEnableLightBlend WRITE setHazeEnableLightBlend 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 hazeAltitude_m MEMBER hazeAltitude_m WRITE setHazeAltitude_m NOTIFY dirty); @@ -70,7 +70,7 @@ public: bool isAltitudeBased{ false }; bool isHazeAttenuateKeyLight{ false }; bool isModulateColorActive{ false }; - bool isHazeEnableLightBlend{ false }; + bool isHazeEnableGlare{ false }; float hazeRange_m{ model::initialHazeRange_m }; float hazeAltitude_m{ model::initialHazeAltitude_m }; @@ -95,7 +95,7 @@ public slots: void setAltitudeBased(const bool active) { isAltitudeBased = active; emit dirty(); } void setHazeAttenuateKeyLight(const bool active) { isHazeAttenuateKeyLight = active; emit dirty(); } void setModulateColorActive(const bool active) { isModulateColorActive = active; emit dirty(); } - void setHazeEnableLightBlend(const bool active) { isHazeEnableLightBlend = 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) { hazeAltitude_m = value; emit dirty(); } @@ -142,7 +142,7 @@ public: bool isAltitudeBased{ false }; bool isHazeAttenuateKeyLight{ false }; bool isModulateColorActive{ false }; - bool isHazeEnableLightBlend{ false }; + bool isHazeEnableGlare{ false }; float hazeRange_m{ model::initialHazeRange_m }; float hazeAltitude_m{ model::initialHazeAltitude_m }; @@ -167,7 +167,7 @@ public: void setAltitudeBased(const bool active); void setHazeAttenuateKeyLight(const bool active); void setModulateColorActive(const bool active); - void setHazeEnableLightBlend(const bool active); + void setHazeEnableGlare(const bool active); void setHazeRange_m(const float value); void setHazeAltitude_m(const float value); diff --git a/libraries/render-utils/src/HazeStage.cpp b/libraries/render-utils/src/HazeStage.cpp index c09fcaa488..aa7a7f554c 100644 --- a/libraries/render-utils/src/HazeStage.cpp +++ b/libraries/render-utils/src/HazeStage.cpp @@ -30,7 +30,7 @@ void FetchHazeStage::configure(const Config& config) { _haze->setAltitudeBased(config.isAltitudeBased); _haze->setHazeAttenuateKeyLight(config.isHazeAttenuateKeyLight); _haze->setModulateColorActive(config.isModulateColorActive); - _haze->setHazeEnableLightBlend(config.isHazeEnableLightBlend); + _haze->setHazeEnableGlare(config.isHazeEnableGlare); _haze->setHazeRangeFactor(model::convertHazeRangeToHazeRangeFactor(config.hazeRange_m)); _haze->setHazeAltitudeFactor(model::convertHazeAltitudeToHazeAltitudeFactor(config.hazeAltitude_m)); diff --git a/libraries/render-utils/src/HazeStage.h b/libraries/render-utils/src/HazeStage.h index 349985ee3b..7cc0c659b0 100644 --- a/libraries/render-utils/src/HazeStage.h +++ b/libraries/render-utils/src/HazeStage.h @@ -97,7 +97,7 @@ class FetchHazeConfig : public render::Job::Config { Q_PROPERTY(bool isAltitudeBased MEMBER isAltitudeBased WRITE setAltitudeBased NOTIFY dirty); Q_PROPERTY(bool isHazeAttenuateKeyLight MEMBER isHazeAttenuateKeyLight WRITE setHazeAttenuateKeyLight NOTIFY dirty); Q_PROPERTY(bool isModulateColorActive MEMBER isModulateColorActive WRITE setModulateColorActive NOTIFY dirty); - Q_PROPERTY(bool isHazeEnableLightBlend MEMBER isHazeEnableLightBlend WRITE setHazeEnableLightBlend 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 hazeAltitude_m MEMBER hazeAltitude_m WRITE setHazeAltitude_m NOTIFY dirty); @@ -124,7 +124,7 @@ public: bool isAltitudeBased{ false }; bool isHazeAttenuateKeyLight{ false }; bool isModulateColorActive{ false }; - bool isHazeEnableLightBlend{ false }; + bool isHazeEnableGlare{ false }; float hazeRange_m{ model::initialHazeRange_m }; float hazeAltitude_m{ model::initialHazeAltitude_m }; @@ -149,7 +149,7 @@ public slots: void setAltitudeBased(const bool active) { isAltitudeBased = active; emit dirty(); } void setHazeAttenuateKeyLight(const bool active) { isHazeAttenuateKeyLight = active; emit dirty(); } void setModulateColorActive(const bool active) { isModulateColorActive = active; emit dirty(); } - void setHazeEnableLightBlend(const bool active) { isHazeEnableLightBlend = 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) { hazeAltitude_m = value; emit dirty(); } diff --git a/libraries/script-engine/src/SceneScriptingInterface.cpp b/libraries/script-engine/src/SceneScriptingInterface.cpp index 41eb10be19..233ecc8b15 100644 --- a/libraries/script-engine/src/SceneScriptingInterface.cpp +++ b/libraries/script-engine/src/SceneScriptingInterface.cpp @@ -167,11 +167,11 @@ void SceneScripting::Stage::setHazeGlareColor(const xColor hazeGlareColor) { xColor SceneScripting::Stage::getHazeGlareColor() const { return _skyStage->getHazeGlareColor(); } -void SceneScripting::Stage::setHazeEnableLightBlend(const bool hazeEnableLightBlend) { - _skyStage->setHazeEnableLightBlend(hazeEnableLightBlend); +void SceneScripting::Stage::setHazeEnableGlare(const bool hazeEnableGlare) { + _skyStage->setHazeEnableGlare(hazeEnableGlare); } -bool SceneScripting::Stage::getHazeEnableLightBlend() const { - return _skyStage->getHazeEnableLightBlend(); +bool SceneScripting::Stage::getHazeEnableGlare() const { + return _skyStage->getHazeEnableGlare(); } void SceneScripting::Stage::setHazeLightBlendAngle(const float hazeLightBlendAngle) { _skyStage->setHazeLightBlendAngle(hazeLightBlendAngle); diff --git a/libraries/script-engine/src/SceneScriptingInterface.h b/libraries/script-engine/src/SceneScriptingInterface.h index ed3158848b..f19e565450 100644 --- a/libraries/script-engine/src/SceneScriptingInterface.h +++ b/libraries/script-engine/src/SceneScriptingInterface.h @@ -137,9 +137,9 @@ namespace SceneScripting { void setHazeGlareColor(xColor value); xColor getHazeGlareColor() const; - Q_PROPERTY(bool hazeEnableLightBlend READ getHazeEnableLightBlend WRITE setHazeEnableLightBlend) - void setHazeEnableLightBlend(bool value); - bool getHazeEnableLightBlend() const; + Q_PROPERTY(bool hazeEnableGlare READ getHazeEnableGlare WRITE setHazeEnableGlare) + void setHazeEnableGlare(bool value); + bool getHazeEnableGlare() const; Q_PROPERTY(float hazeLightBlendAngle READ getHazeLightBlendAngle WRITE setHazeLightBlendAngle) void setHazeLightBlendAngle(float value); diff --git a/scripts/system/html/js/entityProperties.js b/scripts/system/html/js/entityProperties.js index bbb59cab04..1266f88917 100644 --- a/scripts/system/html/js/entityProperties.js +++ b/scripts/system/html/js/entityProperties.js @@ -686,7 +686,7 @@ function loaded() { 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 elZoneHazeEnableLightBlend = document.getElementById("property-zone-haze-enable-light-blend"); + var elZoneHazeEnableGlare = document.getElementById("property-zone-haze-enable-light-blend"); var elZoneHazeLightBlendAngle = document.getElementById("property-zone-haze-blend-angle"); var elZoneHazeAltitudeEffect = document.getElementById("property-zone-haze-altitude-effect"); @@ -1060,7 +1060,7 @@ function loaded() { elZoneHazeGlareColorGreen.value = properties.haze.hazeGlareColor.green; elZoneHazeGlareColorBlue.value = properties.haze.hazeGlareColor.blue; - elZoneHazeEnableLightBlend.checked = properties.haze.hazeEnableLightBlend; + elZoneHazeEnableGlare.checked = properties.haze.hazeEnableGlare; elZoneHazeLightBlendAngle.value = properties.haze.hazeLightBlendAngle.toFixed(0); elZoneHazeAltitudeEffect.checked = properties.haze.hazeAltitudeEffect; @@ -1524,7 +1524,7 @@ function loaded() { elZoneHazeGlareColorGreen.addEventListener('change', zoneHazeGlareColorChangeFunction); elZoneHazeGlareColorBlue.addEventListener('change', zoneHazeGlareColorChangeFunction); - elZoneHazeEnableLightBlend.addEventListener('change', createEmitGroupCheckedPropertyUpdateFunction('haze', 'hazeEnableLightBlend')); + elZoneHazeEnableGlare.addEventListener('change', createEmitGroupCheckedPropertyUpdateFunction('haze', 'hazeEnableGlare')); elZoneHazeLightBlendAngle.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('haze', 'hazeLightBlendAngle')); elZoneHazeAltitudeEffect.addEventListener('change', createEmitGroupCheckedPropertyUpdateFunction('haze', 'hazeAltitudeEffect')); From e51b8047f118efb8fd81bd8240f8e998bb64ceb7 Mon Sep 17 00:00:00 2001 From: Nissim Date: Mon, 16 Oct 2017 11:00:10 -0700 Subject: [PATCH 87/94] Corrected gcc warning. --- libraries/model/src/model/Haze.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libraries/model/src/model/Haze.h b/libraries/model/src/model/Haze.h index 1467c9ce77..1f0188a2ce 100644 --- a/libraries/model/src/model/Haze.h +++ b/libraries/model/src/model/Haze.h @@ -24,9 +24,9 @@ namespace model { // b = -ln(f)/d inline glm::vec3 convertHazeRangeToHazeRangeFactor(const glm::vec3 hazeRange_m) { return glm::vec3( - (float)(-log(p_005) / hazeRange_m.x), - (float)(-log(p_005) / hazeRange_m.y), - (float)(-log(p_005) / hazeRange_m.z)); + -(float)log(p_005) / hazeRange_m.x, + -(float)log(p_005) / hazeRange_m.y, + -(float)log(p_005) / hazeRange_m.z); } inline float convertHazeRangeToHazeRangeFactor(const float hazeRange_m) { return (float)(-log(p_005) / hazeRange_m); } From fd2b0da76d6b40ec4bdde79585504d45099e2a7e Mon Sep 17 00:00:00 2001 From: Nissim Date: Mon, 16 Oct 2017 12:20:31 -0700 Subject: [PATCH 88/94] First version. --- libraries/model/src/model/Light.cpp | 2 +- scripts/system/html/entityProperties.html | 5 ++++ scripts/system/html/js/entityProperties.js | 31 ++++++++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/libraries/model/src/model/Light.cpp b/libraries/model/src/model/Light.cpp index 19da084f84..9c3e0a5282 100755 --- a/libraries/model/src/model/Light.cpp +++ b/libraries/model/src/model/Light.cpp @@ -58,7 +58,7 @@ void Light::setOrientation(const glm::quat& orientation) { } void Light::setDirection(const Vec3& direction) { - _lightSchemaBuffer.edit().volume.direction = (direction); + _lightSchemaBuffer.edit().volume.direction = (_transform.getRotation() * direction); } const Vec3& Light::getDirection() const { diff --git a/scripts/system/html/entityProperties.html b/scripts/system/html/entityProperties.html index 43cd281bbd..4cfc71063f 100644 --- a/scripts/system/html/entityProperties.html +++ b/scripts/system/html/entityProperties.html @@ -514,6 +514,11 @@
+
+ Inherit + Off + On +
diff --git a/scripts/system/html/js/entityProperties.js b/scripts/system/html/js/entityProperties.js index aad26cc7ba..214438de77 100644 --- a/scripts/system/html/js/entityProperties.js +++ b/scripts/system/html/js/entityProperties.js @@ -146,6 +146,22 @@ function createEmitTextPropertyUpdateFunction(propertyName) { }; } +function createZoneComponentModeChangedFunction(zoneComponent, zoneComponentModeInherit, zoneComponentModeDisabled, zoneComponentModeEnabled) { + return function() { + var zoneComponentMode; + + if (zoneComponentModeInherit.checked) { + zoneComponentMode = 'inherit'; + } else if (zoneComponentModeDisabled.checked) { + zoneComponentMode = 'disabled'; + } else if (zoneComponentModeEnabled.checked) { + zoneComponentMode = 'enabled'; + } + + updateProperty(zoneComponent, zoneComponentMode); + } +} + function createEmitGroupTextPropertyUpdateFunction(group, propertyName) { return function() { var properties = {}; @@ -644,6 +660,11 @@ function loaded() { var elZoneSections = document.querySelectorAll(".zone-section"); allSections.push(elZoneSections); + + var elZoneKeyLightModeInherit = document.getElementById("property-zone-component-mode-inherit"); + var elZoneKeyLightModeDisabled = document.getElementById("property-zone-component-mode-disabled"); + var elZoneKeyLightModeEnabled = document.getElementById("property-zone-component-mode-enabled"); + var elZoneStageSunModelEnabled = document.getElementById("property-zone-stage-sun-model-enabled"); var elZoneKeyLightColor = document.getElementById("property-zone-key-light-color"); @@ -983,6 +1004,11 @@ function loaded() { elLightExponent.value = properties.exponent.toFixed(2); elLightCutoff.value = properties.cutoff.toFixed(2); } else if (properties.type == "Zone") { + + elZoneKeyLightModeInherit.checked = (properties.keyLightMode == 'inherit'); + elZoneKeyLightModeDisabled.checked = (properties.keyLightMode == 'disabled'); + elZoneKeyLightModeEnabled.checked = (properties.keyLightMode == 'enabled'); + elZoneStageSunModelEnabled.checked = properties.stage.sunModelEnabled; elZoneKeyLightColor.style.backgroundColor = "rgb(" + properties.keyLight.color.red + "," + properties.keyLight.color.green + "," + properties.keyLight.color.blue + ")"; elZoneKeyLightColorRed.value = properties.keyLight.color.red; @@ -1361,6 +1387,11 @@ function loaded() { } })); + var keyLightModeChanged = createZoneComponentModeChangedFunction('keyLightMode', elZoneKeyLightModeInherit, elZoneKeyLightModeDisabled, elZoneKeyLightModeEnabled) + elZoneKeyLightModeInherit.addEventListener('change', keyLightModeChanged); + elZoneKeyLightModeDisabled.addEventListener('change', keyLightModeChanged); + elZoneKeyLightModeEnabled.addEventListener('change', keyLightModeChanged); + elZoneStageSunModelEnabled.addEventListener('change', createEmitGroupCheckedPropertyUpdateFunction('stage', 'sunModelEnabled')); colorPickers.push($('#property-zone-key-light-color').colpick({ colorScheme: 'dark', From 072ac13120229df1db8805803ae02e08643422e1 Mon Sep 17 00:00:00 2001 From: Nissim Date: Mon, 16 Oct 2017 17:12:59 -0700 Subject: [PATCH 89/94] Fixed gcc warnings. --- libraries/model/src/model/Haze.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/model/src/model/Haze.h b/libraries/model/src/model/Haze.h index 1f0188a2ce..f6d6488b8d 100644 --- a/libraries/model/src/model/Haze.h +++ b/libraries/model/src/model/Haze.h @@ -29,10 +29,10 @@ namespace model { -(float)log(p_005) / hazeRange_m.z); } - inline float convertHazeRangeToHazeRangeFactor(const float hazeRange_m) { return (float)(-log(p_005) / hazeRange_m); } + inline float convertHazeRangeToHazeRangeFactor(const float hazeRange_m) { return (-(float)log(p_005) / hazeRange_m); } inline float convertHazeAltitudeToHazeAltitudeFactor(const float hazeAltitude_m) { - return (float)(-log(p_005) / hazeAltitude_m); + return (-(float)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 a641d6de66817bdf234dcd9f5f5d0394aa661d5a Mon Sep 17 00:00:00 2001 From: Nissim Date: Tue, 17 Oct 2017 09:18:29 -0700 Subject: [PATCH 90/94] Variable rename. --- .../src/RenderableZoneEntityItem.cpp | 2 +- .../entities/src/EntityItemProperties.cpp | 2 +- libraries/entities/src/EntityPropertyFlags.h | 2 +- libraries/entities/src/HazePropertyGroup.cpp | 34 +++++++++---------- libraries/entities/src/HazePropertyGroup.h | 4 +-- libraries/entities/src/ZoneEntityItem.cpp | 8 ++--- libraries/entities/src/ZoneEntityItem.h | 6 ++-- libraries/model/src/model/Haze.h | 15 ++++---- libraries/model/src/model/Stage.h | 6 ++-- .../src/SceneScriptingInterface.cpp | 8 ++--- .../src/SceneScriptingInterface.h | 6 ++-- scripts/system/html/js/entityProperties.js | 6 ++-- 12 files changed, 50 insertions(+), 49 deletions(-) diff --git a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp index b67342ece4..f3b664f9b4 100644 --- a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp @@ -346,7 +346,7 @@ void ZoneEntityRenderer::updateHazeFromEntity(const TypedEntityPointer& entity) xColor hazeGlareColor = _hazeProperties.getHazeGlareColor(); haze->setDirectionalLightColor(glm::vec3(hazeGlareColor.red / 255.0, hazeGlareColor.green / 255.0, hazeGlareColor.blue / 255.0)); haze->setHazeEnableGlare(_hazeProperties.getHazeEnableGlare()); - haze->setDirectionalLightBlend(model::convertDirectionalLightAngleToPower(_hazeProperties.getHazeLightBlendAngle())); + haze->setDirectionalLightBlend(model::convertDirectionalLightAngleToPower(_hazeProperties.getHazeGlareAngle())); float hazeAltitude = _hazeProperties.getHazeCeiling() - _hazeProperties.getHazeBaseRef(); haze->setHazeAltitudeFactor(model::convertHazeAltitudeToHazeAltitudeFactor(hazeAltitude)); diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp index 259b6b4935..7ad2f22144 100644 --- a/libraries/entities/src/EntityItemProperties.cpp +++ b/libraries/entities/src/EntityItemProperties.cpp @@ -1159,7 +1159,7 @@ void EntityItemProperties::entityPropertyFlagsFromScriptValue(const QScriptValue ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_COLOR, Haze, haze, HazeColor, hazeColor); ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_GLARE_COLOR, Haze, haze, HazeGlareColor, hazeGlareColor); ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_ENABLE_GLARE, Haze, haze, HazeEnableGlare, hazeEnableGlare); - ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_LIGHT_BLEND_ANGLE, Haze, haze, HazeLightBlendAngle, hazeLightBlendAngle); + ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_GLARE_ANGLE, Haze, haze, HazeGlareAngle, hazeGlareAngle); ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_ALTITUDE_EFFECT, Haze, haze, HazeAltitudeEffect, hazeAltitudeEfect); ADD_GROUP_PROPERTY_TO_MAP(PROP_HAZE_CEILING, Haze, haze, HazeCeiling, hazeCeiling); diff --git a/libraries/entities/src/EntityPropertyFlags.h b/libraries/entities/src/EntityPropertyFlags.h index e9a3b9e9d6..56ec4faa6d 100644 --- a/libraries/entities/src/EntityPropertyFlags.h +++ b/libraries/entities/src/EntityPropertyFlags.h @@ -238,7 +238,7 @@ enum EntityPropertyList { PROP_HAZE_COLOR = PROP_CUTOFF, PROP_HAZE_GLARE_COLOR = PROP_EXPONENT, PROP_HAZE_ENABLE_GLARE = PROP_IS_SPOTLIGHT, - PROP_HAZE_LIGHT_BLEND_ANGLE = PROP_DIFFUSE_COLOR, + PROP_HAZE_GLARE_ANGLE = PROP_DIFFUSE_COLOR, PROP_HAZE_ALTITUDE_EFFECT = PROP_AMBIENT_COLOR_UNUSED, PROP_HAZE_CEILING = PROP_SPECULAR_COLOR_UNUSED, diff --git a/libraries/entities/src/HazePropertyGroup.cpp b/libraries/entities/src/HazePropertyGroup.cpp index e21f509489..996d2e0cd3 100644 --- a/libraries/entities/src/HazePropertyGroup.cpp +++ b/libraries/entities/src/HazePropertyGroup.cpp @@ -18,7 +18,7 @@ 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_LIGHT_BLEND_ANGLE{ 20.0 }; +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 }; @@ -33,7 +33,7 @@ void HazePropertyGroup::copyToScriptValue(const EntityPropertyFlags& desiredProp COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_COLOR, Haze, haze, HazeColor, hazeColor); COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_GLARE_COLOR, Haze, haze, HazeGlareColor, hazeGlareColor); COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_ENABLE_GLARE, Haze, haze, HazeEnableGlare, hazeEnableGlare); - COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_LIGHT_BLEND_ANGLE, Haze, haze, HazeLightBlendAngle, hazeLightBlendAngle); + COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_GLARE_ANGLE, Haze, haze, HazeGlareAngle, hazeGlareAngle); COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_ALTITUDE_EFFECT, Haze, haze, HazeAltitudeEffect, hazeAltitudeEffect); COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_HAZE_CEILING, Haze, haze, HazeCeiling, hazeCeiling); @@ -51,7 +51,7 @@ void HazePropertyGroup::copyFromScriptValue(const QScriptValue& object, bool& _d COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(haze, hazeColor, xColor, setHazeColor); COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(haze, hazeGlareColor, xColor, setHazeGlareColor); COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(haze, hazeEnableGlare, bool, setHazeEnableGlare); - COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(haze, hazeLightBlendAngle, float, setHazeLightBlendAngle); + COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(haze, hazeGlareAngle, float, setHazeGlareAngle); COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(haze, hazeAltitudeEffect, bool, setHazeAltitudeEffect); COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(haze, hazeCeiling, float, setHazeCeiling); @@ -69,7 +69,7 @@ void HazePropertyGroup::merge(const HazePropertyGroup& other) { COPY_PROPERTY_IF_CHANGED(hazeColor); COPY_PROPERTY_IF_CHANGED(hazeGlareColor); COPY_PROPERTY_IF_CHANGED(hazeEnableGlare); - COPY_PROPERTY_IF_CHANGED(hazeLightBlendAngle); + COPY_PROPERTY_IF_CHANGED(hazeGlareAngle); COPY_PROPERTY_IF_CHANGED(hazeAltitudeEffect); COPY_PROPERTY_IF_CHANGED(hazeCeiling); @@ -89,7 +89,7 @@ void HazePropertyGroup::debugDump() const { qCDebug(entities) << " _hazeColor:" << _hazeColor; qCDebug(entities) << " _hazeGlareColor:" << _hazeGlareColor; qCDebug(entities) << " _hazeEnableGlare:" << _hazeEnableGlare; - qCDebug(entities) << " _hazeLightBlendAngle:" << _hazeLightBlendAngle; + qCDebug(entities) << " _hazeGlareAngle:" << _hazeGlareAngle; qCDebug(entities) << " _hazeAltitudeEffect:" << _hazeAltitudeEffect; qCDebug(entities) << " _hazeCeiling:" << _hazeCeiling; @@ -115,8 +115,8 @@ void HazePropertyGroup::listChangedProperties(QList& out) { if (hazeEnableGlareChanged()) { out << "haze-hazeEnableGlare"; } - if (hazeLightBlendAngleChanged()) { - out << "haze-hazeLightBlendAngle"; + if (hazeGlareAngleChanged()) { + out << "haze-hazeGlareAngle"; } if (hazeAltitudeEffectChanged()) { @@ -157,7 +157,7 @@ bool HazePropertyGroup::appendToEditPacket(OctreePacketData* packetData, APPEND_ENTITY_PROPERTY(PROP_HAZE_COLOR, getHazeColor()); APPEND_ENTITY_PROPERTY(PROP_HAZE_GLARE_COLOR, getHazeGlareColor()); APPEND_ENTITY_PROPERTY(PROP_HAZE_ENABLE_GLARE, getHazeEnableGlare()); - APPEND_ENTITY_PROPERTY(PROP_HAZE_LIGHT_BLEND_ANGLE, getHazeLightBlendAngle()); + APPEND_ENTITY_PROPERTY(PROP_HAZE_GLARE_ANGLE, getHazeGlareAngle()); APPEND_ENTITY_PROPERTY(PROP_HAZE_ALTITUDE_EFFECT, getHazeAltitudeEffect()); APPEND_ENTITY_PROPERTY(PROP_HAZE_CEILING, getHazeCeiling()); @@ -182,7 +182,7 @@ bool HazePropertyGroup::decodeFromEditPacket(EntityPropertyFlags& propertyFlags, READ_ENTITY_PROPERTY(PROP_HAZE_COLOR, xColor, setHazeColor); READ_ENTITY_PROPERTY(PROP_HAZE_GLARE_COLOR, xColor, setHazeGlareColor); READ_ENTITY_PROPERTY(PROP_HAZE_ENABLE_GLARE, bool, setHazeEnableGlare); - READ_ENTITY_PROPERTY(PROP_HAZE_LIGHT_BLEND_ANGLE, float, setHazeLightBlendAngle); + READ_ENTITY_PROPERTY(PROP_HAZE_GLARE_ANGLE, float, setHazeGlareAngle); READ_ENTITY_PROPERTY(PROP_HAZE_ALTITUDE_EFFECT, bool, setHazeAltitudeEffect); READ_ENTITY_PROPERTY(PROP_HAZE_CEILING, float, setHazeCeiling); @@ -198,7 +198,7 @@ bool HazePropertyGroup::decodeFromEditPacket(EntityPropertyFlags& propertyFlags, DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_COLOR, HazeColor); DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_GLARE_COLOR, HazeGlareColor); DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_ENABLE_GLARE, HazeEnableGlare); - DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_LIGHT_BLEND_ANGLE, HazeLightBlendAngle); + DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_GLARE_ANGLE, HazeGlareAngle); DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_ALTITUDE_EFFECT, HazeAltitudeEffect); DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_HAZE_CEILING, HazeCeiling); @@ -222,7 +222,7 @@ void HazePropertyGroup::markAllChanged() { _hazeColorChanged = true; _hazeGlareColorChanged = true; _hazeEnableGlareChanged = true; - _hazeLightBlendAngleChanged = true; + _hazeGlareAngleChanged = true; _hazeAltitudeEffectChanged = true; _hazeCeilingChanged = true; @@ -242,7 +242,7 @@ EntityPropertyFlags HazePropertyGroup::getChangedProperties() const { CHECK_PROPERTY_CHANGE(PROP_HAZE_COLOR, hazeColor); CHECK_PROPERTY_CHANGE(PROP_HAZE_GLARE_COLOR, hazeGlareColor); CHECK_PROPERTY_CHANGE(PROP_HAZE_ENABLE_GLARE, hazeEnableGlare); - CHECK_PROPERTY_CHANGE(PROP_HAZE_LIGHT_BLEND_ANGLE, hazeLightBlendAngle); + CHECK_PROPERTY_CHANGE(PROP_HAZE_GLARE_ANGLE, hazeGlareAngle); CHECK_PROPERTY_CHANGE(PROP_HAZE_ALTITUDE_EFFECT, hazeAltitudeEffect); CHECK_PROPERTY_CHANGE(PROP_HAZE_CEILING, hazeCeiling); @@ -262,7 +262,7 @@ void HazePropertyGroup::getProperties(EntityItemProperties& properties) const { COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Haze, HazeColor, getHazeColor); COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Haze, HazeGlareColor, getHazeGlareColor); COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Haze, HazeEnableGlare, getHazeEnableGlare); - COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Haze, HazeLightBlendAngle, getHazeLightBlendAngle); + COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Haze, HazeGlareAngle, getHazeGlareAngle); COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Haze, HazeAltitudeEffect, getHazeAltitudeEffect); COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Haze, HazeCeiling, getHazeCeiling); @@ -282,7 +282,7 @@ bool HazePropertyGroup::setProperties(const EntityItemProperties& properties) { SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Haze, HazeColor, hazeColor, setHazeColor); SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Haze, HazeGlareColor, hazeGlareColor, setHazeGlareColor); SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Haze, HazeEnableGlare, hazeEnableGlare, setHazeEnableGlare); - SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Haze, HazeLightBlendAngle, hazeLightBlendAngle, setHazeLightBlendAngle); + SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Haze, HazeGlareAngle, hazeGlareAngle, setHazeGlareAngle); SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Haze, HazeAltitudeEffect, hazeAltitudeEffect, setHazeAltitudeEffect); SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Haze, HazeCeiling, hazeCeiling, setHazeCeiling); @@ -304,7 +304,7 @@ EntityPropertyFlags HazePropertyGroup::getEntityProperties(EncodeBitstreamParams requestedProperties += PROP_HAZE_COLOR; requestedProperties += PROP_HAZE_GLARE_COLOR; requestedProperties += PROP_HAZE_ENABLE_GLARE; - requestedProperties += PROP_HAZE_LIGHT_BLEND_ANGLE; + requestedProperties += PROP_HAZE_GLARE_ANGLE; requestedProperties += PROP_HAZE_CEILING; requestedProperties += PROP_HAZE_BASE_REF; @@ -332,7 +332,7 @@ void HazePropertyGroup::appendSubclassData(OctreePacketData* packetData, EncodeB APPEND_ENTITY_PROPERTY(PROP_HAZE_COLOR, getHazeColor()); APPEND_ENTITY_PROPERTY(PROP_HAZE_GLARE_COLOR, getHazeGlareColor()); APPEND_ENTITY_PROPERTY(PROP_HAZE_ENABLE_GLARE, getHazeEnableGlare()); - APPEND_ENTITY_PROPERTY(PROP_HAZE_LIGHT_BLEND_ANGLE, getHazeLightBlendAngle()); + APPEND_ENTITY_PROPERTY(PROP_HAZE_GLARE_ANGLE, getHazeGlareAngle()); APPEND_ENTITY_PROPERTY(PROP_HAZE_ALTITUDE_EFFECT, getHazeAltitudeEffect()); APPEND_ENTITY_PROPERTY(PROP_HAZE_CEILING, getHazeCeiling()); @@ -357,7 +357,7 @@ int HazePropertyGroup::readEntitySubclassDataFromBuffer(const unsigned char* dat READ_ENTITY_PROPERTY(PROP_HAZE_COLOR, xColor, setHazeColor); READ_ENTITY_PROPERTY(PROP_HAZE_GLARE_COLOR, xColor, setHazeGlareColor); READ_ENTITY_PROPERTY(PROP_HAZE_ENABLE_GLARE, bool, setHazeEnableGlare); - READ_ENTITY_PROPERTY(PROP_HAZE_LIGHT_BLEND_ANGLE, float, setHazeLightBlendAngle); + READ_ENTITY_PROPERTY(PROP_HAZE_GLARE_ANGLE, float, setHazeGlareAngle); READ_ENTITY_PROPERTY(PROP_HAZE_ALTITUDE_EFFECT, bool, setHazeAltitudeEffect); READ_ENTITY_PROPERTY(PROP_HAZE_CEILING, float, setHazeCeiling); diff --git a/libraries/entities/src/HazePropertyGroup.h b/libraries/entities/src/HazePropertyGroup.h index 1afd857e5e..cdd36ff7ef 100644 --- a/libraries/entities/src/HazePropertyGroup.h +++ b/libraries/entities/src/HazePropertyGroup.h @@ -77,7 +77,7 @@ public: static const float DEFAULT_HAZE_RANGE; static const xColor DEFAULT_HAZE_COLOR; static const xColor DEFAULT_HAZE_GLARE_COLOR; - static const float DEFAULT_HAZE_LIGHT_BLEND_ANGLE; + static const float DEFAULT_HAZE_GLARE_ANGLE; static const float DEFAULT_HAZE_CEILING; static const float DEFAULT_HAZE_BASE_REF; @@ -92,7 +92,7 @@ public: 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_ENABLE_GLARE, HazeEnableGlare, hazeEnableGlare, bool, false); - DEFINE_PROPERTY_REF(PROP_HAZE_LIGHT_BLEND_ANGLE, HazeLightBlendAngle, hazeLightBlendAngle, float, DEFAULT_HAZE_LIGHT_BLEND_ANGLE); + DEFINE_PROPERTY_REF(PROP_HAZE_GLARE_ANGLE, HazeGlareAngle, hazeGlareAngle, float, DEFAULT_HAZE_GLARE_ANGLE); // Altitude parameters DEFINE_PROPERTY(PROP_HAZE_ALTITUDE_EFFECT, HazeAltitudeEffect, hazeAltitudeEffect, bool, false); diff --git a/libraries/entities/src/ZoneEntityItem.cpp b/libraries/entities/src/ZoneEntityItem.cpp index 764a64b170..077024c3ab 100644 --- a/libraries/entities/src/ZoneEntityItem.cpp +++ b/libraries/entities/src/ZoneEntityItem.cpp @@ -365,13 +365,13 @@ bool ZoneEntityItem::getHazeEnableGlare()const { return _hazeEnableGlare; } -void ZoneEntityItem::setHazeLightBlendAngle(const float hazeLightBlendAngle) { - _hazeLightBlendAngle = hazeLightBlendAngle; +void ZoneEntityItem::setHazeGlareAngle(const float hazeGlareAngle) { + _hazeGlareAngle = hazeGlareAngle; _hazePropertiesChanged = true; } -float ZoneEntityItem::getHazeLightBlendAngle() const { - return _hazeLightBlendAngle; +float ZoneEntityItem::getHazeGlareAngle() const { + return _hazeGlareAngle; } void ZoneEntityItem::setHazeCeiling(const float hazeCeiling) { diff --git a/libraries/entities/src/ZoneEntityItem.h b/libraries/entities/src/ZoneEntityItem.h index df26b37414..066bd5518f 100644 --- a/libraries/entities/src/ZoneEntityItem.h +++ b/libraries/entities/src/ZoneEntityItem.h @@ -81,8 +81,8 @@ public: xColor getHazeGlareColor() const; void setHazeEnableGlare(const bool hazeEnableGlare); bool getHazeEnableGlare() const; - void setHazeLightBlendAngle(const float hazeLightBlendAngle); - float getHazeLightBlendAngle() const; + void setHazeGlareAngle(const float hazeGlareAngle); + float getHazeGlareAngle() const; void setHazeCeiling(const float hazeCeiling); float getHazeCeiling() const; @@ -152,7 +152,7 @@ protected: xColor _hazeColor{ HazePropertyGroup::DEFAULT_HAZE_COLOR }; xColor _hazeGlareColor{ HazePropertyGroup::DEFAULT_HAZE_GLARE_COLOR }; bool _hazeEnableGlare{ false }; - float _hazeLightBlendAngle{ HazePropertyGroup::DEFAULT_HAZE_LIGHT_BLEND_ANGLE }; + float _hazeGlareAngle{ HazePropertyGroup::DEFAULT_HAZE_GLARE_ANGLE }; float _hazeCeiling{ HazePropertyGroup::DEFAULT_HAZE_CEILING }; float _hazeBaseRef{ HazePropertyGroup::DEFAULT_HAZE_BASE_REF }; diff --git a/libraries/model/src/model/Haze.h b/libraries/model/src/model/Haze.h index f6d6488b8d..1bdecc105b 100644 --- a/libraries/model/src/model/Haze.h +++ b/libraries/model/src/model/Haze.h @@ -16,7 +16,8 @@ #include "NumericalConstants.h" namespace model { - const double p_005 = 0.05; + const float LOG_P_005 = (float)log(0.05); + const float LOG_P_05 = (float)log(0.5); // Derivation (d is distance, b is haze coefficient, f is attenuation, solve for f = 0.05 // f = exp(-d * b) @@ -24,15 +25,15 @@ namespace model { // b = -ln(f)/d inline glm::vec3 convertHazeRangeToHazeRangeFactor(const glm::vec3 hazeRange_m) { return glm::vec3( - -(float)log(p_005) / hazeRange_m.x, - -(float)log(p_005) / hazeRange_m.y, - -(float)log(p_005) / hazeRange_m.z); + -LOG_P_005 / hazeRange_m.x, + -LOG_P_005 / hazeRange_m.y, + -LOG_P_005 / hazeRange_m.z); } - inline float convertHazeRangeToHazeRangeFactor(const float hazeRange_m) { return (-(float)log(p_005) / hazeRange_m); } + inline float convertHazeRangeToHazeRangeFactor(const float hazeRange_m) { return (-LOG_P_005 / hazeRange_m); } inline float convertHazeAltitudeToHazeAltitudeFactor(const float hazeAltitude_m) { - return (-(float)log(p_005) / hazeAltitude_m); + 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 @@ -41,7 +42,7 @@ namespace model { // log(m) = p * log(s) // p = log(m) / log(s) inline float convertDirectionalLightAngleToPower(const float directionalLightAngle) { - return (float)(log(0.5) / log(cos(RADIANS_PER_DEGREE * directionalLightAngle))); + return (float)(LOG_P_05 / log(cos(RADIANS_PER_DEGREE * directionalLightAngle))); } const glm::vec3 initialHazeColor{ 0.5f, 0.6f, 0.7f }; diff --git a/libraries/model/src/model/Stage.h b/libraries/model/src/model/Stage.h index 4f704effa7..e009684c62 100644 --- a/libraries/model/src/model/Stage.h +++ b/libraries/model/src/model/Stage.h @@ -194,8 +194,8 @@ public: xColor getHazeGlareColor() const { return _hazeGlareColor; } void setHazeEnableGlare(bool hazeEnableGlare) { _hazeEnableGlare = hazeEnableGlare; } bool getHazeEnableGlare() const { return _hazeEnableGlare; } - void setHazeLightBlendAngle(float hazeLightBlendAngle) { _hazeLightBlendAngle = hazeLightBlendAngle; } - float getHazeLightBlendAngle() const { return _hazeLightBlendAngle; } + void setHazeGlareAngle(float hazeGlareAngle) { _hazeGlareAngle = hazeGlareAngle; } + float getHazeGlareAngle() const { return _hazeGlareAngle; } void setHazeAltitudeEffect(bool hazeAltitudeEffect) { _hazeAltitudeEffect = hazeAltitudeEffect; } bool getHazeAltitudeEffect() const { return _hazeAltitudeEffect; } @@ -223,7 +223,7 @@ protected: xColor _hazeColor; xColor _hazeGlareColor; bool _hazeEnableGlare; - float _hazeLightBlendAngle; + float _hazeGlareAngle; bool _hazeAltitudeEffect; float _hazeCeiling; diff --git a/libraries/script-engine/src/SceneScriptingInterface.cpp b/libraries/script-engine/src/SceneScriptingInterface.cpp index 233ecc8b15..58741f9271 100644 --- a/libraries/script-engine/src/SceneScriptingInterface.cpp +++ b/libraries/script-engine/src/SceneScriptingInterface.cpp @@ -173,11 +173,11 @@ void SceneScripting::Stage::setHazeEnableGlare(const bool hazeEnableGlare) { bool SceneScripting::Stage::getHazeEnableGlare() const { return _skyStage->getHazeEnableGlare(); } -void SceneScripting::Stage::setHazeLightBlendAngle(const float hazeLightBlendAngle) { - _skyStage->setHazeLightBlendAngle(hazeLightBlendAngle); +void SceneScripting::Stage::setHazeGlareAngle(const float hazeGlareAngle) { + _skyStage->setHazeGlareAngle(hazeGlareAngle); } -float SceneScripting::Stage::getHazeLightBlendAngle() const { - return _skyStage->getHazeLightBlendAngle(); +float SceneScripting::Stage::getHazeGlareAngle() const { + return _skyStage->getHazeGlareAngle(); } void SceneScripting::Stage::setHazeAltitudeEffect(const bool hazeAltitudeEffect) { diff --git a/libraries/script-engine/src/SceneScriptingInterface.h b/libraries/script-engine/src/SceneScriptingInterface.h index f19e565450..791390236a 100644 --- a/libraries/script-engine/src/SceneScriptingInterface.h +++ b/libraries/script-engine/src/SceneScriptingInterface.h @@ -141,9 +141,9 @@ namespace SceneScripting { void setHazeEnableGlare(bool value); bool getHazeEnableGlare() const; - Q_PROPERTY(float hazeLightBlendAngle READ getHazeLightBlendAngle WRITE setHazeLightBlendAngle) - void setHazeLightBlendAngle(float value); - float getHazeLightBlendAngle() 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); diff --git a/scripts/system/html/js/entityProperties.js b/scripts/system/html/js/entityProperties.js index 494c47b4a6..a0fa5549af 100644 --- a/scripts/system/html/js/entityProperties.js +++ b/scripts/system/html/js/entityProperties.js @@ -692,7 +692,7 @@ function loaded() { var elZoneHazeGlareColorGreen = document.getElementById("property-zone-haze-blend-out-color-green"); var elZoneHazeGlareColorBlue = document.getElementById("property-zone-haze-blend-out-color-blue"); var elZoneHazeEnableGlare = document.getElementById("property-zone-haze-enable-light-blend"); - var elZoneHazeLightBlendAngle = document.getElementById("property-zone-haze-blend-angle"); + var elZonehazeGlareAngle = document.getElementById("property-zone-haze-blend-angle"); var elZoneHazeAltitudeEffect = document.getElementById("property-zone-haze-altitude-effect"); var elZoneHazeBaseRef = document.getElementById("property-zone-haze-base"); @@ -1071,7 +1071,7 @@ function loaded() { elZoneHazeGlareColorBlue.value = properties.haze.hazeGlareColor.blue; elZoneHazeEnableGlare.checked = properties.haze.hazeEnableGlare; - elZoneHazeLightBlendAngle.value = properties.haze.hazeLightBlendAngle.toFixed(0); + elZonehazeGlareAngle.value = properties.haze.hazeGlareAngle.toFixed(0); elZoneHazeAltitudeEffect.checked = properties.haze.hazeAltitudeEffect; elZoneHazeBaseRef.value = properties.haze.hazeBaseRef.toFixed(0); @@ -1540,7 +1540,7 @@ function loaded() { elZoneHazeGlareColorBlue.addEventListener('change', zoneHazeGlareColorChangeFunction); elZoneHazeEnableGlare.addEventListener('change', createEmitGroupCheckedPropertyUpdateFunction('haze', 'hazeEnableGlare')); - elZoneHazeLightBlendAngle.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('haze', 'hazeLightBlendAngle')); + elZonehazeGlareAngle.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('haze', 'hazeGlareAngle')); elZoneHazeAltitudeEffect.addEventListener('change', createEmitGroupCheckedPropertyUpdateFunction('haze', 'hazeAltitudeEffect')); elZoneHazeCeiling.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('haze', 'hazeCeiling')); From 3e228acdb6a67afa468239da345305ba4e81964d Mon Sep 17 00:00:00 2001 From: Nissim Date: Tue, 17 Oct 2017 10:41:49 -0700 Subject: [PATCH 91/94] Fixed gcc warning. --- libraries/model/src/model/Haze.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/model/src/model/Haze.h b/libraries/model/src/model/Haze.h index 1bdecc105b..5a76d89df8 100644 --- a/libraries/model/src/model/Haze.h +++ b/libraries/model/src/model/Haze.h @@ -42,7 +42,7 @@ namespace model { // log(m) = p * log(s) // p = log(m) / log(s) inline float convertDirectionalLightAngleToPower(const float directionalLightAngle) { - return (float)(LOG_P_05 / log(cos(RADIANS_PER_DEGREE * directionalLightAngle))); + return (float)((LOG_P_05 / log(cos(RADIANS_PER_DEGREE * directionalLightAngle)))); } const glm::vec3 initialHazeColor{ 0.5f, 0.6f, 0.7f }; From 5a1c4d5a308d772367f8fe12f4c48ef9ebcb53e6 Mon Sep 17 00:00:00 2001 From: Nissim Date: Tue, 17 Oct 2017 11:08:15 -0700 Subject: [PATCH 92/94] Fixed gcc warning. --- libraries/model/src/model/Haze.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/model/src/model/Haze.h b/libraries/model/src/model/Haze.h index 5a76d89df8..fe606bf083 100644 --- a/libraries/model/src/model/Haze.h +++ b/libraries/model/src/model/Haze.h @@ -42,7 +42,7 @@ namespace model { // log(m) = p * log(s) // p = log(m) / log(s) inline float convertDirectionalLightAngleToPower(const float directionalLightAngle) { - return (float)((LOG_P_05 / log(cos(RADIANS_PER_DEGREE * directionalLightAngle)))); + return LOG_P_05 / (float)log(cos(RADIANS_PER_DEGREE * directionalLightAngle)); } const glm::vec3 initialHazeColor{ 0.5f, 0.6f, 0.7f }; From 935180bf093bf0b39a749c2e92b39a71b219f056 Mon Sep 17 00:00:00 2001 From: Nissim Date: Tue, 17 Oct 2017 15:02:05 -0700 Subject: [PATCH 93/94] Fixed my bloody stupid mistake... --- scripts/system/html/entityProperties.html | 5 ----- scripts/system/html/js/entityProperties.js | 17 +---------------- 2 files changed, 1 insertion(+), 21 deletions(-) diff --git a/scripts/system/html/entityProperties.html b/scripts/system/html/entityProperties.html index 2aa9753c28..2d5dd35e66 100644 --- a/scripts/system/html/entityProperties.html +++ b/scripts/system/html/entityProperties.html @@ -514,11 +514,6 @@
-
- Inherit - Off - On -
diff --git a/scripts/system/html/js/entityProperties.js b/scripts/system/html/js/entityProperties.js index a0fa5549af..b1e5599dc6 100644 --- a/scripts/system/html/js/entityProperties.js +++ b/scripts/system/html/js/entityProperties.js @@ -660,11 +660,6 @@ function loaded() { var elZoneSections = document.querySelectorAll(".zone-section"); allSections.push(elZoneSections); - - var elZoneKeyLightModeInherit = document.getElementById("property-zone-component-mode-inherit"); - var elZoneKeyLightModeDisabled = document.getElementById("property-zone-component-mode-disabled"); - var elZoneKeyLightModeEnabled = document.getElementById("property-zone-component-mode-enabled"); - var elZoneStageSunModelEnabled = document.getElementById("property-zone-stage-sun-model-enabled"); var elZoneKeyLightColor = document.getElementById("property-zone-key-light-color"); @@ -1030,11 +1025,6 @@ function loaded() { elLightExponent.value = properties.exponent.toFixed(2); elLightCutoff.value = properties.cutoff.toFixed(2); } else if (properties.type == "Zone") { - - elZoneKeyLightModeInherit.checked = (properties.keyLightMode == 'inherit'); - elZoneKeyLightModeDisabled.checked = (properties.keyLightMode == 'disabled'); - elZoneKeyLightModeEnabled.checked = (properties.keyLightMode == 'enabled'); - elZoneStageSunModelEnabled.checked = properties.stage.sunModelEnabled; elZoneKeyLightColor.style.backgroundColor = "rgb(" + properties.keyLight.color.red + "," + properties.keyLight.color.green + "," + properties.keyLight.color.blue + ")"; elZoneKeyLightColorRed.value = properties.keyLight.color.red; @@ -1449,11 +1439,6 @@ function loaded() { } })); - var keyLightModeChanged = createZoneComponentModeChangedFunction('keyLightMode', elZoneKeyLightModeInherit, elZoneKeyLightModeDisabled, elZoneKeyLightModeEnabled) - elZoneKeyLightModeInherit.addEventListener('change', keyLightModeChanged); - elZoneKeyLightModeDisabled.addEventListener('change', keyLightModeChanged); - elZoneKeyLightModeEnabled.addEventListener('change', keyLightModeChanged); - elZoneStageSunModelEnabled.addEventListener('change', createEmitGroupCheckedPropertyUpdateFunction('stage', 'sunModelEnabled')); colorPickers.push($('#property-zone-key-light-color').colpick({ colorScheme: 'dark', @@ -1482,7 +1467,7 @@ function loaded() { elZoneKeyLightDirectionX.addEventListener('change', zoneKeyLightDirectionChangeFunction); elZoneKeyLightDirectionY.addEventListener('change', zoneKeyLightDirectionChangeFunction); - var hazeModeChanged = createHazeModeChangedFunction(elZoneHazeModeInherit, elZoneHazeModeDisabled, elZoneHazeModeEnabled) + var hazeModeChanged = createZoneComponentModeChangedFunction('hazeMode', elZoneHazeModeInherit, elZoneHazeModeDisabled, elZoneHazeModeEnabled) elZoneHazeModeInherit.addEventListener('change', hazeModeChanged); elZoneHazeModeDisabled.addEventListener('change', hazeModeChanged); elZoneHazeModeEnabled.addEventListener('change', hazeModeChanged); From fe286aff832807ccaf74d07d29915cf2f0f74891 Mon Sep 17 00:00:00 2001 From: Nissim Date: Wed, 18 Oct 2017 08:42:07 -0700 Subject: [PATCH 94/94] Andrew's corrections (per coding standard). --- libraries/model/src/model/Haze.cpp | 15 +++++---------- .../render-utils/src/DeferredGlobalLight.slh | 10 ++++++---- .../render-utils/src/DeferredLightingEffect.cpp | 4 ++-- libraries/render-utils/src/DrawHaze.cpp | 2 +- libraries/render-utils/src/Haze.slf | 17 ++++++++--------- .../src/SceneScriptingInterface.cpp | 3 +-- 6 files changed, 23 insertions(+), 28 deletions(-) diff --git a/libraries/model/src/model/Haze.cpp b/libraries/model/src/model/Haze.cpp index f5fc04f55e..679d4ad3d1 100644 --- a/libraries/model/src/model/Haze.cpp +++ b/libraries/model/src/model/Haze.cpp @@ -50,8 +50,7 @@ void Haze::setHazeEnableGlare(const bool isHazeEnableGlare) { if (((params.hazeMode & HAZE_MODE_IS_ENABLE_LIGHT_BLEND) == HAZE_MODE_IS_ENABLE_LIGHT_BLEND) && !isHazeEnableGlare) { _hazeParametersBuffer.edit().hazeMode &= ~HAZE_MODE_IS_ENABLE_LIGHT_BLEND; - } - else if (((params.hazeMode & HAZE_MODE_IS_ENABLE_LIGHT_BLEND) != HAZE_MODE_IS_ENABLE_LIGHT_BLEND) && isHazeEnableGlare) { + } else if (((params.hazeMode & HAZE_MODE_IS_ENABLE_LIGHT_BLEND) != HAZE_MODE_IS_ENABLE_LIGHT_BLEND) && isHazeEnableGlare) { _hazeParametersBuffer.edit().hazeMode |= HAZE_MODE_IS_ENABLE_LIGHT_BLEND; } } @@ -82,8 +81,7 @@ void Haze::setHazeActive(const bool isHazeActive) { if (((params.hazeMode & HAZE_MODE_IS_ACTIVE) == HAZE_MODE_IS_ACTIVE )&& !isHazeActive) { _hazeParametersBuffer.edit().hazeMode &= ~HAZE_MODE_IS_ACTIVE; - } - else if (((params.hazeMode & HAZE_MODE_IS_ACTIVE) != HAZE_MODE_IS_ACTIVE) && isHazeActive) { + } else if (((params.hazeMode & HAZE_MODE_IS_ACTIVE) != HAZE_MODE_IS_ACTIVE) && isHazeActive) { _hazeParametersBuffer.edit().hazeMode |= HAZE_MODE_IS_ACTIVE; } } @@ -93,8 +91,7 @@ void Haze::setAltitudeBased(const bool isAltitudeBased) { if (((params.hazeMode & HAZE_MODE_IS_ALTITUDE_BASED) == HAZE_MODE_IS_ALTITUDE_BASED )&& !isAltitudeBased) { _hazeParametersBuffer.edit().hazeMode &= ~HAZE_MODE_IS_ALTITUDE_BASED; - } - else if (((params.hazeMode & HAZE_MODE_IS_ALTITUDE_BASED) != HAZE_MODE_IS_ALTITUDE_BASED) && isAltitudeBased) { + } else if (((params.hazeMode & HAZE_MODE_IS_ALTITUDE_BASED) != HAZE_MODE_IS_ALTITUDE_BASED) && isAltitudeBased) { _hazeParametersBuffer.edit().hazeMode |= HAZE_MODE_IS_ALTITUDE_BASED; } } @@ -104,8 +101,7 @@ void Haze::setHazeAttenuateKeyLight(const bool isHazeAttenuateKeyLight) { 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) { + } 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; } } @@ -115,8 +111,7 @@ void Haze::setModulateColorActive(const bool isModulateColorActive) { if (((params.hazeMode & HAZE_MODE_IS_MODULATE_COLOR) == HAZE_MODE_IS_MODULATE_COLOR ) && !isModulateColorActive) { _hazeParametersBuffer.edit().hazeMode &= ~HAZE_MODE_IS_MODULATE_COLOR; - } - else if (((params.hazeMode & HAZE_MODE_IS_MODULATE_COLOR) != HAZE_MODE_IS_MODULATE_COLOR) && isModulateColorActive) { + } else if (((params.hazeMode & HAZE_MODE_IS_MODULATE_COLOR) != HAZE_MODE_IS_MODULATE_COLOR) && isModulateColorActive) { _hazeParametersBuffer.edit().hazeMode |= HAZE_MODE_IS_MODULATE_COLOR; } } diff --git a/libraries/render-utils/src/DeferredGlobalLight.slh b/libraries/render-utils/src/DeferredGlobalLight.slh index ae560686e1..cc20f6335e 100644 --- a/libraries/render-utils/src/DeferredGlobalLight.slh +++ b/libraries/render-utils/src/DeferredGlobalLight.slh @@ -145,8 +145,11 @@ vec3 evalSkyboxGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscu Light light = getLight(); vec3 lightDirection = getLightDirection(light); - // Height at which haze density is reduced by 95% - float height_95p = -log(0.05) / hazeParams.hazeAltitudeFactorKeyLight; + // 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; + } // Note that the sine will always be positive float sin_pitch = sqrt(1.0 - lightDirection.y * lightDirection.y); @@ -155,8 +158,7 @@ vec3 evalSkyboxGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscu const float minimumSinPitch = 0.001; if (sin_pitch < minimumSinPitch) { distance = height_95p / minimumSinPitch; - } - else { + } else { distance = height_95p / sin_pitch; } diff --git a/libraries/render-utils/src/DeferredLightingEffect.cpp b/libraries/render-utils/src/DeferredLightingEffect.cpp index 6cd3cb1dca..e6a33a9911 100644 --- a/libraries/render-utils/src/DeferredLightingEffect.cpp +++ b/libraries/render-utils/src/DeferredLightingEffect.cpp @@ -552,7 +552,7 @@ void RenderDeferredSetup::run(const render::RenderContextPointer& renderContext, deferredLightingEffect->setupKeyLightBatch(args, batch, locations->lightBufferUnit, locations->ambientBufferUnit, SKYBOX_MAP_UNIT); // Haze - if (haze != nullptr) { + if (haze) { batch.setUniformBuffer(HAZE_MODEL_BUFFER_SLOT, haze->getHazeParametersBuffer()); } @@ -771,7 +771,7 @@ void DefaultLightingSetup::run(const RenderContextPointer& renderContext) { } } - if (_defaultHaze == nullptr) { + if (!_defaultHaze) { auto hazeStage = renderContext->_scene->getStage(); if (hazeStage) { diff --git a/libraries/render-utils/src/DrawHaze.cpp b/libraries/render-utils/src/DrawHaze.cpp index 369f5df5e2..bf254ce80e 100644 --- a/libraries/render-utils/src/DrawHaze.cpp +++ b/libraries/render-utils/src/DrawHaze.cpp @@ -148,7 +148,7 @@ void DrawHaze::run(const render::RenderContextPointer& renderContext, const Inpu RenderArgs* args = renderContext->args; - if (_hazePipeline == nullptr) { + if (!_hazePipeline) { gpu::ShaderPointer ps = gpu::Shader::createPixel(std::string(Haze_frag)); gpu::ShaderPointer vs = gpu::StandardShaderLib::getDrawViewportQuadTransformTexcoordVS(); diff --git a/libraries/render-utils/src/Haze.slf b/libraries/render-utils/src/Haze.slf index ee552faf63..f9eca755f2 100644 --- a/libraries/render-utils/src/Haze.slf +++ b/libraries/render-utils/src/Haze.slf @@ -69,8 +69,7 @@ void main(void) { vec4 blendedHazeColor; if ((hazeParams.hazeMode & HAZE_MODE_IS_ENABLE_LIGHT_BLEND) == HAZE_MODE_IS_ENABLE_LIGHT_BLEND) { blendedHazeColor = mix(hazeColor, directionalLightColor, power); - } - else { + } else { blendedHazeColor = hazeColor; } @@ -102,15 +101,13 @@ void main(void) { // Compute color after haze effect potentialFragColor = mix(fragColor, vec4(1.0, 1.0, 1.0, 1.0), vec4(hazeAmount, 1.0)); - } - else if ((hazeParams.hazeMode & HAZE_MODE_IS_ALTITUDE_BASED) != HAZE_MODE_IS_ALTITUDE_BASED) { + } else if ((hazeParams.hazeMode & HAZE_MODE_IS_ALTITUDE_BASED) != HAZE_MODE_IS_ALTITUDE_BASED) { // Haze is based only on range float hazeAmount = 1.0 - exp(-distance * hazeParams.hazeRangeFactor); // Compute color after haze effect potentialFragColor = mix(fragColor, blendedHazeColor, hazeAmount); - } - else { + } else { // Haze is based on both range and altitude // Taken from www.crytek.com/download/GDC2007_RealtimeAtmoFxInGamesRev.ppt @@ -128,7 +125,10 @@ void main(void) { float deltaHeight = worldFragPos.y - worldEyePos.y; if (abs(deltaHeight) > slopeThreshold) { float t = hazeParams.hazeAltitudeFactor * deltaHeight; - hazeIntegral *= (1.0 - exp (-t)) / t; + // Protect from wild values + if (abs(t) > 0.0000001) { + hazeIntegral *= (1.0 - exp (-t)) / t; + } } float hazeAmount = 1.0 - exp(-hazeIntegral); @@ -140,8 +140,7 @@ void main(void) { // Mix with background at far range if (distance > 32000.0) { outFragColor = mix(potentialFragColor, fragColor, hazeParams.backgroundBlendValue); - } - else { + } else { outFragColor = potentialFragColor; } } diff --git a/libraries/script-engine/src/SceneScriptingInterface.cpp b/libraries/script-engine/src/SceneScriptingInterface.cpp index 58741f9271..aa22eaa2d1 100644 --- a/libraries/script-engine/src/SceneScriptingInterface.cpp +++ b/libraries/script-engine/src/SceneScriptingInterface.cpp @@ -132,8 +132,7 @@ 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")) { + } else if (mode == QString("haze on")) { _skyStage->setHazeMode(model::SunSkyStage::HAZE_ON); } }