ATOM-15486 Saving material editor user settings

https://jira.agscollab.com/browse/ATOM-15486
main
guthadam 5 years ago
parent 724add6365
commit e80de63d55

@ -0,0 +1,34 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#if !defined(Q_MOC_RUN)
#include <AzCore/Memory/Memory.h>
#include <AzCore/RTTI/RTTI.h>
#include <AzCore/RTTI/ReflectContext.h>
#include <AzCore/UserSettings/UserSettings.h>
#endif
namespace MaterialEditor
{
struct MaterialDocumentSettings
: public AZ::UserSettings
{
AZ_RTTI(MaterialDocumentSettings, "{FA4F4BF3-BF39-4753-AAF7-AF383B868881}", AZ::UserSettings);
AZ_CLASS_ALLOCATOR(MaterialDocumentSettings, AZ::SystemAllocator, 0);
static void Reflect(AZ::ReflectContext* context);
bool m_showReloadDocumentPrompt = true;
};
} // namespace MaterialEditor

@ -1,49 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <AzCore/EBus/EBus.h>
#include <AzCore/std/any.h>
#include <AzCore/Outcome/Outcome.h>
namespace MaterialEditor
{
class MaterialEditorSettingsRequests
: public AZ::EBusTraits
{
public:
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single;
virtual AZ::Outcome<AZStd::any> GetProperty(AZStd::string_view name) const = 0;
virtual AZ::Outcome<AZStd::string> GetStringProperty(AZStd::string_view name) const = 0;
virtual AZ::Outcome<bool> GetBoolProperty(AZStd::string_view name) const = 0;
virtual void SetProperty(AZStd::string_view name, const AZStd::any& value) = 0;
virtual void SetStringProperty(AZStd::string_view name, AZStd::string_view stringValue) = 0;
virtual void SetBoolProperty(AZStd::string_view name, bool boolValue) = 0;
};
using MaterialEditorSettingsRequestBus = AZ::EBus<MaterialEditorSettingsRequests>;
class MaterialEditorSettingsNotifications
: public AZ::EBusTraits
{
public:
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Multiple;
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single;
virtual void OnPropertyChanged(AZStd::string_view name, const AZStd::any& value) = 0;
};
using MaterialEditorSettingsNotificationBus = AZ::EBus<MaterialEditorSettingsNotifications>;
} // namespace MaterialEditor

@ -13,7 +13,6 @@
#include <ACES/Aces.h>
#include <AzCore/EBus/EBus.h>
#include <AzCore/std/smart_ptr/shared_ptr.h>
#include <Atom/Feature/Utils/LightingPreset.h>
#include <Atom/Feature/Utils/ModelPreset.h>

@ -0,0 +1,41 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#if !defined(Q_MOC_RUN)
#include <ACES/Aces.h>
#include <AzCore/Memory/Memory.h>
#include <AzCore/RTTI/RTTI.h>
#include <AzCore/RTTI/ReflectContext.h>
#include <AzCore/UserSettings/UserSettings.h>
#endif
namespace MaterialEditor
{
struct MaterialViewportSettings
: public AZ::UserSettings
{
AZ_RTTI(MaterialViewportSettings, "{16150503-A314-4765-82A3-172670C9EA90}", AZ::UserSettings);
AZ_CLASS_ALLOCATOR(MaterialViewportSettings, AZ::SystemAllocator, 0);
static void Reflect(AZ::ReflectContext* context);
bool m_enableGrid = true;
bool m_enableShadowCatcher = true;
bool m_enableAlternateSkybox = false;
float m_fieldOfView = 90.0f;
AZ::Render::DisplayMapperOperationType m_displayMapperOperationType = AZ::Render::DisplayMapperOperationType::Aces;
AZStd::string m_selectedModelPresetName = "Shader Ball";
AZStd::string m_selectedLightingPresetName = "Neutral Urban";
};
} // namespace MaterialEditor

@ -0,0 +1,37 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#if !defined(Q_MOC_RUN)
#include <AzCore/Memory/Memory.h>
#include <AzCore/RTTI/RTTI.h>
#include <AzCore/RTTI/ReflectContext.h>
#include <AzCore/UserSettings/UserSettings.h>
#endif
namespace MaterialEditor
{
struct MaterialEditorWindowSettings
: public AZ::UserSettings
{
AZ_RTTI(MaterialEditorWindowSettings, "{BB9DEB77-B7BE-4DF5-9FDD-6D9F3136C4EA}", AZ::UserSettings);
AZ_CLASS_ALLOCATOR(MaterialEditorWindowSettings, AZ::SystemAllocator, 0);
static void Reflect(AZ::ReflectContext* context);
bool m_enableGrid = true;
bool m_enableShadowCatcher = true;
bool m_enableAlternateSkybox = false;
float m_fieldOfView = 90.0f;
};
} // namespace MaterialEditor

@ -0,0 +1,51 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <Atom/Document/MaterialDocumentSettings.h>
#include <AzCore/RTTI/BehaviorContext.h>
#include <AzCore/Serialization/EditContext.h>
namespace MaterialEditor
{
void MaterialDocumentSettings::Reflect(AZ::ReflectContext* context)
{
if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
{
serializeContext->Class<MaterialDocumentSettings, AZ::UserSettings>()
->Version(1)
->Field("showReloadDocumentPrompt", &MaterialDocumentSettings::m_showReloadDocumentPrompt)
;
if (auto editContext = serializeContext->GetEditContext())
{
editContext->Class<MaterialDocumentSettings>(
"MaterialDocumentSettings", "")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
->DataElement(AZ::Edit::UIHandlers::Default, &MaterialDocumentSettings::m_showReloadDocumentPrompt, "Show Reload Document Prompt", "")
;
}
}
if (auto behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
{
behaviorContext->Class<MaterialDocumentSettings>("MaterialDocumentSettings")
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common)
->Attribute(AZ::Script::Attributes::Category, "Editor")
->Attribute(AZ::Script::Attributes::Module, "render")
->Constructor()
->Constructor<const MaterialDocumentSettings&>()
->Property("showReloadDocumentPrompt", BehaviorValueProperty(&MaterialDocumentSettings::m_showReloadDocumentPrompt))
;
}
}
} // namespace MaterialEditor

@ -14,6 +14,7 @@
#include <Atom/Document/MaterialDocumentNotificationBus.h>
#include <Atom/Document/MaterialDocumentRequestBus.h>
#include <Atom/Document/MaterialDocumentSettings.h>
#include <Atom/Document/MaterialDocumentSystemRequestBus.h>
#include <Atom/RPI.Edit/Material/MaterialSourceData.h>
#include <Atom/RPI.Edit/Material/MaterialTypeSourceData.h>
@ -40,12 +41,13 @@ AZ_POP_DISABLE_WARNING
namespace MaterialEditor
{
MaterialDocumentSystemComponent::MaterialDocumentSystemComponent()
: m_settings(aznew MaterialEditorSettings)
{
}
void MaterialDocumentSystemComponent::Reflect(AZ::ReflectContext* context)
{
MaterialDocumentSettings::Reflect(context);
if (AZ::SerializeContext* serialize = azrtti_cast<AZ::SerializeContext*>(context))
{
serialize->Class<MaterialDocumentSystemComponent, AZ::Component>()
@ -132,6 +134,7 @@ namespace MaterialEditor
void MaterialDocumentSystemComponent::Activate()
{
m_documentMap.clear();
m_settings = AZ::UserSettings::CreateFind<MaterialDocumentSettings>(AZ::Crc32("MaterialDocumentSettings"), AZ::UserSettings::CT_GLOBAL);
MaterialDocumentSystemRequestBus::Handler::BusConnect();
MaterialDocumentNotificationBus::Handler::BusConnect();
}
@ -188,22 +191,25 @@ namespace MaterialEditor
AZStd::string documentPath;
MaterialDocumentRequestBus::EventResult(documentPath, documentId, &MaterialDocumentRequestBus::Events::GetAbsolutePath);
if (QMessageBox::question(QApplication::activeWindow(),
if (m_settings->m_showReloadDocumentPrompt &&
(QMessageBox::question(QApplication::activeWindow(),
QString("Material document was externally modified"),
QString("Would you like to reopen the document:\n%1?").arg(documentPath.c_str()),
QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes)
QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes))
{
AtomToolsFramework::TraceRecorder traceRecorder(m_maxMessageBoxLineCount);
continue;
}
bool openResult = false;
MaterialDocumentRequestBus::EventResult(openResult, documentId, &MaterialDocumentRequestBus::Events::Open, documentPath);
if (!openResult)
{
QMessageBox::critical(
QApplication::activeWindow(), QString("Material document could not be opened"),
QString("Failed to open: \n%1\n\n%2").arg(documentPath.c_str()).arg(traceRecorder.GetDump().c_str()));
MaterialDocumentSystemRequestBus::Broadcast(&MaterialDocumentSystemRequestBus::Events::CloseDocument, documentId);
}
AtomToolsFramework::TraceRecorder traceRecorder(m_maxMessageBoxLineCount);
bool openResult = false;
MaterialDocumentRequestBus::EventResult(openResult, documentId, &MaterialDocumentRequestBus::Events::Open, documentPath);
if (!openResult)
{
QMessageBox::critical(
QApplication::activeWindow(), QString("Material document could not be opened"),
QString("Failed to open: \n%1\n\n%2").arg(documentPath.c_str()).arg(traceRecorder.GetDump().c_str()));
MaterialDocumentSystemRequestBus::Broadcast(&MaterialDocumentSystemRequestBus::Events::CloseDocument, documentId);
}
}
@ -212,22 +218,25 @@ namespace MaterialEditor
AZStd::string documentPath;
MaterialDocumentRequestBus::EventResult(documentPath, documentId, &MaterialDocumentRequestBus::Events::GetAbsolutePath);
if (QMessageBox::question(QApplication::activeWindow(),
if (m_settings->m_showReloadDocumentPrompt &&
(QMessageBox::question(QApplication::activeWindow(),
QString("Material document dependencies have changed"),
QString("Would you like to update the document with these changes:\n%1?").arg(documentPath.c_str()),
QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes)
QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes))
{
AtomToolsFramework::TraceRecorder traceRecorder(m_maxMessageBoxLineCount);
continue;
}
bool openResult = false;
MaterialDocumentRequestBus::EventResult(openResult, documentId, &MaterialDocumentRequestBus::Events::Rebuild);
if (!openResult)
{
QMessageBox::critical(
QApplication::activeWindow(), QString("Material document could not be opened"),
QString("Failed to open: \n%1\n\n%2").arg(documentPath.c_str()).arg(traceRecorder.GetDump().c_str()));
MaterialDocumentSystemRequestBus::Broadcast(&MaterialDocumentSystemRequestBus::Events::CloseDocument, documentId);
}
AtomToolsFramework::TraceRecorder traceRecorder(m_maxMessageBoxLineCount);
bool openResult = false;
MaterialDocumentRequestBus::EventResult(openResult, documentId, &MaterialDocumentRequestBus::Events::Rebuild);
if (!openResult)
{
QMessageBox::critical(
QApplication::activeWindow(), QString("Material document could not be opened"),
QString("Failed to open: \n%1\n\n%2").arg(documentPath.c_str()).arg(traceRecorder.GetDump().c_str()));
MaterialDocumentSystemRequestBus::Broadcast(&MaterialDocumentSystemRequestBus::Events::CloseDocument, documentId);
}
}

@ -18,10 +18,10 @@
#include <AzCore/Asset/AssetCommon.h>
#include <Atom/Document/MaterialDocumentNotificationBus.h>
#include <Atom/Document/MaterialDocumentSettings.h>
#include <Atom/Document/MaterialDocumentSystemRequestBus.h>
#include <Atom/RPI.Public/WindowContext.h>
#include <Document/MaterialDocument.h>
#include <Document/MaterialEditorSettings.h>
AZ_PUSH_DISABLE_WARNING(4251 4800, "-Wunknown-warning-option") // disable warnings spawned by QT
#include <QFileInfo>
@ -43,7 +43,7 @@ namespace MaterialEditor
MaterialDocumentSystemComponent();
~MaterialDocumentSystemComponent() = default;
MaterialDocumentSystemComponent(const MaterialDocumentSystemComponent&) = delete;
MaterialDocumentSystemComponent& operator =(const MaterialDocumentSystemComponent&) = delete;
MaterialDocumentSystemComponent& operator=(const MaterialDocumentSystemComponent&) = delete;
static void Reflect(AZ::ReflectContext* context);
@ -87,10 +87,10 @@ namespace MaterialEditor
AZ::Uuid OpenDocumentImpl(AZStd::string_view sourcePath, bool checkIfAlreadyOpen);
AZStd::intrusive_ptr<MaterialDocumentSettings> m_settings;
AZStd::unordered_map<AZ::Uuid, AZStd::shared_ptr<MaterialDocument>> m_documentMap;
AZStd::unordered_set<AZ::Uuid> m_documentIdsToRebuild;
AZStd::unordered_set<AZ::Uuid> m_documentIdsToReopen;
AZStd::unique_ptr<MaterialEditorSettings> m_settings;
const size_t m_maxMessageBoxLineCount = 15;
};
}
} // namespace MaterialEditor

@ -1,73 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <Document/MaterialEditorSettings.h>
namespace MaterialEditor
{
MaterialEditorSettings::MaterialEditorSettings()
{
MaterialEditorSettingsRequestBus::Handler::BusConnect();
}
MaterialEditorSettings::~MaterialEditorSettings()
{
MaterialEditorSettingsRequestBus::Handler::BusDisconnect();
}
AZ::Outcome<AZStd::any> MaterialEditorSettings::GetProperty(AZStd::string_view name) const
{
const auto it = m_propertyMap.find(name);
if (it != m_propertyMap.end())
{
return AZ::Success(it->second);
}
AZ_Warning("MaterialEditorSettings", false, "Failed to find property [%s].", name.data());
return AZ::Failure();
}
AZ::Outcome<AZStd::string> MaterialEditorSettings::GetStringProperty(AZStd::string_view name) const
{
AZ::Outcome<AZStd::any> outcome = GetProperty(name);
if (!outcome || !outcome.GetValue().is<AZStd::string>())
{
return AZ::Failure();
}
return AZ::Success(AZStd::any_cast<AZStd::string>(outcome.GetValue()));
}
AZ::Outcome<bool> MaterialEditorSettings::GetBoolProperty(AZStd::string_view name) const
{
AZ::Outcome<AZStd::any> outcome = GetProperty(name);
if (!outcome || !outcome.GetValue().is<bool>())
{
return AZ::Failure();
}
return AZ::Success(AZStd::any_cast<bool>(outcome.GetValue()));
}
void MaterialEditorSettings::SetProperty(AZStd::string_view name, const AZStd::any& value)
{
m_propertyMap[name] = value;
MaterialEditorSettingsNotificationBus::Broadcast(&MaterialEditorSettingsNotifications::OnPropertyChanged, name, value);
}
void MaterialEditorSettings::SetStringProperty(AZStd::string_view name, AZStd::string_view stringValue)
{
SetProperty(name, AZStd::any(AZStd::string(stringValue)));
}
void MaterialEditorSettings::SetBoolProperty(AZStd::string_view name, bool boolValue)
{
SetProperty(name, AZStd::any(boolValue));
}
}

@ -1,45 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <AzCore/RTTI/RTTI.h>
#include <AzCore/Memory/SystemAllocator.h>
#include <AzCore/std/any.h>
#include <Atom/Document/MaterialEditorSettingsBus.h>
namespace MaterialEditor
{
class MaterialEditorSettings
: public MaterialEditorSettingsRequestBus::Handler
{
public:
AZ_RTTI(MaterialEditorSettings, "{9C6B6E20-A28E-45DD-85BE-68CA35E9305E}");
AZ_CLASS_ALLOCATOR(MaterialEditorSettings, AZ::SystemAllocator, 0);
MaterialEditorSettings();
~MaterialEditorSettings();
AZ::Outcome<AZStd::any> GetProperty(AZStd::string_view name) const override;
AZ::Outcome<AZStd::string> GetStringProperty(AZStd::string_view name) const override;
AZ::Outcome<bool> GetBoolProperty(AZStd::string_view name) const override;
void SetProperty(AZStd::string_view name, const AZStd::any& value) override;
void SetStringProperty(AZStd::string_view name, AZStd::string_view stringValue) override;
void SetBoolProperty(AZStd::string_view name, bool boolValue) override;
private:
AZStd::unordered_map<AZStd::string, AZStd::any> m_propertyMap;
};
} // namespace MaterialEditor

@ -284,7 +284,7 @@ namespace MaterialEditor
AZ_Assert(context, "No serialize context");
char resolvedPath[AZ_MAX_PATH_LEN] = "";
AZ::IO::FileIOBase::GetInstance()->ResolvePath("@user@/EditorUserSettings.xml", resolvedPath, AZ_ARRAY_SIZE(resolvedPath));
AZ::IO::FileIOBase::GetInstance()->ResolvePath("@user@/MaterialEditorUserSettings.xml", resolvedPath, AZ_ARRAY_SIZE(resolvedPath));
m_localUserSettings.Save(resolvedPath, context);
}
}
@ -546,6 +546,9 @@ namespace MaterialEditor
void MaterialEditorApplication::Stop()
{
MaterialEditor::MaterialEditorWindowFactoryRequestBus::Broadcast(
&MaterialEditor::MaterialEditorWindowFactoryRequestBus::Handler::DestroyMaterialEditorWindow);
UnloadSettings();
AzFramework::Application::Stop();
}

@ -24,6 +24,7 @@
#include <Viewport/MaterialViewportComponent.h>
#include <Atom/Viewport/MaterialViewportNotificationBus.h>
#include <Atom/Viewport/MaterialViewportSettings.h>
#include <Atom/ImageProcessing/ImageObject.h>
#include <Atom/ImageProcessing/ImageProcessingBus.h>
@ -70,6 +71,8 @@ namespace MaterialEditor
void MaterialViewportComponent::Reflect(AZ::ReflectContext* context)
{
MaterialViewportSettings::Reflect(context);
if (AZ::SerializeContext* serialize = azrtti_cast<AZ::SerializeContext*>(context))
{
serialize->Class<MaterialViewportComponent, AZ::Component>()
@ -160,6 +163,9 @@ namespace MaterialEditor
void MaterialViewportComponent::Activate()
{
m_viewportSettings =
AZ::UserSettings::CreateFind<MaterialViewportSettings>(AZ::Crc32("MaterialViewportSettings"), AZ::UserSettings::CT_GLOBAL);
m_lightingPresetPreviewImageDefault = QImage(180, 90, QImage::Format::Format_RGBA8888);
m_lightingPresetPreviewImageDefault.fill(Qt::GlobalColor::black);
@ -192,13 +198,14 @@ namespace MaterialEditor
MaterialViewportNotificationBus::Broadcast(&MaterialViewportNotificationBus::Events::OnBeginReloadContent);
const AZStd::string prevLightingPresetSelectionName = m_lightingPresetSelection ? m_lightingPresetSelection->m_displayName : "";
const AZStd::string prevModelPresetSelectionName = m_modelPresetSelection ? m_modelPresetSelection->m_displayName : "";
const AZStd::string selectedLightingPresetNameOld = m_viewportSettings->m_selectedLightingPresetName;
m_lightingPresetVector.clear();
m_lightingPresetLastSavePathMap.clear();
m_lightingPresetSelection.reset();
const AZStd::string selectedModelPresetNameOld = m_viewportSettings->m_selectedModelPresetName;
m_modelPresetVector.clear();
m_modelPresetLastSavePathMap.clear();
m_modelPresetSelection.reset();
@ -263,8 +270,8 @@ namespace MaterialEditor
// If there was a prior selection, this will keep the same configuration selected.
// Otherwise, these strings are empty and the operation will be ignored.
SelectLightingPresetByName(prevLightingPresetSelectionName);
SelectModelPresetByName(prevModelPresetSelectionName);
SelectLightingPresetByName(selectedLightingPresetNameOld);
SelectModelPresetByName(selectedModelPresetNameOld);
MaterialViewportNotificationBus::Broadcast(&MaterialViewportNotificationBus::Events::OnEndReloadContent);
@ -327,6 +334,7 @@ namespace MaterialEditor
if (preset)
{
m_lightingPresetSelection = preset;
m_viewportSettings->m_selectedLightingPresetName = preset->m_displayName;
MaterialViewportNotificationBus::Broadcast(&MaterialViewportNotificationBus::Events::OnLightingPresetSelected, m_lightingPresetSelection);
}
}
@ -422,6 +430,7 @@ namespace MaterialEditor
if (preset)
{
m_modelPresetSelection = preset;
m_viewportSettings->m_selectedModelPresetName = preset->m_displayName;
MaterialViewportNotificationBus::Broadcast(&MaterialViewportNotificationBus::Events::OnModelPresetSelected, m_modelPresetSelection);
}
}
@ -463,71 +472,66 @@ namespace MaterialEditor
void MaterialViewportComponent::SetShadowCatcherEnabled(bool enable)
{
m_shadowCatcherEnabled = enable;
m_viewportSettings->m_enableShadowCatcher = enable;
MaterialViewportNotificationBus::Broadcast(&MaterialViewportNotificationBus::Events::OnShadowCatcherEnabledChanged, enable);
}
bool MaterialViewportComponent::GetShadowCatcherEnabled() const
{
return m_shadowCatcherEnabled;
return m_viewportSettings->m_enableShadowCatcher;
}
void MaterialViewportComponent::SetGridEnabled(bool enable)
{
m_gridEnabled = enable;
m_viewportSettings->m_enableGrid = enable;
MaterialViewportNotificationBus::Broadcast(&MaterialViewportNotificationBus::Events::OnGridEnabledChanged, enable);
}
bool MaterialViewportComponent::GetGridEnabled() const
{
return m_gridEnabled;
return m_viewportSettings->m_enableGrid;
}
void MaterialViewportComponent::SetAlternateSkyboxEnabled(bool enable)
{
m_alternateSkyboxEnabled = enable;
m_viewportSettings->m_enableAlternateSkybox = enable;
MaterialViewportNotificationBus::Broadcast(&MaterialViewportNotificationBus::Events::OnAlternateSkyboxEnabledChanged, enable);
}
bool MaterialViewportComponent::GetAlternateSkyboxEnabled() const
{
return m_alternateSkyboxEnabled;
return m_viewportSettings->m_enableAlternateSkybox;
}
void MaterialViewportComponent::SetFieldOfView(float fieldOfView)
{
m_fieldOfView = fieldOfView;
m_viewportSettings->m_fieldOfView = fieldOfView;
MaterialViewportNotificationBus::Broadcast(&MaterialViewportNotificationBus::Events::OnFieldOfViewChanged, fieldOfView);
}
float MaterialViewportComponent::GetFieldOfView() const
{
return m_fieldOfView;
return m_viewportSettings->m_fieldOfView;
}
void MaterialViewportComponent::SetDisplayMapperOperationType(AZ::Render::DisplayMapperOperationType operationType)
{
m_displayMapperOperationType = operationType;
m_viewportSettings->m_displayMapperOperationType = operationType;
MaterialViewportNotificationBus::Broadcast(&MaterialViewportNotificationBus::Events::OnDisplayMapperOperationTypeChanged, operationType);
}
AZ::Render::DisplayMapperOperationType MaterialViewportComponent::GetDisplayMapperOperationType() const
{
return m_displayMapperOperationType;
return m_viewportSettings->m_displayMapperOperationType;
}
void MaterialViewportComponent::OnCatalogLoaded([[maybe_unused]] const char* catalogFile)
{
AZ::TickBus::QueueFunction([this]() {
ReloadContent();
// Automatically select preferred default presets if they exist
// We will later data drive this with editor settings
SelectLightingPresetByName("Neutral Urban");
SelectModelPresetByName("Shader Ball");
});
}
}

@ -13,13 +13,12 @@
#pragma once
#include <ACES/Aces.h>
#include <AzCore/Component/Component.h>
#include <AzFramework/Asset/AssetCatalogBus.h>
#include <Atom/Feature/Utils/LightingPreset.h>
#include <Atom/Feature/Utils/ModelPreset.h>
#include <Atom/Viewport/MaterialViewportRequestBus.h>
#include <Atom/Viewport/MaterialViewportSettings.h>
#include <AzCore/Component/Component.h>
#include <AzFramework/Asset/AssetCatalogBus.h>
namespace MaterialEditor
{
@ -111,10 +110,6 @@ namespace MaterialEditor
mutable AZStd::map<AZ::Render::LightingPresetPtr, AZStd::string> m_lightingPresetLastSavePathMap;
mutable AZStd::map<AZ::Render::ModelPresetPtr, AZStd::string> m_modelPresetLastSavePathMap;
bool m_shadowCatcherEnabled = true;
bool m_gridEnabled = true;
bool m_alternateSkyboxEnabled = false;
float m_fieldOfView = 90.0f;
AZ::Render::DisplayMapperOperationType m_displayMapperOperationType = AZ::Render::DisplayMapperOperationType::Aces;
AZStd::intrusive_ptr<MaterialViewportSettings> m_viewportSettings;
};
}

@ -41,6 +41,7 @@
#include <Atom/Feature/Utils/ModelPreset.h>
#include <Atom/Viewport/MaterialViewportRequestBus.h>
#include <Atom/Viewport/PerformanceMonitorRequestBus.h>
#include <Atom/Viewport/MaterialViewportSettings.h>
#include <AtomLyIntegration/CommonFeatures/Grid/GridComponentConstants.h>
#include <AtomLyIntegration/CommonFeatures/Grid/GridComponentConfig.h>
@ -92,6 +93,7 @@ namespace MaterialEditor
auto sceneSystem = AzFramework::SceneSystemInterface::Get();
AZ_Assert(sceneSystem, "MaterialViewportRenderer was unable to get the scene system during construction.");
AZStd::shared_ptr<AzFramework::Scene> mainScene = sceneSystem->GetScene(AzFramework::Scene::MainSceneName);
// This should never happen unless scene creation has changed.
AZ_Assert(mainScene, "Main scenes missing during system component initialization");
mainScene->SetSubsystem(m_scene);
@ -138,7 +140,6 @@ namespace MaterialEditor
m_renderPipeline->SetDefaultViewFromEntity(m_cameraEntity->GetId());
// Configure tone mapper
AzFramework::EntityContextRequestBus::EventResult(m_postProcessEntity, entityContextId, &AzFramework::EntityContextRequestBus::Events::CreateEntity, "postProcessEntity");
AZ_Assert(m_postProcessEntity != nullptr, "Failed to create post process entity.");
@ -154,13 +155,11 @@ namespace MaterialEditor
m_displayMapperFeatureProcessor = m_scene->GetFeatureProcessor<Render::DisplayMapperFeatureProcessorInterface>();
// Init Skybox
m_skyboxFeatureProcessor = m_scene->GetFeatureProcessor<AZ::Render::SkyBoxFeatureProcessorInterface>();
m_skyboxFeatureProcessor->Enable(true);
m_skyboxFeatureProcessor->SetSkyboxMode(AZ::Render::SkyBoxMode::Cubemap);
// Create IBL
AzFramework::EntityContextRequestBus::EventResult(m_iblEntity, entityContextId, &AzFramework::EntityContextRequestBus::Events::CreateEntity, "IblEntity");
AZ_Assert(m_iblEntity != nullptr, "Failed to create ibl entity.");
@ -176,8 +175,8 @@ namespace MaterialEditor
m_modelEntity->CreateComponent(AZ::Render::MaterialComponentTypeId);
m_modelEntity->CreateComponent(azrtti_typeid<AzFramework::TransformComponent>());
m_modelEntity->Activate();
// Create shadow catcher
// Create shadow catcher
AzFramework::EntityContextRequestBus::EventResult(m_shadowCatcherEntity, entityContextId, &AzFramework::EntityContextRequestBus::Events::CreateEntity, "ViewportShadowCatcher");
AZ_Assert(m_shadowCatcherEntity != nullptr, "Failed to create shadow catcher entity.");
m_shadowCatcherEntity->CreateComponent(AZ::Render::MeshComponentTypeId);
@ -208,7 +207,6 @@ namespace MaterialEditor
}
// Create grid
AzFramework::EntityContextRequestBus::EventResult(m_gridEntity, entityContextId, &AzFramework::EntityContextRequestBus::Events::CreateEntity, "ViewportGrid");
AZ_Assert(m_gridEntity != nullptr, "Failed to create grid entity.");
@ -235,6 +233,16 @@ namespace MaterialEditor
MaterialViewportRequestBus::BroadcastResult(modelPreset, &MaterialViewportRequestBus::Events::GetModelPresetSelection);
OnModelPresetSelected(modelPreset);
// Apply user settinngs restored since last run
AZStd::intrusive_ptr<MaterialViewportSettings> viewportSettings =
AZ::UserSettings::CreateFind<MaterialViewportSettings>(AZ::Crc32("MaterialViewportSettings"), AZ::UserSettings::CT_GLOBAL);
OnGridEnabledChanged(viewportSettings->m_enableGrid);
OnShadowCatcherEnabledChanged(viewportSettings->m_enableShadowCatcher);
OnAlternateSkyboxEnabledChanged(viewportSettings->m_enableAlternateSkybox);
OnFieldOfViewChanged(viewportSettings->m_fieldOfView);
OnDisplayMapperOperationTypeChanged(viewportSettings->m_displayMapperOperationType);
MaterialDocumentNotificationBus::Handler::BusConnect();
MaterialViewportNotificationBus::Handler::BusConnect();
AZ::TickBus::Handler::BusConnect();

@ -0,0 +1,72 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <Atom/Viewport/MaterialViewportSettings.h>
#include <AzCore/RTTI/BehaviorContext.h>
#include <AzCore/Serialization/EditContext.h>
namespace MaterialEditor
{
void MaterialViewportSettings::Reflect(AZ::ReflectContext* context)
{
if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
{
serializeContext->Class<MaterialViewportSettings, AZ::UserSettings>()
->Version(1)
->Field("enableGrid", &MaterialViewportSettings::m_enableGrid)
->Field("enableShadowCatcher", &MaterialViewportSettings::m_enableShadowCatcher)
->Field("enableAlternateSkybox", &MaterialViewportSettings::m_enableAlternateSkybox)
->Field("fieldOfView", &MaterialViewportSettings::m_fieldOfView)
->Field("displayMapperOperationType", &MaterialViewportSettings::m_displayMapperOperationType)
->Field("selectedModelPresetName", &MaterialViewportSettings::m_selectedModelPresetName)
->Field("selectedLightingPresetName", &MaterialViewportSettings::m_selectedLightingPresetName)
;
if (auto editContext = serializeContext->GetEditContext())
{
editContext->Class<MaterialViewportSettings>(
"MaterialViewportSettings", "")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
->DataElement(AZ::Edit::UIHandlers::Default, &MaterialViewportSettings::m_enableGrid, "Enable Grid", "")
->DataElement(AZ::Edit::UIHandlers::Default, &MaterialViewportSettings::m_enableShadowCatcher, "Enable Shadow Catcher", "")
->DataElement(AZ::Edit::UIHandlers::Default, &MaterialViewportSettings::m_enableAlternateSkybox, "Enable Alternate Skybox", "")
->DataElement(AZ::Edit::UIHandlers::Slider, &MaterialViewportSettings::m_fieldOfView, "Field Of View", "")
->Attribute(AZ::Edit::Attributes::Min, 60.0f)
->Attribute(AZ::Edit::Attributes::Max, 120.0f)
->DataElement(AZ::Edit::UIHandlers::ComboBox, &MaterialViewportSettings::m_displayMapperOperationType, "Display Mapper Type", "")
->EnumAttribute(AZ::Render::DisplayMapperOperationType::Aces, "Aces")
->EnumAttribute(AZ::Render::DisplayMapperOperationType::AcesLut, "AcesLut")
->EnumAttribute(AZ::Render::DisplayMapperOperationType::Passthrough, "Passthrough")
->EnumAttribute(AZ::Render::DisplayMapperOperationType::GammaSRGB, "GammaSRGB")
->EnumAttribute(AZ::Render::DisplayMapperOperationType::Reinhard, "Reinhard")
;
}
}
if (auto behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
{
behaviorContext->Class<MaterialViewportSettings>("MaterialViewportSettings")
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common)
->Attribute(AZ::Script::Attributes::Category, "Editor")
->Attribute(AZ::Script::Attributes::Module, "render")
->Constructor()
->Constructor<const MaterialViewportSettings&>()
->Property("enableGrid", BehaviorValueProperty(&MaterialViewportSettings::m_enableGrid))
->Property("enableShadowCatcher", BehaviorValueProperty(&MaterialViewportSettings::m_enableShadowCatcher))
->Property("enableAlternateSkybox", BehaviorValueProperty(&MaterialViewportSettings::m_enableAlternateSkybox))
->Property("fieldOfView", BehaviorValueProperty(&MaterialViewportSettings::m_fieldOfView))
->Property("displayMapperOperationType", BehaviorValueProperty(&MaterialViewportSettings::m_displayMapperOperationType))
;
}
}
} // namespace MaterialEditor

@ -10,14 +10,15 @@
*
*/
#include <AzFramework/StringFunc/StringFunc.h>
#include <AzFramework/Application/Application.h>
#include <AzToolsFramework/AssetBrowser/AssetBrowserEntry.h>
#include <AzToolsFramework/API/EditorPythonRunnerRequestsBus.h>
#include <AzToolsFramework/API/EditorAssetSystemAPI.h>
#include <AzToolsFramework/PythonTerminal/ScriptTermDialog.h>
#include <AzFramework/StringFunc/StringFunc.h>
#include <AzQtComponents/Components/StyleManager.h>
#include <AzQtComponents/Utilities/QtPluginPaths.h>
#include <AzToolsFramework/API/EditorAssetSystemAPI.h>
#include <AzToolsFramework/API/EditorPythonRunnerRequestsBus.h>
#include <AzToolsFramework/AssetBrowser/AssetBrowserEntry.h>
#include <AzToolsFramework/PythonTerminal/ScriptTermDialog.h>
#include <AzToolsFramework/UI/UICore/QWidgetSavedState.h>
#include <AtomToolsFramework/Util/Util.h>
@ -121,10 +122,24 @@ namespace MaterialEditor
MaterialEditorWindowRequestBus::Handler::BusConnect();
MaterialDocumentNotificationBus::Handler::BusConnect();
OnDocumentOpened(AZ::Uuid::CreateNull());
auto windowState = AZ::UserSettings::Find<AzToolsFramework::QWidgetSavedState>(
AZ::Crc32("MaterialEditorWindowState"), AZ::UserSettings::CT_GLOBAL);
if (windowState)
{
windowState->RestoreGeometry(this);
}
}
MaterialEditorWindow::~MaterialEditorWindow()
{
auto windowState = AZ::UserSettings::CreateFind<AzToolsFramework::QWidgetSavedState>(
AZ::Crc32("MaterialEditorWindowState"), AZ::UserSettings::CT_GLOBAL);
if (windowState)
{
windowState->CaptureGeometry(this);
}
MaterialDocumentNotificationBus::Handler::BusDisconnect();
MaterialEditorWindowRequestBus::Handler::BusDisconnect();
}

@ -10,25 +10,24 @@
*
*/
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/Serialization/EditContext.h>
#include <Atom/Window/MaterialEditorWindowFactoryRequestBus.h>
#include <Atom/Window/MaterialEditorWindowSettings.h>
#include <AzCore/RTTI/BehaviorContext.h>
#include <AzToolsFramework/API/ViewPaneOptions.h>
#include <AzCore/Serialization/EditContext.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <AzToolsFramework/API/EditorAssetSystemAPI.h>
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
#include <AzToolsFramework/API/ViewPaneOptions.h>
#include <AzToolsFramework/UI/UICore/QWidgetSavedState.h>
#include <Atom/Window/MaterialEditorWindowFactoryRequestBus.h>
#include <Source/Window/MaterialEditorWindowComponent.h>
#include <Source/Window/MaterialEditorWindow.h>
#include <Source/Window/ViewportSettingsInspector/ViewportSettingsInspector.h>
#include <Window/MaterialEditorWindow.h>
#include <Window/MaterialEditorWindowComponent.h>
#include <Window/ViewportSettingsInspector/ViewportSettingsInspector.h>
namespace MaterialEditor
{
void MaterialEditorWindowComponent::Reflect(AZ::ReflectContext* context)
{
GeneralViewportSettings::Reflect(context);
MaterialEditorWindowSettings::Reflect(context);
if (AZ::SerializeContext* serialize = azrtti_cast<AZ::SerializeContext*>(context))
{

@ -0,0 +1,62 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <Atom/Window/MaterialEditorWindowSettings.h>
#include <AzCore/RTTI/BehaviorContext.h>
#include <AzCore/Serialization/EditContext.h>
namespace MaterialEditor
{
void MaterialEditorWindowSettings::Reflect(AZ::ReflectContext* context)
{
if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
{
serializeContext->Class<MaterialEditorWindowSettings, AZ::UserSettings>()
->Version(1)
->Field("enableGrid", &MaterialEditorWindowSettings::m_enableGrid)
->Field("enableShadowCatcher", &MaterialEditorWindowSettings::m_enableShadowCatcher)
->Field("enableAlternateSkybox", &MaterialEditorWindowSettings::m_enableAlternateSkybox)
->Field("fieldOfView", &MaterialEditorWindowSettings::m_fieldOfView)
;
if (auto editContext = serializeContext->GetEditContext())
{
editContext->Class<MaterialEditorWindowSettings>(
"MaterialEditorWindowSettings", "")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
->DataElement(AZ::Edit::UIHandlers::Default, &MaterialEditorWindowSettings::m_enableGrid, "Enable Grid", "")
->DataElement(AZ::Edit::UIHandlers::Default, &MaterialEditorWindowSettings::m_enableShadowCatcher, "Enable Shadow Catcher", "")
->DataElement(AZ::Edit::UIHandlers::Default, &MaterialEditorWindowSettings::m_enableAlternateSkybox, "Enable Alternate Skybox", "")
->DataElement(AZ::Edit::UIHandlers::Slider, &MaterialEditorWindowSettings::m_fieldOfView, "Field Of View", "")
->Attribute(AZ::Edit::Attributes::Min, 60.0f)
->Attribute(AZ::Edit::Attributes::Max, 120.0f)
;
}
}
if (auto behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
{
behaviorContext->Class<MaterialEditorWindowSettings>("MaterialEditorWindowSettings")
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common)
->Attribute(AZ::Script::Attributes::Category, "Editor")
->Attribute(AZ::Script::Attributes::Module, "render")
->Constructor()
->Constructor<const MaterialEditorWindowSettings&>()
->Property("enableGrid", BehaviorValueProperty(&MaterialEditorWindowSettings::m_enableGrid))
->Property("enableShadowCatcher", BehaviorValueProperty(&MaterialEditorWindowSettings::m_enableShadowCatcher))
->Property("enableAlternateSkybox", BehaviorValueProperty(&MaterialEditorWindowSettings::m_enableAlternateSkybox))
->Property("fieldOfView", BehaviorValueProperty(&MaterialEditorWindowSettings::m_fieldOfView))
;
}
}
} // namespace MaterialEditor

@ -10,13 +10,13 @@
*
*/
#include <Atom/Document/MaterialEditorSettingsBus.h>
#include <Atom/Viewport/MaterialViewportNotificationBus.h>
#include <Atom/Viewport/MaterialViewportRequestBus.h>
#include <Atom/Viewport/MaterialViewportSettings.h>
#include <AzCore/std/containers/vector.h>
#include <Source/Window/ToolBar/LightingPresetComboBox.h>
#include <Source/Window/ToolBar/MaterialEditorToolBar.h>
#include <Source/Window/ToolBar/ModelPresetComboBox.h>
#include <Window/ToolBar/LightingPresetComboBox.h>
#include <Window/ToolBar/MaterialEditorToolBar.h>
#include <Window/ToolBar/ModelPresetComboBox.h>
AZ_PUSH_DISABLE_WARNING(4251 4800, "-Wunknown-warning-option") // disable warnings spawned by QT
#include <AzQtComponents/Components/Widgets/ToolBar.h>
@ -33,15 +33,16 @@ namespace MaterialEditor
{
AzQtComponents::ToolBar::addMainToolBarStyle(this);
AZStd::intrusive_ptr<MaterialViewportSettings> viewportSettings =
AZ::UserSettings::CreateFind<MaterialViewportSettings>(AZ::Crc32("MaterialViewportSettings"), AZ::UserSettings::CT_GLOBAL);
// Add toggle grid button
m_toggleGrid = addAction(QIcon(":/Icons/grid.svg"), "Toggle Grid");
m_toggleGrid->setCheckable(true);
connect(m_toggleGrid, &QAction::triggered, [this]() {
MaterialViewportRequestBus::Broadcast(&MaterialViewportRequestBus::Events::SetGridEnabled, m_toggleGrid->isChecked());
});
bool enableGrid = false;
MaterialViewportRequestBus::BroadcastResult(enableGrid, &MaterialViewportRequestBus::Events::GetGridEnabled);
m_toggleGrid->setChecked(enableGrid);
});
m_toggleGrid->setChecked(viewportSettings->m_enableGrid);
// Add toggle shadow catcher button
m_toggleShadowCatcher = addAction(QIcon(":/Icons/shadow.svg"), "Toggle Shadow Catcher");
@ -49,34 +50,32 @@ namespace MaterialEditor
connect(m_toggleShadowCatcher, &QAction::triggered, [this]() {
MaterialViewportRequestBus::Broadcast(
&MaterialViewportRequestBus::Events::SetShadowCatcherEnabled, m_toggleShadowCatcher->isChecked());
});
bool enableShadowCatcher = false;
MaterialViewportRequestBus::BroadcastResult(enableShadowCatcher, &MaterialViewportRequestBus::Events::GetShadowCatcherEnabled);
m_toggleShadowCatcher->setChecked(enableShadowCatcher);
});
m_toggleShadowCatcher->setChecked(viewportSettings->m_enableShadowCatcher);
// Add mapping selection button
QToolButton* toneMappingButton = new QToolButton(this);
QMenu* toneMappingMenu = new QMenu(toneMappingButton);
m_operationNames =
{
{ AZ::Render::DisplayMapperOperationType::Reinhard, "Reinhard" },
{ AZ::Render::DisplayMapperOperationType::GammaSRGB, "GammaSRGB" },
{ AZ::Render::DisplayMapperOperationType::Passthrough, "Passthrough" },
{ AZ::Render::DisplayMapperOperationType::AcesLut, "AcesLut" },
{ AZ::Render::DisplayMapperOperationType::Aces, "Aces" }
};
m_operationNames = {
{AZ::Render::DisplayMapperOperationType::Reinhard, "Reinhard"},
{AZ::Render::DisplayMapperOperationType::GammaSRGB, "GammaSRGB"},
{AZ::Render::DisplayMapperOperationType::Passthrough, "Passthrough"},
{AZ::Render::DisplayMapperOperationType::AcesLut, "AcesLut"},
{AZ::Render::DisplayMapperOperationType::Aces, "Aces"}};
for (auto operationNamePair : m_operationNames)
{
m_operationActions[operationNamePair.first] = toneMappingMenu->addAction(operationNamePair.second, [operationNamePair]() {
MaterialViewportRequestBus::Broadcast(
&MaterialViewportRequestBus::Events::SetDisplayMapperOperationType,
operationNamePair.first);
});
&MaterialViewportRequestBus::Events::SetDisplayMapperOperationType, operationNamePair.first);
});
m_operationActions[operationNamePair.first]->setCheckable(true);
m_operationActions[operationNamePair.first]->setChecked(
operationNamePair.first == viewportSettings->m_displayMapperOperationType);
}
m_operationActions[AZ::Render::DisplayMapperOperationType::Aces]->setChecked(true);
toneMappingButton->setMenu(toneMappingMenu);
toneMappingButton->setText("Tone Mapping");
toneMappingButton->setIcon(QIcon(":/Icons/toneMapping.svg"));
@ -122,4 +121,4 @@ namespace MaterialEditor
} // namespace MaterialEditor
#include <Source/Window/ToolBar/moc_MaterialEditorToolBar.cpp>
#include <Window/ToolBar/moc_MaterialEditorToolBar.cpp>

@ -26,61 +26,12 @@
namespace MaterialEditor
{
void GeneralViewportSettings::Reflect(AZ::ReflectContext* context)
{
if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
{
serializeContext->Class<GeneralViewportSettings>()
->Version(1)
->Field("enableGrid", &GeneralViewportSettings::m_enableGrid)
->Field("enableShadowCatcher", &GeneralViewportSettings::m_enableShadowCatcher)
->Field("enableAlternateSkybox", &GeneralViewportSettings::m_enableAlternateSkybox)
->Field("fieldOfView", &GeneralViewportSettings::m_fieldOfView)
->Field("displayMapperOperationType", &GeneralViewportSettings::m_displayMapperOperationType)
;
if (auto editContext = serializeContext->GetEditContext())
{
editContext->Class<GeneralViewportSettings>(
"GeneralViewportSettings", "")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
->DataElement(AZ::Edit::UIHandlers::Default, &GeneralViewportSettings::m_enableGrid, "Enable Grid", "")
->DataElement(AZ::Edit::UIHandlers::Default, &GeneralViewportSettings::m_enableShadowCatcher, "Enable Shadow Catcher", "")
->DataElement(AZ::Edit::UIHandlers::Default, &GeneralViewportSettings::m_enableAlternateSkybox, "Enable Alternate Skybox", "")
->DataElement(AZ::Edit::UIHandlers::Slider, &GeneralViewportSettings::m_fieldOfView, "Field Of View", "")
->Attribute(AZ::Edit::Attributes::Min, 60.0f)
->Attribute(AZ::Edit::Attributes::Max, 120.0f)
->DataElement(AZ::Edit::UIHandlers::ComboBox, &GeneralViewportSettings::m_displayMapperOperationType, "Display Mapper Type", "")
->EnumAttribute(AZ::Render::DisplayMapperOperationType::Aces, "Aces")
->EnumAttribute(AZ::Render::DisplayMapperOperationType::AcesLut, "AcesLut")
->EnumAttribute(AZ::Render::DisplayMapperOperationType::Passthrough, "Passthrough")
->EnumAttribute(AZ::Render::DisplayMapperOperationType::GammaSRGB, "GammaSRGB")
->EnumAttribute(AZ::Render::DisplayMapperOperationType::Reinhard, "Reinhard")
;
}
}
if (auto behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
{
behaviorContext->Class<GeneralViewportSettings>("GeneralViewportSettings")
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common)
->Attribute(AZ::Script::Attributes::Category, "Editor")
->Attribute(AZ::Script::Attributes::Module, "render")
->Constructor()
->Constructor<const GeneralViewportSettings&>()
->Property("enableGrid", BehaviorValueProperty(&GeneralViewportSettings::m_enableGrid))
->Property("enableShadowCatcher", BehaviorValueProperty(&GeneralViewportSettings::m_enableShadowCatcher))
->Property("enableAlternateSkybox", BehaviorValueProperty(&GeneralViewportSettings::m_enableAlternateSkybox))
->Property("fieldOfView", BehaviorValueProperty(&GeneralViewportSettings::m_fieldOfView))
->Property("displayMapperOperationType", BehaviorValueProperty(&GeneralViewportSettings::m_displayMapperOperationType))
;
}
}
ViewportSettingsInspector::ViewportSettingsInspector(QWidget* parent)
: AtomToolsFramework::InspectorWidget(parent)
{
m_viewportSettings =
AZ::UserSettings::CreateFind<MaterialViewportSettings>(AZ::Crc32("MaterialViewportSettings"), AZ::UserSettings::CT_GLOBAL);
MaterialViewportNotificationBus::Handler::BusConnect();
}
@ -109,7 +60,7 @@ namespace MaterialEditor
AddGroup(
groupNameId, groupDisplayName, groupDescription,
new AtomToolsFramework::InspectorPropertyGroupWidget(&m_generalSettings, nullptr, m_generalSettings.TYPEINFO_Uuid(), this));
new AtomToolsFramework::InspectorPropertyGroupWidget(m_viewportSettings.get(), nullptr, m_viewportSettings->TYPEINFO_Uuid(), this));
}
void ViewportSettingsInspector::AddModelGroup()
@ -300,13 +251,13 @@ namespace MaterialEditor
m_lightingPreset.reset();
MaterialViewportRequestBus::BroadcastResult(m_lightingPreset, &MaterialViewportRequestBus::Events::GetLightingPresetSelection);
MaterialViewportRequestBus::BroadcastResult(m_generalSettings.m_enableGrid, &MaterialViewportRequestBus::Events::GetGridEnabled);
MaterialViewportRequestBus::BroadcastResult(m_viewportSettings->m_enableGrid, &MaterialViewportRequestBus::Events::GetGridEnabled);
MaterialViewportRequestBus::BroadcastResult(
m_generalSettings.m_enableShadowCatcher, &MaterialViewportRequestBus::Events::GetShadowCatcherEnabled);
m_viewportSettings->m_enableShadowCatcher, &MaterialViewportRequestBus::Events::GetShadowCatcherEnabled);
MaterialViewportRequestBus::BroadcastResult(
m_generalSettings.m_enableAlternateSkybox, &MaterialViewportRequestBus::Events::GetAlternateSkyboxEnabled);
MaterialViewportRequestBus::BroadcastResult(m_generalSettings.m_fieldOfView, &MaterialViewportRequestBus::Handler::GetFieldOfView);
MaterialViewportRequestBus::BroadcastResult(m_generalSettings.m_displayMapperOperationType, &MaterialViewportRequestBus::Handler::GetDisplayMapperOperationType);
m_viewportSettings->m_enableAlternateSkybox, &MaterialViewportRequestBus::Events::GetAlternateSkyboxEnabled);
MaterialViewportRequestBus::BroadcastResult(m_viewportSettings->m_fieldOfView, &MaterialViewportRequestBus::Handler::GetFieldOfView);
MaterialViewportRequestBus::BroadcastResult(m_viewportSettings->m_displayMapperOperationType, &MaterialViewportRequestBus::Handler::GetDisplayMapperOperationType);
AtomToolsFramework::InspectorRequestBus::Handler::BusDisconnect();
AtomToolsFramework::InspectorWidget::Reset();
@ -330,31 +281,31 @@ namespace MaterialEditor
void ViewportSettingsInspector::OnShadowCatcherEnabledChanged(bool enable)
{
m_generalSettings.m_enableShadowCatcher = enable;
m_viewportSettings->m_enableShadowCatcher = enable;
RefreshGroup("general");
}
void ViewportSettingsInspector::OnGridEnabledChanged(bool enable)
{
m_generalSettings.m_enableGrid = enable;
m_viewportSettings->m_enableGrid = enable;
RefreshGroup("general");
}
void ViewportSettingsInspector::OnAlternateSkyboxEnabledChanged(bool enable)
{
m_generalSettings.m_enableAlternateSkybox = enable;
m_viewportSettings->m_enableAlternateSkybox = enable;
RefreshGroup("general");
}
void ViewportSettingsInspector::OnFieldOfViewChanged(float fieldOfView)
{
m_generalSettings.m_fieldOfView = fieldOfView;
m_viewportSettings->m_fieldOfView = fieldOfView;
RefreshGroup("general");
}
void ViewportSettingsInspector::OnDisplayMapperOperationTypeChanged(AZ::Render::DisplayMapperOperationType operationType)
{
m_generalSettings.m_displayMapperOperationType = operationType;
m_viewportSettings->m_displayMapperOperationType = operationType;
RefreshGroup("general");
}
@ -379,13 +330,13 @@ namespace MaterialEditor
{
MaterialViewportNotificationBus::Broadcast(&MaterialViewportNotificationBus::Events::OnLightingPresetChanged, m_lightingPreset);
MaterialViewportNotificationBus::Broadcast(&MaterialViewportNotificationBus::Events::OnModelPresetChanged, m_modelPreset);
MaterialViewportRequestBus::Broadcast(&MaterialViewportRequestBus::Events::SetGridEnabled, m_generalSettings.m_enableGrid);
MaterialViewportRequestBus::Broadcast(&MaterialViewportRequestBus::Events::SetGridEnabled, m_viewportSettings->m_enableGrid);
MaterialViewportRequestBus::Broadcast(
&MaterialViewportRequestBus::Events::SetShadowCatcherEnabled, m_generalSettings.m_enableShadowCatcher);
&MaterialViewportRequestBus::Events::SetShadowCatcherEnabled, m_viewportSettings->m_enableShadowCatcher);
MaterialViewportRequestBus::Broadcast(
&MaterialViewportRequestBus::Events::SetAlternateSkyboxEnabled, m_generalSettings.m_enableAlternateSkybox);
MaterialViewportRequestBus::Broadcast(&MaterialViewportRequestBus::Handler::SetFieldOfView, m_generalSettings.m_fieldOfView);
MaterialViewportRequestBus::Broadcast(&MaterialViewportRequestBus::Handler::SetDisplayMapperOperationType, m_generalSettings.m_displayMapperOperationType);
&MaterialViewportRequestBus::Events::SetAlternateSkyboxEnabled, m_viewportSettings->m_enableAlternateSkybox);
MaterialViewportRequestBus::Broadcast(&MaterialViewportRequestBus::Handler::SetFieldOfView, m_viewportSettings->m_fieldOfView);
MaterialViewportRequestBus::Broadcast(&MaterialViewportRequestBus::Handler::SetDisplayMapperOperationType, m_viewportSettings->m_displayMapperOperationType);
}
AZStd::string ViewportSettingsInspector::GetDefaultUniqueSaveFilePath(const AZStd::string& baseName) const

@ -14,28 +14,16 @@
#if !defined(Q_MOC_RUN)
#include <ACES/Aces.h>
#include <Atom/Viewport/MaterialViewportNotificationBus.h>
#include <Atom/Feature/Utils/LightingPreset.h>
#include <Atom/Feature/Utils/ModelPreset.h>
#include <AzToolsFramework/UI/PropertyEditor/PropertyEditorAPI_Internals.h>
#include <Atom/Viewport/MaterialViewportNotificationBus.h>
#include <Atom/Viewport/MaterialViewportSettings.h>
#include <AtomToolsFramework/Inspector/InspectorWidget.h>
#include <AzToolsFramework/UI/PropertyEditor/PropertyEditorAPI_Internals.h>
#endif
namespace MaterialEditor
{
struct GeneralViewportSettings
{
AZ_TYPE_INFO(GeneralViewportSettings, "{16150503-A314-4765-82A3-172670C9EA90}");
AZ_CLASS_ALLOCATOR(GeneralViewportSettings, AZ::SystemAllocator, 0);
static void Reflect(AZ::ReflectContext* context);
bool m_enableGrid = true;
bool m_enableShadowCatcher = true;
bool m_enableAlternateSkybox = false;
float m_fieldOfView = 90.0f;
AZ::Render::DisplayMapperOperationType m_displayMapperOperationType = AZ::Render::DisplayMapperOperationType::Aces;
};
//! Provides controls for viewing and editing a material document settings.
//! The settings can be divided into cards, with each one showing a subset of properties.
class ViewportSettingsInspector
@ -90,7 +78,7 @@ namespace MaterialEditor
AZStd::string GetDefaultUniqueSaveFilePath(const AZStd::string& baseName) const;
GeneralViewportSettings m_generalSettings;
AZStd::intrusive_ptr<MaterialViewportSettings> m_viewportSettings;
AZ::Render::ModelPresetPtr m_modelPreset;
AZ::Render::LightingPresetPtr m_lightingPreset;
};

@ -13,7 +13,5 @@ set(FILES
Source/main.cpp
Source/MaterialEditorApplication.cpp
Source/MaterialEditorApplication.h
Include/Atom/Document/MaterialDocumentModule.h
Source/Document/MaterialDocumentModule.cpp
tool_dependencies.cmake
)

@ -14,11 +14,11 @@ set(FILES
Include/Atom/Document/MaterialDocumentSystemRequestBus.h
Include/Atom/Document/MaterialDocumentNotificationBus.h
Include/Atom/Document/MaterialDocumentRequestBus.h
Include/Atom/Document/MaterialEditorSettingsBus.h
Include/Atom/Document/MaterialDocumentSettings.h
Source/Document/MaterialDocumentModule.cpp
Source/Document/MaterialDocumentSystemComponent.cpp
Source/Document/MaterialDocumentSystemComponent.h
Source/Document/MaterialDocument.cpp
Source/Document/MaterialDocument.h
Source/Document/MaterialEditorSettings.cpp
Source/Document/MaterialEditorSettings.h
Source/Document/MaterialDocumentSettings.cpp
)

@ -12,6 +12,7 @@
set(FILES
Include/Atom/Viewport/InputController/MaterialEditorViewportInputControllerBus.h
Include/Atom/Viewport/MaterialViewportModule.h
Include/Atom/Viewport/MaterialViewportSettings.h
Include/Atom/Viewport/MaterialViewportRequestBus.h
Include/Atom/Viewport/MaterialViewportNotificationBus.h
Include/Atom/Viewport/PerformanceMetrics.h
@ -35,6 +36,7 @@ set(FILES
Source/Viewport/InputController/RotateModelBehavior.cpp
Source/Viewport/InputController/RotateModelBehavior.h
Source/Viewport/MaterialViewportModule.cpp
Source/Viewport/MaterialViewportSettings.cpp
Source/Viewport/MaterialViewportComponent.cpp
Source/Viewport/MaterialViewportComponent.h
Source/Viewport/MaterialViewportWidget.cpp

@ -11,6 +11,7 @@
set(FILES
Include/Atom/Window/MaterialEditorWindowModule.h
Include/Atom/Window/MaterialEditorWindowSettings.h
Include/Atom/Window/MaterialEditorWindowNotificationBus.h
Include/Atom/Window/MaterialEditorWindowRequestBus.h
Include/Atom/Window/MaterialEditorWindowFactoryRequestBus.h
@ -19,6 +20,7 @@ set(FILES
Source/Window/MaterialEditorWindow.h
Source/Window/MaterialEditorWindow.cpp
Source/Window/MaterialEditorWindowModule.cpp
Source/Window/MaterialEditorWindowSettings.cpp
Source/Window/MaterialBrowserWidget.h
Source/Window/MaterialBrowserWidget.cpp
Source/Window/MaterialBrowserWidget.ui

Loading…
Cancel
Save