Merge branch 'main' into LoadPipelineFromGitHub

This commit is contained in:
Brian Herrera
2021-03-26 17:05:57 -07:00
765 changed files with 11513 additions and 20246 deletions
@@ -42,11 +42,11 @@ ly_add_target(
)
ly_add_target(
NAME AtomToolsFramework.Editor MODULE
NAME AtomToolsFramework.Editor GEM_MODULE
NAMESPACE Gem
AUTOMOC
AUTORCC
OUTPUT_NAME Gem.AtomToolsFramework.Editor.3e0ee0c27f204f5188146baac822d020.v0.1.0
FILES_CMAKE
atomtoolsframework_shared_files.cmake
INCLUDE_DIRECTORIES
@@ -14,6 +14,8 @@
#include <AzCore/EBus/EBus.h>
#include <AzCore/std/string/string.h>
class QWidget;
namespace AtomToolsFramework
{
class InspectorGroupWidget;
@@ -40,7 +42,7 @@ namespace AtomToolsFramework
const AZStd::string& groupNameId,
const AZStd::string& groupDisplayName,
const AZStd::string& groupDescription,
InspectorGroupWidget* groupWidget) = 0;
QWidget* groupWidget) = 0;
//! Calls Refresh for a specific InspectorGroupWidget, allowing for non-destructive UI changes
virtual void RefreshGroup(const AZStd::string& groupNameId) = 0;
@@ -58,7 +58,7 @@ namespace AtomToolsFramework
const AZStd::string& groupNameId,
const AZStd::string& groupDisplayName,
const AZStd::string& groupDescription,
InspectorGroupWidget* groupWidget) override;
QWidget* groupWidget) override;
void RefreshGroup(const AZStd::string& groupNameId) override;
void RebuildGroup(const AZStd::string& groupNameId) override;
@@ -63,7 +63,7 @@ namespace AtomToolsFramework
const AZStd::string& groupNameId,
const AZStd::string& groupDisplayName,
const AZStd::string& groupDescription,
InspectorGroupWidget* groupWidget)
QWidget* groupWidget)
{
InspectorGroupHeaderWidget* groupHeader = new InspectorGroupHeaderWidget(m_ui->m_propertyContent);
groupHeader->setText(groupDisplayName.c_str());
@@ -63,6 +63,7 @@ ly_add_target(
Gem::AtomToolsFramework.Editor
Gem::Atom_RPI.Public
Gem::Atom_Feature_Common.Public
Gem::ImageProcessingAtom.Headers
)
ly_add_target(
@@ -132,6 +133,12 @@ ly_add_target_dependencies(
Source/Platform/${PAL_PLATFORM_NAME}/tool_dependencies_${PAL_PLATFORM_NAME_LOWERCASE}.cmake
)
# Inject the project path into the MaterialEditor VS debugger command arguments if the build system being invoked
# in a project centric view
if(NOT PROJECT_NAME STREQUAL "O3DE")
set_property(TARGET MaterialEditor APPEND PROPERTY VS_DEBUGGER_COMMAND_ARGUMENTS "--project-path=\"${CMAKE_SOURCE_DIR}\"")
endif()
# Adds the MaterialEditor target as a C preprocessor define so that it can be used as a Settings Registry
# specialization in order to look up the generated .setreg which contains the dependencies
# specified for the target.
@@ -60,6 +60,12 @@ namespace MaterialEditor
//! Notify when enabled state for grid changes
virtual void OnGridEnabledChanged([[maybe_unused]] bool enable) {}
//! Notify when enabled state for alternate skybox changes
virtual void OnAlternateSkyboxEnabledChanged([[maybe_unused]] bool enable) {}
//! Notify when field of view changes
virtual void OnFieldOfViewChanged([[maybe_unused]] float fieldOfView) {}
};
using MaterialViewportNotificationBus = AZ::EBus<MaterialViewportNotifications>;
@@ -16,6 +16,7 @@
#include <AzCore/std/string/string.h>
#include <Atom/Feature/Utils/LightingPreset.h>
#include <Atom/Feature/Utils/ModelPreset.h>
#include <QImage>
namespace MaterialEditor
{
@@ -42,7 +43,7 @@ namespace MaterialEditor
//! Save lighting preset
//! @returns true if preset was saved, otherwise false
virtual bool SaveLightingPresetSelection(const AZStd::string& path) const = 0;
virtual bool SaveLightingPreset(AZ::Render::LightingPresetPtr preset, const AZStd::string& path) const = 0;
//! Get lighting preset by name
//! @param name preset name to search for
@@ -54,7 +55,7 @@ namespace MaterialEditor
virtual AZ::Render::LightingPresetPtr GetLightingPresetSelection() const = 0;
//! Select lighting preset
//! @param name preset to select
//! @param preset to select
virtual void SelectLightingPreset(AZ::Render::LightingPresetPtr preset) = 0;
//! Select lighting preset by name
@@ -64,6 +65,19 @@ namespace MaterialEditor
//! Get set of lighting preset names
virtual MaterialViewportPresetNameSet GetLightingPresetNames() const = 0;
//! Set lighting preset preview image
//! @param preset used to set preview image
//! @param preview image
virtual void SetLightingPresetPreview(AZ::Render::LightingPresetPtr preset, const QImage& image) = 0;
//! Get lighting preset preview image
//! @param preset used to find preview image
virtual QImage GetLightingPresetPreview(AZ::Render::LightingPresetPtr preset) const = 0;
//! Get model preset last save path
//! @param preset to lookup last save path
virtual AZStd::string GetLightingPresetLastSavePath(AZ::Render::LightingPresetPtr preset) const = 0;
//! Add model preset
//! @param preset model preset to add for selection
//! @returns pointer to new, managed preset
@@ -75,7 +89,7 @@ namespace MaterialEditor
//! Save Model preset
//! @returns true if preset was saved, otherwise false
virtual bool SaveModelPresetSelection(const AZStd::string& path) const = 0;
virtual bool SaveModelPreset(AZ::Render::ModelPresetPtr preset, const AZStd::string& path) const = 0;
//! Get model preset by name
//! @param name preset name to search for
@@ -97,6 +111,19 @@ namespace MaterialEditor
//! Get set of model preset names
virtual MaterialViewportPresetNameSet GetModelPresetNames() const = 0;
//! Set model preset preview image
//! @param preset used to set preview image
//! @param preview image
virtual void SetModelPresetPreview(AZ::Render::ModelPresetPtr preset, const QImage& image) = 0;
//! Get model preset preview image
//! @param preset used to find preview image
virtual QImage GetModelPresetPreview(AZ::Render::ModelPresetPtr preset) const = 0;
//! Get model preset last save path
//! @param preset to lookup last save path
virtual AZStd::string GetModelPresetLastSavePath(AZ::Render::ModelPresetPtr preset) const = 0;
//! Set enabled state for shadow catcher
virtual void SetShadowCatcherEnabled(bool enable) = 0;
@@ -108,6 +135,18 @@ namespace MaterialEditor
//! Get enabled state for grid
virtual bool GetGridEnabled() const = 0;
//! Set enabled state for alternate skybox
virtual void SetAlternateSkyboxEnabled(bool enable) = 0;
//! Get enabled state for alternate skybox
virtual bool GetAlternateSkyboxEnabled() const = 0;
//! Set field of view
virtual void SetFieldOfView(float fieldOfView) = 0;
//! Get field of view
virtual float GetFieldOfView() const = 0;
};
using MaterialViewportRequestBus = AZ::EBus<MaterialViewportRequests>;
@@ -457,10 +457,8 @@ namespace MaterialEditor
{
AZ::SettingsRegistryInterface* settingsRegistry = AZ::SettingsRegistry::Get();
AZ::IO::FixedMaxPath assetDatabaseSqlitePath;
if (settingsRegistry && settingsRegistry->Get(assetDatabaseSqlitePath.Native(), AZ::SettingsRegistryMergeUtils::FilePathKey_CacheRootFolder))
if (settingsRegistry && settingsRegistry->Get(assetDatabaseSqlitePath.Native(), AZ::SettingsRegistryMergeUtils::FilePathKey_CacheProjectRootFolder))
{
// Grab the Parent of the Asset RootPath to remove the <asset> platform from the end of the path
assetDatabaseSqlitePath = assetDatabaseSqlitePath.ParentPath();
assetDatabaseSqlitePath /= "assetdb.sqlite";
result = AZStd::string_view(assetDatabaseSqlitePath.Native());
return true;
@@ -14,6 +14,7 @@
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/Serialization/EditContext.h>
#include <AzCore/RTTI/BehaviorContext.h>
#include <AzCore/Jobs/JobFunction.h>
#include <AzFramework/Asset/AssetSystemBus.h>
#include <AzFramework/StringFunc/StringFunc.h>
@@ -24,6 +25,9 @@
#include <Viewport/MaterialViewportComponent.h>
#include <Atom/Viewport/MaterialViewportNotificationBus.h>
#include <Atom/ImageProcessing/ImageObject.h>
#include <Atom/ImageProcessing/ImageProcessingBus.h>
#include <AtomCore/Serialization/Json/JsonUtils.h>
#include <Atom/RPI.Reflect/Asset/AssetUtils.h>
@@ -33,6 +37,33 @@
namespace MaterialEditor
{
using LoadImageAsyncCallback = AZStd::function<void(const QImage&)>;
void LoadImageAsync(const AZStd::string& path, LoadImageAsyncCallback callback)
{
AZ::Job* job = AZ::CreateJobFunction([path, callback]() {
ImageProcessingAtom::IImageObjectPtr imageObject;
ImageProcessingAtom::ImageProcessingRequestBus::BroadcastResult(imageObject, &ImageProcessingAtom::ImageProcessingRequests::LoadImagePreview, path);
if (imageObject)
{
AZ::u8* imageBuf = nullptr;
AZ::u32 pitch = 0;
AZ::u32 mip = 0;
imageObject->GetImagePointer(mip, imageBuf, pitch);
const AZ::u32 width = imageObject->GetWidth(mip);
const AZ::u32 height = imageObject->GetHeight(mip);
QImage image(imageBuf, width, height, pitch, QImage::Format_RGBA8888);
if (callback)
{
callback(image);
}
}
}, true);
job->Start();
}
MaterialViewportComponent::MaterialViewportComponent()
{
}
@@ -62,25 +93,31 @@ namespace MaterialEditor
->Attribute(AZ::Script::Attributes::Module, "materialeditor")
->Event("ReloadContent", &MaterialViewportRequestBus::Events::ReloadContent)
->Event("AddLightingPreset", &MaterialViewportRequestBus::Events::AddLightingPreset)
->Event("SaveLightingPresetSelection", &MaterialViewportRequestBus::Events::SaveLightingPresetSelection)
->Event("SaveLightingPreset", &MaterialViewportRequestBus::Events::SaveLightingPreset)
->Event("GetLightingPresets", &MaterialViewportRequestBus::Events::GetLightingPresets)
->Event("GetLightingPresetByName", &MaterialViewportRequestBus::Events::GetLightingPresetByName)
->Event("GetLightingPresetSelection", &MaterialViewportRequestBus::Events::GetLightingPresetSelection)
->Event("SelectLightingPreset", &MaterialViewportRequestBus::Events::SelectLightingPreset)
->Event("SelectLightingPresetByName", &MaterialViewportRequestBus::Events::SelectLightingPresetByName)
->Event("GetLightingPresetNames", &MaterialViewportRequestBus::Events::GetLightingPresetNames)
->Event("GetLightingPresetLastSavePath", &MaterialViewportRequestBus::Events::GetLightingPresetLastSavePath)
->Event("AddModelPreset", &MaterialViewportRequestBus::Events::AddModelPreset)
->Event("SaveModelPresetSelection", &MaterialViewportRequestBus::Events::SaveModelPresetSelection)
->Event("SaveModelPreset", &MaterialViewportRequestBus::Events::SaveModelPreset)
->Event("GetModelPresets", &MaterialViewportRequestBus::Events::GetModelPresets)
->Event("GetModelPresetByName", &MaterialViewportRequestBus::Events::GetModelPresetByName)
->Event("GetModelPresetSelection", &MaterialViewportRequestBus::Events::GetModelPresetSelection)
->Event("SelectModelPreset", &MaterialViewportRequestBus::Events::SelectModelPreset)
->Event("SelectModelPresetByName", &MaterialViewportRequestBus::Events::SelectModelPresetByName)
->Event("GetModelPresetNames", &MaterialViewportRequestBus::Events::GetModelPresetNames)
->Event("GetModelPresetLastSavePath", &MaterialViewportRequestBus::Events::GetModelPresetLastSavePath)
->Event("SetShadowCatcherEnabled", &MaterialViewportRequestBus::Events::SetShadowCatcherEnabled)
->Event("GetShadowCatcherEnabled", &MaterialViewportRequestBus::Events::GetShadowCatcherEnabled)
->Event("SetGridEnabled", &MaterialViewportRequestBus::Events::SetGridEnabled)
->Event("GetGridEnabled", &MaterialViewportRequestBus::Events::GetGridEnabled)
->Event("SetAlternateSkyboxEnabled", &MaterialViewportRequestBus::Events::SetAlternateSkyboxEnabled)
->Event("GetAlternateSkyboxEnabled", &MaterialViewportRequestBus::Events::GetAlternateSkyboxEnabled)
->Event("SetFieldOfView", &MaterialViewportRequestBus::Events::SetFieldOfView)
->Event("GetFieldOfView", &MaterialViewportRequestBus::Events::GetFieldOfView)
;
behaviorContext->EBus<MaterialViewportNotificationBus>("MaterialViewportNotificationBus")
@@ -95,6 +132,8 @@ namespace MaterialEditor
->Event("OnModelPresetChanged", &MaterialViewportNotificationBus::Events::OnModelPresetChanged)
->Event("OnShadowCatcherEnabledChanged", &MaterialViewportNotificationBus::Events::OnShadowCatcherEnabledChanged)
->Event("OnGridEnabledChanged", &MaterialViewportNotificationBus::Events::OnGridEnabledChanged)
->Event("OnAlternateSkyboxEnabledChanged", &MaterialViewportNotificationBus::Events::OnAlternateSkyboxEnabledChanged)
->Event("OnFieldOfViewChanged", &MaterialViewportNotificationBus::Events::OnFieldOfViewChanged)
;
}
}
@@ -102,6 +141,7 @@ namespace MaterialEditor
void MaterialViewportComponent::GetRequiredServices([[maybe_unused]] AZ::ComponentDescriptor::DependencyArrayType& required)
{
required.push_back(AZ_CRC("PerformanceMonitorService", 0x6a44241a));
required.push_back(AZ_CRC("AtomImageBuilderService", 0x76ded592));
}
void MaterialViewportComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
@@ -120,6 +160,12 @@ namespace MaterialEditor
void MaterialViewportComponent::Activate()
{
m_lightingPresetPreviewImageDefault = QImage(180, 90, QImage::Format::Format_RGBA8888);
m_lightingPresetPreviewImageDefault.fill(Qt::GlobalColor::black);
m_modelPresetPreviewImageDefault = QImage(90, 90, QImage::Format::Format_RGBA8888);
m_modelPresetPreviewImageDefault.fill(Qt::GlobalColor::black);
MaterialViewportRequestBus::Handler::BusConnect();
AzFramework::AssetCatalogEventBus::Handler::BusConnect();
}
@@ -129,10 +175,14 @@ namespace MaterialEditor
AzFramework::AssetCatalogEventBus::Handler::BusDisconnect();
MaterialViewportRequestBus::Handler::BusDisconnect();
m_lightingPresetPreviewImages.clear();
m_lightingPresetVector.clear();
m_lightingPresetLastSavePathMap.clear();
m_lightingPresetSelection.reset();
m_modelPresetPreviewImages.clear();
m_modelPresetVector.clear();
m_modelPresetLastSavePathMap.clear();
m_modelPresetSelection.reset();
}
@@ -146,9 +196,11 @@ namespace MaterialEditor
const AZStd::string prevModelPresetSelectionName = m_modelPresetSelection ? m_modelPresetSelection->m_displayName : "";
m_lightingPresetVector.clear();
m_lightingPresetLastSavePathMap.clear();
m_lightingPresetSelection.reset();
m_modelPresetVector.clear();
m_modelPresetLastSavePathMap.clear();
m_modelPresetSelection.reset();
AZStd::vector<AZ::Data::AssetInfo> lightingAssetInfoVector;
@@ -182,7 +234,8 @@ namespace MaterialEditor
const AZ::Render::LightingPreset* preset = asset->GetDataAs<AZ::Render::LightingPreset>();
if (preset)
{
AddLightingPreset(*preset);
auto presetPtr = AddLightingPreset(*preset);
m_lightingPresetLastSavePathMap[presetPtr] = AZ::RPI::AssetUtils::GetSourcePathByAssetId(info.m_assetId);
AZ_TracePrintf("Material Editor", "Loaded viewport configurtion: %s.\n", info.m_relativePath.c_str());
}
}
@@ -193,14 +246,15 @@ namespace MaterialEditor
{
if (info.m_assetId.IsValid())
{
AZ::Data::Asset<AZ::RPI::AnyAsset> asset = AZ::RPI::AssetUtils::LoadAssetById<AZ::RPI::AnyAsset>(
info.m_assetId, AZ::RPI::AssetUtils::TraceLevel::Warning);
AZ::Data::Asset<AZ::RPI::AnyAsset> asset =
AZ::RPI::AssetUtils::LoadAssetById<AZ::RPI::AnyAsset>(info.m_assetId, AZ::RPI::AssetUtils::TraceLevel::Warning);
if (asset)
{
const AZ::Render::ModelPreset* preset = asset->GetDataAs<AZ::Render::ModelPreset>();
if (preset)
{
AddModelPreset(*preset);
auto presetPtr = AddModelPreset(*preset);
m_modelPresetLastSavePathMap[presetPtr] = AZ::RPI::AssetUtils::GetSourcePathByAssetId(info.m_assetId);
AZ_TracePrintf("Material Editor", "Loaded viewport configurtion: %s.\n", info.m_relativePath.c_str());
}
}
@@ -220,15 +274,24 @@ namespace MaterialEditor
AZ::Render::LightingPresetPtr MaterialViewportComponent::AddLightingPreset(const AZ::Render::LightingPreset& preset)
{
m_lightingPresetVector.push_back(AZStd::make_shared<AZ::Render::LightingPreset>(preset));
MaterialViewportNotificationBus::Broadcast(&MaterialViewportNotificationBus::Events::OnLightingPresetAdded,
m_lightingPresetVector.back());
auto presetPtr = m_lightingPresetVector.back();
MaterialViewportNotificationBus::Broadcast(&MaterialViewportNotificationBus::Events::OnLightingPresetAdded, presetPtr);
if (preset.m_autoSelect || m_lightingPresetVector.size() == 1)
{
SelectLightingPreset(m_lightingPresetVector.back());
SelectLightingPreset(presetPtr);
}
return m_lightingPresetVector.back();
const auto& imagePath = AZ::RPI::AssetUtils::GetSourcePathByAssetId(presetPtr->m_skyboxImageAsset.GetId());
LoadImageAsync(imagePath, [presetPtr](const QImage& image) {
QImage imageScaled = image.scaled(180, 90, Qt::AspectRatioMode::KeepAspectRatio);
AZ::TickBus::QueueFunction([presetPtr, imageScaled]() {
MaterialViewportRequestBus::Broadcast(&MaterialViewportRequestBus::Events::SetLightingPresetPreview, presetPtr, imageScaled);
});
});
return presetPtr;
}
AZ::Render::LightingPresetPtr MaterialViewportComponent::GetLightingPresetByName(const AZStd::string& name) const
@@ -243,12 +306,12 @@ namespace MaterialEditor
return m_lightingPresetVector;
}
bool MaterialViewportComponent::SaveLightingPresetSelection(const AZStd::string& path) const
bool MaterialViewportComponent::SaveLightingPreset(AZ::Render::LightingPresetPtr preset, const AZStd::string& path) const
{
if (m_lightingPresetSelection)
if (preset && AZ::JsonSerializationUtils::SaveObjectToFile<AZ::Render::LightingPreset>(preset.get(), path).IsSuccess())
{
return AZ::JsonSerializationUtils::SaveObjectToFile<AZ::Render::LightingPreset>(
m_lightingPresetSelection.get(), path).IsSuccess();
m_lightingPresetLastSavePathMap[preset] = path;
return true;
}
return false;
@@ -286,18 +349,44 @@ namespace MaterialEditor
return names;
}
void MaterialViewportComponent::SetLightingPresetPreview(AZ::Render::LightingPresetPtr preset, const QImage& image)
{
m_lightingPresetPreviewImages[preset] = image;
}
QImage MaterialViewportComponent::GetLightingPresetPreview(AZ::Render::LightingPresetPtr preset) const
{
auto imageItr = m_lightingPresetPreviewImages.find(preset);
return imageItr != m_lightingPresetPreviewImages.end() ? imageItr->second : m_lightingPresetPreviewImageDefault;
}
AZStd::string MaterialViewportComponent::GetLightingPresetLastSavePath(AZ::Render::LightingPresetPtr preset) const
{
auto pathItr = m_lightingPresetLastSavePathMap.find(preset);
return pathItr != m_lightingPresetLastSavePathMap.end() ? pathItr->second : AZStd::string();
}
AZ::Render::ModelPresetPtr MaterialViewportComponent::AddModelPreset(const AZ::Render::ModelPreset& preset)
{
m_modelPresetVector.push_back(AZStd::make_shared<AZ::Render::ModelPreset>(preset));
MaterialViewportNotificationBus::Broadcast(&MaterialViewportNotificationBus::Events::OnModelPresetAdded,
m_modelPresetVector.back());
auto presetPtr = m_modelPresetVector.back();
MaterialViewportNotificationBus::Broadcast(&MaterialViewportNotificationBus::Events::OnModelPresetAdded, presetPtr);
if (preset.m_autoSelect || m_modelPresetVector.size() == 1)
{
SelectModelPreset(m_modelPresetVector.back());
SelectModelPreset(presetPtr);
}
return m_modelPresetVector.back();
const auto& imagePath = AZ::RPI::AssetUtils::GetSourcePathByAssetId(presetPtr->m_previewImageAsset.GetId());
LoadImageAsync(imagePath, [presetPtr](const QImage& image) {
QImage imageScaled = image.scaled(90, 90, Qt::AspectRatioMode::KeepAspectRatio);
AZ::TickBus::QueueFunction([presetPtr, imageScaled]() {
MaterialViewportRequestBus::Broadcast(&MaterialViewportRequestBus::Events::SetModelPresetPreview, presetPtr, imageScaled);
});
});
return presetPtr;
}
AZ::Render::ModelPresetPtr MaterialViewportComponent::GetModelPresetByName(const AZStd::string& name) const
@@ -312,12 +401,12 @@ namespace MaterialEditor
return m_modelPresetVector;
}
bool MaterialViewportComponent::SaveModelPresetSelection(const AZStd::string& path) const
bool MaterialViewportComponent::SaveModelPreset(AZ::Render::ModelPresetPtr preset, const AZStd::string& path) const
{
if (m_modelPresetSelection)
if (preset && AZ::JsonSerializationUtils::SaveObjectToFile<AZ::Render::ModelPreset>(preset.get(), path).IsSuccess())
{
return AZ::JsonSerializationUtils::SaveObjectToFile<AZ::Render::ModelPreset>(
m_modelPresetSelection.get(), path).IsSuccess();
m_modelPresetLastSavePathMap[preset] = path;
return true;
}
return false;
@@ -355,6 +444,23 @@ namespace MaterialEditor
return names;
}
void MaterialViewportComponent::SetModelPresetPreview(AZ::Render::ModelPresetPtr preset, const QImage& image)
{
m_modelPresetPreviewImages[preset] = image;
}
QImage MaterialViewportComponent::GetModelPresetPreview(AZ::Render::ModelPresetPtr preset) const
{
auto imageItr = m_modelPresetPreviewImages.find(preset);
return imageItr != m_modelPresetPreviewImages.end() ? imageItr->second : m_modelPresetPreviewImageDefault;
}
AZStd::string MaterialViewportComponent::GetModelPresetLastSavePath(AZ::Render::ModelPresetPtr preset) const
{
auto pathItr = m_modelPresetLastSavePathMap.find(preset);
return pathItr != m_modelPresetLastSavePathMap.end() ? pathItr->second : AZStd::string();
}
void MaterialViewportComponent::SetShadowCatcherEnabled(bool enable)
{
m_shadowCatcherEnabled = enable;
@@ -378,6 +484,30 @@ namespace MaterialEditor
return m_gridEnabled;
}
void MaterialViewportComponent::SetAlternateSkyboxEnabled(bool enable)
{
m_alternateSkyboxEnabled = enable;
MaterialViewportNotificationBus::Broadcast(&MaterialViewportNotificationBus::Events::OnAlternateSkyboxEnabledChanged, enable);
}
bool MaterialViewportComponent::GetAlternateSkyboxEnabled() const
{
return m_alternateSkyboxEnabled;
}
void MaterialViewportComponent::SetFieldOfView(float fieldOfView)
{
m_fieldOfView = fieldOfView;
MaterialViewportNotificationBus::Broadcast(&MaterialViewportNotificationBus::Events::OnFieldOfViewChanged, fieldOfView);
}
float MaterialViewportComponent::GetFieldOfView() const
{
return m_fieldOfView;
}
void MaterialViewportComponent::OnCatalogLoaded([[maybe_unused]] const char* catalogFile)
{
AZ::TickBus::QueueFunction([this]() { ReloadContent(); });
@@ -55,26 +55,36 @@ namespace MaterialEditor
AZ::Render::LightingPresetPtr AddLightingPreset(const AZ::Render::LightingPreset& preset) override;
AZ::Render::LightingPresetPtrVector GetLightingPresets() const override;
bool SaveLightingPresetSelection(const AZStd::string& path) const override;
bool SaveLightingPreset(AZ::Render::LightingPresetPtr preset, const AZStd::string& path) const override;
AZ::Render::LightingPresetPtr GetLightingPresetByName(const AZStd::string& name) const override;
AZ::Render::LightingPresetPtr GetLightingPresetSelection() const override;
void SelectLightingPreset(AZ::Render::LightingPresetPtr preset) override;
void SelectLightingPresetByName(const AZStd::string& name) override;
MaterialViewportPresetNameSet GetLightingPresetNames() const override;
void SetLightingPresetPreview(AZ::Render::LightingPresetPtr preset, const QImage& image) override;
QImage GetLightingPresetPreview(AZ::Render::LightingPresetPtr preset) const override;
AZStd::string GetLightingPresetLastSavePath(AZ::Render::LightingPresetPtr preset) const override;
AZ::Render::ModelPresetPtr AddModelPreset(const AZ::Render::ModelPreset& preset) override;
AZ::Render::ModelPresetPtrVector GetModelPresets() const override;
bool SaveModelPresetSelection(const AZStd::string& path) const override;
bool SaveModelPreset(AZ::Render::ModelPresetPtr preset, const AZStd::string& path) const override;
AZ::Render::ModelPresetPtr GetModelPresetByName(const AZStd::string& name) const override;
AZ::Render::ModelPresetPtr GetModelPresetSelection() const override;
void SelectModelPreset(AZ::Render::ModelPresetPtr preset) override;
void SelectModelPresetByName(const AZStd::string& name) override;
MaterialViewportPresetNameSet GetModelPresetNames() const override;
void SetModelPresetPreview(AZ::Render::ModelPresetPtr preset, const QImage& image) override;
QImage GetModelPresetPreview(AZ::Render::ModelPresetPtr preset) const override;
AZStd::string GetModelPresetLastSavePath(AZ::Render::ModelPresetPtr preset) const override;
void SetShadowCatcherEnabled(bool enable) override;
bool GetShadowCatcherEnabled() const override;
void SetGridEnabled(bool enable) override;
bool GetGridEnabled() const override;
void SetAlternateSkyboxEnabled(bool enable) override;
bool GetAlternateSkyboxEnabled() const override;
void SetFieldOfView(float fieldOfView) override;
float GetFieldOfView() const override;
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
@@ -88,7 +98,18 @@ namespace MaterialEditor
AZ::Render::ModelPresetPtrVector m_modelPresetVector;
AZ::Render::ModelPresetPtr m_modelPresetSelection;
AZStd::map<AZ::Render::LightingPresetPtr, QImage> m_lightingPresetPreviewImages;
AZStd::map<AZ::Render::ModelPresetPtr, QImage> m_modelPresetPreviewImages;
QImage m_lightingPresetPreviewImageDefault;
QImage m_modelPresetPreviewImageDefault;
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;
};
}
@@ -318,6 +318,9 @@ namespace MaterialEditor
Camera::Configuration cameraConfig;
Camera::CameraRequestBus::EventResult(cameraConfig, m_cameraEntity->GetId(), &Camera::CameraRequestBus::Events::GetCameraConfiguration);
bool enableAlternateSkybox = false;
MaterialViewportRequestBus::BroadcastResult(enableAlternateSkybox, &MaterialViewportRequestBus::Events::GetAlternateSkyboxEnabled);
preset->ApplyLightingPreset(
iblFeatureProcessor,
m_skyboxFeatureProcessor,
@@ -326,7 +329,8 @@ namespace MaterialEditor
cameraConfig,
m_lightHandles,
m_shadowCatcherMaterial,
m_shadowCatcherOpacityPropertyIndex);
m_shadowCatcherOpacityPropertyIndex,
enableAlternateSkybox);
}
void MaterialViewportRenderer::OnLightingPresetChanged(AZ::Render::LightingPresetPtr preset)
@@ -392,12 +396,24 @@ namespace MaterialEditor
}
}
void MaterialViewportRenderer::OnAlternateSkyboxEnabledChanged(bool enable)
{
AZ_UNUSED(enable);
AZ::Render::LightingPresetPtr selectedPreset;
MaterialViewportRequestBus::BroadcastResult(selectedPreset, &MaterialViewportRequestBus::Events::GetLightingPresetSelection);
OnLightingPresetSelected(selectedPreset);
}
void MaterialViewportRenderer::OnFieldOfViewChanged(float fieldOfView)
{
MaterialEditorViewportInputControllerRequestBus::Broadcast(&MaterialEditorViewportInputControllerRequestBus::Handler::SetFieldOfView, fieldOfView);
}
void MaterialViewportRenderer::OnAssetReady(AZ::Data::Asset<AZ::Data::AssetData> asset)
{
if (m_modelAssetId == asset.GetId())
{
MaterialEditorViewportInputControllerRequestBus::Broadcast(
&MaterialEditorViewportInputControllerRequestBus::Handler::Reset);
MaterialEditorViewportInputControllerRequestBus::Broadcast(&MaterialEditorViewportInputControllerRequestBus::Handler::Reset);
AZ::Data::AssetBus::Handler::BusDisconnect(asset.GetId());
}
}
@@ -69,6 +69,8 @@ namespace MaterialEditor
void OnModelPresetChanged(AZ::Render::ModelPresetPtr preset) override;
void OnShadowCatcherEnabledChanged(bool enable) override;
void OnGridEnabledChanged(bool enable) override;
void OnAlternateSkyboxEnabledChanged(bool enable) override;
void OnFieldOfViewChanged(float fieldOfView) override;
// AZ::Data::AssetBus::Handler interface overrides...
void OnAssetReady(AZ::Data::Asset<AZ::Data::AssetData> asset) override;
@@ -24,7 +24,6 @@
#include <Atom/Document/MaterialDocumentRequestBus.h>
#include <Atom/Document/MaterialDocumentSystemRequestBus.h>
#include <Atom/Window/MaterialEditorWindowNotificationBus.h>
#include <Atom/Viewport/MaterialViewportRequestBus.h>
#include <Atom/RHI/Factory.h>
@@ -420,50 +419,6 @@ namespace MaterialEditor
m_menuFile->addSeparator();
auto presetMenu = m_menuFile->addMenu("Presets");
presetMenu->addAction("New Model Preset", [this]() {
AZ::Render::ModelPresetPtr preset;
MaterialViewportRequestBus::BroadcastResult(preset, &MaterialViewportRequestBus::Events::AddModelPreset, AZ::Render::ModelPreset());
MaterialViewportRequestBus::Broadcast(&MaterialViewportRequestBus::Events::SelectModelPreset, preset);
});
presetMenu->addAction("Save Model Preset", [this]() {
const QString defaultPath = AtomToolsFramework::GetUniqueFileInfo(
QString(AZ::IO::FileIOBase::GetInstance()->GetAlias("@devassets@")) +
AZ_CORRECT_FILESYSTEM_SEPARATOR + "Materials" +
AZ_CORRECT_FILESYSTEM_SEPARATOR + "untitled.modelpreset.azasset").absoluteFilePath();
MaterialViewportRequestBus::Broadcast(&MaterialViewportRequestBus::Events::SaveModelPresetSelection,
AtomToolsFramework::GetSaveFileInfo(defaultPath).absoluteFilePath().toUtf8().constData());
});
presetMenu->addSeparator();
presetMenu->addAction("New Lighting Preset", [this]() {
AZ::Render::LightingPresetPtr preset;
MaterialViewportRequestBus::BroadcastResult(preset, &MaterialViewportRequestBus::Events::AddLightingPreset, AZ::Render::LightingPreset());
MaterialViewportRequestBus::Broadcast(&MaterialViewportRequestBus::Events::SelectLightingPreset, preset);
});
presetMenu->addAction("Save Lighting Preset", [this]() {
const QString defaultPath = AtomToolsFramework::GetUniqueFileInfo(
QString(AZ::IO::FileIOBase::GetInstance()->GetAlias("@devassets@")) +
AZ_CORRECT_FILESYSTEM_SEPARATOR + "Materials" +
AZ_CORRECT_FILESYSTEM_SEPARATOR + "untitled.lightingpreset.azasset").absoluteFilePath();
MaterialViewportRequestBus::Broadcast(&MaterialViewportRequestBus::Events::SaveLightingPresetSelection,
AtomToolsFramework::GetSaveFileInfo(defaultPath).absoluteFilePath().toUtf8().constData());
});
presetMenu->addSeparator();
presetMenu->addAction("Reload Presets", [this]() {
MaterialViewportRequestBus::Broadcast(&MaterialViewportRequestBus::Events::ReloadContent);
}, QKeySequence::Refresh);
m_menuFile->addSeparator();
m_menuFile->addAction("Run &Python...", [this]() {
const QString script = QFileDialog::getOpenFileName(this, "Run Script", QString(), QString("*.py"));
if (!script.isEmpty())
@@ -22,11 +22,14 @@
#include <Atom/Window/MaterialEditorWindowFactoryRequestBus.h>
#include <Source/Window/MaterialEditorWindowComponent.h>
#include <Source/Window/MaterialEditorWindow.h>
#include <Source/Window/ViewportSettingsInspector/ViewportSettingsInspector.h>
namespace MaterialEditor
{
void MaterialEditorWindowComponent::Reflect(AZ::ReflectContext* context)
{
GeneralViewportSettings::Reflect(context);
if (AZ::SerializeContext* serialize = azrtti_cast<AZ::SerializeContext*>(context))
{
serialize->Class<MaterialEditorWindowComponent, AZ::Component>()
@@ -0,0 +1,73 @@
/*
* 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/Feature/Utils/LightingPreset.h>
#include <Atom/Viewport/MaterialViewportRequestBus.h>
#include <AtomToolsFramework/Util/Util.h>
#include <AzFramework/Application/Application.h>
#include <Window/PresetBrowserDialogs/LightingPresetBrowserDialog.h>
namespace MaterialEditor
{
LightingPresetBrowserDialog::LightingPresetBrowserDialog(QWidget* parent)
: PresetBrowserDialog(parent)
{
QSignalBlocker signalBlocker(this);
setWindowTitle("Lighting Preset Browser");
MaterialViewportRequestBus::BroadcastResult(m_initialPreset, &MaterialViewportRequestBus::Events::GetLightingPresetSelection);
AZ::Render::LightingPresetPtrVector presets;
MaterialViewportRequestBus::BroadcastResult(presets, &MaterialViewportRequestBus::Events::GetLightingPresets);
AZStd::sort(presets.begin(), presets.end(), [](const auto& a, const auto& b) { return a->m_displayName < b->m_displayName; });
QListWidgetItem* selectedItem = nullptr;
for (const auto& preset : presets)
{
QImage image;
MaterialViewportRequestBus::BroadcastResult(image, &MaterialViewportRequestBus::Events::GetLightingPresetPreview, preset);
QListWidgetItem* item = CreateListItem(preset->m_displayName.c_str(), image);
m_listItemToPresetMap[item] = preset;
if (m_initialPreset == preset)
{
selectedItem = item;
}
}
if (selectedItem)
{
m_ui->m_presetList->setCurrentItem(selectedItem);
m_ui->m_presetList->scrollToItem(selectedItem);
}
}
void LightingPresetBrowserDialog::SelectCurrentPreset()
{
auto presetItr = m_listItemToPresetMap.find(m_ui->m_presetList->currentItem());
if (presetItr != m_listItemToPresetMap.end())
{
MaterialViewportRequestBus::Broadcast(&MaterialViewportRequestBus::Events::SelectLightingPreset, presetItr->second);
}
}
void LightingPresetBrowserDialog::SelectInitialPreset()
{
MaterialViewportRequestBus::Broadcast(&MaterialViewportRequestBus::Events::SelectLightingPreset, m_initialPreset);
}
} // namespace MaterialEditor
#include <Window/PresetBrowserDialogs/moc_LightingPresetBrowserDialog.cpp>
@@ -0,0 +1,40 @@
/*
* 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 <Atom/Feature/Utils/LightingPreset.h>
#include <Atom/Viewport/MaterialViewportNotificationBus.h>
#include <AzCore/std/containers/vector.h>
#endif
#include <Window/PresetBrowserDialogs/PresetBrowserDialog.h>
namespace MaterialEditor
{
//! Widget for managing and selecting from a library of preset assets
class LightingPresetBrowserDialog : public PresetBrowserDialog
{
Q_OBJECT
public:
LightingPresetBrowserDialog(QWidget* parent = nullptr);
~LightingPresetBrowserDialog() = default;
private:
void SelectCurrentPreset() override;
void SelectInitialPreset() override;
AZ::Render::LightingPresetPtr m_initialPreset;
AZStd::unordered_map<QListWidgetItem*, AZ::Render::LightingPresetPtr> m_listItemToPresetMap;
};
} // namespace MaterialEditor
@@ -0,0 +1,73 @@
/*
* 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/Feature/Utils/ModelPreset.h>
#include <Atom/Viewport/MaterialViewportRequestBus.h>
#include <AtomToolsFramework/Util/Util.h>
#include <AzFramework/Application/Application.h>
#include <Window/PresetBrowserDialogs/ModelPresetBrowserDialog.h>
namespace MaterialEditor
{
ModelPresetBrowserDialog::ModelPresetBrowserDialog(QWidget* parent)
: PresetBrowserDialog(parent)
{
QSignalBlocker signalBlocker(this);
setWindowTitle("Model Preset Browser");
MaterialViewportRequestBus::BroadcastResult(m_initialPreset, &MaterialViewportRequestBus::Events::GetModelPresetSelection);
AZ::Render::ModelPresetPtrVector presets;
MaterialViewportRequestBus::BroadcastResult(presets, &MaterialViewportRequestBus::Events::GetModelPresets);
AZStd::sort(presets.begin(), presets.end(), [](const auto& a, const auto& b) { return a->m_displayName < b->m_displayName; });
QListWidgetItem* selectedItem = nullptr;
for (const auto& preset : presets)
{
QImage image;
MaterialViewportRequestBus::BroadcastResult(image, &MaterialViewportRequestBus::Events::GetModelPresetPreview, preset);
QListWidgetItem* item = CreateListItem(preset->m_displayName.c_str(), image);
m_listItemToPresetMap[item] = preset;
if (m_initialPreset == preset)
{
selectedItem = item;
}
}
if (selectedItem)
{
m_ui->m_presetList->setCurrentItem(selectedItem);
m_ui->m_presetList->scrollToItem(selectedItem);
}
}
void ModelPresetBrowserDialog::SelectCurrentPreset()
{
auto presetItr = m_listItemToPresetMap.find(m_ui->m_presetList->currentItem());
if (presetItr != m_listItemToPresetMap.end())
{
MaterialViewportRequestBus::Broadcast(&MaterialViewportRequestBus::Events::SelectModelPreset, presetItr->second);
}
}
void ModelPresetBrowserDialog::SelectInitialPreset()
{
MaterialViewportRequestBus::Broadcast(&MaterialViewportRequestBus::Events::SelectModelPreset, m_initialPreset);
}
} // namespace MaterialEditor
#include <Window/PresetBrowserDialogs/moc_ModelPresetBrowserDialog.cpp>
@@ -0,0 +1,40 @@
/*
* 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 <Atom/Feature/Utils/ModelPreset.h>
#include <Atom/Viewport/MaterialViewportNotificationBus.h>
#include <AzCore/std/containers/vector.h>
#endif
#include <Window/PresetBrowserDialogs/PresetBrowserDialog.h>
namespace MaterialEditor
{
//! Widget for managing and selecting from a library of preset assets
class ModelPresetBrowserDialog : public PresetBrowserDialog
{
Q_OBJECT
public:
ModelPresetBrowserDialog(QWidget* parent = nullptr);
~ModelPresetBrowserDialog() = default;
private:
void SelectCurrentPreset() override;
void SelectInitialPreset() override;
AZ::Render::ModelPresetPtr m_initialPreset;
AZStd::unordered_map<QListWidgetItem*, AZ::Render::ModelPresetPtr> m_listItemToPresetMap;
};
} // namespace MaterialEditor
@@ -0,0 +1,115 @@
/*
* 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 <AtomToolsFramework/Util/Util.h>
#include <AzFramework/Application/Application.h>
#include <AzQtComponents/Components/StyleManager.h>
#include <AzQtComponents/Components/Widgets/ElidingLabel.h>
#include <AzQtComponents/Components/Widgets/LineEdit.h>
#include <AzQtComponents/Components/Widgets/Text.h>
#include <Window/PresetBrowserDialogs/PresetBrowserDialog.h>
#include <QLabel>
#include <QLineEdit>
#include <QMenu>
namespace MaterialEditor
{
PresetBrowserDialog::PresetBrowserDialog(QWidget* parent)
: QDialog(parent)
, m_ui(new Ui::PresetBrowserDialog)
{
m_ui->setupUi(this);
QSignalBlocker signalBlocker(this);
SetupPresetList();
SetupSearchWidget();
SetupDialogButtons();
}
void PresetBrowserDialog::SetupPresetList()
{
m_ui->m_presetList->setFlow(QListView::LeftToRight);
m_ui->m_presetList->setResizeMode(QListView::Adjust);
m_ui->m_presetList->setGridSize(QSize(0, 0));
m_ui->m_presetList->setWrapping(true);
QObject::connect(m_ui->m_presetList, &QListWidget::currentItemChanged, [this]() { SelectCurrentPreset(); });
}
QListWidgetItem* PresetBrowserDialog::CreateListItem(const QString& title, const QImage& image)
{
const QSize gridSize = m_ui->m_presetList->gridSize();
m_ui->m_presetList->setGridSize(
QSize(AZStd::max(gridSize.width(), image.width() + 10), AZStd::max(gridSize.height(), image.height() + 10)));
QListWidgetItem* item = new QListWidgetItem(m_ui->m_presetList);
item->setData(Qt::UserRole, title);
item->setSizeHint(image.size() + QSize(4, 4));
m_ui->m_presetList->addItem(item);
QLabel* previewImage = new QLabel(m_ui->m_presetList);
previewImage->setFixedSize(image.size());
previewImage->setMargin(0);
previewImage->setPixmap(QPixmap::fromImage(image));
previewImage->updateGeometry();
AzQtComponents::ElidingLabel* previewLabel = new AzQtComponents::ElidingLabel(previewImage);
previewLabel->setText(title);
previewLabel->setFixedSize(QSize(image.width(), 15));
previewLabel->setMargin(0);
previewLabel->setStyleSheet("background-color: rgb(35, 35, 35)");
AzQtComponents::Text::addPrimaryStyle(previewLabel);
AzQtComponents::Text::addLabelStyle(previewLabel);
m_ui->m_presetList->setItemWidget(item, previewImage);
return item;
}
void PresetBrowserDialog::SetupSearchWidget()
{
m_ui->m_searchWidget->setReadOnly(false);
m_ui->m_searchWidget->setContextMenuPolicy(Qt::CustomContextMenu);
AzQtComponents::LineEdit::applySearchStyle(m_ui->m_searchWidget);
connect(m_ui->m_searchWidget, &QLineEdit::textChanged, this, [this]() { ApplySearchFilter(); });
connect(m_ui->m_searchWidget, &QWidget::customContextMenuRequested, this, [this](const QPoint& pos) { ShowSearchMenu(pos); });
}
void PresetBrowserDialog::SetupDialogButtons()
{
connect(m_ui->m_buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
connect(m_ui->m_buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
connect(this, &QDialog::rejected, this, [this]() { SelectInitialPreset(); });
}
void PresetBrowserDialog::ApplySearchFilter()
{
for (int index = 0; index < m_ui->m_presetList->count(); ++index)
{
QListWidgetItem* item = m_ui->m_presetList->item(index);
const QString& title = item->data(Qt::UserRole).toString();
const QString filter = m_ui->m_searchWidget->text();
item->setHidden(!filter.isEmpty() && !title.contains(filter, Qt::CaseInsensitive));
}
}
void PresetBrowserDialog::ShowSearchMenu(const QPoint& pos)
{
QScopedPointer<QMenu> menu(m_ui->m_searchWidget->createStandardContextMenu());
menu->setStyleSheet("background-color: #333333");
menu->exec(m_ui->m_searchWidget->mapToGlobal(pos));
}
} // namespace MaterialEditor
#include <Window/PresetBrowserDialogs/moc_PresetBrowserDialog.cpp>
@@ -0,0 +1,50 @@
/*
* 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/std/containers/vector.h>
#include <QDialog>
#endif
#include <Window/PresetBrowserDialogs/ui_PresetBrowserDialog.h>
class QImage;
class QListWidgetItem;
class QString;
namespace MaterialEditor
{
//! Widget for managing and selecting from a library of preset assets
class PresetBrowserDialog : public QDialog
{
Q_OBJECT
public:
PresetBrowserDialog(QWidget* parent = nullptr);
~PresetBrowserDialog() = default;
protected:
void SetupPresetList();
QListWidgetItem* CreateListItem(const QString& title, const QImage& image);
void SetupSearchWidget();
void SetupDialogButtons();
void ApplySearchFilter();
void ShowSearchMenu(const QPoint& pos);
virtual void SelectCurrentPreset() = 0;
virtual void SelectInitialPreset() = 0;
QScopedPointer<Ui::PresetBrowserDialog> m_ui;
};
} // namespace MaterialEditor
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PresetBrowserDialog</class>
<widget class="QWidget" name="PresetBrowserDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>100</height>
</size>
</property>
<property name="windowTitle">
<string>Preset Browser</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLineEdit" name="m_searchWidget"/>
</item>
<item>
<widget class="QListWidget" name="m_presetList"/>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QDialogButtonBox" name="m_buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
@@ -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.
*
*/
#include <AzQtComponents/Components/Widgets/Slider.h>
#include <Viewport/InputController/MaterialEditorViewportInputController.h>
#include <Source/Window/ToolBar/FovSliderWidget.h>
AZ_PUSH_DISABLE_WARNING(4251 4800, "-Wunknown-warning-option") // disable warnings spawned by QT
#include <QHBoxLayout>
#include <QLabel>
AZ_POP_DISABLE_WARNING
namespace MaterialEditor
{
FovSliderWidget::FovSliderWidget(QWidget* parent)
: QWidget(parent)
{
QHBoxLayout* layout = new QHBoxLayout();
m_label = new QLabel("Field of View");
layout->addWidget(m_label);
AzQtComponents::SliderInt* slider = new AzQtComponents::SliderInt(Qt::Orientation::Horizontal);
slider->setRange(60, 120);
connect(slider, &AzQtComponents::SliderInt::valueChanged, this, &FovSliderWidget::SliderValueChanged);
slider->setValue(90);
layout->addWidget(slider);
setLayout(layout);
}
void FovSliderWidget::SliderValueChanged(int value) const
{
m_label->setText(QString("Field of View (%1)").arg(value));
MaterialEditorViewportInputControllerRequestBus::Broadcast(
&MaterialEditorViewportInputControllerRequestBus::Handler::SetFieldOfView,
aznumeric_cast<float>(value));
}
} // namespace MaterialEditor
@@ -1,39 +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/PlatformDef.h>
AZ_PUSH_DISABLE_WARNING(4251 4800, "-Wunknown-warning-option") // disable warnings spawned by QT
#include <QLabel>
#include <QWidget>
AZ_POP_DISABLE_WARNING
namespace MaterialEditor
{
//! Widget for adjusting Field of View in viewport
class FovSliderWidget
: public QWidget
{
Q_OBJECT
public:
FovSliderWidget(QWidget* parent = 0);
~FovSliderWidget() = default;
private:
QLabel* m_label;
private Q_SLOTS:
void SliderValueChanged(int value) const;
};
} // namespace MaterialEditor
@@ -13,12 +13,15 @@
#include <Source/Window/ToolBar/MaterialEditorToolBar.h>
#include <Source/Window/ToolBar/ModelPresetComboBox.h>
#include <Source/Window/ToolBar/LightingPresetComboBox.h>
#include <Source/Window/ToolBar/FovSliderWidget.h>
#include <Atom/Document/MaterialEditorSettingsBus.h>
#include <Atom/Viewport/MaterialViewportRequestBus.h>
#include <AzCore/std/containers/vector.h>
#include <Atom/Viewport/MaterialViewportNotificationBus.h>
AZ_PUSH_DISABLE_WARNING(4251 4800, "-Wunknown-warning-option") // disable warnings spawned by QT
#include <AzQtComponents/Components/Widgets/ToolBar.h>
#include <QIcon>
#include <QMenu>
#include <QToolButton>
#include <QAction>
@@ -36,7 +39,7 @@ namespace MaterialEditor
toggleGrid->setCheckable(true);
connect(toggleGrid, &QAction::triggered, [this, toggleGrid]() {
MaterialViewportRequestBus::Broadcast(&MaterialViewportRequestBus::Events::SetGridEnabled, toggleGrid->isChecked());
});
});
bool enableGrid = false;
MaterialViewportRequestBus::BroadcastResult(enableGrid, &MaterialViewportRequestBus::Events::GetGridEnabled);
toggleGrid->setChecked(enableGrid);
@@ -46,7 +49,7 @@ namespace MaterialEditor
toggleShadowCatcher->setCheckable(true);
connect(toggleShadowCatcher, &QAction::triggered, [this, toggleShadowCatcher]() {
MaterialViewportRequestBus::Broadcast(&MaterialViewportRequestBus::Events::SetShadowCatcherEnabled, toggleShadowCatcher->isChecked());
});
});
bool enableShadowCatcher = false;
MaterialViewportRequestBus::BroadcastResult(enableShadowCatcher, &MaterialViewportRequestBus::Events::GetShadowCatcherEnabled);
toggleShadowCatcher->setChecked(enableShadowCatcher);
@@ -57,13 +60,13 @@ namespace MaterialEditor
QMenu* toneMappingMenu = new QMenu(toneMappingButton);
toneMappingMenu->addAction("None", [this]() {
MaterialEditorSettingsRequestBus::Broadcast(&MaterialEditorSettingsRequests::SetStringProperty, "toneMapping", "None");
});
});
toneMappingMenu->addAction("Gamma2.2", [this]() {
MaterialEditorSettingsRequestBus::Broadcast(&MaterialEditorSettingsRequests::SetStringProperty, "toneMapping", "Gamma2.2");
});
});
toneMappingMenu->addAction("ACES", [this]() {
MaterialEditorSettingsRequestBus::Broadcast(&MaterialEditorSettingsRequests::SetStringProperty, "toneMapping", "ACES");
});
});
toneMappingButton->setMenu(toneMappingMenu);
toneMappingButton->setText("Tone Mapping");
toneMappingButton->setIcon(QIcon(":/Icons/toneMapping.svg"));
@@ -82,10 +85,6 @@ namespace MaterialEditor
auto lightingPresetComboBox = new LightingPresetComboBox(this);
lightingPresetComboBox->setSizeAdjustPolicy(QComboBox::SizeAdjustPolicy::AdjustToContents);
addWidget(lightingPresetComboBox);
FovSliderWidget* fovSlider = new FovSliderWidget(this);
fovSlider->setFixedWidth(250);
addWidget(fovSlider);
}
} // namespace MaterialEditor
@@ -12,11 +12,65 @@
#include <Window/ViewportSettingsInspector/ViewportSettingsInspector.h>
#include <Atom/Viewport/MaterialViewportRequestBus.h>
#include <AtomToolsFramework/Inspector/InspectorPropertyGroupWidget.h>
#include <AtomToolsFramework/Util/Util.h>
#include <Window/PresetBrowserDialogs/LightingPresetBrowserDialog.h>
#include <Window/PresetBrowserDialogs/ModelPresetBrowserDialog.h>
#include <QApplication>
#include <QPushButton>
#include <QToolButton>
#include <QAction>
#include <QHBoxLayout>
#include <QVBoxLayout>
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)
;
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)
;
}
}
if (auto behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
{
behaviorContext->Class<GeneralViewportSettings>("GeneralViewportSettings")
->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::Preview)
->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))
;
}
}
ViewportSettingsInspector::ViewportSettingsInspector(QWidget* parent)
: AtomToolsFramework::InspectorWidget(parent)
{
@@ -34,40 +88,218 @@ namespace MaterialEditor
void ViewportSettingsInspector::Popuate()
{
AddGroupsBegin();
AddGeneralGroup();
AddModelGroup();
AddLightingGroup();
AddGroupsEnd();
}
m_modelPreset.reset();
MaterialViewportRequestBus::BroadcastResult(m_modelPreset, &MaterialViewportRequestBus::Events::GetModelPresetSelection);
void ViewportSettingsInspector::AddGeneralGroup()
{
const AZStd::string groupNameId = "general";
const AZStd::string groupDisplayName = "General";
const AZStd::string groupDescription = "General";
AddGroup(
groupNameId, groupDisplayName, groupDescription,
new AtomToolsFramework::InspectorPropertyGroupWidget(&m_generalSettings, nullptr, m_generalSettings.TYPEINFO_Uuid(), this));
}
void ViewportSettingsInspector::AddModelGroup()
{
const AZStd::string groupNameId = "model";
const AZStd::string groupDisplayName = "Model";
const AZStd::string groupDescription = "Model";
auto groupWidget = new QWidget(this);
auto buttonGroupWidget = new QWidget(groupWidget);
auto addButtonWidget = new QPushButton("Add", buttonGroupWidget);
auto selectButtonWidget = new QPushButton("Select", buttonGroupWidget);
auto saveButtonWidget = new QPushButton("Save", buttonGroupWidget);
auto refreshButtonWidget = new QPushButton("Refresh", buttonGroupWidget);
buttonGroupWidget->setLayout(new QHBoxLayout(buttonGroupWidget));
buttonGroupWidget->layout()->addWidget(addButtonWidget);
buttonGroupWidget->layout()->addWidget(selectButtonWidget);
buttonGroupWidget->layout()->addWidget(saveButtonWidget);
buttonGroupWidget->layout()->addWidget(refreshButtonWidget);
groupWidget->setLayout(new QVBoxLayout(groupWidget));
groupWidget->layout()->addWidget(buttonGroupWidget);
QObject::connect(addButtonWidget, &QPushButton::clicked, this, [this]() { AddModelPreset(); });
QObject::connect(selectButtonWidget, &QPushButton::clicked, this, [this]() { SelectModelPreset(); });
QObject::connect(saveButtonWidget, &QPushButton::clicked, this, [this]() { SaveModelPreset(); });
QObject::connect(refreshButtonWidget, &QPushButton::clicked, this, [this]() { RefreshPresets(); });
if (m_modelPreset)
{
const AZStd::string groupNameId = "model";
const AZStd::string groupDisplayName = "Model";
const AZStd::string groupDescription = "Model";
auto inspectorWidget = new AtomToolsFramework::InspectorPropertyGroupWidget(
m_modelPreset.get(), nullptr, m_modelPreset.get()->TYPEINFO_Uuid(), nullptr, groupWidget);
AddGroup(groupNameId, groupDisplayName, groupDescription,
new AtomToolsFramework::InspectorPropertyGroupWidget(m_modelPreset.get(), nullptr, m_modelPreset.get()->TYPEINFO_Uuid(), this));
groupWidget->layout()->addWidget(inspectorWidget);
}
m_lightingPreset.reset();
MaterialViewportRequestBus::BroadcastResult(m_lightingPreset, &MaterialViewportRequestBus::Events::GetLightingPresetSelection);
AddGroup(groupNameId, groupDisplayName, groupDescription, groupWidget);
}
void ViewportSettingsInspector::AddModelPreset()
{
const AZStd::string defaultPath = GetDefaultUniqueSaveFilePath("untitled.modelpreset.azasset");
const AZStd::string savePath = AtomToolsFramework::GetSaveFileInfo(defaultPath.c_str()).absoluteFilePath().toUtf8().constData();
if (!savePath.empty())
{
AZ::Render::ModelPresetPtr preset;
MaterialViewportRequestBus::BroadcastResult(
preset, &MaterialViewportRequestBus::Events::AddModelPreset, AZ::Render::ModelPreset());
MaterialViewportRequestBus::Broadcast(&MaterialViewportRequestBus::Events::SaveModelPreset, preset, savePath);
MaterialViewportRequestBus::Broadcast(&MaterialViewportRequestBus::Events::SelectModelPreset, preset);
}
}
void ViewportSettingsInspector::SelectModelPreset()
{
ModelPresetBrowserDialog dialog(QApplication::activeWindow());
dialog.setFixedSize(800, 400);
dialog.show();
// Removing fixed size to allow drag resizing
dialog.setMinimumSize(0, 0);
dialog.setMaximumSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
dialog.exec();
}
void ViewportSettingsInspector::SaveModelPreset()
{
AZ::Render::ModelPresetPtr preset;
MaterialViewportRequestBus::BroadcastResult(preset, &MaterialViewportRequestBus::Events::GetModelPresetSelection);
AZStd::string defaultPath;
MaterialViewportRequestBus::BroadcastResult(defaultPath, &MaterialViewportRequestBus::Events::GetModelPresetLastSavePath, preset);
if (defaultPath.empty())
{
defaultPath = GetDefaultUniqueSaveFilePath("untitled.modelpreset.azasset");
}
const AZStd::string savePath = AtomToolsFramework::GetSaveFileInfo(defaultPath.c_str()).absoluteFilePath().toUtf8().constData();
if (!savePath.empty())
{
MaterialViewportRequestBus::Broadcast(&MaterialViewportRequestBus::Events::SaveModelPreset, preset, savePath);
}
}
void ViewportSettingsInspector::AddLightingGroup()
{
const AZStd::string groupNameId = "lighting";
const AZStd::string groupDisplayName = "Lighting";
const AZStd::string groupDescription = "Lighting";
auto groupWidget = new QWidget(this);
auto buttonGroupWidget = new QWidget(groupWidget);
auto addButtonWidget = new QPushButton("Add", buttonGroupWidget);
auto selectButtonWidget = new QPushButton("Select", buttonGroupWidget);
auto saveButtonWidget = new QPushButton("Save", buttonGroupWidget);
auto refreshButtonWidget = new QPushButton("Refresh", buttonGroupWidget);
buttonGroupWidget->setLayout(new QHBoxLayout(buttonGroupWidget));
buttonGroupWidget->layout()->addWidget(addButtonWidget);
buttonGroupWidget->layout()->addWidget(selectButtonWidget);
buttonGroupWidget->layout()->addWidget(saveButtonWidget);
buttonGroupWidget->layout()->addWidget(refreshButtonWidget);
groupWidget->setLayout(new QVBoxLayout(groupWidget));
groupWidget->layout()->addWidget(buttonGroupWidget);
QObject::connect(addButtonWidget, &QPushButton::clicked, this, [this]() { AddLightingPreset(); });
QObject::connect(selectButtonWidget, &QPushButton::clicked, this, [this]() { SelectLightingPreset(); });
QObject::connect(saveButtonWidget, &QPushButton::clicked, this, [this]() { SaveLightingPreset(); });
QObject::connect(refreshButtonWidget, &QPushButton::clicked, this, [this]() { RefreshPresets(); });
if (m_lightingPreset)
{
const AZStd::string groupNameId = "lighting";
const AZStd::string groupDisplayName = "Lighting";
const AZStd::string groupDescription = "Lighting";
auto inspectorWidget = new AtomToolsFramework::InspectorPropertyGroupWidget(
m_lightingPreset.get(), nullptr, m_lightingPreset.get()->TYPEINFO_Uuid(), nullptr, groupWidget);
AddGroup(groupNameId, groupDisplayName, groupDescription,
new AtomToolsFramework::InspectorPropertyGroupWidget(m_lightingPreset.get(), nullptr, m_lightingPreset.get()->TYPEINFO_Uuid(), this));
groupWidget->layout()->addWidget(inspectorWidget);
}
AddGroupsEnd();
AddGroup(groupNameId, groupDisplayName, groupDescription, groupWidget);
}
void ViewportSettingsInspector::AddLightingPreset()
{
const AZStd::string defaultPath = GetDefaultUniqueSaveFilePath("untitled.lightingpreset.azasset");
const AZStd::string savePath = AtomToolsFramework::GetSaveFileInfo(defaultPath.c_str()).absoluteFilePath().toUtf8().constData();
if (!savePath.empty())
{
AZ::Render::LightingPresetPtr preset;
MaterialViewportRequestBus::BroadcastResult(
preset, &MaterialViewportRequestBus::Events::AddLightingPreset, AZ::Render::LightingPreset());
MaterialViewportRequestBus::Broadcast(
&MaterialViewportRequestBus::Events::SaveLightingPreset, preset, savePath);
MaterialViewportRequestBus::Broadcast(&MaterialViewportRequestBus::Events::SelectLightingPreset, preset);
}
}
void ViewportSettingsInspector::SelectLightingPreset()
{
LightingPresetBrowserDialog dialog(QApplication::activeWindow());
dialog.setFixedSize(800, 400);
dialog.show();
// Removing fixed size to allow drag resizing
dialog.setMinimumSize(0, 0);
dialog.setMaximumSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
dialog.exec();
}
void ViewportSettingsInspector::SaveLightingPreset()
{
AZ::Render::LightingPresetPtr preset;
MaterialViewportRequestBus::BroadcastResult(preset, &MaterialViewportRequestBus::Events::GetLightingPresetSelection);
AZStd::string defaultPath;
MaterialViewportRequestBus::BroadcastResult(defaultPath, &MaterialViewportRequestBus::Events::GetLightingPresetLastSavePath, preset);
if (defaultPath.empty())
{
defaultPath = GetDefaultUniqueSaveFilePath("untitled.lightingpreset.azasset");
}
const AZStd::string savePath = AtomToolsFramework::GetSaveFileInfo(defaultPath.c_str()).absoluteFilePath().toUtf8().constData();
if (!savePath.empty())
{
MaterialViewportRequestBus::Broadcast(&MaterialViewportRequestBus::Events::SaveLightingPreset, preset, savePath);
}
}
void ViewportSettingsInspector::RefreshPresets()
{
MaterialViewportRequestBus::Broadcast(&MaterialViewportRequestBus::Events::ReloadContent);
}
void ViewportSettingsInspector::Reset()
{
m_lightingPreset.reset();
m_modelPreset.reset();
MaterialViewportRequestBus::BroadcastResult(m_modelPreset, &MaterialViewportRequestBus::Events::GetModelPresetSelection);
m_lightingPreset.reset();
MaterialViewportRequestBus::BroadcastResult(m_lightingPreset, &MaterialViewportRequestBus::Events::GetLightingPresetSelection);
MaterialViewportRequestBus::BroadcastResult(m_generalSettings.m_enableGrid, &MaterialViewportRequestBus::Events::GetGridEnabled);
MaterialViewportRequestBus::BroadcastResult(
m_generalSettings.m_enableShadowCatcher, &MaterialViewportRequestBus::Events::GetShadowCatcherEnabled);
MaterialViewportRequestBus::BroadcastResult(
m_generalSettings.m_enableAlternateSkybox, &MaterialViewportRequestBus::Events::GetAlternateSkyboxEnabled);
MaterialViewportRequestBus::BroadcastResult(m_generalSettings.m_fieldOfView, &MaterialViewportRequestBus::Handler::GetFieldOfView);
AtomToolsFramework::InspectorRequestBus::Handler::BusDisconnect();
AtomToolsFramework::InspectorWidget::Reset();
}
@@ -88,6 +320,30 @@ namespace MaterialEditor
}
}
void ViewportSettingsInspector::OnShadowCatcherEnabledChanged(bool enable)
{
m_generalSettings.m_enableShadowCatcher = enable;
RefreshGroup("general");
}
void ViewportSettingsInspector::OnGridEnabledChanged(bool enable)
{
m_generalSettings.m_enableGrid = enable;
RefreshGroup("general");
}
void ViewportSettingsInspector::OnAlternateSkyboxEnabledChanged(bool enable)
{
m_generalSettings.m_enableAlternateSkybox = enable;
RefreshGroup("general");
}
void ViewportSettingsInspector::OnFieldOfViewChanged(float fieldOfView)
{
m_generalSettings.m_fieldOfView = fieldOfView;
RefreshGroup("general");
}
void ViewportSettingsInspector::BeforePropertyModified(AzToolsFramework::InstanceDataNode* pNode)
{
AZ_UNUSED(pNode);
@@ -96,17 +352,37 @@ namespace MaterialEditor
void ViewportSettingsInspector::AfterPropertyModified(AzToolsFramework::InstanceDataNode* pNode)
{
AZ_UNUSED(pNode);
MaterialViewportNotificationBus::Broadcast(&MaterialViewportNotificationBus::Events::OnLightingPresetChanged, m_lightingPreset);
MaterialViewportNotificationBus::Broadcast(&MaterialViewportNotificationBus::Events::OnModelPresetChanged, m_modelPreset);
ApplyChanges();
}
void ViewportSettingsInspector::SetPropertyEditingComplete(AzToolsFramework::InstanceDataNode* pNode)
{
AZ_UNUSED(pNode);
MaterialViewportNotificationBus::Broadcast(&MaterialViewportNotificationBus::Events::OnLightingPresetChanged, m_lightingPreset);
MaterialViewportNotificationBus::Broadcast(&MaterialViewportNotificationBus::Events::OnModelPresetChanged, m_modelPreset);
ApplyChanges();
}
void ViewportSettingsInspector::ApplyChanges()
{
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::SetShadowCatcherEnabled, m_generalSettings.m_enableShadowCatcher);
MaterialViewportRequestBus::Broadcast(
&MaterialViewportRequestBus::Events::SetAlternateSkyboxEnabled, m_generalSettings.m_enableAlternateSkybox);
MaterialViewportRequestBus::Broadcast(&MaterialViewportRequestBus::Handler::SetFieldOfView, m_generalSettings.m_fieldOfView);
}
AZStd::string ViewportSettingsInspector::GetDefaultUniqueSaveFilePath(const AZStd::string& baseName) const
{
AZStd::string savePath = AZ::IO::FileIOBase::GetInstance()->GetAlias("@devassets@");
savePath += AZ_CORRECT_FILESYSTEM_SEPARATOR;
savePath += "Materials";
savePath += AZ_CORRECT_FILESYSTEM_SEPARATOR;
savePath += baseName;
savePath = AtomToolsFramework::GetUniqueFileInfo(savePath.c_str()).absoluteFilePath().toUtf8().constData();
return savePath;
}
} // namespace MaterialEditor
#include <Source/Window/ViewportSettingsInspector/moc_ViewportSettingsInspector.cpp>
@@ -22,6 +22,18 @@
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;
};
//! 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
@@ -38,6 +50,19 @@ namespace MaterialEditor
private:
void Popuate();
void AddGeneralGroup();
void AddModelGroup();
void AddModelPreset();
void SelectModelPreset();
void SaveModelPreset();
void AddLightingGroup();
void AddLightingPreset();
void SelectLightingPreset();
void SaveLightingPreset();
void RefreshPresets();
// AtomToolsFramework::InspectorRequestBus::Handler overrides...
void Reset() override;
@@ -45,16 +70,24 @@ namespace MaterialEditor
// MaterialViewportNotificationBus::Handler overrides...
void OnLightingPresetSelected([[maybe_unused]] AZ::Render::LightingPresetPtr preset) override;
void OnModelPresetSelected([[maybe_unused]] AZ::Render::ModelPresetPtr preset) override;
void OnShadowCatcherEnabledChanged(bool enable) override;
void OnGridEnabledChanged(bool enable) override;
void OnAlternateSkyboxEnabledChanged(bool enable) override;
void OnFieldOfViewChanged(float fieldOfView) override;
// AzToolsFramework::IPropertyEditorNotify overrides...
void BeforePropertyModified(AzToolsFramework::InstanceDataNode* pNode) override;
void AfterPropertyModified(AzToolsFramework::InstanceDataNode* pNode) override;
void SetPropertyEditingActive([[maybe_unused]] AzToolsFramework::InstanceDataNode* pNode) override {}
void SetPropertyEditingComplete(AzToolsFramework::InstanceDataNode* pNode) override;
void ApplyChanges();
void SealUndoStack() override {}
void RequestPropertyContextMenu(AzToolsFramework::InstanceDataNode*, const QPoint&) override {}
void PropertySelectionChanged(AzToolsFramework::InstanceDataNode*, bool) override {}
AZStd::string GetDefaultUniqueSaveFilePath(const AZStd::string& baseName) const;
GeneralViewportSettings m_generalSettings;
AZ::Render::ModelPresetPtr m_modelPreset;
AZ::Render::LightingPresetPtr m_lightingPreset;
};
@@ -10,6 +10,8 @@
*
*/
#include <AzCore/IO/Path/Path.h>
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
#include <AzQtComponents/Components/StyleManager.h>
#include <AzQtComponents/Utilities/QtPluginPaths.h>
#include <AzQtComponents/Components/GlobalEventFilter.h>
@@ -43,12 +45,17 @@ int main(int argc, char** argv)
AzQtComponents::Utilities::HandleDpiAwareness(AzQtComponents::Utilities::SystemDpiAware);
MaterialEditor::MaterialEditorApplication app(&argc, &argv);
AZ::IO::FixedMaxPath engineRootPath;
if (auto settingsRegistry = AZ::SettingsRegistry::Get(); settingsRegistry != nullptr)
{
settingsRegistry->Get(engineRootPath.Native(), AZ::SettingsRegistryMergeUtils::FilePathKey_EngineRootFolder);
}
auto globalEventFilter = new AzQtComponents::GlobalEventFilter(&app);
app.installEventFilter(globalEventFilter);
AzQtComponents::StyleManager styleManager(&app);
styleManager.Initialize(&app);
styleManager.initialize(&app, engineRootPath);
app.Start(AZ::ComponentApplication::Descriptor{});
app.exec();
@@ -29,11 +29,16 @@ set(FILES
Source/Window/CreateMaterialDialog/CreateMaterialDialog.cpp
Source/Window/CreateMaterialDialog/CreateMaterialDialog.h
Source/Window/CreateMaterialDialog/CreateMaterialDialog.ui
Source/Window/PresetBrowserDialogs/PresetBrowserDialog.cpp
Source/Window/PresetBrowserDialogs/PresetBrowserDialog.h
Source/Window/PresetBrowserDialogs/PresetBrowserDialog.ui
Source/Window/PresetBrowserDialogs/LightingPresetBrowserDialog.cpp
Source/Window/PresetBrowserDialogs/LightingPresetBrowserDialog.h
Source/Window/PresetBrowserDialogs/ModelPresetBrowserDialog.cpp
Source/Window/PresetBrowserDialogs/ModelPresetBrowserDialog.h
Source/Window/PerformanceMonitor/PerformanceMonitorWidget.cpp
Source/Window/PerformanceMonitor/PerformanceMonitorWidget.h
Source/Window/PerformanceMonitor/PerformanceMonitorWidget.ui
Source/Window/ToolBar/FovSliderWidget.h
Source/Window/ToolBar/FovSliderWidget.cpp
Source/Window/ToolBar/MaterialEditorToolBar.h
Source/Window/ToolBar/MaterialEditorToolBar.cpp
Source/Window/ToolBar/ModelPresetComboBox.h
@@ -102,6 +102,12 @@ ly_add_target_dependencies(
Source/Platform/${PAL_PLATFORM_NAME}/tool_dependencies_${PAL_PLATFORM_NAME_LOWERCASE}.cmake
)
# Inject the project path into the ShaderManagementConsole VS debugger command arguments if the build system being invoked
# in a project centric view
if(NOT PROJECT_NAME STREQUAL "O3DE")
set_property(TARGET ShaderManagementConsole APPEND PROPERTY VS_DEBUGGER_COMMAND_ARGUMENTS "--project-path=\"${CMAKE_SOURCE_DIR}\"")
endif()
# Adds the ShaderManagementConsole target as a C preprocessor define so that it can be used as a Settings Registry
# specialization in order to look up the generated .setreg which contains the dependencies
# specified for the target.
@@ -379,10 +379,8 @@ namespace ShaderManagementConsole
{
AZ::SettingsRegistryInterface* settingsRegistry = AZ::SettingsRegistry::Get();
AZ::IO::FixedMaxPath assetDatabaseSqlitePath;
if (settingsRegistry && settingsRegistry->Get(assetDatabaseSqlitePath.Native(), AZ::SettingsRegistryMergeUtils::FilePathKey_CacheRootFolder))
if (settingsRegistry && settingsRegistry->Get(assetDatabaseSqlitePath.Native(), AZ::SettingsRegistryMergeUtils::FilePathKey_CacheProjectRootFolder))
{
// Grab the Parent of the Asset RootPath to remove the <asset> platform from the end of the path
assetDatabaseSqlitePath = assetDatabaseSqlitePath.ParentPath();
assetDatabaseSqlitePath /= "assetdb.sqlite";
result = AZStd::string_view(assetDatabaseSqlitePath.Native());
return true;
@@ -10,6 +10,8 @@
*
*/
#include <AzCore/IO/Path/Path.h>
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
#include <AzQtComponents/Components/StyleManager.h>
#include <AzQtComponents/Utilities/QtPluginPaths.h>
#include <AzQtComponents/Components/GlobalEventFilter.h>
@@ -43,12 +45,17 @@ int main(int argc, char** argv)
AzQtComponents::Utilities::HandleDpiAwareness(AzQtComponents::Utilities::PerScreenDpiAware);
ShaderManagementConsole::ShaderManagementConsoleApplication app(&argc, &argv);
AZ::IO::FixedMaxPath engineRootPath;
if (auto settingsRegistry = AZ::SettingsRegistry::Get(); settingsRegistry != nullptr)
{
settingsRegistry->Get(engineRootPath.Native(), AZ::SettingsRegistryMergeUtils::FilePathKey_EngineRootFolder);
}
auto globalEventFilter = new AzQtComponents::GlobalEventFilter(&app);
app.installEventFilter(globalEventFilter);
AzQtComponents::StyleManager styleManager(&app);
styleManager.Initialize(&app);
styleManager.initialize(&app, engineRootPath);
app.Start({});
app.exec();