diff --git a/libraries/render-utils/src/FadeEffect.cpp b/libraries/render-utils/src/FadeEffect.cpp index ef15953b2b..7c975ef201 100644 --- a/libraries/render-utils/src/FadeEffect.cpp +++ b/libraries/render-utils/src/FadeEffect.cpp @@ -94,29 +94,46 @@ void FadeSwitchJob::distribute(const render::RenderContextPointer& renderContext void FadeJobConfig::setEditedCategory(int value) { assert(value < EVENT_CATEGORY_COUNT); editedCategory = std::min(EVENT_CATEGORY_COUNT, value); + emit dirtyCategory(); emit dirty(); } void FadeJobConfig::setDuration(float value) { - duration[editedCategory] = value; + _duration[editedCategory] = value; emit dirty(); } +float FadeJobConfig::getDuration() const { + return _duration[editedCategory]; +} + void FadeJobConfig::setBaseSizeX(float value) { baseSize[editedCategory].x = FADE_MIN_SCALE*powf(FADE_MAX_SCALE/ FADE_MIN_SCALE, value); emit dirty(); } +float FadeJobConfig::getBaseSizeX() const { + return logf(baseSize[editedCategory].x / FADE_MIN_SCALE) / logf(FADE_MAX_SCALE / FADE_MIN_SCALE); +} + void FadeJobConfig::setBaseSizeY(float value) { baseSize[editedCategory].y = FADE_MIN_SCALE*powf(FADE_MAX_SCALE / FADE_MIN_SCALE, value); emit dirty(); } +float FadeJobConfig::getBaseSizeY() const { + return logf(baseSize[editedCategory].y / FADE_MIN_SCALE) / logf(FADE_MAX_SCALE / FADE_MIN_SCALE); +} + void FadeJobConfig::setBaseSizeZ(float value) { baseSize[editedCategory].z = FADE_MIN_SCALE*powf(FADE_MAX_SCALE / FADE_MIN_SCALE, value); emit dirty(); } +float FadeJobConfig::getBaseSizeZ() const { + return logf(baseSize[editedCategory].z / FADE_MIN_SCALE) / logf(FADE_MAX_SCALE / FADE_MIN_SCALE); +} + void FadeJobConfig::setBaseLevel(float value) { baseLevel[editedCategory] = value; emit dirty(); @@ -127,21 +144,37 @@ void FadeJobConfig::setBaseInverted(bool value) { emit dirty(); } +bool FadeJobConfig::isBaseInverted() const { + return baseInverted[editedCategory]; +} + void FadeJobConfig::setNoiseSizeX(float value) { noiseSize[editedCategory].x = FADE_MIN_SCALE*powf(FADE_MAX_SCALE / FADE_MIN_SCALE, value); emit dirty(); } +float FadeJobConfig::getNoiseSizeX() const { + return logf(noiseSize[editedCategory].x / FADE_MIN_SCALE) / logf(FADE_MAX_SCALE / FADE_MIN_SCALE); +} + void FadeJobConfig::setNoiseSizeY(float value) { noiseSize[editedCategory].y = FADE_MIN_SCALE*powf(FADE_MAX_SCALE / FADE_MIN_SCALE, value); emit dirty(); } +float FadeJobConfig::getNoiseSizeY() const { + return logf(noiseSize[editedCategory].y / FADE_MIN_SCALE) / logf(FADE_MAX_SCALE / FADE_MIN_SCALE); +} + void FadeJobConfig::setNoiseSizeZ(float value) { noiseSize[editedCategory].z = FADE_MIN_SCALE*powf(FADE_MAX_SCALE / FADE_MIN_SCALE, value); emit dirty(); } +float FadeJobConfig::getNoiseSizeZ() const { + return logf(noiseSize[editedCategory].z / FADE_MIN_SCALE) / logf(FADE_MAX_SCALE / FADE_MIN_SCALE); +} + void FadeJobConfig::setNoiseLevel(float value) { noiseLevel[editedCategory] = value; emit dirty(); @@ -152,6 +185,10 @@ void FadeJobConfig::setEdgeWidth(float value) { emit dirty(); } +float FadeJobConfig::getEdgeWidth() const { + return sqrtf(edgeWidth[editedCategory]); +} + void FadeJobConfig::setEdgeInnerColorR(float value) { edgeInnerColor[editedCategory].r = value; emit dirty(); @@ -205,7 +242,7 @@ void FadeConfigureJob::configure(const Config& config) { for (auto i = 0; i < FadeJobConfig::EVENT_CATEGORY_COUNT; i++) { auto& configuration = _configurations[i]; - _parameters->_durations[i] = config.duration[i]; + _parameters->_durations[i] = config._duration[i]; configuration._baseInvSizeAndLevel.x = 1.f / config.baseSize[i].x; configuration._baseInvSizeAndLevel.y = 1.f / config.baseSize[i].y; configuration._baseInvSizeAndLevel.z = 1.f / config.baseSize[i].z; diff --git a/libraries/render-utils/src/FadeEffect.h b/libraries/render-utils/src/FadeEffect.h index c3e82c6c5d..122449e08a 100644 --- a/libraries/render-utils/src/FadeEffect.h +++ b/libraries/render-utils/src/FadeEffect.h @@ -32,7 +32,7 @@ signals: class FadeJobConfig : public render::Job::Config { Q_OBJECT - Q_PROPERTY(int editedCategory MEMBER editedCategory WRITE setEditedCategory NOTIFY dirty) + Q_PROPERTY(int editedCategory MEMBER editedCategory WRITE setEditedCategory NOTIFY dirtyCategory) Q_PROPERTY(float duration READ getDuration WRITE setDuration NOTIFY dirty) Q_PROPERTY(float baseSizeX READ getBaseSizeX WRITE setBaseSizeX NOTIFY dirty) Q_PROPERTY(float baseSizeY READ getBaseSizeY WRITE setBaseSizeY NOTIFY dirty) @@ -69,37 +69,37 @@ public: void setEditedCategory(int value); void setDuration(float value); - float getDuration() const { return duration[editedCategory]; } + float getDuration() const; void setBaseSizeX(float value); - float getBaseSizeX() const { return baseSize[editedCategory].x; } + float getBaseSizeX() const; void setBaseSizeY(float value); - float getBaseSizeY() const { return baseSize[editedCategory].y; } + float getBaseSizeY() const; void setBaseSizeZ(float value); - float getBaseSizeZ() const { return baseSize[editedCategory].z; } + float getBaseSizeZ() const; void setBaseLevel(float value); float getBaseLevel() const { return baseLevel[editedCategory]; } void setBaseInverted(bool value); - bool isBaseInverted() const { return baseInverted[editedCategory]; } + bool isBaseInverted() const; void setNoiseSizeX(float value); - float getNoiseSizeX() const { return noiseSize[editedCategory].x; } + float getNoiseSizeX() const; void setNoiseSizeY(float value); - float getNoiseSizeY() const { return noiseSize[editedCategory].y; } + float getNoiseSizeY() const; void setNoiseSizeZ(float value); - float getNoiseSizeZ() const { return noiseSize[editedCategory].z; } + float getNoiseSizeZ() const; void setNoiseLevel(float value); float getNoiseLevel() const { return noiseLevel[editedCategory]; } void setEdgeWidth(float value); - float getEdgeWidth() const { return edgeWidth[editedCategory]; } + float getEdgeWidth() const; void setEdgeInnerColorR(float value); float getEdgeInnerColorR() const { return edgeInnerColor[editedCategory].r; } @@ -127,11 +127,11 @@ public: int editedCategory{ ELEMENT_ENTER_LEAVE_DOMAIN }; glm::vec3 baseSize[EVENT_CATEGORY_COUNT]{ - { 0.35f, 0.35f, 0.35f }, // ELEMENT_ENTER_LEAVE_DOMAIN - { 0.35f, 0.35f, 0.35f }, // BUBBLE_ISECT_OWNER - { 0.35f, 0.35f, 0.35f }, // BUBBLE_ISECT_TRESPASSER - { 0.35f, 0.35f, 0.35f }, // USER_ENTER_LEAVE_DOMAIN - { 0.35f, 0.35f, 0.35f }, // AVATAR_CHANGE + { 0.4f, 0.4f, 0.4f }, // ELEMENT_ENTER_LEAVE_DOMAIN + { 0.4f, 0.4f, 0.4f }, // BUBBLE_ISECT_OWNER + { 0.4f, 0.4f, 0.4f }, // BUBBLE_ISECT_TRESPASSER + { 0.875f, 0.4f, 0.875f }, // USER_ENTER_LEAVE_DOMAIN + { 0.4f, 0.4f, 0.4f }, // AVATAR_CHANGE }; float baseLevel[EVENT_CATEGORY_COUNT]{ 1.0f, // ELEMENT_ENTER_LEAVE_DOMAIN @@ -144,15 +144,15 @@ public: false, // ELEMENT_ENTER_LEAVE_DOMAIN false, // BUBBLE_ISECT_OWNER false, // BUBBLE_ISECT_TRESPASSER - false, // USER_ENTER_LEAVE_DOMAIN + true, // USER_ENTER_LEAVE_DOMAIN false, // AVATAR_CHANGE }; glm::vec3 noiseSize[EVENT_CATEGORY_COUNT]{ - { 0.35f, 0.35f, 0.35f }, // ELEMENT_ENTER_LEAVE_DOMAIN - { 0.35f, 0.35f, 0.35f }, // BUBBLE_ISECT_OWNER - { 0.35f, 0.35f, 0.35f }, // BUBBLE_ISECT_TRESPASSER - { 0.35f, 0.35f, 0.35f }, // USER_ENTER_LEAVE_DOMAIN - { 0.35f, 0.35f, 0.35f }, // AVATAR_CHANGE + { 0.41f, 0.41f, 0.41f }, // ELEMENT_ENTER_LEAVE_DOMAIN + { 0.4f, 0.4f, 0.4f }, // BUBBLE_ISECT_OWNER + { 0.4f, 0.4f, 0.4f }, // BUBBLE_ISECT_TRESPASSER + { 0.4f, 0.4f, 0.4f }, // USER_ENTER_LEAVE_DOMAIN + { 0.4f, 0.4f, 0.4f }, // AVATAR_CHANGE }; float noiseLevel[EVENT_CATEGORY_COUNT]{ 1.0f, // ELEMENT_ENTER_LEAVE_DOMAIN @@ -161,18 +161,18 @@ public: 1.0f, // USER_ENTER_LEAVE_DOMAIN 1.0f, // AVATAR_CHANGE }; - float duration[EVENT_CATEGORY_COUNT]{ - 5.0f, // ELEMENT_ENTER_LEAVE_DOMAIN + float _duration[EVENT_CATEGORY_COUNT]{ + 4.0f, // ELEMENT_ENTER_LEAVE_DOMAIN 0.0f, // BUBBLE_ISECT_OWNER 0.0f, // BUBBLE_ISECT_TRESPASSER 3.0f, // USER_ENTER_LEAVE_DOMAIN 3.0f, // AVATAR_CHANGE }; float edgeWidth[EVENT_CATEGORY_COUNT]{ - 0.05f, // ELEMENT_ENTER_LEAVE_DOMAIN - 0.05f, // BUBBLE_ISECT_OWNER - 0.05f, // BUBBLE_ISECT_TRESPASSER - 0.05f, // USER_ENTER_LEAVE_DOMAIN + 0.10f, // ELEMENT_ENTER_LEAVE_DOMAIN + 0.10f, // BUBBLE_ISECT_OWNER + 0.10f, // BUBBLE_ISECT_TRESPASSER + 0.10f, // USER_ENTER_LEAVE_DOMAIN 0.05f, // AVATAR_CHANGE }; glm::vec4 edgeInnerColor[EVENT_CATEGORY_COUNT]{ @@ -192,6 +192,7 @@ public: signals: void dirty(); + void dirtyCategory(); }; diff --git a/scripts/developer/utilities/render/configSlider/ConfigSlider.qml b/scripts/developer/utilities/render/configSlider/ConfigSlider.qml index 996cf4b34c..c1a6d6b7f3 100644 --- a/scripts/developer/utilities/render/configSlider/ConfigSlider.qml +++ b/scripts/developer/utilities/render/configSlider/ConfigSlider.qml @@ -38,6 +38,7 @@ Item { } Label { + id: labelValue text: sliderControl.value.toFixed(root.integral ? 0 : 2) anchors.left: root.left anchors.leftMargin: 200 diff --git a/scripts/developer/utilities/render/debugFade.js b/scripts/developer/utilities/render/debugFade.js index df18e0370a..6632cd8094 100644 --- a/scripts/developer/utilities/render/debugFade.js +++ b/scripts/developer/utilities/render/debugFade.js @@ -15,8 +15,7 @@ var window = new OverlayWindow({ title: 'Fade', source: qml, width: 500, - height: 900 + height: 900, }); window.setPosition(50, 50); window.closed.connect(function() { Script.stop(); }); -Render.getConfig("RenderMainView.DrawFadedOpaqueBounds").enabled = true \ No newline at end of file diff --git a/scripts/developer/utilities/render/fade.qml b/scripts/developer/utilities/render/fade.qml index 3aff96d7cd..9b6ef95837 100644 --- a/scripts/developer/utilities/render/fade.qml +++ b/scripts/developer/utilities/render/fade.qml @@ -23,220 +23,244 @@ Column { CheckBox { text: "Edit Fade" checked: root.switchConfig["editFade"] - onCheckedChanged: { root.switchConfig["editFade"] = checked } + onCheckedChanged: { + root.switchConfig["editFade"] = checked; + Render.getConfig("RenderMainView.DrawFadedOpaqueBounds").enabled = checked; + } } ComboBox { + id: categoryBox width: 400 model: ["Elements enter/leave domain", "Bubble isect. - Owner POV", "Bubble isect. - Trespasser POV", "Another user leaves/arrives", "Changing an avatar"] - onCurrentIndexChanged: { root.config["editedCategory"] = currentIndex } + Timer { + id: postpone + interval: 100; running: false; repeat: false + onTriggered: { paramWidgetLoader.sourceComponent = paramWidgets } + } + onCurrentIndexChanged: { + root.config["editedCategory"] = currentIndex; + // This is a hack to be sure the widgets below properly reflect the change of category: delete the Component + // by setting the loader source to Null and then recreate it 100ms later + paramWidgetLoader.sourceComponent = undefined; + postpone.start() + } } } - Column { - spacing: 8 - ConfigSlider { - label: "Duration" - integral: false - config: root.config - property: "duration" - max: 10.0 - min: 0.1 - width: 400 - } - GroupBox { - title: "Base Gradient" - width: 500 - Column { - spacing: 8 + Component { + id: paramWidgets - ConfigSlider { - label: "Size X" - integral: false - config: root.config - property: "baseSizeX" - max: 1.0 - min: 0.0 - width: 400 - } - ConfigSlider { - label: "Size Y" - integral: false - config: root.config - property: "baseSizeY" - max: 1.0 - min: 0.0 - width: 400 - } - ConfigSlider { - label: "Size Z" - integral: false - config: root.config - property: "baseSizeZ" - max: 1.0 - min: 0.0 - width: 400 - } - ConfigSlider { - label: "Level" - integral: false - config: root.config - property: "baseLevel" - max: 1.0 - min: 0.0 - width: 400 - } - CheckBox { - text: "Invert" - checked: root.config["baseInverted"] - onCheckedChanged: { root.config["baseInverted"] = checked } - } + Column { + spacing: 8 + + ConfigSlider { + label: "Duration" + integral: false + config: root.config + property: "duration" + max: 10.0 + min: 0.1 + width: 400 } - } - GroupBox { - title: "Noise Gradient" - width: 500 - Column { - spacing: 8 + GroupBox { + title: "Base Gradient" + width: 500 + Column { + spacing: 8 - ConfigSlider { - label: "Size X" - integral: false - config: root.config - property: "noiseSizeX" - max: 1.0 - min: 0.0 - width: 400 - } - ConfigSlider { - label: "Size Y" - integral: false - config: root.config - property: "noiseSizeY" - max: 1.0 - min: 0.0 - width: 400 - } - ConfigSlider { - label: "Size Z" - integral: false - config: root.config - property: "noiseSizeZ" - max: 1.0 - min: 0.0 - width: 400 - } - ConfigSlider { - label: "Level" - integral: false - config: root.config - property: "noiseLevel" - max: 1.0 - min: 0.0 - width: 400 - } - } - } - GroupBox { - title: "Edge" - width: 500 - Column { - spacing: 8 - - ConfigSlider { - label: "Width" - integral: false - config: root.config - property: "edgeWidth" - max: 1.0 - min: 0.0 - width: 400 - } - GroupBox { - title: "Inner color" - Column { - spacing: 8 - ConfigSlider { - label: "Color R" - integral: false - config: root.config - property: "edgeInnerColorR" - max: 1.0 - min: 0.0 - width: 400 - } - ConfigSlider { - label: "Color G" - integral: false - config: root.config - property: "edgeInnerColorG" - max: 1.0 - min: 0.0 - width: 400 - } - ConfigSlider { - label: "Color B" - integral: false - config: root.config - property: "edgeInnerColorB" - max: 1.0 - min: 0.0 - width: 400 - } - ConfigSlider { - label: "Color intensity" - integral: false - config: root.config - property: "edgeInnerIntensity" - max: 5.0 - min: 0.0 - width: 400 - } + ConfigSlider { + label: "Size X" + integral: false + config: root.config + property: "baseSizeX" + max: 1.0 + min: 0.0 + width: 400 + } + ConfigSlider { + label: "Size Y" + integral: false + config: root.config + property: "baseSizeY" + max: 1.0 + min: 0.0 + width: 400 + } + ConfigSlider { + label: "Size Z" + integral: false + config: root.config + property: "baseSizeZ" + max: 1.0 + min: 0.0 + width: 400 + } + ConfigSlider { + label: "Level" + integral: false + config: root.config + property: "baseLevel" + max: 1.0 + min: 0.0 + width: 400 + } + CheckBox { + text: "Invert" + checked: root.config["baseInverted"] + onCheckedChanged: { root.config["baseInverted"] = checked } } } - GroupBox { - title: "Outer color" - Column { - spacing: 8 - ConfigSlider { - label: "Color R" - integral: false - config: root.config - property: "edgeOuterColorR" - max: 1.0 - min: 0.0 - width: 400 - } - ConfigSlider { - label: "Color G" - integral: false - config: root.config - property: "edgeOuterColorG" - max: 1.0 - min: 0.0 - width: 400 + } + GroupBox { + title: "Noise Gradient" + width: 500 + Column { + spacing: 8 + + ConfigSlider { + label: "Size X" + integral: false + config: root.config + property: "noiseSizeX" + max: 1.0 + min: 0.0 + width: 400 + } + ConfigSlider { + label: "Size Y" + integral: false + config: root.config + property: "noiseSizeY" + max: 1.0 + min: 0.0 + width: 400 + } + ConfigSlider { + label: "Size Z" + integral: false + config: root.config + property: "noiseSizeZ" + max: 1.0 + min: 0.0 + width: 400 + } + ConfigSlider { + label: "Level" + integral: false + config: root.config + property: "noiseLevel" + max: 1.0 + min: 0.0 + width: 400 + } + } + } + GroupBox { + title: "Edge" + width: 500 + Column { + spacing: 8 + + ConfigSlider { + label: "Width" + integral: false + config: root.config + property: "edgeWidth" + max: 1.0 + min: 0.0 + width: 400 + } + GroupBox { + title: "Inner color" + Column { + spacing: 8 + ConfigSlider { + label: "Color R" + integral: false + config: root.config + property: "edgeInnerColorR" + max: 1.0 + min: 0.0 + width: 400 + } + ConfigSlider { + label: "Color G" + integral: false + config: root.config + property: "edgeInnerColorG" + max: 1.0 + min: 0.0 + width: 400 + } + ConfigSlider { + label: "Color B" + integral: false + config: root.config + property: "edgeInnerColorB" + max: 1.0 + min: 0.0 + width: 400 + } + ConfigSlider { + label: "Color intensity" + integral: false + config: root.config + property: "edgeInnerIntensity" + max: 5.0 + min: 0.0 + width: 400 + } } - ConfigSlider { - label: "Color B" - integral: false - config: root.config - property: "edgeOuterColorB" - max: 1.0 - min: 0.0 - width: 400 - } - ConfigSlider { - label: "Color intensity" - integral: false - config: root.config - property: "edgeOuterIntensity" - max: 5.0 - min: 0.0 - width: 400 + } + GroupBox { + title: "Outer color" + Column { + spacing: 8 + ConfigSlider { + label: "Color R" + integral: false + config: root.config + property: "edgeOuterColorR" + max: 1.0 + min: 0.0 + width: 400 + } + ConfigSlider { + label: "Color G" + integral: false + config: root.config + property: "edgeOuterColorG" + max: 1.0 + min: 0.0 + width: 400 + } + ConfigSlider { + label: "Color B" + integral: false + config: root.config + property: "edgeOuterColorB" + max: 1.0 + min: 0.0 + width: 400 + } + ConfigSlider { + label: "Color intensity" + integral: false + config: root.config + property: "edgeOuterIntensity" + max: 5.0 + min: 0.0 + width: 400 + } } } } } } } + + Loader { + id: paramWidgetLoader + sourceComponent: paramWidgets + } } -