Merge branch 'development' into o3de_sdk/installer_configs

Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>

# Conflicts:
#	Gems/AtomLyIntegration/CommonFeatures/Code/Source/Material/EditorMaterialSystemComponent.cpp
#	cmake/Platform/Common/Install_common.cmake
This commit is contained in:
Esteban Papp
2021-10-25 12:47:36 -07:00
1023 changed files with 33913 additions and 13107 deletions
@@ -1,5 +1,5 @@
{
"Source" : "LyShineUI",
"Source" : "LyShineUI.azsl",
"DepthStencilState" : {
"Depth" : {
@@ -1,5 +1,5 @@
{
"Source" : "SimpleTextured",
"Source" : "SimpleTextured.azsl",
"DepthStencilState" : {
"Depth" : {
@@ -84,10 +84,6 @@ namespace AtomImGuiTools
{
m_imguiGpuProfiler.Draw(m_showGpuProfiler, AZ::RPI::PassSystemInterface::Get()->GetRootPass().get());
}
if (m_showCpuProfiler)
{
m_imguiCpuProfiler.Draw(m_showCpuProfiler);
}
if (m_showTransientAttachmentProfiler)
{
auto* transientStats = AZ::RHI::RHISystemInterface::Get()->GetTransientAttachmentStatistics();
@@ -108,12 +104,6 @@ namespace AtomImGuiTools
{
ImGui::MenuItem("Pass Viewer", "", &m_showPassTree);
ImGui::MenuItem("Gpu Profiler", "", &m_showGpuProfiler);
if (ImGui::MenuItem("Cpu Profiler", "", &m_showCpuProfiler))
{
AZ::RHI::RHISystemInterface::Get()->ModifyFrameSchedulerStatisticsFlags(
AZ::RHI::FrameSchedulerStatisticsFlags::GatherCpuTimingStatistics, m_showCpuProfiler);
AZ::RHI::CpuProfiler::Get()->SetProfilerEnabled(m_showCpuProfiler);
}
if (ImGui::MenuItem("Transient Attachment Profiler", "", &m_showTransientAttachmentProfiler))
{
AZ::RHI::RHISystemInterface::Get()->ModifyFrameSchedulerStatisticsFlags(
@@ -15,7 +15,6 @@
#if defined(IMGUI_ENABLED)
#include <ImGuiBus.h>
#include <imgui/imgui.h>
#include <Atom/Utils/ImGuiCpuProfiler.h>
#include <Atom/Utils/ImGuiGpuProfiler.h>
#include <Atom/Utils/ImGuiPassTree.h>
#include <Atom/Utils/ImGuiShaderMetrics.h>
@@ -63,9 +62,6 @@ namespace AtomImGuiTools
AZ::Render::ImGuiGpuProfiler m_imguiGpuProfiler;
bool m_showGpuProfiler = false;
AZ::Render::ImGuiCpuProfiler m_imguiCpuProfiler;
bool m_showCpuProfiler = false;
AZ::Render::ImGuiTransientAttachmentProfiler m_imguiTransientAttachmentProfiler;
bool m_showTransientAttachmentProfiler = false;
@@ -1,5 +1,5 @@
{
"Source" : "TexturedIcon",
"Source" : "TexturedIcon.azsl",
"DepthStencilState" : {
"Depth" : {
@@ -836,7 +836,7 @@
</Class>
<Class name="AZ::Render::MeshComponentController" field="Controller" type="{D0F35FAC-4194-4C89-9487-D000DDB8B272}">
<Class name="AZ::Render::MeshComponentConfig" field="Configuration" version="1" type="{63737345-51B1-472B-9355-98F99993909B}">
<Class name="Asset" field="ModelAsset" value="id={935F694A-8639-515B-8133-81CDC7948E5B}:1087c6db,type={2C7477B6-69C5-45BE-8163-BCD6A275B6D8},hint={objects/groudplane/groundplane_521x521m.azmodel},loadBehavior=1" version="2" type="{77A19D40-8731-4D3C-9041-1B43047366A4}"/>
<Class name="Asset" field="ModelAsset" value="id={0CD745C0-6AA8-569A-A68A-73A3270986C4}:10904372,type={2C7477B6-69C5-45BE-8163-BCD6A275B6D8},hint={objects/groudplane/groundplane_512x512m.azmodel},loadBehavior=1" version="2" type="{77A19D40-8731-4D3C-9041-1B43047366A4}"/>
<Class name="AZ::s64" field="SortKey" value="0" type="{70D8A282-A1EA-462D-9D04-51EDE81FAC2F}"/>
<Class name="unsigned char" field="LodOverride" value="255" type="{72B9409A-7D1A-4831-9CFE-FCB3FADD3426}"/>
<Class name="bool" field="ExcludeFromReflectionCubeMaps" value="false" type="{A0CA880C-AFE4-43CB-926C-59AC48496112}"/>
@@ -168,6 +168,22 @@ namespace AZ
//! Sets whether the directional shadowmap should use receiver plane bias.
//! @param enable flag specifying whether to enable the receiver plane bias feature
virtual void SetShadowReceiverPlaneBiasEnabled(bool enable) = 0;
//! Shadow bias reduces acne by applying a small amount of offset along shadow-space z.
//! @return Returns the amount of bias to apply.
virtual float GetShadowBias() const = 0;
//! Shadow bias reduces acne by applying a small amount of offset along shadow-space z.
//! @param Sets the amount of bias to apply.
virtual void SetShadowBias(float bias) = 0;
//! Reduces acne by biasing the shadowmap lookup along the geometric normal.
//! @return Returns the amount of bias to apply.
virtual float GetNormalShadowBias() const = 0;
//! Reduces acne by biasing the shadowmap lookup along the geometric normal.
//! @param normalShadowBias Sets the amount of normal shadow bias to apply.
virtual void SetNormalShadowBias(float normalShadowBias) = 0;
};
using DirectionalLightRequestBus = EBus<DirectionalLightRequests>;
@@ -101,6 +101,9 @@ namespace AZ
//! Method of shadow's filtering.
ShadowFilterMethod m_shadowFilterMethod = ShadowFilterMethod::None;
// Reduces acne by biasing the shadowmap lookup along the geometric normal.
float m_normalShadowBias = 0.0f;
//! Sample Count for filtering (from 4 to 64)
//! It is used only when the pixel is predicted as on the boundary.
uint16_t m_filteringSampleCount = 32;
@@ -109,6 +112,9 @@ namespace AZ
//! This uses partial derivatives to reduce shadow acne when using large pcf kernels.
bool m_receiverPlaneBiasEnabled = true;
//! Reduces shadow acne by applying a small amount of offset along shadow-space z.
float m_shadowBias = 0.0f;
bool IsSplitManual() const;
bool IsSplitAutomatic() const;
bool IsCascadeCorrectionDisabled() const;
@@ -43,6 +43,9 @@ namespace AZ
virtual void ClearInvalidMaterialOverrides() = 0;
//! Repair materials that reference missing assets by assigning the default asset
virtual void RepairInvalidMaterialOverrides() = 0;
//! Repair material property overrides that reference missing properties by auto-renaming them where possible
//! @return the number of properties that were updated
virtual uint32_t ApplyAutomaticPropertyUpdates() = 0;
//! Set default material override
virtual void SetDefaultMaterialOverride(const AZ::Data::AssetId& materialAssetId) = 0;
//! Get default material override
@@ -38,7 +38,9 @@ namespace AZ
->Field("IsDebugColoringEnabled", &DirectionalLightComponentConfig::m_isDebugColoringEnabled)
->Field("ShadowFilterMethod", &DirectionalLightComponentConfig::m_shadowFilterMethod)
->Field("PcfFilteringSampleCount", &DirectionalLightComponentConfig::m_filteringSampleCount)
->Field("ShadowReceiverPlaneBiasEnabled", &DirectionalLightComponentConfig::m_receiverPlaneBiasEnabled);
->Field("ShadowReceiverPlaneBiasEnabled", &DirectionalLightComponentConfig::m_receiverPlaneBiasEnabled)
->Field("Shadow Bias", &DirectionalLightComponentConfig::m_shadowBias)
->Field("Normal Shadow Bias", &DirectionalLightComponentConfig::m_normalShadowBias);
}
}
@@ -84,6 +84,10 @@ namespace AZ
->Event("SetFilteringSampleCount", &DirectionalLightRequestBus::Events::SetFilteringSampleCount)
->Event("GetShadowReceiverPlaneBiasEnabled", &DirectionalLightRequestBus::Events::GetShadowReceiverPlaneBiasEnabled)
->Event("SetShadowReceiverPlaneBiasEnabled", &DirectionalLightRequestBus::Events::SetShadowReceiverPlaneBiasEnabled)
->Event("GetShadowBias", &DirectionalLightRequestBus::Events::GetShadowBias)
->Event("SetShadowBias", &DirectionalLightRequestBus::Events::SetShadowBias)
->Event("GetNormalShadowBias", &DirectionalLightRequestBus::Events::GetNormalShadowBias)
->Event("SetNormalShadowBias", &DirectionalLightRequestBus::Events::SetNormalShadowBias)
->VirtualProperty("Color", "GetColor", "SetColor")
->VirtualProperty("Intensity", "GetIntensity", "SetIntensity")
->VirtualProperty("AngularDiameter", "GetAngularDiameter", "SetAngularDiameter")
@@ -98,7 +102,9 @@ namespace AZ
->VirtualProperty("DebugColoringEnabled", "GetDebugColoringEnabled", "SetDebugColoringEnabled")
->VirtualProperty("ShadowFilterMethod", "GetShadowFilterMethod", "SetShadowFilterMethod")
->VirtualProperty("FilteringSampleCount", "GetFilteringSampleCount", "SetFilteringSampleCount")
->VirtualProperty("ShadowReceiverPlaneBiasEnabled", "GetShadowReceiverPlaneBiasEnabled", "SetShadowReceiverPlaneBiasEnabled");
->VirtualProperty("ShadowReceiverPlaneBiasEnabled", "GetShadowReceiverPlaneBiasEnabled", "SetShadowReceiverPlaneBiasEnabled")
->VirtualProperty("ShadowBias", "GetShadowBias", "SetShadowBias")
->VirtualProperty("NormalShadowBias", "GetNormalShadowBias", "SetNormalShadowBias");
;
}
}
@@ -406,6 +412,34 @@ namespace AZ
return aznumeric_cast<uint32_t>(m_configuration.m_filteringSampleCount);
}
void DirectionalLightComponentController::SetShadowBias(float bias)
{
m_configuration.m_shadowBias = bias;
if (m_featureProcessor)
{
m_featureProcessor->SetShadowBias(m_lightHandle, bias);
}
}
float DirectionalLightComponentController::GetShadowBias() const
{
return m_configuration.m_shadowBias;
}
void DirectionalLightComponentController::SetNormalShadowBias(float bias)
{
m_configuration.m_normalShadowBias = bias;
if (m_featureProcessor)
{
m_featureProcessor->SetNormalShadowBias(m_lightHandle, bias);
}
}
float DirectionalLightComponentController::GetNormalShadowBias() const
{
return m_configuration.m_normalShadowBias;
}
void DirectionalLightComponentController::SetFilteringSampleCount(uint32_t count)
{
const uint16_t count16 = GetMin(Shadow::MaxPcfSamplingCount, aznumeric_cast<uint16_t>(count));
@@ -499,6 +533,8 @@ namespace AZ
SetViewFrustumCorrectionEnabled(m_configuration.m_isCascadeCorrectionEnabled);
SetDebugColoringEnabled(m_configuration.m_isDebugColoringEnabled);
SetShadowFilterMethod(m_configuration.m_shadowFilterMethod);
SetShadowBias(m_configuration.m_shadowBias);
SetNormalShadowBias(m_configuration.m_normalShadowBias);
SetFilteringSampleCount(m_configuration.m_filteringSampleCount);
SetShadowReceiverPlaneBiasEnabled(m_configuration.m_receiverPlaneBiasEnabled);
@@ -80,6 +80,10 @@ namespace AZ
void SetFilteringSampleCount(uint32_t count) override;
bool GetShadowReceiverPlaneBiasEnabled() const override;
void SetShadowReceiverPlaneBiasEnabled(bool enable) override;
float GetShadowBias() const override;
void SetShadowBias(float bias) override;
float GetNormalShadowBias() const override;
void SetNormalShadowBias(float bias) override;
private:
friend class EditorDirectionalLightComponent;
@@ -136,7 +136,7 @@ namespace AZ
->Attribute(Edit::Attributes::Min, 0.0f)
->Attribute(Edit::Attributes::Max, 100.0f)
->Attribute(Edit::Attributes::SoftMin, 0.0f)
->Attribute(Edit::Attributes::SoftMax, 1.0f)
->Attribute(Edit::Attributes::SoftMax, 2.0f)
->Attribute(Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
->Attribute(Edit::Attributes::Visibility, &AreaLightComponentConfig::SupportsShadows)
->Attribute(Edit::Attributes::ReadOnly, &AreaLightComponentConfig::ShadowsDisabled)
@@ -133,8 +133,8 @@ namespace AZ
->EnumAttribute(ShadowFilterMethod::Esm, "ESM")
->EnumAttribute(ShadowFilterMethod::EsmPcf, "ESM+PCF")
->Attribute(Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
->DataElement(Edit::UIHandlers::Slider, &DirectionalLightComponentConfig::m_filteringSampleCount, "Filtering sample count",
"This is used only when the pixel is predicted as on the boundary. "
->DataElement(Edit::UIHandlers::Slider, &DirectionalLightComponentConfig::m_filteringSampleCount, "Filtering sample count\n",
"This is used only when the pixel is predicted to be on the boundary.\n"
"Specific to PCF and ESM+PCF.")
->Attribute(Edit::Attributes::Min, 4)
->Attribute(Edit::Attributes::Max, 64)
@@ -142,10 +142,26 @@ namespace AZ
->Attribute(Edit::Attributes::ReadOnly, &DirectionalLightComponentConfig::IsShadowPcfDisabled)
->DataElement(
Edit::UIHandlers::CheckBox, &DirectionalLightComponentConfig::m_receiverPlaneBiasEnabled,
"Shadow Receiver Plane Bias Enable",
"Shadow Receiver Plane Bias Enable\n",
"This reduces shadow acne when using large pcf kernels.")
->Attribute(Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
->Attribute(Edit::Attributes::ReadOnly, &DirectionalLightComponentConfig::IsShadowPcfDisabled);
->Attribute(Edit::Attributes::ReadOnly, &DirectionalLightComponentConfig::IsShadowPcfDisabled)
->DataElement(
Edit::UIHandlers::Slider, &DirectionalLightComponentConfig::m_shadowBias,
"Shadow Bias\n",
"Reduces acne by applying a fixed bias along z in shadow-space.\n"
"If this is 0, no biasing is applied.")
->Attribute(Edit::Attributes::Min, 0.f)
->Attribute(Edit::Attributes::Max, 0.2)
->Attribute(Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
->DataElement(
Edit::UIHandlers::Slider, &DirectionalLightComponentConfig::m_normalShadowBias, "Normal Shadow Bias\n",
"Reduces acne by biasing the shadowmap lookup along the geometric normal.\n"
"If this is 0, no biasing is applied.")
->Attribute(Edit::Attributes::Min, 0.f)
->Attribute(Edit::Attributes::Max, 10.0f)
->Attribute(Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
;
}
}
@@ -216,11 +216,17 @@ namespace AZ
using namespace LyIntegration;
ThumbnailerRequestsBus::Broadcast(
&ThumbnailerRequests::RegisterThumbnailProvider, MAKE_TCACHE(SharedThumbnailCache),
ThumbnailContext::DefaultContext);
&ThumbnailerRequests::RegisterThumbnailProvider, MAKE_TCACHE(SharedThumbnailCache), ThumbnailContext::DefaultContext);
m_renderer = AZStd::make_unique<AZ::LyIntegration::SharedThumbnailRenderer>();
m_previewerFactory = AZStd::make_unique<LyIntegration::SharedPreviewerFactory>();
if (!m_thumbnailRenderer)
{
m_thumbnailRenderer = AZStd::make_unique<AZ::LyIntegration::SharedThumbnailRenderer>();
}
if (!m_previewerFactory)
{
m_previewerFactory = AZStd::make_unique<LyIntegration::SharedPreviewerFactory>();
}
}
void EditorCommonFeaturesSystemComponent::TeardownThumbnails()
@@ -232,7 +238,7 @@ namespace AZ
&ThumbnailerRequests::UnregisterThumbnailProvider, SharedThumbnailCache::ProviderName,
ThumbnailContext::DefaultContext);
m_renderer.reset();
m_thumbnailRenderer.reset();
m_previewerFactory.reset();
}
} // namespace Render
@@ -78,7 +78,7 @@ namespace AZ
AZStd::string m_atomLevelDefaultAssetPath{ "LevelAssets/default.slice" };
float m_envProbeHeight{ 200.0f };
AZStd::unique_ptr<AZ::LyIntegration::SharedThumbnailRenderer> m_renderer;
AZStd::unique_ptr<AZ::LyIntegration::SharedThumbnailRenderer> m_thumbnailRenderer;
AZStd::unique_ptr<LyIntegration::SharedPreviewerFactory> m_previewerFactory;
};
} // namespace Render
@@ -240,6 +240,19 @@ namespace AZ
UpdateMaterialSlots();
});
action->setToolTip("Repair materials that reference missing assets by assigning the default asset.");
action = menu->addAction("Apply Automatic Property Updates", [this]() {
AzToolsFramework::ScopedUndoBatch undoBatch("Applying automatic property updates.");
SetDirty();
uint32_t propertiesUpdated = 0;
MaterialComponentRequestBus::EventResult(propertiesUpdated, GetEntityId(), &MaterialComponentRequestBus::Events::ApplyAutomaticPropertyUpdates);
AZ_Printf("EditorMaterialComponent", "Updated %u property(s).", propertiesUpdated);
UpdateMaterialSlots();
});
action->setToolTip("Repair material property overrides that reference missing properties by auto-renaming them where possible.");
}
void EditorMaterialComponent::SetPrimaryAsset(const AZ::Data::AssetId& assetId)
@@ -352,6 +352,25 @@ namespace AZ
m_editData.m_materialPropertyOverrideMap, m_entityId, &MaterialComponentRequestBus::Events::GetPropertyOverrides,
m_materialAssignmentId);
// Apply any automatic property renames so that the material inspector will be properly initialized with the right values
// for properties that have new names.
{
AZStd::vector<AZStd::pair<Name, Name>> renamedProperties;
for (auto& propertyOverridePair : m_editData.m_materialPropertyOverrideMap)
{
Name name = propertyOverridePair.first;
if (m_materialInstance->GetAsset()->GetMaterialTypeAsset()->ApplyPropertyRenames(name))
{
renamedProperties.emplace_back(propertyOverridePair.first, name);
}
}
for (const auto& [oldName, newName] : renamedProperties)
{
m_editData.m_materialPropertyOverrideMap[newName] = m_editData.m_materialPropertyOverrideMap[oldName];
m_editData.m_materialPropertyOverrideMap.erase(oldName);
}
}
for (auto& group : m_groups)
{
for (auto& property : group.second.m_properties)
@@ -99,7 +99,6 @@ namespace AZ
{
// Construct the material source data object that will be exported
AZ::RPI::MaterialSourceData exportData;
exportData.m_propertyLayoutVersion = editData.m_materialTypeSourceData.m_propertyLayout.m_version;
// Converting absolute material paths to relative paths
bool result = false;
@@ -95,6 +95,7 @@ namespace AZ
void EditorMaterialSystemComponent::Activate()
{
AZ::EntitySystemBus::Handler::BusConnect();
EditorMaterialSystemComponentNotificationBus::Handler::BusConnect();
EditorMaterialSystemComponentRequestBus::Handler::BusConnect();
AzToolsFramework::AssetBrowser::AssetBrowserInteractionNotificationBus::Handler::BusConnect();
@@ -106,6 +107,7 @@ namespace AZ
void EditorMaterialSystemComponent::Deactivate()
{
AZ::EntitySystemBus::Handler::BusDisconnect();
EditorMaterialSystemComponentNotificationBus::Handler::BusDisconnect();
EditorMaterialSystemComponentRequestBus::Handler::BusDisconnect();
AzToolsFramework::AssetBrowser::AssetBrowserInteractionNotificationBus::Handler::BusDisconnect();
@@ -185,7 +187,7 @@ namespace AZ
materialAssignmentId);
previewRenderer->AddCaptureRequest(
{ 128,
{ MaterialPreviewResolution,
AZStd::make_shared<AZ::LyIntegration::SharedPreviewContent>(
previewRenderer->GetScene(), previewRenderer->GetView(), previewRenderer->GetEntityContextId(),
AZ::RPI::AssetUtils::GetAssetIdForProductPath(DefaultModelPath), materialAssetId,
@@ -223,11 +225,17 @@ namespace AZ
return QPixmap();
}
void EditorMaterialSystemComponent::OnEntityDestroyed(const AZ::EntityId& entityId)
{
m_materialPreviews.erase(entityId);
}
void EditorMaterialSystemComponent::OnRenderMaterialPreviewComplete(
[[maybe_unused]] const AZ::EntityId& entityId,
[[maybe_unused]] const AZ::Render::MaterialAssignmentId& materialAssignmentId,
[[maybe_unused]] const QPixmap& pixmap)
{
PurgePreviews();
m_materialPreviews[entityId][materialAssignmentId] = pixmap;
}
@@ -284,5 +292,19 @@ namespace AZ
}
return AzToolsFramework::AssetBrowser::SourceFileDetails();
}
void EditorMaterialSystemComponent::PurgePreviews()
{
size_t materialPreviewCount = 0;
for (const auto& materialPreviewPair : m_materialPreviews)
{
materialPreviewCount += materialPreviewPair.second.size();
}
if (materialPreviewCount > MaterialPreviewLimit)
{
m_materialPreviews.clear();
}
}
} // namespace Render
} // namespace AZ
@@ -11,6 +11,7 @@
#include <AtomLyIntegration/CommonFeatures/Material/EditorMaterialSystemComponentRequestBus.h>
#include <AzCore/Asset/AssetCommon.h>
#include <AzCore/Component/Component.h>
#include <AzCore/Component/EntityBus.h>
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
#include <AzToolsFramework/AssetBrowser/AssetBrowserBus.h>
#include <AzToolsFramework/Viewport/ActionBus.h>
@@ -24,6 +25,7 @@ namespace AZ
//! System component that manages launching and maintaining connections with the material editor.
class EditorMaterialSystemComponent final
: public AZ::Component
, public AZ::EntitySystemBus::Handler
, public EditorMaterialSystemComponentNotificationBus::Handler
, public EditorMaterialSystemComponentRequestBus::Handler
, public AzToolsFramework::AssetBrowser::AssetBrowserInteractionNotificationBus::Handler
@@ -54,9 +56,12 @@ namespace AZ
QPixmap GetRenderedMaterialPreview(
const AZ::EntityId& entityId, const AZ::Render::MaterialAssignmentId& materialAssignmentId) const override;
// AZ::EntitySystemBus::Handler overrides...
void OnEntityDestroyed(const AZ::EntityId& entityId) override;
//! EditorMaterialSystemComponentNotificationBus::Handler overrides...
void OnRenderMaterialPreviewComplete(
const AZ::EntityId& entityId, const AZ::Render::MaterialAssignmentId& materialAssignmentId, const QPixmap& pixmap)override;
const AZ::EntityId& entityId, const AZ::Render::MaterialAssignmentId& materialAssignmentId, const QPixmap& pixmap) override;
//! AssetBrowserInteractionNotificationBus::Handler overrides...
AzToolsFramework::AssetBrowser::SourceFileDetails GetSourceFileDetails(const char* fullSourceFileName) override;
@@ -68,9 +73,13 @@ namespace AZ
// AztoolsFramework::EditorEvents::Bus::Handler overrides...
void NotifyRegisterViews() override;
void PurgePreviews();
QAction* m_openMaterialEditorAction = nullptr;
AZStd::unique_ptr<MaterialBrowserInteractions> m_materialBrowserInteractions;
AZStd::unordered_map<AZ::EntityId, AZStd::unordered_map<AZ::Render::MaterialAssignmentId, QPixmap>> m_materialPreviews;
static constexpr const size_t MaterialPreviewLimit = 100;
static constexpr const int MaterialPreviewResolution = 128;
};
} // namespace Render
} // namespace AZ
@@ -49,6 +49,7 @@ namespace AZ
->Event("ClearIncompatibleMaterialOverrides", &MaterialComponentRequestBus::Events::ClearIncompatibleMaterialOverrides)
->Event("ClearInvalidMaterialOverrides", &MaterialComponentRequestBus::Events::ClearInvalidMaterialOverrides)
->Event("RepairInvalidMaterialOverrides", &MaterialComponentRequestBus::Events::RepairInvalidMaterialOverrides)
->Event("ApplyAutomaticPropertyUpdates", &MaterialComponentRequestBus::Events::ApplyAutomaticPropertyUpdates)
->Event("SetMaterialOverride", &MaterialComponentRequestBus::Events::SetMaterialOverride)
->Event("GetMaterialOverride", &MaterialComponentRequestBus::Events::GetMaterialOverride)
->Event("ClearMaterialOverride", &MaterialComponentRequestBus::Events::ClearMaterialOverride)
@@ -406,6 +407,37 @@ namespace AZ
}
LoadMaterials();
}
uint32_t MaterialComponentController::ApplyAutomaticPropertyUpdates()
{
uint32_t propertiesUpdated = 0;
for (auto& materialAssignmentPair : m_configuration.m_materials)
{
MaterialAssignment& materialAssignment = materialAssignmentPair.second;
AZStd::vector<AZStd::pair<Name, Name>> renamedProperties;
for (const auto& propertyPair : materialAssignment.m_propertyOverrides)
{
Name propertyId = propertyPair.first;
if (materialAssignment.m_materialInstance->GetAsset()->GetMaterialTypeAsset()->ApplyPropertyRenames(propertyId))
{
renamedProperties.emplace_back(propertyPair.first, propertyId);
++propertiesUpdated;
}
}
for (const auto& [oldName, newName] : renamedProperties)
{
materialAssignment.m_propertyOverrides[newName] = materialAssignment.m_propertyOverrides[oldName];
materialAssignment.m_propertyOverrides.erase(oldName);
}
}
return propertiesUpdated;
}
void MaterialComponentController::SetDefaultMaterialOverride(const AZ::Data::AssetId& materialAssetId)
{
@@ -58,6 +58,7 @@ namespace AZ
void ClearIncompatibleMaterialOverrides() override;
void ClearInvalidMaterialOverrides() override;
void RepairInvalidMaterialOverrides() override;
uint32_t ApplyAutomaticPropertyUpdates() override;
void SetDefaultMaterialOverride(const AZ::Data::AssetId& materialAssetId) override;
const AZ::Data::AssetId GetDefaultMaterialOverride() const override;
void ClearDefaultMaterialOverride() override;
@@ -7,6 +7,10 @@
*/
#include <PostProcess/ColorGrading/EditorHDRColorGradingComponent.h>
#include <AzToolsFramework/API/EditorPythonRunnerRequestsBus.h>
#include <AzToolsFramework/API/ComponentEntityObjectBus.h>
#include <AzToolsFramework/UI/PropertyEditor/PropertyEditorAPI.h>
#include <AzCore/StringFunc/StringFunc.h>
namespace AZ
{
@@ -18,7 +22,10 @@ namespace AZ
if (AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
{
serializeContext->Class<EditorHDRColorGradingComponent, BaseClass>()->Version(1);
serializeContext->Class<EditorHDRColorGradingComponent, BaseClass>()
->Version(2)
->Field("generatedLut", &EditorHDRColorGradingComponent::m_generatedLutAbsolutePath)
;
if (AZ::EditContext* editContext = serializeContext->GetEditContext())
{
@@ -31,6 +38,20 @@ namespace AZ
->Attribute(Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC_CE("Game"))
->Attribute(Edit::Attributes::AutoExpand, true)
->Attribute(Edit::Attributes::HelpPageURL, "https://") // [TODO ATOM-2672][PostFX] need to create page for PostProcessing.
->ClassElement(AZ::Edit::ClassElements::Group, "LUT Generation")
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
->UIElement(AZ::Edit::UIHandlers::Button, "Generate LUT", "Generates a LUT from the scene's enabled color grading blend.")
->Attribute(AZ::Edit::Attributes::NameLabelOverride, "")
->Attribute(AZ::Edit::Attributes::ButtonText, "Generate LUT")
->Attribute(AZ::Edit::Attributes::ChangeNotify, &EditorHDRColorGradingComponent::GenerateLut)
->DataElement(AZ::Edit::UIHandlers::MultiLineEdit, &EditorHDRColorGradingComponent::m_generatedLutAbsolutePath, "Generated LUT Path", "Generated LUT Path")
->Attribute(AZ::Edit::Attributes::ReadOnly, true)
->Attribute(AZ::Edit::Attributes::Visibility, &EditorHDRColorGradingComponent::GetGeneratedLutVisibilitySettings)
->UIElement(AZ::Edit::UIHandlers::Button, "Activate LUT", "Use the generated LUT asset in a Look Modification component")
->Attribute(AZ::Edit::Attributes::NameLabelOverride, "")
->Attribute(AZ::Edit::Attributes::ButtonText, "Activate LUT")
->Attribute(AZ::Edit::Attributes::ChangeNotify, &EditorHDRColorGradingComponent::ActivateLut)
->Attribute(AZ::Edit::Attributes::Visibility, &EditorHDRColorGradingComponent::GetGeneratedLutVisibilitySettings)
;
editContext->Class<HDRColorGradingComponentController>(
@@ -47,6 +68,9 @@ namespace AZ
"Enable HDR color grading.")
->ClassElement(AZ::Edit::ClassElements::Group, "Color Adjustment")
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
->DataElement(AZ::Edit::UIHandlers::Slider, &HDRColorGradingComponentConfig::m_colorAdjustmentWeight, "Weight", "Weight of color adjustments")
->Attribute(Edit::Attributes::Min, 0.0f)
->Attribute(Edit::Attributes::Max, 1.0f)
->DataElement(AZ::Edit::UIHandlers::Slider, &HDRColorGradingComponentConfig::m_colorGradingExposure, "Exposure", "Exposure Value")
->Attribute(Edit::Attributes::Min, AZStd::numeric_limits<float>::lowest())
->Attribute(Edit::Attributes::Max, AZStd::numeric_limits<float>::max())
@@ -66,27 +90,34 @@ namespace AZ
->DataElement(AZ::Edit::UIHandlers::Slider, &HDRColorGradingComponentConfig::m_colorGradingFilterMultiply, "Filter Multiply", "Filter Multiply Value")
->Attribute(Edit::Attributes::Min, 0.0f)
->Attribute(Edit::Attributes::Max, 1.0f)
->DataElement(AZ::Edit::UIHandlers::Color, &HDRColorGradingComponentConfig::m_colorFilterSwatch, "Color Filter Swatch", "Color Filter Swatch Value")
->DataElement(AZ::Edit::UIHandlers::Color, &HDRColorGradingComponentConfig::m_colorFilterSwatch, "Filter Swatch", "Color Filter Swatch Value")
->ClassElement(AZ::Edit::ClassElements::Group, "White Balance")
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
->DataElement(AZ::Edit::UIHandlers::Slider, &HDRColorGradingComponentConfig::m_whiteBalanceWeight, "Weight", "Weight of white balance")
->Attribute(Edit::Attributes::Min, 0.0f)
->Attribute(Edit::Attributes::Max, 1.0f)
->DataElement(AZ::Edit::UIHandlers::Slider, &HDRColorGradingComponentConfig::m_whiteBalanceKelvin, "Temperature", "Temperature in Kelvin")
->Attribute(Edit::Attributes::Min, 1000.0f)
->Attribute(Edit::Attributes::Max, 40000.0f)
->Attribute(AZ::Edit::Attributes::SliderCurveMidpoint, 0.165f)
->DataElement(AZ::Edit::UIHandlers::Slider, &HDRColorGradingComponentConfig::m_whiteBalanceTint, "Tint", "Tint Value")
->Attribute(Edit::Attributes::Min, -100.0f)
->Attribute(Edit::Attributes::Max, 100.0f)
->DataElement(AZ::Edit::UIHandlers::Slider, &HDRColorGradingComponentConfig::m_whiteBalanceLuminancePreservation, "Luminance Preservation", "Modulate the preservation of luminance")
->Attribute(Edit::Attributes::Min, 0.0f)
->Attribute(Edit::Attributes::Max, 1.0f)
->ClassElement(AZ::Edit::ClassElements::Group, "Split Toning")
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
->DataElement(AZ::Edit::UIHandlers::Slider, &HDRColorGradingComponentConfig::m_splitToneWeight, "Split Tone Weight", "Modulates the split toning effect.")
->DataElement(AZ::Edit::UIHandlers::Slider, &HDRColorGradingComponentConfig::m_splitToneWeight, "Weight", "Modulates the split toning effect.")
->Attribute(Edit::Attributes::Min, 0.0f)
->Attribute(Edit::Attributes::Max, 1.0f)
->DataElement(AZ::Edit::UIHandlers::Slider, &HDRColorGradingComponentConfig::m_splitToneBalance, "Split Tone Balance", "Split Tone Balance Value")
->Attribute(Edit::Attributes::Min, 0.0f)
->DataElement(AZ::Edit::UIHandlers::Slider, &HDRColorGradingComponentConfig::m_splitToneBalance, "Balance", "Split Tone Balance Value")
->Attribute(Edit::Attributes::Min, -1.0f)
->Attribute(Edit::Attributes::Max, 1.0f)
->DataElement(AZ::Edit::UIHandlers::Color, &HDRColorGradingComponentConfig::m_splitToneShadowsColor, "Split Tone Shadows Color", "Split Tone Shadows Color")
->DataElement(AZ::Edit::UIHandlers::Color, &HDRColorGradingComponentConfig::m_splitToneHighlightsColor, "Split Tone Highlights Color", "Split Tone Highlights Color")
->DataElement(AZ::Edit::UIHandlers::Color, &HDRColorGradingComponentConfig::m_splitToneShadowsColor, "Shadows Color", "Split Tone Shadows Color")
->DataElement(AZ::Edit::UIHandlers::Color, &HDRColorGradingComponentConfig::m_splitToneHighlightsColor, "Highlights Color", "Split Tone Highlights Color")
->ClassElement(AZ::Edit::ClassElements::Group, "Channel Mixing")
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
@@ -99,33 +130,56 @@ namespace AZ
->ClassElement(AZ::Edit::ClassElements::Group, "Shadow Midtones Highlights")
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
->DataElement(AZ::Edit::UIHandlers::Slider, &HDRColorGradingComponentConfig::m_smhWeight, "SMH Weight", "Modulates the SMH effect.")
->DataElement(AZ::Edit::UIHandlers::Slider, &HDRColorGradingComponentConfig::m_smhWeight, "Weight", "Modulates the SMH effect.")
->Attribute(Edit::Attributes::Min, 0.0f)
->Attribute(Edit::Attributes::Max, 1.0f)
->DataElement(AZ::Edit::UIHandlers::Slider, &HDRColorGradingComponentConfig::m_smhShadowsStart, "SMH Shadows Start", "SMH Shadows Start Value")
->DataElement(AZ::Edit::UIHandlers::Slider, &HDRColorGradingComponentConfig::m_smhShadowsStart, "Shadows Start", "SMH Shadows Start Value")
->Attribute(Edit::Attributes::Min, 0.0f)
->Attribute(Edit::Attributes::Max, 1.0f)
->DataElement(AZ::Edit::UIHandlers::Slider, &HDRColorGradingComponentConfig::m_smhShadowsEnd, "SMH Shadows End", "SMH Shadows End Value")
->Attribute(Edit::Attributes::Max, 16.0f)
->Attribute(Edit::Attributes::SoftMax, 2.0f)
->DataElement(AZ::Edit::UIHandlers::Slider, &HDRColorGradingComponentConfig::m_smhShadowsEnd, "Shadows End", "SMH Shadows End Value")
->Attribute(Edit::Attributes::Min, 0.0f)
->Attribute(Edit::Attributes::Max, 1.0f)
->DataElement(AZ::Edit::UIHandlers::Slider, &HDRColorGradingComponentConfig::m_smhHighlightsStart, "SMH Highlights Start", "SMH Highlights Start Value")
->Attribute(Edit::Attributes::Max, 16.0f)
->Attribute(Edit::Attributes::SoftMax, 2.0f)
->DataElement(AZ::Edit::UIHandlers::Slider, &HDRColorGradingComponentConfig::m_smhHighlightsStart, "Highlights Start", "SMH Highlights Start Value")
->Attribute(Edit::Attributes::Min, 0.0f)
->Attribute(Edit::Attributes::Max, 1.0f)
->DataElement(AZ::Edit::UIHandlers::Slider, &HDRColorGradingComponentConfig::m_smhHighlightsEnd, "SMH Highlights End", "SMH Highlights End Value")
->Attribute(Edit::Attributes::Max, 16.0f)
->Attribute(Edit::Attributes::SoftMax, 2.0f)
->DataElement(AZ::Edit::UIHandlers::Slider, &HDRColorGradingComponentConfig::m_smhHighlightsEnd, "Highlights End", "SMH Highlights End Value")
->Attribute(Edit::Attributes::Min, 0.0f)
->Attribute(Edit::Attributes::Max, 1.0f)
->DataElement(AZ::Edit::UIHandlers::Color, &HDRColorGradingComponentConfig::m_smhShadowsColor, "SMH Shadows Color", "SMH Shadows Color")
->DataElement(AZ::Edit::UIHandlers::Color, &HDRColorGradingComponentConfig::m_smhMidtonesColor, "SMH Midtones Color", "SMH Midtones Color")
->DataElement(AZ::Edit::UIHandlers::Color, &HDRColorGradingComponentConfig::m_smhHighlightsColor, "SMH Highlights Color", "SMH Highlights Color")
->Attribute(Edit::Attributes::Max, 16.0f)
->Attribute(Edit::Attributes::SoftMax, 2.0f)
->DataElement(AZ::Edit::UIHandlers::Color, &HDRColorGradingComponentConfig::m_smhShadowsColor, "Shadows Color", "SMH Shadows Color")
->DataElement(AZ::Edit::UIHandlers::Color, &HDRColorGradingComponentConfig::m_smhMidtonesColor, "Midtones Color", "SMH Midtones Color")
->DataElement(AZ::Edit::UIHandlers::Color, &HDRColorGradingComponentConfig::m_smhHighlightsColor, "Highlights Color", "SMH Highlights Color")
->ClassElement(AZ::Edit::ClassElements::Group, "Final Adjustment")
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
->DataElement(AZ::Edit::UIHandlers::Slider, &HDRColorGradingComponentConfig::m_finalAdjustmentWeight, "Weight", "Weight of final adjustments")
->Attribute(Edit::Attributes::Min, 0.0f)
->Attribute(Edit::Attributes::Max, 1.0f)
->DataElement(AZ::Edit::UIHandlers::Slider, &HDRColorGradingComponentConfig::m_colorGradingHueShift, "Hue Shift", "Hue Shift Value")
->Attribute(Edit::Attributes::Min, 0.0f)
->Attribute(Edit::Attributes::Max, 1.0f)
->DataElement(AZ::Edit::UIHandlers::Slider, &HDRColorGradingComponentConfig::m_colorGradingPostSaturation, "Post Saturation", "Post Saturation Value")
->Attribute(Edit::Attributes::Min, -100.0f)
->Attribute(Edit::Attributes::Max, 100.0f)
->ClassElement(AZ::Edit::ClassElements::Group, "LUT Generation")
->DataElement(AZ::Edit::UIHandlers::ComboBox, &HDRColorGradingComponentConfig::m_lutResolution, "LUT Resolution", "Resolution of generated LUT")
->EnumAttribute(LutResolution::Lut16x16x16, "16x16x16")
->EnumAttribute(LutResolution::Lut32x32x32, "32x32x32")
->EnumAttribute(LutResolution::Lut64x64x64, "64x64x64")
->DataElement(Edit::UIHandlers::ComboBox, &HDRColorGradingComponentConfig::m_shaperPresetType,
"Shaper Type", "Shaper Type.")
->EnumAttribute(ShaperPresetType::None, "None")
->EnumAttribute(ShaperPresetType::LinearCustomRange, "Linear Custom Range")
->EnumAttribute(ShaperPresetType::Log2_48Nits, "Log2 48 nits")
->EnumAttribute(ShaperPresetType::Log2_1000Nits, "Log2 1000 nits")
->EnumAttribute(ShaperPresetType::Log2_2000Nits, "Log2 2000 nits")
->EnumAttribute(ShaperPresetType::Log2_4000Nits, "Log2 4000 nits")
->EnumAttribute(ShaperPresetType::Log2CustomRange, "Log2 Custom Range")
->EnumAttribute(ShaperPresetType::PqSmpteSt2084, "PQ (SMPTE ST 2084)")
;
}
}
@@ -136,6 +190,120 @@ namespace AZ
{
}
void EditorHDRColorGradingComponent::OnTick([[maybe_unused]] float deltaTime, [[maybe_unused]] AZ::ScriptTimePoint time)
{
if (m_waitOneFrame)
{
m_waitOneFrame = false;
return;
}
const char* LutAttachment = "LutOutput";
const AZStd::vector<AZStd::string> LutGenerationPassHierarchy{ "LutGenerationPass" };
char resolvedOutputFilePath[AZ_MAX_PATH_LEN] = { 0 };
AZ::IO::FileIOBase::GetDirectInstance()->ResolvePath(m_currentTiffFilePath.c_str(), resolvedOutputFilePath, AZ_MAX_PATH_LEN);
AZStd::string lutGenerationCacheFolder;
AzFramework::StringFunc::Path::GetFolderPath(resolvedOutputFilePath, lutGenerationCacheFolder);
AZ::IO::SystemFile::CreateDir(lutGenerationCacheFolder.c_str());
bool startedCapture = false;
AZ::Render::FrameCaptureRequestBus::BroadcastResult(
startedCapture,
&AZ::Render::FrameCaptureRequestBus::Events::CapturePassAttachment,
LutGenerationPassHierarchy,
AZStd::string(LutAttachment),
m_currentTiffFilePath,
AZ::RPI::PassAttachmentReadbackOption::Output);
if (startedCapture)
{
AZ::TickBus::Handler::BusDisconnect();
AZ::Render::FrameCaptureNotificationBus::Handler::BusConnect();
}
}
void EditorHDRColorGradingComponent::OnCaptureFinished([[maybe_unused]] AZ::Render::FrameCaptureResult result, [[maybe_unused]]const AZStd::string& info)
{
char resolvedInputFilePath[AZ_MAX_PATH_LEN] = { 0 };
AZ::IO::FileIOBase::GetDirectInstance()->ResolvePath(m_currentTiffFilePath.c_str(), resolvedInputFilePath, AZ_MAX_PATH_LEN);
char resolvedOutputFilePath[AZ_MAX_PATH_LEN] = { 0 };
AZ::IO::FileIOBase::GetDirectInstance()->ResolvePath(m_currentLutFilePath.c_str(), resolvedOutputFilePath, AZ_MAX_PATH_LEN);
AZStd::string lutGenerationFolder;
AzFramework::StringFunc::Path::GetFolderPath(resolvedOutputFilePath, lutGenerationFolder);
AZ::IO::SystemFile::CreateDir(lutGenerationFolder.c_str());
AZStd::vector<AZStd::string_view> pythonArgs
{
"--i", resolvedInputFilePath,
"--o", resolvedOutputFilePath
};
AzToolsFramework::EditorPythonRunnerRequestBus::Broadcast(
&AzToolsFramework::EditorPythonRunnerRequestBus::Events::ExecuteByFilenameWithArgs,
TiffToAzassetPythonScriptPath,
pythonArgs);
m_controller.m_configuration.m_generateLut = false;
m_controller.OnConfigChanged();
m_generatedLutAbsolutePath = resolvedOutputFilePath + AZStd::string(".azasset");
AzToolsFramework::PropertyEditorGUIMessages::Bus::Broadcast(
&AzToolsFramework::PropertyEditorGUIMessages::RequestRefresh,
AzToolsFramework::PropertyModificationRefreshLevel::Refresh_EntireTree);
AZ::Render::FrameCaptureNotificationBus::Handler::BusDisconnect();
}
void EditorHDRColorGradingComponent::GenerateLut()
{
// turn on lut generation pass
AZ::Uuid uuid = AZ::Uuid::CreateRandom();
AZStd::string uuidString;
uuid.ToString(uuidString);
m_currentTiffFilePath = AZStd::string::format(TempTiffFilePath, uuidString.c_str());
m_currentLutFilePath = "@projectroot@/" + AZStd::string::format(GeneratedLutRelativePath, uuidString.c_str());
m_controller.SetGenerateLut(true);
m_controller.OnConfigChanged();
m_waitOneFrame = true;
AZ::TickBus::Handler::BusConnect();
}
AZ::u32 EditorHDRColorGradingComponent::ActivateLut()
{
using namespace AzFramework::StringFunc::Path;
AZStd::string entityName;
AZ::ComponentApplicationBus::BroadcastResult(entityName, &AZ::ComponentApplicationRequests::GetEntityName, GetEntityId());
AZStd::string filename;
GetFileName(m_generatedLutAbsolutePath.c_str(), filename);
AZStd::string assetRelativePath = "LutGeneration/" + filename + ".azasset";
AZStd::vector<AZStd::string_view> pythonArgs
{
"--entityName", entityName,
"--assetRelativePath", assetRelativePath
};
AzToolsFramework::EditorPythonRunnerRequestBus::Broadcast(
&AzToolsFramework::EditorPythonRunnerRequestBus::Events::ExecuteByFilenameWithArgs,
ActivateLutAssetPythonScriptPath,
pythonArgs);
return AZ::Edit::PropertyRefreshLevels::EntireTree;
}
bool EditorHDRColorGradingComponent::GetGeneratedLutVisibilitySettings()
{
return !m_generatedLutAbsolutePath.empty();
}
u32 EditorHDRColorGradingComponent::OnConfigurationChanged()
{
m_controller.OnConfigChanged();
@@ -8,16 +8,25 @@
#pragma once
#include <AzCore/Component/TickBus.h>
#include <AzToolsFramework/ToolsComponents/EditorComponentAdapter.h>
#include <Atom/Feature/Utils/FrameCaptureBus.h>
#include <PostProcess/ColorGrading/HDRColorGradingComponent.h>
namespace AZ
{
namespace Render
{
static constexpr const char* const TempTiffFilePath{ "@usercache@/LutGeneration/SavedLut_%s.tiff" };
static constexpr const char* const GeneratedLutRelativePath = { "LutGeneration/SavedLut_%s" };
static constexpr const char* const TiffToAzassetPythonScriptPath{ "@engroot@/Gems/Atom/Feature/Common/Editor/Scripts/ColorGrading/tiff_to_3dl_azasset.py" };
static constexpr const char* const ActivateLutAssetPythonScriptPath{ "@engroot@/Gems/Atom/Feature/Common/Editor/Scripts/ColorGrading/activate_lut_asset.py" };
class EditorHDRColorGradingComponent final
: public AzToolsFramework::Components::
EditorComponentAdapter<HDRColorGradingComponentController, HDRColorGradingComponent, HDRColorGradingComponentConfig>
, private TickBus::Handler
, private FrameCaptureNotificationBus::Handler
{
public:
using BaseClass = AzToolsFramework::Components::EditorComponentAdapter<HDRColorGradingComponentController, HDRColorGradingComponent, HDRColorGradingComponentConfig>;
@@ -30,6 +39,23 @@ namespace AZ
//! EditorRenderComponentAdapter overrides...
AZ::u32 OnConfigurationChanged() override;
private:
// AZ::TickBus overrides ...
void OnTick(float deltaTime, AZ::ScriptTimePoint time) override;
// FrameCaptureNotificationBus overrides ...
void OnCaptureFinished(AZ::Render::FrameCaptureResult result, const AZStd::string& info) override;
void GenerateLut();
AZ::u32 ActivateLut();
bool GetGeneratedLutVisibilitySettings();
bool m_waitOneFrame = false;
AZStd::string m_currentTiffFilePath;
AZStd::string m_currentLutFilePath;
AZStd::string m_generatedLutAbsolutePath;
};
} // namespace Render
} // namespace AZ
@@ -52,6 +52,7 @@ namespace AZ
void HDRColorGradingComponentController::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
{
incompatible.push_back(AZ_CRC_CE("HDRColorGradingService"));
incompatible.push_back(AZ_CRC_CE("LookModificationService"));
}
void HDRColorGradingComponentController::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
@@ -49,12 +49,12 @@ namespace AZ
void LookModificationComponentController::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
{
provided.push_back(AZ_CRC("LookModificationService", 0x207b7539));
provided.push_back(AZ_CRC_CE("LookModificationService"));
}
void LookModificationComponentController::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
{
incompatible.push_back(AZ_CRC("LookModificationService", 0x207b7539));
incompatible.push_back(AZ_CRC("LookModificationService"));
}
void LookModificationComponentController::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="24px" height="24px" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 60 (88103) - https://sketch.com -->
<title>Icons / Video Control / Video</title>
<desc>Created with Sketch.</desc>
<g id="Icons-/-Video-Control-/-Video" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<rect id="Path" fill-opacity="0" fill="#E9E9E9" x="0" y="0" width="24" height="24"></rect>
<polygon id="Combined-Shape" fill="#FFFFFF" points="20 19 15 14 15 20 2 20 2 4 15 4 15 10 20 5 22 5 22 19"></polygon>
</g>
</svg>

After

Width:  |  Height:  |  Size: 681 B

@@ -0,0 +1,5 @@
<RCC>
<qresource prefix="/EMotionFXAtom">
<file>Camera_category.svg</file>
</qresource>
</RCC>
@@ -49,6 +49,7 @@ if(PAL_TRAIT_BUILD_HOST_TOOLS)
NAME EMotionFX_Atom.Editor GEM_MODULE
NAMESPACE Gem
AUTORCC
FILES_CMAKE
emotionfx_atom_editor_files.cmake
INCLUDE_DIRECTORIES
@@ -181,6 +181,31 @@ namespace EMStudio
ResetEnvironment();
}
AZ::Vector3 AnimViewportRenderer::GetCharacterCenter() const
{
AZ::Vector3 result = AZ::Vector3::CreateZero();
if (!m_actorEntities.empty())
{
// Find the actor instance and calculate the center from aabb.
AZ::Vector3 actorCenter = AZ::Vector3::CreateZero();
EMotionFX::Integration::ActorComponent* actorComponent =
m_actorEntities[0]->FindComponent<EMotionFX::Integration::ActorComponent>();
EMotionFX::ActorInstance* actorInstance = actorComponent->GetActorInstance();
if (actorInstance)
{
actorCenter += actorInstance->GetAabb().GetCenter();
}
// Just return the position of the first entity.
AZ::Transform worldTransform;
AZ::TransformBus::EventResult(worldTransform, m_actorEntities[0]->GetId(), &AZ::TransformBus::Events::GetWorldTM);
result = worldTransform.GetTranslation();
result += actorCenter;
}
return result;
}
void AnimViewportRenderer::ResetEnvironment()
{
// Reset environment
@@ -49,6 +49,9 @@ namespace EMStudio
void Reinit();
//! Return the center position of the existing objects.
AZ::Vector3 GetCharacterCenter() const;
private:
// This function resets the light, camera and other environment settings.
@@ -0,0 +1,41 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#include <AzCore/EBus/EBus.h>
namespace EMStudio
{
enum CameraViewMode
{
FRONT,
BACK,
TOP,
BOTTOM,
LEFT,
RIGHT,
DEFAULT
};
class AnimViewportRequests
: public AZ::EBusTraits
{
public:
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single;
//! Reset the camera to initial state.
virtual void ResetCamera() = 0;
//! Set the camera view mode.
virtual void SetCameraViewMode(CameraViewMode mode) = 0;
};
using AnimViewportRequestBus = AZ::EBus<AnimViewportRequests>;
} // namespace EMStudio
@@ -0,0 +1,60 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include <QToolButton>
#include <QMenu>
#include <EMStudio/AnimViewportToolBar.h>
#include <EMStudio/AnimViewportRequestBus.h>
#include <AzCore/std/string/string.h>
#include <AzQtComponents/Components/Widgets/ToolBar.h>
namespace EMStudio
{
AnimViewportToolBar::AnimViewportToolBar(QWidget* parent)
: QToolBar(parent)
{
AzQtComponents::ToolBar::addMainToolBarStyle(this);
// Add the camera button
QToolButton* cameraButton = new QToolButton(this);
QMenu* cameraMenu = new QMenu(cameraButton);
// Add the camera option
const AZStd::vector<AZStd::pair<CameraViewMode, AZStd::string>> cameraOptionNames = {
{ CameraViewMode::FRONT, "Front" }, { CameraViewMode::BACK, "Back" }, { CameraViewMode::TOP, "Top" },
{ CameraViewMode::BOTTOM, "Bottom" }, { CameraViewMode::LEFT, "Left" }, { CameraViewMode::RIGHT, "Right" },
};
for (const auto& pair : cameraOptionNames)
{
CameraViewMode mode = pair.first;
cameraMenu->addAction(
pair.second.c_str(),
[mode]()
{
// Send the reset camera event.
AnimViewportRequestBus::Broadcast(&AnimViewportRequestBus::Events::SetCameraViewMode, mode);
});
}
cameraMenu->addSeparator();
cameraMenu->addAction("Reset Camera",
[]()
{
// Send the reset camera event.
AnimViewportRequestBus::Broadcast(&AnimViewportRequestBus::Events::ResetCamera);
});
cameraButton->setMenu(cameraMenu);
cameraButton->setText("Camera Option");
cameraButton->setPopupMode(QToolButton::InstantPopup);
cameraButton->setVisible(true);
cameraButton->setIcon(QIcon(":/EMotionFXAtom/Camera_category.svg"));
addWidget(cameraButton);
}
} // namespace EMStudio
@@ -0,0 +1,24 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#if !defined(Q_MOC_RUN)
#include <QAction>
#include <QToolBar>
#endif
namespace EMStudio
{
class AnimViewportToolBar : public QToolBar
{
public:
AnimViewportToolBar(QWidget* parent = nullptr);
~AnimViewportToolBar() = default;
};
}
@@ -34,6 +34,23 @@ namespace EMStudio
SetupCameras();
SetupCameraController();
Reinit();
AnimViewportRequestBus::Handler::BusConnect();
}
AnimViewportWidget::~AnimViewportWidget()
{
AnimViewportRequestBus::Handler::BusDisconnect();
}
void AnimViewportWidget::Reinit(bool resetCamera)
{
if (resetCamera)
{
ResetCamera();
}
m_renderer->Reinit();
}
void AnimViewportWidget::SetupCameras()
@@ -100,4 +117,42 @@ namespace EMStudio
});
GetControllerList()->Add(controller);
}
void AnimViewportWidget::ResetCamera()
{
SetCameraViewMode(CameraViewMode::DEFAULT);
}
void AnimViewportWidget::SetCameraViewMode([[maybe_unused]]CameraViewMode mode)
{
// Set the camera view mode.
const AZ::Vector3 targetPosition = m_renderer->GetCharacterCenter();
AZ::Vector3 cameraPosition;
switch (mode)
{
case CameraViewMode::FRONT:
cameraPosition.Set(0.0f, CameraDistance, targetPosition.GetZ());
break;
case CameraViewMode::BACK:
cameraPosition.Set(0.0f, -CameraDistance, targetPosition.GetZ());
break;
case CameraViewMode::TOP:
cameraPosition.Set(0.0f, 0.0f, CameraDistance + targetPosition.GetZ());
break;
case CameraViewMode::BOTTOM:
cameraPosition.Set(0.0f, 0.0f, -CameraDistance + targetPosition.GetZ());
break;
case CameraViewMode::LEFT:
cameraPosition.Set(-CameraDistance, 0.0f, targetPosition.GetZ());
break;
case CameraViewMode::RIGHT:
cameraPosition.Set(CameraDistance, 0.0f, targetPosition.GetZ());
break;
case CameraViewMode::DEFAULT:
// The default view mode is looking from the top left of the character.
cameraPosition.Set(-CameraDistance, CameraDistance, CameraDistance + targetPosition.GetZ());
break;
}
GetViewportContext()->SetCameraTransform(AZ::Transform::CreateLookAt(cameraPosition, targetPosition));
}
} // namespace EMStudio
@@ -9,6 +9,7 @@
#include <AtomToolsFramework/Viewport/RenderViewportWidget.h>
#include <AzFramework/Viewport/CameraInput.h>
#include <EMStudio/AnimViewportRequestBus.h>
namespace EMStudio
{
@@ -16,15 +17,25 @@ namespace EMStudio
class AnimViewportWidget
: public AtomToolsFramework::RenderViewportWidget
, private AnimViewportRequestBus::Handler
{
public:
AnimViewportWidget(QWidget* parent = nullptr);
~AnimViewportWidget() override;
AnimViewportRenderer* GetAnimViewportRenderer() { return m_renderer.get(); }
void Reinit(bool resetCamera = true);
private:
void SetupCameras();
void SetupCameraController();
// AnimViewportRequestBus::Handler overrides
void ResetCamera();
void SetCameraViewMode(CameraViewMode mode);
static constexpr float CameraDistance = 2.0f;
AZStd::unique_ptr<AnimViewportRenderer> m_renderer;
AZStd::shared_ptr<AzFramework::RotateCameraInput> m_rotateCamera;
AZStd::shared_ptr<AzFramework::TranslateCameraInput> m_translateCamera;
@@ -8,6 +8,7 @@
#include <EMStudio/AtomRenderPlugin.h>
#include <EMStudio/AnimViewportRenderer.h>
#include <EMStudio/AnimViewportToolBar.h>
#include <Integration/Components/ActorComponent.h>
#include <EMotionFX/CommandSystem/Source/CommandManager.h>
@@ -76,7 +77,7 @@ namespace EMStudio
void AtomRenderPlugin::ReinitRenderer()
{
m_animViewportWidget->GetAnimViewportRenderer()->Reinit();
m_animViewportWidget->Reinit();
}
bool AtomRenderPlugin::Init()
@@ -88,6 +89,12 @@ namespace EMStudio
verticalLayout->setSizeConstraint(QLayout::SetNoConstraint);
verticalLayout->setSpacing(1);
verticalLayout->setMargin(0);
// Add the tool bar
AnimViewportToolBar* toolBar = new AnimViewportToolBar(m_innerWidget);
verticalLayout->addWidget(toolBar);
// Add the viewport widget
m_animViewportWidget = new AnimViewportWidget(m_innerWidget);
verticalLayout->addWidget(m_animViewportWidget);
@@ -7,6 +7,7 @@
#
set(FILES
../Assets/Icons/Resources.qrc
Source/ActorModule.cpp
Source/Editor/EditorSystemComponent.h
Source/Editor/EditorSystemComponent.cpp
@@ -18,4 +19,7 @@ set(FILES
Tools/EMStudio/AnimViewportRenderer.cpp
Tools/EMStudio/AnimViewportSettings.h
Tools/EMStudio/AnimViewportSettings.cpp
Tools/EMStudio/AnimViewportToolBar.h
Tools/EMStudio/AnimViewportToolBar.cpp
Tools/EMStudio/AnimViewportRequestBus.h
)
@@ -1,6 +1,6 @@
{
"Source" : "ImGuiAtom",
"Source" : "ImGuiAtom.azsl",
"RasterState" : { "CullMode" : "None" },
@@ -4,18 +4,18 @@
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
#
# -- This line is 75 characters -------------------------------------------
# -------------------------------------------------------------------------
# Sets up the project environment for python scripting using the
export DYNACONF_COMPANY=Amazon
# if a lumberyard project isn't set use this gem
export DYNACONF_LY_PROJECT=DccScriptingInterface
export DYNACONF_LY_PROJECT_PATH=`pwd`
export DYNACONF_LY_DEV=${LY_PROJECT_PATH}\..\..\..\..
# if a O3DE project isn't set use this gem
export DYNACONF_O3DE_PROJECT=DccScriptingInterface
export DYNACONF_O3DE_PROJECT_PATH=`pwd`
export DYNACONF_O3DE_DEV=${O3DE_PROJECT_PATH}\..\..\..\..
# LY build folder
export DYNACONF_LY_BUILD_PATH=${LY_DEV}\build
export DYNACONF_LY_BIN_PATH=${LY_BUILD_PATH}\bin\profile
export DYNACONF_O3DE_BUILD_PATH=${O3DE_DEV}\build
export DYNACONF_O3DE_BIN_PATH=${O3DE_BUILD_PATH}\bin\profile
# default IDE and debug settings
#export DYNACONF_DCCSI_GDEBUG=false
@@ -24,9 +24,9 @@ export DYNACONF_DCCSI_GDEBUGGER=WING
export DYNACONF_DCCSI_LOGLEVEL=20
# defaults for DccScriptingInterface (DCCsi)
export DYNACONF_DCCSIG_PATH=${LY_DEV}\Gems\AtomLyIntegration\TechnicalArt\DccScriptingInterface
export DYNACONF_DCCSIG_PATH=${O3DE_DEV}\Gems\AtomLyIntegration\TechnicalArt\DccScriptingInterface
# set up default python interpreter (Lumberyard)
# set up default python interpreter (O3DE)
# we may want to entirely remove these and rely on config.py to dynamically set up
# however VScode can be configured with a .env so might be valueable to keep
export DYNACONF_DCCSI_PY_VERSION_MAJOR=3
@@ -40,13 +40,13 @@ export DYNACONF_DCCSI_PYTHON_PATH=${DCCSIG_PATH}\3rdParty\Python
export DYNACONF_DCCSI_PYTHON_LIB_PATH=${DCCSI_PYTHON_PATH}\Lib\${DCCSI_PY_VERSION_MAJOR}.x\${DCCSI_PY_VERSION_MAJOR}.${DCCSI_PY_VERSION_MINOR}.x\site-packages
# TO DO: figure out how to best deal with OS folder (i.e. 'windows')
export DYNACONF_DCCSI_PYTHON_INSTALL=${LY_DEV}\python
export DYNACONF_DDCCSI_PY_BASE=${DCCSI_PYTHON_INSTALL}\python.cmd
export DYNACONF_O3DE_PYTHON_INSTALL=${O3DE_DEV}\python
export DYNACONF_DCCSI_PY_BASE=${O3DE_PYTHON_INSTALL}\python.cmd
# set up Qt / PySide2
# TO DO: These should NOT be set in the global env as they will cause conflicts
# with other Qt apps (like DCC tools), only set in local.env, or modify config.py
# for utils/tools/apps that need them ( see config.init_ly_pyside() )
#export DYNACONF_QTFORPYTHON_PATH=${LY_DEV}\Gems\QtForPython\3rdParty\pyside2\windows\release
#export DYNACONF_QT_PLUGIN_PATH=${LY_BUILD_PATH}\bin\profile\EditorPlugins
#export DYNACONF_QT_QPA_PLATFORM_PLUGIN_PATH=${LY_BUILD_PATH}\bin\profile\EditorPlugins\platforms
#export DYNACONF_QTFORPYTHON_PATH=${O3DE_DEV}\Gems\QtForPython\3rdParty\pyside2\windows\release
#export DYNACONF_QT_PLUGIN_PATH=${O3DE_BUILD_PATH}\bin\profile\EditorPlugins
#export DYNACONF_QT_QPA_PLATFORM_PLUGIN_PATH=${O3DE_BUILD_PATH}\bin\profile\EditorPlugins\platforms
@@ -8,4 +8,6 @@ workspace.xml
# Ignore dynaconf secret files
.secrets.*
settings.local.json
azpy/_sample_package_/*
azpy/_sample_package_/*
.env
settings_export.json.tmp
@@ -19,3 +19,4 @@ __WIP__/*
!.gitignore
.secrets.*
settings.local.json
.env
@@ -0,0 +1,36 @@
DccScriptingInterface (DCCsi)
This location can be extended with additional 3rdParty Python Utils, Tools, Packages, etc.
These are not installed or distributed with O3DE
However, there is some stubbed scaffolding in place.
This is a bootstrapped sandbox for installing python libs (version bootstrapped procedurally):
C:\Depot\o3de-engine\Gems\AtomLyIntegration\TechnicalArt\DccScriptingInterface\3rdParty\Python\Lib\2.x\2.7.x\site-packages
C:\Depot\o3de-engine\Gems\AtomLyIntegration\TechnicalArt\DccScriptingInterface\3rdParty\Python\Lib\3.x\3.7.x\site-packages
Any libs installed to this location will be accessible (use at your own risk)
For instance, if you want to add py2.7 compatible libs, for apps like Maya2020:
"C:\Depot\o3de-engine\Gems\AtomLyIntegration\TechnicalArt\DccScriptingInterface\Tools\DCC\Maya\readme.txt"
These pyside2-tools can be useful, and they are not pip installed, nor distributed.
C:\Depot\o3de-engine\Gems\AtomLyIntegration\TechnicalArt\DccScriptingInterface\3rdParty\Python\pyside2-tools
pyside2-tools instructions:
1. clone the repo in this location: C:\Depot\o3de-engine\Gems\AtomLyIntegration\TechnicalArt\DccScriptingInterface\3rdParty\Python
>git clone https://github.com/pyside/pyside2-tools
2. to use as a python package ...
find this and copy:
"< local DCCsi >\3rdParty\Python\pyside2-tools\pyside2uic\__init__.py.in"
and rename to this:
"< local DCCsi >\3rdParty\Python\pyside2-tools\pyside2uic\__init__.py"
3. add to PYTHONPATH: < local DCCsi >\3rdParty\Python
in .py something like: site.addsitedir(DCCSI_PYSIDE2_TOOLS)
See: "< local DCCsi >\config.py"
@@ -7,9 +7,9 @@
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
#
# -- This line is 75 characters -------------------------------------------
# -------------------------------------------------------------------------
"""This module is for use in boostrapping the DccScriptingInterface Gem
with Lumberyard. Note: this boostrap is only designed fo be py3 compatible.
with O3DE. Note: this boostrap is only designed fo be py3 compatible.
If you need DCCsi access in py27 (Autodesk Maya for instance) you may need
to implement your own boostrapper module. Currently this is boostrapped
from add_dccsi.py, as a temporty measure related to this Jira:
@@ -24,40 +24,64 @@ import logging as _logging
# -------------------------------------------------------------------------
# -------------------------------------------------------------------------
_O3DE_RUNNING=None
try:
import azlmbr
_O3DE_RUNNING=True
except:
_O3DE_RUNNING=False
# -------------------------------------------------------------------------
# -------------------------------------------------------------------------
# we don't use dynaconf setting here as we might not yet have access
# to that site-dir.
_MODULE = 'DCCsi.bootstrap'
_MODULENAME = __name__
if _MODULENAME is '__main__':
_MODULENAME = 'O3DE.DCCsi.bootstrap'
# set up module logging
for handler in _logging.root.handlers[:]:
_logging.root.removeHandler(handler)
_LOGGER = _logging.getLogger(_MODULENAME)
# we need to set up basic access to the DCCsi
_MODULE_PATH = os.path.realpath(__file__) # To Do: what if frozen?
_DCCSIG_PATH = os.path.normpath(os.path.join(_MODULE_PATH, '../../..'))
_DCCSIG_PATH = os.getenv('DCCSIG_PATH', _DCCSIG_PATH)
site.addsitedir(_DCCSIG_PATH)
_DCCSI_PATH = os.path.normpath(os.path.join(_MODULE_PATH, '../../..'))
_DCCSI_PATH = os.getenv('DCCSI_PATH', _DCCSI_PATH)
site.addsitedir(_DCCSI_PATH)
# we can get basic access to the DCCsi.azpy api now
import azpy
# now we have azpy api access
from azpy.env_bool import env_bool
from azpy.constants import ENVAR_DCCSI_GDEBUG
from azpy.constants import ENVAR_DCCSI_DEV_MODE
from azpy.constants import ENVAR_DCCSI_LOGLEVEL
from azpy.constants import FRMT_LOG_LONG
# early attach WingIDE debugger (can refactor to include other IDEs later)
while 0: # flag on to attemp to connect wingIDE debugger
from azpy.env_bool import env_bool
if not env_bool('DCCSI_DEBUGGER_ATTACHED', False):
# if not already attached lets do it here
from azpy.test.entry_test import connect_wing
foo = connect_wing()
# set up global space, logging etc.
# set these true if you want them set globally for debugging
_DCCSI_GDEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False)
_DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False)
_DCCSI_LOGLEVEL = int(env_bool(ENVAR_DCCSI_LOGLEVEL, int(20)))
if _DCCSI_GDEBUG:
_DCCSI_LOGLEVEL = int(10)
_logging.basicConfig(format=FRMT_LOG_LONG, level=_DCCSI_LOGLEVEL)
_LOGGER.debug('Initializing: {0}.'.format({_MODULENAME}))
# -------------------------------------------------------------------------
# -------------------------------------------------------------------------
# settings.setenv() # doing this will add the additional DYNACONF_ envars
def get_dccsi_config(DCCSIG_PATH=_DCCSIG_PATH):
# _settings.setenv() # doing this will add the additional DYNACONF_ envars
def get_dccsi_config(DCCSI_PATH=_DCCSI_PATH):
"""Convenience method to set and retreive settings directly from module."""
# we can go ahead and just make sure the the DCCsi env is set
# config is SO generic this ensures we are importing a specific one
_spec_dccsi_config = importlib.util.spec_from_file_location("dccsi.config",
Path(DCCSIG_PATH,
# _config is SO generic this ensures we are importing a specific one
_spec_dccsi_config = importlib.util.spec_from_file_location("dccsi._config",
Path(DCCSI_PATH,
"config.py"))
_dccsi_config = importlib.util.module_from_spec(_spec_dccsi_config)
_spec_dccsi_config.loader.exec_module(_dccsi_config)
@@ -65,9 +89,12 @@ def get_dccsi_config(DCCSIG_PATH=_DCCSIG_PATH):
return _dccsi_config
# -------------------------------------------------------------------------
# set and retreive the base settings on import
config = get_dccsi_config()
settings = config.get_config_settings()
# set and retreive the base env context/_settings on import
_config = get_dccsi_config()
_settings = _config.get_config_settings()
if _DCCSI_DEV_MODE:
_config.attach_debugger() # attempts to start debugger
# done with basic setup
# --- END -----------------------------------------------------------------
@@ -77,50 +104,99 @@ settings = config.get_config_settings()
# -------------------------------------------------------------------------
if __name__ == '__main__':
"""Run this file as main"""
# -------------------------------------------------------------------------
_O3DE_RUNNING=None
try:
import azlmbr
_O3DE_RUNNING=True
except:
_O3DE_RUNNING=False
# -------------------------------------------------------------------------
_G_DEBUG = False
_G_TEST_PYSIDE = False
_MODULENAME = __name__
if _MODULENAME is '__main__':
_MODULENAME = 'O3DE.DCCsi.bootstrap'
from azpy.constants import STR_CROSSBAR
# module internal debugging flags
while 0: # temp internal debug flag
_DCCSI_GDEBUG = True
break
# overide logger for standalone to be more verbose and log to file
import azpy
_LOGGER = azpy.initialize_logger(_MODULENAME,
log_to_file=_DCCSI_GDEBUG,
default_log_level=_DCCSI_LOGLEVEL)
# happy print
_LOGGER.info(STR_CROSSBAR)
_LOGGER.info('~ constants.py ... Running script as __main__')
_LOGGER.info(STR_CROSSBAR)
# parse the command line args
import argparse
parser = argparse.ArgumentParser(
description='O3DE DCCsi Boostrap (Test)',
epilog="Will externally test the DCCsi boostrap")
_config = get_dccsi_config()
_settings = config.get_config_settings()
_log_level = int(_settings.DCCSI_LOGLEVEL)
if _G_DEBUG:
_log_level = int(10) # force debug level
_LOGGER = azpy.initialize_logger(_MODULE,
log_to_file=True,
default_log_level=_log_level)
_settings = _config.get_config_settings(enable_o3de_python=True,
enable_o3de_pyside2=True)
parser.add_argument('-gd', '--global-debug',
type=bool,
required=False,
help='Enables global debug flag.')
parser.add_argument('-dm', '--developer-mode',
type=bool,
required=False,
help='Enables dev mode for early auto attaching debugger.')
parser.add_argument('-tp', '--test-pyside2',
type=bool,
required=False,
help='Runs Qt/PySide2 tests and reports.')
args = parser.parse_args()
# we can now grab values from the DCCsi.config.py dynamic env settings
# the rest of this block is basic debug testing the dynamic settings at boot
_LOGGER.info(f'Running module: {_MODULE}')
_LOGGER.info(f'DCCSIG_PATH: {_settings.DCCSIG_PATH}')
_LOGGER.info(f'DCCSI_G_DEBUG: {_settings.DCCSI_GDEBUG}')
_LOGGER.info(f'DCCSI_DEV_MODE: {_settings.DCCSI_DEV_MODE}')
_LOGGER.info(f'OS_FOLDER: {_settings.OS_FOLDER}')
_LOGGER.info(f'LY_PROJECT: {_settings.LY_PROJECT}')
_LOGGER.info(f'LY_PROJECT_PATH: {_settings.LY_PROJECT_PATH}')
_LOGGER.info(f'LY_DEV: {_settings.LY_DEV}')
_LOGGER.info(f'LY_BUILD_PATH: {_settings.LY_BUILD_PATH}')
_LOGGER.info(f'LY_BIN_PATH: {_settings.LY_BIN_PATH}')
# easy overrides
if args.global_debug:
_DCCSI_GDEBUG = True
if args.developer_mode:
_DCCSI_DEV_MODE = True
_config.attach_debugger() # attempts to start debugger
_LOGGER.info(f'DCCSIG_PATH: {_settings.DCCSIG_PATH}')
_LOGGER.info(f'DCCSI_PYTHON_LIB_PATH: {_settings.DCCSI_PYTHON_LIB_PATH}')
_LOGGER.info(f'DDCCSI_PY_BASE: {_settings.DDCCSI_PY_BASE}')
if _DCCSI_GDEBUG:
_LOGGER.info(f'DCCSI_PATH: {_settings.DCCSI_PATH}')
_LOGGER.info(f'DCCSI_G_DEBUG: {_settings.DCCSI_GDEBUG}')
_LOGGER.info(f'DCCSI_DEV_MODE: {_settings.DCCSI_DEV_MODE}')
_LOGGER.info(f'DCCSI_OS_FOLDER: {_settings.DCCSI_OS_FOLDER}')
_LOGGER.info(f'O3DE_PROJECT: {_settings.O3DE_PROJECT}')
_LOGGER.info(f'O3DE_PROJECT_PATH: {_settings.O3DE_PROJECT_PATH}')
_LOGGER.info(f'O3DE_DEV: {_settings.O3DE_DEV}')
_LOGGER.info(f'O3DE_BUILD_PATH: {_settings.O3DE_BUILD_PATH}')
_LOGGER.info(f'O3DE_BIN_PATH: {_settings.O3DE_BIN_PATH}')
_LOGGER.info(f'DCCSI_PATH: {_settings.DCCSI_PATH}')
_LOGGER.info(f'DCCSI_PYTHON_LIB_PATH: {_settings.DCCSI_PYTHON_LIB_PATH}')
_LOGGER.info(f'DCCSI_PY_BASE: {_settings.DCCSI_PY_BASE}')
if _G_TEST_PYSIDE:
if _DCCSI_GDEBUG or args.test_pyside2:
try:
import PySide2
except:
# set up Qt/PySide2 access and test
_settings = _config.get_config_settings(setup_ly_pyside=True)
_settings = _config.get_config_settings(enable_o3de_pyside2=True)
import PySide2
_LOGGER.info(f'PySide2: {PySide2}')
_LOGGER.info(f'LY_BIN_PATH: {_settings.LY_BIN_PATH}')
_LOGGER.info(f'O3DE_BIN_PATH: {_settings.O3DE_BIN_PATH}')
_LOGGER.info(f'QT_PLUGIN_PATH: {_settings.QT_PLUGIN_PATH}')
_LOGGER.info(f'QT_QPA_PLATFORM_PLUGIN_PATH: {_settings.QT_QPA_PLATFORM_PLUGIN_PATH}')
_config.test_pyside2()
if not _O3DE_RUNNING:
# return
sys.exit()
# --- END -----------------------------------------------------------------
@@ -0,0 +1,87 @@
"""
Copyright (c) Contributors to the Open 3D Engine Project.
For complete copyright and license terms please see the LICENSE at the root of this distribution.
SPDX-License-Identifier: Apache-2.0 OR MIT
"""
# -------------------------------------------------------------------------
This folder contains the DccScriptingInterface (DCCsi) for O3DE
Notice: The old \\SDK folder is being replaced with \\Tools
The scripts in \\SDK may be out of data (and not run)
When scripts are finished being updated and refactored into \\Tools the \\SDK will be removed
What is the DCCsi?
- A shared development environment for technical art oriented to working with Python across a number of DCC tools.
- Leverage the existing python ecosystem for technical art.
- Integrate a DCC app like Substance (or Substance SAT api) from the Python driven VFX and Games ecosystem.
- Extend O3DE and unlock its potential for content creators, and the Technical Artists that service them.
Tenets:
(1) Interoperability: Design DCC-agnostic modules and DCC-bespoke modules
to work together efficiently and intuitively.
(2) Encapsulation: Define a module in terms of its essential features and interface to other components,
to facilitate logical layered design and easy maintenance.
(3) Extensibility: Design the tool set to be easily extensible with new functionality and new tools.
Individual pieces should have a generic communication mechanism to allow newly written tools to slot cleanly and transparently into the tool chain.
What is provided (High Level):
- DCC-Agnostic Python Framework (as a modular Gem) related to multiple integrations for:
O3DE Editor (python scripting, utils and PySide2 tools)
DCC applications and their Python APIs/SDKs
Custom standalone tools and utils (python based)
external from cmd line
external standalone
integrated to run within O3DE Editor
What is provided (by folder):
\3rdParty: Allows third party libs/packages to be integrated outside of O3DE
Example: O3DE is py3, Maya 2020 (and earlier) is py27
O3DE provides a patterns for Gems to provide a requirements.txt
See:
DccScriptingInterface\reqiurements.txt
^ These packages will be fetched and installed into O3DE python at build time
This means for some applications like Maya we need another way to add the same packages
See:
DccScriptingInterface\SDK\Maya\readme.txt
DccScriptingInterface\SDK\Maya\requirements.txt
DccScriptingInterface\3rdParty\Python\Lib\2.x\2.7.x\site-packages\*
Packages that reside in 3rdParty are never commited to the repo (only fetched+installed)
\Assets: All O3DE Gems can maintain an asset folder
If a Gem contains an \Asset folder, these assets are folded into the projects asset data
These assets are processed by the Asset Processor for use in the Editor and Runtime
In the DCCsi the \Assets folder primarily contains TestData
\azpy Core (shared) API, A pure python Package and Modules
\Code Contains the bare bones C++ scaffold to build and integrate the Gem with O3DE
Notes: portions of the DCCsi can be utilized outside of O3DE
thus this Gem doens't have to be enabled and built for some use cases
\Editor This folder provides an entry point pattern for extending O3DE Editor with python
When a Gem is enabled ...
If the following if found, it will be executed when the Editor boots:
"Editor\Scripts\bootstrap.py"
This can be used to initialize code access, extend the editor (PySide2), etc.
\Tools This is where the following is maintained:
\Tools\DCC Integration for DCC tools:
configuration of tool (managed env, etc.)
bootstrapping, such as providing the tool access to azpy api code
extensibility, such as adding new functionality or tool to the app
\Tools\DCC\Maya An example of adding a integration for Autodesk Maya
\Tools\Env\Windows This provides a .bat file managed env to configure and bootsrap windows apps
\Tools\Launchers\windows Provides .bat files based tool launchers for windows (accesses env)
@@ -1,132 +0,0 @@
"""
Copyright (c) Contributors to the Open 3D Engine Project.
For complete copyright and license terms please see the LICENSE at the root of this distribution.
SPDX-License-Identifier: Apache-2.0 OR MIT
"""
# -------------------------------------------------------------------------
import pymel.core as pmc
import sys
import types
def syspath():
print 'sys.path:'
for p in sys.path:
print ' ' + p
def info(obj):
"""Prints information about the object."""
lines = ['Info for %s' % obj.name(),
'Attributes:']
# Get the name of all attributes
for a in obj.listAttr():
lines.append(' ' + a.name())
lines.append('MEL type: %s' % obj.type())
lines.append('MRO:')
lines.extend([' ' + t.__name__ for t in type(obj).__mro__])
result = '\n'.join(lines)
print result
def _is_pymel(obj):
try: # (1)
module = obj.__module__ # (2)
except AttributeError: # (3)
try:
module = obj.__name__ # (4)
except AttributeError:
return None # (5)
return module.startswith('pymel') # (6)
def _py_to_helpstr(obj):
if isinstance(obj, basestring):
return 'search.html?q=%s' % (obj.replace(' ', '+'))
if not _is_pymel(obj):
return None
if isinstance(obj, types.ModuleType):
return ('generated/%(module)s.html#module-%(module)s' %
dict(module=obj.__name__))
if isinstance(obj, types.MethodType):
return ('generated/classes/%(module)s/'
'%(module)s.%(typename)s.html'
'#%(module)s.%(typename)s.%(methname)s' % dict(
module=obj.__module__,
typename=obj.im_class.__name__,
methname=obj.__name__))
if isinstance(obj, types.FunctionType):
return ('generated/functions/%(module)s/'
'%(module)s.%(funcname)s.html'
'#%(module)s.%(funcname)s' % dict(
module=obj.__module__,
funcname=obj.__name__))
if not isinstance(obj, type):
obj = type(obj)
return ('generated/classes/%(module)s/'
'%(module)s.%(typename)s.html'
'#%(module)s.%(typename)s' % dict(
module=obj.__module__,
typename=obj.__name__))
def test_py_to_helpstr():
def dotest(obj, ideal):
result = _py_to_helpstr(obj)
assert result == ideal, '%s != %s' % (result, ideal)
dotest('maya rocks', 'search.html?q=maya+rocks')
dotest(pmc.nodetypes,
'generated/pymel.core.nodetypes.html'
'#module-pymel.core.nodetypes')
dotest(pmc.nodetypes.Joint,
'generated/classes/pymel.core.nodetypes/'
'pymel.core.nodetypes.Joint.html'
'#pymel.core.nodetypes.Joint')
dotest(pmc.nodetypes.Joint(),
'generated/classes/pymel.core.nodetypes/'
'pymel.core.nodetypes.Joint.html'
'#pymel.core.nodetypes.Joint')
dotest(pmc.nodetypes.Joint().getTranslation,
'generated/classes/pymel.core.nodetypes/'
'pymel.core.nodetypes.Joint.html'
'#pymel.core.nodetypes.Joint.getTranslation')
dotest(pmc.joint,
'generated/functions/pymel.core.animation/'
'pymel.core.animation.joint.html'
'#pymel.core.animation.joint')
dotest(object(), None)
dotest(10, None)
dotest([], None)
dotest(sys, None)
def test_py_to_helpstrFAIL():
assert 1 == 2, '1 != 2'
import webbrowser # (1)
HELP_ROOT_URL = ('http://help.autodesk.com/cloudhelp/2018/ENU/Maya-Tech-Docs/PyMel/')# (2)
def pmhelp(obj): # (3)
"""Gives help for a pymel or python object.
If obj is not a PyMEL object, use Python's built-in
`help` function.
If obj is a string, open a web browser to a search in the
PyMEL help for the string.
Otherwise, open a web browser to the page for the object.
"""
tail = _py_to_helpstr(obj)
if tail is None:
help(obj) # (4)
else:
webbrowser.open(HELP_ROOT_URL + tail) # (5)
if __name__ == '__main__':
test_py_to_helpstr()
print 'Tests ran successfully.'
@@ -1,85 +0,0 @@
@echo off
REM
REM Copyright (c) Contributors to the Open 3D Engine Project.
REM For complete copyright and license terms please see the LICENSE at the root of this distribution.
REM
REM SPDX-License-Identifier: Apache-2.0 OR MIT
REM
REM
:: Set up and run LY Python CMD prompt
:: Sets up the DccScriptingInterface_Env,
:: Puts you in the CMD within the dev environment
:: Set up window
TITLE Lumberyard DCC Scripting Interface Cmd
:: Use obvious color to prevent confusion (Grey with Yellow Text)
COLOR 8E
%~d0
cd %~dp0
:: Keep changes local
SETLOCAL enableDelayedExpansion
:: This maps up to the \Dev folder
IF "%DEV_REL_PATH%"=="" (set DEV_REL_PATH=..\..\..\..\..\..\..\..\..)
:: Change to root Lumberyard dev dir
:: Don't use the LY_DEV so we can test that ENVAR!!!
CD /d %DEV_REL_PATH%
set Rel_Dev=%CD%
echo Rel_Dev = %Rel_Dev%
:: Restore original directory
popd
set DCCSI_PYTHON_INSTALL=%Rel_Dev%\Tools\Python\3.7.5\windows
:: add to the PATH
SET PATH=%DCCSI_PYTHON_INSTALL%;%PATH%
:: dcc scripting interface gem path
set DCCSIG_PATH=%Rel_Dev%\Gems\AtomLyIntegration\TechnicalArt\DccScriptingInterface
echo DCCSIG_PATH = %DCCSIG_PATH%
:: add to the PATH
SET PATH=%DCCSIG_PATH%;%PATH%
:: Constant Vars (Global)
:: global debug (propogates)
IF "%DCCSI_GDEBUG%"=="" (set DCCSI_GDEBUG=false)
echo DCCSI_GDEBUG = %DCCSI_GDEBUG%
:: initiates debugger connection
IF "%DCCSI_DEV_MODE%"=="" (set DCCSI_DEV_MODE=false)
echo DCCSI_DEV_MODE = %DCCSI_DEV_MODE%
:: sets debugger, options: WING, PYCHARM
IF "%DCCSI_GDEBUGGER%"=="" (set DCCSI_GDEBUGGER=WING)
echo DCCSI_GDEBUGGER = %DCCSI_GDEBUGGER%
echo.
echo _____________________________________________________________________
echo.
echo ~ LY DCCsi, DCC Material Converter
echo _____________________________________________________________________
echo.
:: Change to root dir
CD /D %DCCSIG_PATH%
:: add to the PATH
SET PATH=%DCCSIG_PATH%;%PATH%
set PYTHONPATH=%DCCSIG_PATH%;%PYTHONPATH%
CALL %DCCSI_PYTHON_INSTALL%\python.exe "%DCCSIG_PATH%\SDK\Maya\Scripts\Python\kitbash_converter\standalone.py"
ENDLOCAL
:: Return to starting directory
POPD
:END_OF_FILE
exit /b 0
@@ -51,8 +51,8 @@ module_name = 'kitbash_converter.main'
log_file_path = os.path.join(settings.DCCSI_LOG_PATH, f'{module_name}.log')
_log_level = int(20)
_G_DEBUG = True
if _G_DEBUG:
_DCCSI_GDEBUG = True
if _DCCSI_GDEBUG:
_log_level = int(10)
from azpy.constants import FRMT_LOG_LONG
@@ -1,45 +0,0 @@
:: coding:utf-8
:: !/usr/bin/python
::
:: Copyright (c) Contributors to the Open 3D Engine Project.
:: For complete copyright and license terms please see the LICENSE at the root of this distribution.
::
:: SPDX-License-Identifier: Apache-2.0 OR MIT
::
::
@echo off
:: Set up and run LY Python CMD prompt
:: Sets up the DccScriptingInterface_Env,
:: Puts you in the CMD within the dev environment
:: Set up window
TITLE Lumberyard DCC Scripting Interface Cmd
:: Use obvious color to prevent confusion (Grey with Yellow Text)
COLOR 8E
%~d0
cd %~dp0
PUSHD %~dp0
:: Keep changes local
SETLOCAL enableDelayedExpansion
CALL %~dp0\Project_Env.bat
echo.
echo _____________________________________________________________________
echo.
echo ~ LY DCC Scripting Interface CMD ...
echo _____________________________________________________________________
echo.
:: Create command prompt with environment
CALL %windir%\system32\cmd.exe
ENDLOCAL
:: Return to starting directory
POPD
:END_OF_FILE
@@ -1,68 +0,0 @@
:: coding:utf-8
:: !/usr/bin/python
::
:: Copyright (c) Contributors to the Open 3D Engine Project.
:: For complete copyright and license terms please see the LICENSE at the root of this distribution.
::
:: SPDX-License-Identifier: Apache-2.0 OR MIT
::
::
@echo off
:: Launches maya with a bunch of local hooks for Lumberyard
:: ToDo: move all of this to a .json data driven boostrapping system
%~d0
cd %~dp0
PUSHD %~dp0
echo ________________________________
echo ~ calling PROJ_Env.bat
:: Keep changes local
SETLOCAL enableDelayedExpansion
:: PY version Major
set DCCSI_PY_VERSION_MAJOR=2
echo DCCSI_PY_VERSION_MAJOR = %DCCSI_PY_VERSION_MAJOR%
:: PY version Major
set DCCSI_PY_VERSION_MINOR=7
echo DCCSI_PY_VERSION_MINOR = %DCCSI_PY_VERSION_MINOR%
:: Maya Version
set MAYA_VERSION=2020
echo MAYA_VERSION = %MAYA_VERSION%
:: if a local customEnv.bat exists, run it
IF EXIST "%~dp0Project_Env.bat" CALL %~dp0Project_Env.bat
echo ________________________________
echo Launching Maya %MAYA_VERSION% for Lumberyard...
:::: Set Maya native project acess to this project
::set MAYA_PROJECT=%LY_PROJECT%
::echo MAYA_PROJECT = %MAYA_PROJECT%
:: DX11 Viewport
Set MAYA_VP2_DEVICE_OVERRIDE = VirtualDeviceDx11
:: Default to the right version of Maya if we can detect it... and launch
IF EXIST "%MAYA_LOCATION%\bin\Maya.exe" (
start "" "%MAYA_LOCATION%\bin\Maya.exe" %*
) ELSE (
Where maya.exe 2> NUL
IF ERRORLEVEL 1 (
echo Maya.exe could not be found
pause
) ELSE (
start "" Maya.exe %*
)
)
:: Return to starting directory
POPD
:END_OF_FILE
exit /b 0
@@ -1,81 +0,0 @@
:: coding:utf-8
:: !/usr/bin/python
::
:: Copyright (c) Contributors to the Open 3D Engine Project.
:: For complete copyright and license terms please see the LICENSE at the root of this distribution.
::
:: SPDX-License-Identifier: Apache-2.0 OR MIT
::
::
@echo off
:: Launches Wing IDE and the DccScriptingInterface Project Files
echo.
echo _____________________________________________________________________
echo.
echo ~ Setting up LY DCCsi WingIDE Dev Env...
echo _____________________________________________________________________
echo.
:: Store current dir
%~d0
cd %~dp0
PUSHD %~dp0
:: Keep changes local
SETLOCAL enableDelayedExpansion
SET ABS_PATH=%~dp0
echo Current Dir, %ABS_PATH%
:: WingIDE version Major
SET WING_VERSION_MAJOR=7
echo WING_VERSION_MAJOR = %WING_VERSION_MAJOR%
:: WingIDE version Major
SET WING_VERSION_MINOR=1
echo WING_VERSION_MINOR = %WING_VERSION_MINOR%
:: note the changed path from IDE to Pro
set WINGHOME=%PROGRAMFILES(X86)%\Wing Pro %WING_VERSION_MAJOR%.%WING_VERSION_MINOR%
echo WINGHOME = %WINGHOME%
CALL %~dp0\Project_Env.bat
echo.
echo _____________________________________________________________________
echo.
echo ~ WingIDE Version %WING_VERSION_MAJOR%.%WING_VERSION_MINOR%
echo _____________________________________________________________________
echo.
SET WING_PROJ=%DCCSIG_PATH%\Solutions\.wing\DCCsi_%WING_VERSION_MAJOR%x.wpr
echo WING_PROJ = %WING_PROJ%
echo.
echo _____________________________________________________________________
echo.
echo ~ Launching %LY_PROJECT% project in WingIDE %WING_VERSION_MAJOR%.%WING_VERSION_MINOR% ...
echo _____________________________________________________________________
echo.
IF EXIST "%WINGHOME%\bin\wing.exe" (
start "" "%WINGHOME%\bin\wing.exe" "%WING_PROJ%"
) ELSE (
Where wing.exe 2> NUL
IF ERRORLEVEL 1 (
echo wing.exe could not be found
pause
) ELSE (
start "" wing.exe "%WING_PROJ%"
)
)
ENDLOCAL
:: Return to starting directory
POPD
:END_OF_FILE
@@ -1,72 +0,0 @@
:: coding:utf-8
:: !/usr/bin/python
::
:: Copyright (c) Contributors to the Open 3D Engine Project.
:: For complete copyright and license terms please see the LICENSE at the root of this distribution.
::
:: SPDX-License-Identifier: Apache-2.0 OR MIT
::
::
@echo off
:: Sets up environment for Lumberyard DCC tools and code access
:: Store current dir
%~d0
cd %~dp0
PUSHD %~dp0
for %%a in (.) do set LY_PROJECT=%%~na
echo.
echo _____________________________________________________________________
echo.
echo ~ Setting up LY DSI PROJECT Environment ...
echo _____________________________________________________________________
echo.
echo LY_PROJECT = %LY_PROJECT%
:: Put you project env vars and overrides here
:: chanhe the relative path up to dev
set DEV_REL_PATH=../../..
set ABS_PATH=%~dp0
:: Override the default maya version
set MAYA_VERSION=2020
echo MAYA_VERSION = %MAYA_VERSION%
set LY_PROJECT_PATH=%ABS_PATH%
echo LY_PROJECT_PATH = %LY_PROJECT_PATH%
:: Change to root Lumberyard dev dir
CD /d %LY_PROJECT_PATH%\%DEV_REL_PATH%
set LY_DEV=%CD%
echo LY_DEV = %LY_DEV%
CALL %LY_DEV%\Gems\AtomLyIntegration\TechnicalArt\DccScriptingInterface\Launchers\Windows\Env.bat
rem :: Constant Vars (Global)
rem SET LYPY_GDEBUG=0
rem echo LYPY_GDEBUG = %LYPY_GDEBUG%
rem SET LYPY_DEV_MODE=0
rem echo LYPY_DEV_MODE = %LYPY_DEV_MODE%
rem SET LYPY_DEBUGGER=WING
rem echo LYPY_DEBUGGER = %LYPY_DEBUGGER%
:: Restore original directory
popd
:: Change to root dir
CD /D %ABS_PATH%
:: if the user has set up a custom env call it
IF EXIST "%~dp0User_Env.bat" CALL %~dp0User_Env.bat
GOTO END_OF_FILE
:: Return to starting directory
POPD
:END_OF_FILE
@@ -80,8 +80,8 @@ module_name = 'legacy_asset_converter.main'
log_file_path = os.path.join(settings.DCCSI_LOG_PATH, f'{module_name}.log')
_log_level = int(20)
_G_DEBUG = True
if _G_DEBUG:
_DCCSI_GDEBUG = True
if _DCCSI_GDEBUG:
_log_level = int(10)
from azpy.constants import FRMT_LOG_LONG
@@ -1,135 +0,0 @@
# -*- coding: utf-8 -*-
# !/usr/bin/python
#
# Copyright (c) Contributors to the Open 3D Engine Project.
# For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
#
# -------------------------------------------------------------------------
import pymel.core as pmc
import sys
import types
def syspath():
print 'sys.path:'
for p in sys.path:
print ' ' + p
def info(obj):
"""Prints information about the object."""
lines = ['Info for %s' % obj.name(),
'Attributes:']
# Get the name of all attributes
for a in obj.listAttr():
lines.append(' ' + a.name())
lines.append('MEL type: %s' % obj.type())
lines.append('MRO:')
lines.extend([' ' + t.__name__ for t in type(obj).__mro__])
result = '\n'.join(lines)
print result
def _is_pymel(obj):
try: # (1)
module = obj.__module__ # (2)
except AttributeError: # (3)
try:
module = obj.__name__ # (4)
except AttributeError:
return None # (5)
return module.startswith('pymel') # (6)
def _py_to_helpstr(obj):
if isinstance(obj, basestring):
return 'search.html?q=%s' % (obj.replace(' ', '+'))
if not _is_pymel(obj):
return None
if isinstance(obj, types.ModuleType):
return ('generated/%(module)s.html#module-%(module)s' %
dict(module=obj.__name__))
if isinstance(obj, types.MethodType):
return ('generated/classes/%(module)s/'
'%(module)s.%(typename)s.html'
'#%(module)s.%(typename)s.%(methname)s' % dict(
module=obj.__module__,
typename=obj.im_class.__name__,
methname=obj.__name__))
if isinstance(obj, types.FunctionType):
return ('generated/functions/%(module)s/'
'%(module)s.%(funcname)s.html'
'#%(module)s.%(funcname)s' % dict(
module=obj.__module__,
funcname=obj.__name__))
if not isinstance(obj, type):
obj = type(obj)
return ('generated/classes/%(module)s/'
'%(module)s.%(typename)s.html'
'#%(module)s.%(typename)s' % dict(
module=obj.__module__,
typename=obj.__name__))
def test_py_to_helpstr():
def dotest(obj, ideal):
result = _py_to_helpstr(obj)
assert result == ideal, '%s != %s' % (result, ideal)
dotest('maya rocks', 'search.html?q=maya+rocks')
dotest(pmc.nodetypes,
'generated/pymel.core.nodetypes.html'
'#module-pymel.core.nodetypes')
dotest(pmc.nodetypes.Joint,
'generated/classes/pymel.core.nodetypes/'
'pymel.core.nodetypes.Joint.html'
'#pymel.core.nodetypes.Joint')
dotest(pmc.nodetypes.Joint(),
'generated/classes/pymel.core.nodetypes/'
'pymel.core.nodetypes.Joint.html'
'#pymel.core.nodetypes.Joint')
dotest(pmc.nodetypes.Joint().getTranslation,
'generated/classes/pymel.core.nodetypes/'
'pymel.core.nodetypes.Joint.html'
'#pymel.core.nodetypes.Joint.getTranslation')
dotest(pmc.joint,
'generated/functions/pymel.core.animation/'
'pymel.core.animation.joint.html'
'#pymel.core.animation.joint')
dotest(object(), None)
dotest(10, None)
dotest([], None)
dotest(sys, None)
def test_py_to_helpstrFAIL():
assert 1 == 2, '1 != 2'
import webbrowser # (1)
HELP_ROOT_URL = ('http://help.autodesk.com/cloudhelp/2018/ENU/Maya-Tech-Docs/PyMel/')# (2)
def pmhelp(obj): # (3)
"""Gives help for a pymel or python object.
If obj is not a PyMEL object, use Python's built-in
`help` function.
If obj is a string, open a web browser to a search in the
PyMEL help for the string.
Otherwise, open a web browser to the page for the object.
"""
tail = _py_to_helpstr(obj)
if tail is None:
help(obj) # (4)
else:
webbrowser.open(HELP_ROOT_URL + tail) # (5)
if __name__ == '__main__':
test_py_to_helpstr()
print 'Tests ran successfully.'
@@ -23,7 +23,7 @@ def returnStubDir(stub):
break
if (len(tail) == 0):
path = ""
if _G_DEBUG:
if _DCCSI_GDEBUG:
print('~ Debug Message: I was not able to find the '
'path to that file (stub) in a walk-up from currnet path')
break
@@ -24,7 +24,7 @@ def returnStubDir(stub, start_path):
break
if (len(tail) == 0):
path = ""
if _G_DEBUG:
if _DCCSI_GDEBUG:
print('~ Debug Message: I was not able to find the '
'path to that file (stub) in a walk-up from currnet path')
break
@@ -42,7 +42,7 @@ from azpy.constants import ENVAR_DCCSI_GDEBUG
from azpy.constants import ENVAR_DCCSI_DEV_MODE
# global space
_G_DEBUG = env_bool(ENVAR_DCCSI_GDEBUG, True)
_DCCSI_GDEBUG = env_bool(ENVAR_DCCSI_GDEBUG, True)
_DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, True)
_MODULENAME = r'DCCsi.SDK.Maya.Scripts.set_callbacks'
@@ -37,7 +37,7 @@ from azpy.constants import ENVAR_DCCSI_GDEBUG
from azpy.constants import ENVAR_DCCSI_DEV_MODE
# global space
_G_DEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False)
_DCCSI_GDEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False)
_DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False)
_MODULENAME = r'DCCsi.SDK.Maya.Scripts.set_defaults'
@@ -37,7 +37,7 @@ from azpy.constants import ENVAR_DCCSI_GDEBUG
from azpy.constants import ENVAR_DCCSI_DEV_MODE
# global space
_G_DEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False)
_DCCSI_GDEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False)
_DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False)
_MODULENAME = r'DCCsi.SDK.Maya.Scripts.set_menu'
@@ -56,7 +56,7 @@ import maya.mel as mel
# -------------------------------------------------------------------------
# global space
_G_DEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False)
_DCCSI_GDEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False)
_DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False)
#_DCCSI_DEV_MODE = True # force true for debugger testing
@@ -69,7 +69,7 @@ _MODULENAME = str('{0}.{1}'.format(_APP_TAG, _TOOL_TAG))
_LOGGER = azpy.initialize_logger(_MODULENAME, default_log_level=int(20))
_LOGGER.info('Initializing: {0}.'.format({_MODULENAME}))
_LOGGER.info('DCCSI_GDEBUG: {0}.'.format({_G_DEBUG}))
_LOGGER.info('DCCSI_GDEBUG: {0}.'.format({_DCCSI_GDEBUG}))
_LOGGER.info('DCCSI_DEV_MODE: {0}.'.format({_DCCSI_DEV_MODE}))
# flag to turn off setting up callbacks, until they are fully implemented
@@ -175,17 +175,17 @@ try:
except Exception as e:
_LOGGER.critical(_STR_ERROR_ENVAR.format(_BASE_ENVVAR_DICT[ENVAR_DCCSI_SDK_PATH]))
_LY_PROJECT_PATH = None
_O3DE_PROJECT_PATH = None
try:
_LY_PROJECT_PATH = _BASE_ENVVAR_DICT[ENVAR_LY_PROJECT_PATH]
_O3DE_PROJECT_PATH = _BASE_ENVVAR_DICT[ENVAR_O3DE_PROJECT_PATH]
except Exception as e:
_LOGGER.critical(_STR_ERROR_ENVAR.format(_BASE_ENVVAR_DICT[ENVAR_LY_PROJECT_PATH]))
_LOGGER.critical(_STR_ERROR_ENVAR.format(_BASE_ENVVAR_DICT[ENVAR_O3DE_PROJECT_PATH]))
# check some env var tags (fail if no, likely means no proper code access)
_LY_DEV = _BASE_ENVVAR_DICT[ENVAR_LY_DEV]
_LY_DCCSIG_PATH = _BASE_ENVVAR_DICT[ENVAR_DCCSIG_PATH]
_LY_DCCSI_LOG_PATH = _BASE_ENVVAR_DICT[ENVAR_DCCSI_LOG_PATH]
_LY_AZPY_PATH = _BASE_ENVVAR_DICT[ENVAR_DCCSI_AZPY_PATH]
_O3DE_DEV = _BASE_ENVVAR_DICT[ENVAR_O3DE_DEV]
_O3DE_DCCSIG_PATH = _BASE_ENVVAR_DICT[ENVAR_DCCSIG_PATH]
_O3DE_DCCSI_LOG_PATH = _BASE_ENVVAR_DICT[ENVAR_DCCSI_LOG_PATH]
_O3DE_AZPY_PATH = _BASE_ENVVAR_DICT[ENVAR_DCCSI_AZPY_PATH]
# -------------------------------------------------------------------------
@@ -270,18 +270,18 @@ def post_startup():
install_fix_paths()
# set the project workspace
#_LY_PROJECT_PATH = _BASE_ENVVAR_DICT[ENVAR_LY_PROJECT_PATH]
_project_workspace = os.path.join(_LY_PROJECT_PATH, TAG_MAYA_WORKSPACE)
#_O3DE_PROJECT_PATH = _BASE_ENVVAR_DICT[ENVAR_O3DE_PROJECT_PATH]
_project_workspace = os.path.join(_O3DE_PROJECT_PATH, TAG_MAYA_WORKSPACE)
if os.path.isfile(_project_workspace):
try:
# load workspace
maya.cmds.workspace(_LY_PROJECT_PATH, openWorkspace=True)
maya.cmds.workspace(_O3DE_PROJECT_PATH, openWorkspace=True)
_LOGGER.info('Loaded workspace file: {0}'.format(_project_workspace))
maya.cmds.workspace(_LY_PROJECT_PATH, update=True)
maya.cmds.workspace(_O3DE_PROJECT_PATH, update=True)
except Exception as e:
_LOGGER.error(e)
else:
_LOGGER.warning('Workspace file not found: {1}'.format(_LY_PROJECT_PATH))
_LOGGER.warning('Workspace file not found: {1}'.format(_O3DE_PROJECT_PATH))
# Set up Lumberyard, maya default setting
from set_defaults import set_defaults
@@ -292,7 +292,7 @@ def post_startup():
_LOGGER.info('Add UI dependent tools')
# wrap in a try, because we haven't implmented it yet
try:
mel.eval(str(r'source "{}"'.format(TAG_LY_DCC_MAYA_MEL)))
mel.eval(str(r'source "{}"'.format(TAG_O3DE_DCC_MAYA_MEL)))
except Exception as e:
_LOGGER.error(e)
@@ -1,85 +0,0 @@
# Copyright (c) Contributors to the Open 3D Engine Project.
# For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
#
import bpy
import collections
import json
def get_shader_information():
"""
Queries all materials and corresponding material attributes and file textures in the Blender scene.
:return:
"""
# TODO - link file texture location to PBR material plugs- finding it difficult to track down how this is achieved
# in the Blender Python API documentation and/or in forums
materials_count = 1
shader_types = get_blender_shader_types()
materials_dictionary = {}
for target_mesh in [o for o in bpy.data.objects if type(o.data) is bpy.types.Mesh]:
material_information = collections.OrderedDict(DccApplication='Blender', AppliedMesh=target_mesh,
SceneName=bpy.data.filepath, MaterialAttributes={},
FileConnections={})
for target_material in target_mesh.data.materials:
material_information['MaterialName'] = target_material.name
shader_attributes = {}
shader_file_connections = {}
for node in target_material.node_tree.nodes:
socket = node.inputs[0]
print('NODE: {}'.format(node))
print('Socket: {}'.format(socket))
for material_input in node.inputs:
attribute_name = material_input.name
try:
attribute_value = material_input.default_value
print('Name: [{}] [{}] ValueType ::::::> {}'.format(attribute_name, attribute_value,
type(attribute_value)))
material_information['MaterialAttributes'].update({attribute_name: str(attribute_value)})
except Exception as e:
pass
print('\n')
if node.type == 'TEX_IMAGE':
material_information['FileConnections'].update({str(node): str(node.image.filepath)})
if node.name in shader_types.keys():
material_information['MaterialType'] = shader_types[node.name]
# material_information['MaterialAttributes'] = shader_attributes
materials_dictionary['Material_{}'.format(materials_count)] = material_information
materials_count += 1
print('_________________________________________________________________\n')
return materials_dictionary
def get_blender_shader_types():
"""
This returns all the material types present in the Blender scene
:return:
"""
shader_types = {}
ddir = lambda data, filter_str: [i for i in dir(data) if i.startswith(filter_str)]
get_nodes = lambda cat: [i for i in getattr(bpy.types, cat).category.items(None)]
cycles_categories = ddir(bpy.types, "NODE_MT_category_SH_NEW")
for cat in cycles_categories:
if cat == 'NODE_MT_category_SH_NEW_SHADER':
for node in get_nodes(cat):
shader_types[node.label] = node.nodetype
return shader_types
materials_dictionary = get_shader_information()
#print('Materials Dictionary:')
#print(materials_dictionary)
#parsed = json.loads(str(materials_dictionary))
#print(json.dumps(parsed, indent=4, sort_keys=True))
@@ -1,52 +0,0 @@
# coding:utf-8
#!/usr/bin/python
#
# Copyright (c) Contributors to the Open 3D Engine Project.
# For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
#
# -- This line is 75 characters -------------------------------------------
import click
import os
import main as app_main
@click.version_option('1.0.0')
@click.option('--output', default='PBR', help='Lumberyard material type. Current options: [pbr_basic]')
@click.argument('operands', type=click.STRING, nargs=-1)
@click.command(context_settings=dict(ignore_unknown_options=True))
def main(output, operands):
target_files = []
for index, operand in enumerate(operands):
entry_path = os.path.abspath(str(operand))
if os.path.isdir(entry_path):
for directory_path, directory_names, file_names in os.walk(entry_path):
for file_name in file_names:
if is_valid_file(file_name):
target_files.append(os.path.join(entry_path, file_name))
else:
if is_valid_file(operand):
target_files.append(operand)
if len(target_files):
app_main.launch_material_converter('standalone', output, target_files)
def is_valid_file(file_name):
"""
Allows only supported DCC application files by extensions
:param file_name: The name of the file.
:return:
"""
target_extensions = 'ma mb fbx blend max'.split(' ')
if file_name.split('.')[-1] in target_extensions:
return True
return False
if __name__ == '__main__':
main()
@@ -1,65 +0,0 @@
# coding:utf-8
#!/usr/bin/python
#
# Copyright (c) Contributors to the Open 3D Engine Project.
# For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
#
# -- This line is 75 characters -------------------------------------------
import logging
logging.basicConfig(level=logging.DEBUG)
def get_maya_material_mapping(name, material_type, file_connections):
"""
Helps map found material DCC attribute values/file connections with Lumberyard materials.
:param name: Material name from within Maya
:param material_type: Maya Material type to match values to (i.e. Stingray PBS, aiStandardSurface(Arnold)
:param file_connections: List of all connected texture files from Maya
:return: Key value pairs for attributes/file textures assigned as Lumberyard material values
"""
material_properties = {}
if material_type == 'StingrayPBS':
logging.debug('Mapping StingrayPBS')
maps = 'color, metallic, roughness, normal, emissive, ao, opacity'.split(', ')
naming_exceptions = {'color': 'baseColor', 'ao': 'ambientOcclusion'}
for m in maps:
texture_attribute = 'TEX_{}_map'.format(m)
for tex in file_connections.keys():
if tex.find(texture_attribute) != -1:
key = m if m not in naming_exceptions else naming_exceptions.get(m)
logging.debug('Key, Value: {} {}.{}'.format(key, name, texture_attribute))
material_properties[key] = {'useTexture': 'true',
'textureMap': file_connections.get(
'{}.{}'.format(name, texture_attribute))}
elif material_type == 'aiStandardSurface':
logging.debug('Mapping AiStandardSurface')
# TODO- Occlusion is based on a more difficult setup- there is no standard channel. Set this up as time permits
maps = 'baseColor, metalness, specularRoughness, normal, emissionColor, opacity'.split(', ')
naming_exceptions = {'metalness': 'metallic', 'specularRoughness': 'roughness', 'emissionColor': 'emissive'}
for m in maps:
key = m if m not in naming_exceptions.keys() else naming_exceptions.get(m)
texture_attribute = m
for tex in file_connections.keys():
if tex.find(texture_attribute) != -1:
logging.debug('Key, Value: {} {}.{}'.format(key, name, texture_attribute))
material_properties[key] = {'useTexture': 'true',
'textureMap': file_connections.get(
'{}.{}'.format(name, texture_attribute))}
else:
pass
return material_properties
def get_blender_material_mapping(name, material_type, file_connections):
pass
def get_max_material_mapping(name, material_type, file_connections):
pass
@@ -1,65 +0,0 @@
# coding:utf-8
#!/usr/bin/python
#
# Copyright (c) Contributors to the Open 3D Engine Project.
# For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
#
# -- This line is 75 characters -------------------------------------------
from PySide2 import QtWidgets, QtCore
from PySide2.QtCore import Signal
class DragAndDrop(QtWidgets.QWidget):
drop_update = QtCore.Signal(list)
drop_over = QtCore.Signal(bool)
def __init__(self, frame_color=None, highlight=None, parent=None):
super(DragAndDrop, self).__init__(parent)
self.urls = []
self.frame_color = frame_color
self.frame_highlight = highlight
self.setContentsMargins(0, 0, 0, 0)
self.setAcceptDrops(True)
self.drag_and_drop_frame = QtWidgets.QFrame(self)
self.drag_and_drop_frame.setGeometry(0, 0, 5000, 5000)
self.drag_and_drop_frame.setStyleSheet('background-color:rgb({});'.format(self.frame_color))
def dragEnterEvent(self, e):
if e.mimeData().hasUrls:
e.accept()
self.drop_over.emit(True)
if self.frame_highlight:
self.drag_and_drop_frame.setStyleSheet('background-color:rgb({});'.format(self.frame_highlight))
else:
e.ignore()
def dragLeaveEvent(self, e):
self.drop_over.emit(False)
if self.frame_highlight:
self.drag_and_drop_frame.setStyleSheet('background-color:rgb({});'.format(self.frame_color))
def dragMoveEvent(self, e):
if e.mimeData().hasUrls:
e.accept()
else:
e.ignore()
def dropEvent(self, e):
if e.mimeData().hasUrls:
e.setDropAction(QtCore.Qt.CopyAction)
e.accept()
for url in e.mimeData().urls():
file_name = str(url.toLocalFile())
self.urls.append(file_name)
self.drop_update.emit(self.urls)
if self.frame_highlight:
self.drag_and_drop_frame.setStyleSheet('background-color:rgb({});'.format(self.frame_color))
else:
e.ignore()
@@ -1,85 +0,0 @@
@echo off
REM
REM Copyright (c) Contributors to the Open 3D Engine Project.
REM For complete copyright and license terms please see the LICENSE at the root of this distribution.
REM
REM SPDX-License-Identifier: Apache-2.0 OR MIT
REM
REM
:: Set up and run LY Python CMD prompt
:: Sets up the DccScriptingInterface_Env,
:: Puts you in the CMD within the dev environment
:: Set up window
TITLE Lumberyard DCC Scripting Interface Cmd
:: Use obvious color to prevent confusion (Grey with Yellow Text)
COLOR 8E
%~d0
cd %~dp0
:: Keep changes local
SETLOCAL enableDelayedExpansion
:: This maps up to the \Dev folder
IF "%DEV_REL_PATH%"=="" (set DEV_REL_PATH=..\..\..\..\..\..\..)
:: Change to root Lumberyard dev dir
:: Don't use the LY_DEV so we can test that ENVAR!!!
CD /d %DEV_REL_PATH%
set Rel_Dev=%CD%
echo Rel_Dev = %Rel_Dev%
:: Restore original directory
popd
set DCCSI_PYTHON_INSTALL=%Rel_Dev%\Tools\Python\3.7.5\windows
:: add to the PATH
SET PATH=%DCCSI_PYTHON_INSTALL%;%PATH%
:: dcc scripting interface gem path
set DCCSIG_PATH=%Rel_Dev%\Gems\AtomLyIntegration\TechnicalArt\DccScriptingInterface
echo DCCSIG_PATH = %DCCSIG_PATH%
:: add to the PATH
SET PATH=%DCCSIG_PATH%;%PATH%
:: Constant Vars (Global)
:: global debug (propogates)
IF "%DCCSI_GDEBUG%"=="" (set DCCSI_GDEBUG=false)
echo DCCSI_GDEBUG = %DCCSI_GDEBUG%
:: initiates debugger connection
IF "%DCCSI_DEV_MODE%"=="" (set DCCSI_DEV_MODE=false)
echo DCCSI_DEV_MODE = %DCCSI_DEV_MODE%
:: sets debugger, options: WING, PYCHARM
IF "%DCCSI_GDEBUGGER%"=="" (set DCCSI_GDEBUGGER=WING)
echo DCCSI_GDEBUGGER = %DCCSI_GDEBUGGER%
echo.
echo _____________________________________________________________________
echo.
echo ~ LY DCCsi, DCC Material Converter
echo _____________________________________________________________________
echo.
:: Change to root dir
CD /D %DCCSIG_PATH%
:: add to the PATH
SET PATH=%DCCSIG_PATH%;%PATH%
set PYTHONPATH=%DCCSIG_PATH%;%PYTHONPATH%
CALL %DCCSI_PYTHON_INSTALL%\python.exe "%DCCSIG_PATH%\SDK\PythonTools\DCC_Material_Converter\standalone.py"
ENDLOCAL
:: Return to starting directory
POPD
:END_OF_FILE
exit /b 0
@@ -1,169 +0,0 @@
# Copyright (c) Contributors to the Open 3D Engine Project.
# For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
from PySide2 import QtCore
import maya.standalone
maya.standalone.initialize(name='python')
import maya.cmds as mc
import collections
import logging
import json
import sys
import os
for handler in logging.root.handlers[:]:
logging.root.removeHandler(handler)
logging.basicConfig(level=logging.INFO,
format='%(name)s - %(levelname)s - %(message)s',
datefmt='%m-%d %H:%M',
filename='output.log',
filemode='w')
class MayaMaterials(QtCore.QObject):
def __init__(self, files_list, materials_count, parent=None):
super(MayaMaterials, self).__init__(parent)
self.files_list = files_list
self.current_scene = None
self.materials_dictionary = {}
self.materials_count = int(materials_count)
self.get_material_information()
def get_material_information(self):
"""
Main entry point for the material information extraction. Because this class is run
in Standalone mode as a subprocess, the list is passed as a string- some parsing/measures
need to be taken in order to separate values that originated as a list before passed.
:return: A dictionary of all of the materials gathered. Sent back to main UI through stdout
"""
for target_file in file_list:
self.current_scene = os.path.abspath(target_file.replace('\'', ''))
mc.file(self.current_scene, open=True, force=True)
self.set_material_descriptions()
json.dump(self.materials_dictionary, sys.stdout)
@staticmethod
def get_materials(target_mesh):
"""
Gathers a list of all materials attached to each mesh's shader
:param target_mesh: The target mesh to pull attached material information from.
:return: List of unique material values attached to the mesh passed as an argument.
"""
shading_group = mc.listConnections(target_mesh, type='shadingEngine')
materials = mc.ls(mc.listConnections(shading_group), materials=1)
return list(set(materials))
@staticmethod
def get_shader(material_name):
"""
Convenience function for obtaining the shader that the specified material (as an argument)
is attached to.
:param material_name: Takes the material name as an argument to get associated shader object
:return:
"""
connections = mc.listConnections(material_name, type='shadingEngine')[0]
shader_name = '{}.surfaceShader'.format(connections)
shader = mc.listConnections(shader_name)[0]
return shader
def get_shader_information(self, shader, material_mesh):
"""
Helper function for extracting shader/material attributes used to form the DCC specific dictionary
of found material values for conversion.
:param shader: The target shader object to analyze
:param material_mesh: The material mesh needs to be passed to search for textures attached to it.
:return: Complete set (in the form of two dictionaries) of file connections and material attribute values
"""
shader_file_connections = {}
materials = self.get_materials(material_mesh)
for material in materials:
material_files = [x for x in mc.listConnections(material, plugs=1, source=1) if x.startswith('file')]
for file_name in material_files:
file_texture = mc.getAttr('{}.fileTextureName'.format(file_name.split('.')[0]))
if os.path.basename(file_texture).split('.')[-1] != 'dds':
key_name = mc.listConnections(file_name, plugs=1, source=1)[0]
shader_file_connections[key_name] = file_texture
shader_attributes = {}
for shader_attribute in mc.listAttr(shader, s=True, iu=True):
try:
shader_attributes[str(shader_attribute)] = str(mc.getAttr('{}.{}'.format(shader, shader_attribute)))
except Exception as e:
logging.error('MayaAttributeError: {}'.format(e))
return shader_file_connections, shader_attributes
def set_material_dictionary(self, material_name, material_type, material_mesh):
"""
When a unique material has been found, this creates a dictionary entry with all relevant material values. This
includes material attributes as well as attached file textures. Later in the process this information is
leveraged when creating the Lumberyard material definition.
:param material_name: The name attached to the material
:param material_type: Specific type of material (Arnold, Stingray, etc.)
:param material_mesh: Mesh that the material is applied to
:return:
"""
self.materials_count += 1
shader = self.get_shader(material_name)
shader_file_connections, shader_attributes = self.get_shader_information(shader, material_mesh)
material_dictionary = collections.OrderedDict(MaterialName=material_name, MaterialType=material_type,
DccApplication='Maya', AppliedMesh=material_mesh,
FileConnections=shader_file_connections,
SceneName=str(self.current_scene),
MaterialAttributes=shader_attributes)
material_name = 'Material_{}'.format(self.materials_count)
self.materials_dictionary[material_name] = material_dictionary
logging.info('\n\n:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::\n'
'MATERIAL DEFINITION: {} \n'
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::\n{}'.format(
self.materials_dictionary[material_name]['MaterialType'],
json.dumps(self.materials_dictionary[material_name], indent=4)))
def set_material_descriptions(self):
"""
This function serves as the clearinghouse for all analyzed materials passing through the system.
It will determine whether or not the found material has already been processed, or if it needs to
be added to the final material dictionary. In the event that an encountered material has already
been processed, this function creates a register of all meshes it is applied to in the 'AppliedMesh'
attribute.
:return:
"""
scene_geo = mc.ls(v=True, geometry=True)
for target_mesh in scene_geo:
material_list = self.get_materials(target_mesh)
for material_name in material_list:
material_type = mc.nodeType(material_name)
if material_type != 'lambert':
material_listed = [x for x in self.materials_dictionary
if self.materials_dictionary[x]['MaterialName'] == material_name]
if not material_listed:
self.set_material_dictionary(str(material_name), str(material_type), str(target_mesh))
else:
mesh_list = self.materials_dictionary[material_name].get('AppliedMesh')
if not isinstance(mesh_list, list):
self.materials_dictionary[str(material_name)]['AppliedMesh'] = [mesh_list, target_mesh]
else:
mesh_list.append(target_mesh)
# ++++++++++++++++++++++++++++++++++++++++++++++++#
# Maya Specific Shader Mapping #
# ++++++++++++++++++++++++++++++++++++++++++++++++#
file_list = sys.argv[1:-1]
count = sys.argv[-1]
instance = MayaMaterials(file_list, count)
@@ -1,154 +0,0 @@
# Copyright (c) Contributors to the Open 3D Engine Project.
# For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
#
from PySide2.QtCore import QAbstractItemModel, QModelIndex, Qt
class MaterialsModel(QAbstractItemModel):
def __init__(self, headers, data, parent=None):
super(MaterialsModel, self).__init__(parent)
self.rootItem = TreeNode(headers)
self.parents = [self.rootItem]
self.indentations = [0]
self.create_data(data)
def create_data(self, data, indent=-1):
"""
Recursive loop that structures Model data into tree form.
:param data: Row information.
:param indent: Column information. This helps to facilitate the creation of nested rows.
:return:
"""
if type(data) == dict:
indent += 1
position = 4 * indent
for key, value in data.items():
if position > self.indentations[-1]:
if self.parents[-1].childCount() > 0:
self.parents.append(self.parents[-1].child(self.parents[-1].childCount() - 1))
self.indentations.append(position)
else:
while position < self.indentations[-1] and len(self.parents) > 0:
self.parents.pop()
self.indentations.pop()
parent = self.parents[-1]
parent.insertChildren(parent.childCount(), 1, parent.columnCount())
parent.child(parent.childCount() - 1).setData(0, key)
value_string = str(value) if type(value) != dict else str('')
parent.child(parent.childCount() - 1).setData(1, value_string)
try:
self.create_data(value, indent)
except RuntimeError:
pass
@staticmethod
def get_attribute_value(search_string, search_column):
""" Convenience function for quickly accessing row information based on attribute keys. """
for childIndex in range(search_column.childCount()):
child_item = search_column.child(childIndex)
child_value = child_item.itemData
if child_value[0] == search_string:
return child_value[1]
return None
def index(self, row, column, index=QModelIndex()):
""" Returns the index of the item in the model specified by the given row, column and parent index """
if not self.hasIndex(row, column, index):
return QModelIndex()
if not index.isValid():
item = self.rootItem
else:
item = index.internalPointer()
child = item.child(row)
if child:
return self.createIndex(row, column, child)
return QModelIndex()
def parent(self, index):
"""
Returns the parent of the model item with the given index If the item has no parent,
an invalid QModelIndex is returned
"""
if not index.isValid():
return QModelIndex()
item = index.internalPointer()
if not item:
return QModelIndex()
parent = item.parentItem
if parent == self.rootItem:
return QModelIndex()
else:
return self.createIndex(parent.childNumber(), 0, parent)
def rowCount(self, index=QModelIndex()):
"""
Returns the number of rows under the given parent. When the parent is valid it means that
rowCount is returning the number of children of parent
"""
if index.isValid():
parent = index.internalPointer()
else:
parent = self.rootItem
return parent.childCount()
def columnCount(self, index=QModelIndex()):
""" Returns the number of columns for the children of the given parent """
return self.rootItem.columnCount()
def data(self, index, role=Qt.DisplayRole):
""" Returns the data stored under the given role for the item referred to by the index """
if index.isValid() and role == Qt.DisplayRole:
return index.internalPointer().data(index.column())
elif not index.isValid():
return self.rootItem.data(index.column())
def headerData(self, section, orientation, role=Qt.DisplayRole):
""" Returns the data for the given role and section in the header with the specified orientation """
if orientation == Qt.Horizontal and role == Qt.DisplayRole:
return self.rootItem.data(section)
class TreeNode(object):
def __init__(self, data, parent=None):
self.parentItem = parent
self.itemData = data
self.children = []
def child(self, row):
return self.children[row]
def childCount(self):
return len(self.children)
def childNumber(self):
if self.parentItem is not None:
return self.parentItem.children.index(self)
def columnCount(self):
return len(self.itemData)
def data(self, column):
return self.itemData[column]
def insertChildren(self, position, count, columns):
if position < 0 or position > len(self.children):
return False
for row in range(count):
data = [v for v in range(columns)]
item = TreeNode(data, self)
self.children.insert(position, item)
def parent(self):
return self.parentItem
def setData(self, column, value):
if column < 0 or column >= len(self.itemData):
return False
self.itemData[column] = value
@@ -1,37 +0,0 @@
# coding:utf-8
#!/usr/bin/python
#
# Copyright (c) Contributors to the Open 3D Engine Project.
# For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
"""Boostraps and Starts Standalone DCC Material Converter utility"""
# built in's
import os
import site
# -------------------------------------------------------------------------
# \dev\Gems\AtomLyIntegration\TechnicalArt\DccScriptingInterface\SDK\PythonTools\DCC_Material_Converter\standalone.py
_MODULE_PATH = os.path.abspath(__file__)
_DCCSIG_REL_PATH = "../../../.."
_DCCSIG_PATH = os.path.join(_MODULE_PATH, _DCCSIG_REL_PATH)
_DCCSIG_PATH = os.path.normpath(_DCCSIG_PATH)
_DCCSIG_PATH = os.getenv('DCCSIG_PATH',
os.path.abspath(_DCCSIG_PATH))
# we don't have access yet to the DCCsi Lib\site-packages
site.addsitedir(_DCCSIG_PATH) # PYTHONPATH
# azpy bootstrapping and extensions
import azpy.config_utils
_config = azpy.config_utils.get_dccsi_config()
settings = _config.get_config_settings(setup_ly_pyside=True)
from main import launch_material_converter
launch_material_converter()
@@ -1,74 +0,0 @@
# coding:utf-8
#!/usr/bin/python
# coding:utf-8
#!/usr/bin/python
#
# Copyright (c) Contributors to the Open 3D Engine Project.
# For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
#
# -- This line is 75 characters -------------------------------------------
# built-ins
import os
import sys
import logging as _logging
# azpy extensions
import azpy.config_utils
_config = azpy.config_utils.get_dccsi_config()
settings = _config.get_config_settings(setup_ly_pyside=True)
# 3rd Party (we may or do provide)
from pathlib import Path
from pathlib import PurePath
# Lumberyard extensions
from azpy.env_bool import env_bool
from azpy.constants import ENVAR_DCCSI_GDEBUG
from azpy.constants import ENVAR_DCCSI_DEV_MODE
# -------------------------------------------------------------------------
# set up global space, logging etc.
_G_DEBUG = env_bool(ENVAR_DCCSI_GDEBUG, settings.DCCSI_GDEBUG)
_DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, settings.DCCSI_GDEBUG)
for handler in _logging.root.handlers[:]:
_logging.root.removeHandler(handler)
_MODULENAME = 'DCCsi.SDK.pythontools.launcher.main'
_log_level = _logging.INFO
if _G_DEBUG:
_log_level = _logging.DEBUG
_LOGGER = azpy.initialize_logger(name=_MODULENAME,
log_to_file=True,
default_log_level=_log_level)
_LOGGER.debug('Starting up: {0}.'.format({_MODULENAME}))
# -------------------------------------------------------------------------
# -------------------------------------------------------------------------
def main():
from PySide2.QtWidgets import QApplication, QPushButton
app = QApplication(sys.argv)
# -------------------------------------------------------------------------
# --------------------------------------------------------------------------
if __name__ == '__main__':
"""Run this file as main"""
app = QApplication([]) # Start an application.
window = QWidget() # Create a window.
layout = QVBoxLayout() # Create a layout.
button = QPushButton("I'm just a Button man") # Define a button
layout.addWidget(QLabel('Hello World!')) # Add a label
layout.addWidget(button) # Add the button man
window.setLayout(layout) # Pass the layout to the window
window.show() # Show window
app.exec_() # Execute the App
@@ -29,7 +29,7 @@ from pathlib import Path
# -------------------------------------------------------------------------
# set up global space, logging etc.
_G_DEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False)
_DCCSI_GDEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False)
_DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False)
_PACKAGENAME = __name__
@@ -34,20 +34,20 @@ from azpy.constants import ENVAR_DCCSI_GDEBUG
from azpy.constants import ENVAR_DCCSI_DEV_MODE
# these are for module debugging, set to false on submit
_G_DEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False)
_DCCSI_GDEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False)
_DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False)
_PACKAGENAME = 'DCCsi.SDK.substance.builder.bootstrap'
_log_level = int(20)
if _G_DEBUG:
if _DCCSI_GDEBUG:
_log_level = int(10)
_LOGGER = azpy.initialize_logger(_PACKAGENAME,
log_to_file=True,
default_log_level=_log_level)
_LOGGER.debug('Starting up: {0}.'.format({_PACKAGENAME}))
_LOGGER.debug('_DCCSIG_PATH: {}'.format(_DCCSIG_PATH))
_LOGGER.debug('_G_DEBUG: {}'.format(_G_DEBUG))
_LOGGER.debug('_G_DEBUG: {}'.format(_DCCSI_GDEBUG))
_LOGGER.debug('_DCCSI_DEV_MODE: {}'.format(_DCCSI_DEV_MODE))
if _DCCSI_DEV_MODE:
@@ -69,7 +69,7 @@ from dynaconf import settings
try:
from PySide2.QtWidgets import QApplication
except:
_dccsi_config.init_ly_pyside(settings.LY_DEV) # init for standalone
_dccsi_config.init_o3de_pyside(settings.O3DE_DEV) # init for standalone
# running in the editor if the QtForPython Gem is enabled
# you should already have access and shouldn't need to set up
@@ -92,20 +92,20 @@ os.environ["PYSBS_DIR_PATH"] = str(_PYSBS_DIR_PATH)
# standard paths we may use downstream
# To Do: move these into a dynaconf config extension specific to this tool?
from azpy.constants import ENVAR_LY_DEV
_LY_DEV = Path(os.getenv(ENVAR_LY_DEV,
settings.LY_DEV)).resolve()
from azpy.constants import ENVAR_O3DE_DEV
_O3DE_DEV = Path(os.getenv(ENVAR_O3DE_DEV,
settings.O3DE_DEV)).resolve()
from azpy.constants import ENVAR_LY_PROJECT_PATH
_LY_PROJECT_PATH = Path(os.getenv(ENVAR_LY_PROJECT_PATH,
settings.LY_PROJECT_PATH)).resolve()
from azpy.constants import ENVAR_O3DE_PROJECT_PATH
_O3DE_PROJECT_PATH = Path(os.getenv(ENVAR_O3DE_PROJECT_PATH,
settings.O3DE_PROJECT_PATH)).resolve()
from azpy.constants import ENVAR_DCCSI_SDK_PATH
_DCCSI_SDK_PATH = Path(os.getenv(ENVAR_DCCSI_SDK_PATH,
settings.DCCSIG_SDK_PATH)).resolve()
# build some reuseable path parts for the substance builder
_PROJECT_ASSETS_PATH = Path(_LY_PROJECT_PATH, 'Assets').resolve()
_PROJECT_ASSETS_PATH = Path(_O3DE_PROJECT_PATH, 'Assets').resolve()
_PROJECT_MATERIALS_PATH = Path(_PROJECT_ASSETS_PATH, 'Materials').resolve()
# -------------------------------------------------------------------------
@@ -116,15 +116,15 @@ _PROJECT_MATERIALS_PATH = Path(_PROJECT_ASSETS_PATH, 'Materials').resolve()
if __name__ == "__main__":
"""Run this file as main"""
_LOGGER.info('_LY_DEV: {}'.format(_LY_DEV))
_LOGGER.info('_LY_PROJECT_PATH: {}'.format(_LY_PROJECT_PATH))
_LOGGER.info('_O3DE_DEV: {}'.format(_O3DE_DEV))
_LOGGER.info('_O3DE_PROJECT_PATH: {}'.format(_O3DE_PROJECT_PATH))
_LOGGER.info('_DCCSI_SDK_PATH: {}'.format(_DCCSI_SDK_PATH))
_LOGGER.info('_PYSBS_DIR_PATH: {}'.format(_PYSBS_DIR_PATH))
_LOGGER.info('_PROJECT_ASSETS_PATH: {}'.format(_PROJECT_ASSETS_PATH))
_LOGGER.info('_PROJECT_MATERIALS_PATH: {}'.format(_PROJECT_MATERIALS_PATH))
if _G_DEBUG:
if _DCCSI_GDEBUG:
_dccsi_config.test_pyside2() # runs a small PySdie2 test
# remove the logger
@@ -35,7 +35,7 @@ from azpy.constants import ENVAR_DCCSI_GDEBUG
from azpy.constants import ENVAR_DCCSI_DEV_MODE
# set up global space, logging etc.
_G_DEBUG = env_bool(ENVAR_DCCSI_GDEBUG, settings.DCCSI_GDEBUG)
_DCCSI_GDEBUG = env_bool(ENVAR_DCCSI_GDEBUG, settings.DCCSI_GDEBUG)
_DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, settings.DCCSI_GDEBUG)
for handler in _logging.root.handlers[:]:
@@ -44,7 +44,7 @@ for handler in _logging.root.handlers[:]:
_MODULENAME = 'DCCsi.SDK.substance.builder.sb_gui_main'
_log_level = _logging.INFO
if _G_DEBUG:
if _DCCSI_GDEBUG:
_log_level = _logging.DEBUG
_LOGGER = azpy.initialize_logger(name=_MODULENAME,
@@ -71,12 +71,12 @@ import config
_LOGGER.debug('config.py is: {}'.format(config))
# initialize the Lumberyard Qt / PySide2
config.init_ly_pyside(settings.LY_DEV) # for standalone
config.init_o3de_pyside(settings.O3DE_DEV) # for standalone
settings.setenv() # for standalone
# log debug info about Qt/PySide2
_LOGGER.debug('QTFORPYTHON_PATH: {}'.format(settings.QTFORPYTHON_PATH))
_LOGGER.debug('LY_BIN_PATH: {}'.format(settings.LY_BIN_PATH))
_LOGGER.debug('O3DE_BIN_PATH: {}'.format(settings.O3DE_BIN_PATH))
_LOGGER.debug('QT_PLUGIN_PATH: {}'.format(settings.QT_PLUGIN_PATH))
_LOGGER.debug('QT_QPA_PLATFORM_PLUGIN_PATH: {}'.format(settings.QT_QPA_PLATFORM_PLUGIN_PATH))
# -------------------------------------------------------------------------
@@ -123,26 +123,26 @@ from atom_material import AtomMaterial
# -------------------------------------------------------------------------
# To Do: still should manage via dynaconf (dynamic config and settings)
from azpy.constants import ENVAR_LY_DEV
_LY_DEV = Path(os.getenv(ENVAR_LY_DEV, None)).resolve()
from azpy.constants import ENVAR_O3DE_DEV
_O3DE_DEV = Path(os.getenv(ENVAR_O3DE_DEV, None)).resolve()
from azpy.constants import ENVAR_LY_PROJECT
_LY_PROJECT = os.getenv(ENVAR_LY_PROJECT, None)
from azpy.constants import ENVAR_O3DE_PROJECT
_O3DE_PROJECT = os.getenv(ENVAR_O3DE_PROJECT, None)
from azpy.constants import ENVAR_LY_PROJECT_PATH
_LY_PROJECT_PATH = Path(os.getenv(ENVAR_LY_PROJECT_PATH, None)).resolve()
from azpy.constants import ENVAR_O3DE_PROJECT_PATH
_O3DE_PROJECT_PATH = Path(os.getenv(ENVAR_O3DE_PROJECT_PATH, None)).resolve()
from azpy.constants import ENVAR_DCCSI_SDK_PATH
_DCCSI_SDK_PATH = Path(os.getenv(ENVAR_DCCSI_SDK_PATH, None)).resolve()
# build some reuseable path parts
_PROJECT_ASSET_PATH = Path(_LY_PROJECT_PATH).resolve()
_PROJECT_ASSETS_PATH = Path(_LY_PROJECT_PATH, 'Materials').resolve()
_PROJECT_ASSET_PATH = Path(_O3DE_PROJECT_PATH).resolve()
_PROJECT_ASSETS_PATH = Path(_O3DE_PROJECT_PATH, 'Materials').resolve()
# To Do: figure out a proper way to deal with Lumberyard game projects
_GEM_MATPLAY_PATH = Path(_LY_DEV, 'Gems', 'AtomContent', 'AtomMaterialPlayground').resolve()
_GEM_ROYALTYFREE = Path(_LY_DEV, 'Gems', 'AtomContent', 'RoyaltyFreeAssets').resolve()
_GEM_SUBSOURCELIBRARY = Path(_LY_DEV, 'Gems', 'AtomContent', 'SubstanceSourceLibrary').resolve()
_GEM_MATPLAY_PATH = Path(_O3DE_DEV, 'Gems', 'AtomContent', 'AtomMaterialPlayground').resolve()
_GEM_ROYALTYFREE = Path(_O3DE_DEV, 'Gems', 'AtomContent', 'RoyaltyFreeAssets').resolve()
_GEM_SUBSOURCELIBRARY = Path(_O3DE_DEV, 'Gems', 'AtomContent', 'SubstanceSourceLibrary').resolve()
_SUB_LIBRARY_PATH = Path(_GEM_SUBSOURCELIBRARY, 'Assets', 'SubstanceSource', 'Library').resolve()
# ^ This hard codes a bunch of known asset gems, again bad
# To Do: figure out a proper way to scrap the gem registry from project
@@ -150,9 +150,9 @@ _SUB_LIBRARY_PATH = Path(_GEM_SUBSOURCELIBRARY, 'Assets', 'SubstanceSource', 'Li
# path to watcher script
_WATCHER_SCRIPT_PATH = Path(_DCCSI_SDK_PATH, 'substance', 'builder', 'watchdog', '__init__.py').resolve()
_TEX_RNDR_PATH = Path(_LY_PROJECT_PATH, 'Materials', 'Substance').resolve()
_MAT_OUTPUT_PATH = Path(_LY_PROJECT_PATH, 'Materials', 'Substance').resolve()
_SBSAR_COOK_PATH = Path(_LY_PROJECT_PATH, 'Materials', 'Substance').resolve()
_TEX_RNDR_PATH = Path(_O3DE_PROJECT_PATH, 'Materials', 'Substance').resolve()
_MAT_OUTPUT_PATH = Path(_O3DE_PROJECT_PATH, 'Materials', 'Substance').resolve()
_SBSAR_COOK_PATH = Path(_O3DE_PROJECT_PATH, 'Materials', 'Substance').resolve()
# -------------------------------------------------------------------------
@@ -171,7 +171,7 @@ class Window(QtWidgets.QDialog):
# we should really init non-Qt stuff and set things up as properties
if project_path is None:
self.project_path = str(_LY_PROJECT_PATH)
self.project_path = str(_O3DE_PROJECT_PATH)
else:
self.project_path = Path(project_path)
@@ -213,7 +213,7 @@ class Window(QtWidgets.QDialog):
self.matOutputPathComboBox = self.createComboBox(str(_MAT_OUTPUT_PATH))
# self.directoryComboBox = self.createComboBox(QtCore.QDir.currentPath())
# I changed this to scan the _LY_PROJECT
# I changed this to scan the _O3DE_PROJECT
# self.sbsarDirectory = self.return_1st_sbsar(Path(self.project_path, 'Assets')).resolve().parent
self.sbsarDirectory = QtCore.QDir()
self.sbsarDirectory.setCurrent(str(_PROJECT_ASSET_PATH))
@@ -672,13 +672,13 @@ class Window(QtWidgets.QDialog):
# if you want relative paths here is a better way
# first of all, assume we know the project we are in
#_LY_PROJECT_PATH
#_O3DE_PROJECT_PATH
texture_output_path = Path(self.texRenderPathComboBox.currentText()).resolve()
rel_tex_path = None
for p in texture_output_path.parts:
if _LY_PROJECT == p:
index = texture_output_path.parts.index(_LY_PROJECT)
if _O3DE_PROJECT == p:
index = texture_output_path.parts.index(_O3DE_PROJECT)
rel_tuple = texture_output_path.parts[index + 1:]
rel_tex_path = Path(*list(rel_tuple))
@@ -47,7 +47,7 @@ import pysbs.context as pysbs_context
# -------------------------------------------------------------------------
# set up global space, logging etc.
_G_DEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False)
_DCCSI_GDEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False)
_DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False)
_PACKAGENAME = __name__
@@ -68,10 +68,10 @@ _SYNTH_ENV_DICT = OrderedDict()
_SYNTH_ENV_DICT = azpy.synthetic_env.stash_env(_SYNTH_ENV_DICT)
# grab a specific path from the base_env
_PATH_DCCSI = _SYNTH_ENV_DICT[ENVAR_DCCSIG_PATH]
_LY_PROJECT_PATH = _SYNTH_ENV_DICT[ENVAR_LY_PROJECT_PATH]
_O3DE_PROJECT_PATH = _SYNTH_ENV_DICT[ENVAR_O3DE_PROJECT_PATH]
# build some reuseable path parts
_PATH_MOCK_ASSETS = Path(_LY_PROJECT_PATH, 'Assets').norm()
_PATH_MOCK_ASSETS = Path(_O3DE_PROJECT_PATH, 'Assets').norm()
_PATH_MOCK_SUBLIB = Path(_PATH_MOCK_ASSETS, 'SubstanceSource').norm()
_PATH_MOCK_SBS = Path(_PATH_MOCK_SUBLIB, 'sbs').norm()
@@ -47,7 +47,7 @@ import pysbs.context as pysbs_context
# -------------------------------------------------------------------------
# set up global space, logging etc.
_G_DEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False)
_DCCSI_GDEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False)
_DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False)
_PACKAGENAME = __name__
@@ -62,7 +62,7 @@ _LOGGER.debug('Starting up: {0}.'.format({_PACKAGENAME}))
# -------------------------------------------------------------------------
# global space debug flag
_G_DEBUG = os.getenv(ENVAR_DCCSI_GDEBUG, False)
_DCCSI_GDEBUG = os.getenv(ENVAR_DCCSI_GDEBUG, False)
# global space debug flag
_DCCSI_DEV_MODE = os.getenv(ENVAR_DCCSI_DEV_MODE, False)
@@ -88,10 +88,10 @@ _SYNTH_ENV_DICT = OrderedDict()
_SYNTH_ENV_DICT = azpy.synthetic_env.stash_env(_SYNTH_ENV_DICT)
# grab a specific path from the base_env
_PATH_DCCSI = _SYNTH_ENV_DICT[ENVAR_DCCSIG_PATH]
_LY_PROJECT_PATH = _SYNTH_ENV_DICT[ENVAR_LY_PROJECT_PATH]
_O3DE_PROJECT_PATH = _SYNTH_ENV_DICT[ENVAR_O3DE_PROJECT_PATH]
# build some reuseable path parts
_PATH_MOCK_ASSETS = Path(_LY_PROJECT_PATH, 'Assets').norm()
_PATH_MOCK_ASSETS = Path(_O3DE_PROJECT_PATH, 'Assets').norm()
_PATH_MOCK_SUBLIB = Path(_PATH_MOCK_ASSETS, 'SubstanceSource').norm()
_PATH_MOCK_SBS = Path(_PATH_MOCK_SUBLIB, 'sbs').norm()
@@ -45,7 +45,7 @@ import pysbs.context as pysbs_context
# -------------------------------------------------------------------------
# set up global space, logging etc.
_G_DEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False)
_DCCSI_GDEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False)
_DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False)
_PACKAGENAME = __name__
@@ -66,10 +66,10 @@ _SYNTH_ENV_DICT = OrderedDict()
_SYNTH_ENV_DICT = azpy.synthetic_env.stash_env(_SYNTH_ENV_DICT)
# grab a specific path from the base_env
_PATH_DCCSI = _SYNTH_ENV_DICT[ENVAR_DCCSIG_PATH]
_LY_PROJECT_PATH = _SYNTH_ENV_DICT[ENVAR_LY_PROJECT_PATH]
_O3DE_PROJECT_PATH = _SYNTH_ENV_DICT[ENVAR_O3DE_PROJECT_PATH]
# build some reuseable path parts
_PATH_MOCK_ASSETS = Path(_LY_PROJECT_PATH, 'Assets').norm()
_PATH_MOCK_ASSETS = Path(_O3DE_PROJECT_PATH, 'Assets').norm()
_PATH_MOCK_SUBLIB = Path(_PATH_MOCK_ASSETS, 'SubstanceSource').norm()
_PATH_MOCK_SBS = Path(_PATH_MOCK_SUBLIB, 'sbs').norm()
@@ -28,7 +28,7 @@ from azpy.constants import ENVAR_DCCSI_DEV_MODE
from dynaconf import settings
from pathlib import Path
_G_DEBUG = env_bool(ENVAR_DCCSI_GDEBUG, settings.DCCSI_GDEBUG)
_DCCSI_GDEBUG = env_bool(ENVAR_DCCSI_GDEBUG, settings.DCCSI_GDEBUG)
_DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, settings.DCCSI_DEV_MODE)
_MODULENAME = 'DCCsi.SDK.substance.builder.sbsar_utils'
@@ -190,15 +190,15 @@ if __name__ == "__main__":
_SYNTH_ENV_DICT = synthetic_env.stash_env()
from azpy.constants import ENVAR_DCCSIG_PATH
from azpy.constants import ENVAR_LY_PROJECT_PATH
from azpy.constants import ENVAR_O3DE_PROJECT_PATH
# grab a specific path from the base_env
_PATH_DCCSI = _SYNTH_ENV_DICT[ENVAR_DCCSIG_PATH]
# use DCCsi as the project path for this test
_LY_PROJECT_PATH = _PATH_DCCSI
_O3DE_PROJECT_PATH = _PATH_DCCSI
_PROJECT_ASSETS_PATH = Path(_LY_PROJECT_PATH, 'Assets').resolve()
_PROJECT_ASSETS_PATH = Path(_O3DE_PROJECT_PATH, 'Assets').resolve()
_PROJECT_MATERIALS_PATH = Path(_PROJECT_ASSETS_PATH, 'Materials').resolve()
# this will combine two parts into a single path (object)
@@ -46,7 +46,7 @@ import pysbs.context as pysbs_context
# -------------------------------------------------------------------------
# set up global space, logging etc.
_G_DEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False)
_DCCSI_GDEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False)
_DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False)
_PACKAGENAME = __name__
@@ -67,10 +67,10 @@ _SYNTH_ENV_DICT = OrderedDict()
_SYNTH_ENV_DICT = azpy.synthetic_env.stash_env(_SYNTH_ENV_DICT)
# grab a specific path from the base_env
_PATH_DCCSI = _SYNTH_ENV_DICT[ENVAR_DCCSIG_PATH]
_LY_PROJECT_PATH = _SYNTH_ENV_DICT[ENVAR_LY_PROJECT_PATH]
_O3DE_PROJECT_PATH = _SYNTH_ENV_DICT[ENVAR_O3DE_PROJECT_PATH]
# build some reuseable path parts
_PATH_MOCK_ASSETS = Path(_LY_PROJECT_PATH, 'Assets').norm()
_PATH_MOCK_ASSETS = Path(_O3DE_PROJECT_PATH, 'Assets').norm()
_PATH_MOCK_SUBLIB = Path(_PATH_MOCK_ASSETS, 'SubstanceSource').norm()
_PATH_MOCK_SBS = Path(_PATH_MOCK_SUBLIB, 'sbs').norm()
@@ -53,7 +53,7 @@ import pysbs.context as pysbs_context
# -------------------------------------------------------------------------
# set up global space, logging etc.
_G_DEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False)
_DCCSI_GDEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False)
_DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False)
_PACKAGENAME = __name__
@@ -71,8 +71,8 @@ _LOGGER.debug('Starting up: {0}.'.format({_PACKAGENAME}))
from collections import OrderedDict
_SYNTH_ENV_DICT = OrderedDict()
_SYNTH_ENV_DICT = azpy.synthetic_env.stash_env(_SYNTH_ENV_DICT)
_LY_DEV = _SYNTH_ENV_DICT[ENVAR_LY_DEV]
_LY_PROJECT_PATH = _SYNTH_ENV_DICT[ENVAR_LY_PROJECT_PATH]
_O3DE_DEV = _SYNTH_ENV_DICT[ENVAR_O3DE_DEV]
_O3DE_PROJECT_PATH = _SYNTH_ENV_DICT[ENVAR_O3DE_PROJECT_PATH]
# -------------------------------------------------------------------------
@@ -90,7 +90,7 @@ class MyHandler(PatternMatchingEventHandler):
"""
self.outputName = event.src_path.split(".sbsar")[0].split("/")[-1]
self.outputCookPath = event.src_path.split(self.outputName)
self.outputRenderPath = Path(_LY_PROJECT_PATH, 'Assets', 'Textures', 'Substance').norm()
self.outputRenderPath = Path(_O3DE_PROJECT_PATH, 'Assets', 'Textures', 'Substance').norm()
_LOGGER.debug(self.outputCookPath, self.outputName, self.outputRenderPath)
pysbs_batch.sbsrender_info(input=event.src_path)
@@ -0,0 +1,9 @@
# coding:utf-8
#!/usr/bin/python
"""
Copyright (c) Contributors to the Open 3D Engine Project.
For complete copyright and license terms please see the LICENSE at the root of this distribution.
SPDX-License-Identifier: Apache-2.0 OR MIT
"""
# -------------------------------------------------------------------------
@@ -0,0 +1,9 @@
# coding:utf-8
#!/usr/bin/python
"""
Copyright (c) Contributors to the Open 3D Engine Project.
For complete copyright and license terms please see the LICENSE at the root of this distribution.
SPDX-License-Identifier: Apache-2.0 OR MIT
"""
# -------------------------------------------------------------------------
@@ -0,0 +1,21 @@
# coding:utf-8
#!/usr/bin/python
"""
Copyright (c) Contributors to the Open 3D Engine Project.
For complete copyright and license terms please see the LICENSE at the root of this distribution.
SPDX-License-Identifier: Apache-2.0 OR MIT
"""
# -------------------------------------------------------------------------
# DCCsi\\Tools\\Blender\\AddOns\\MaterialExporter\\main.py
""" A in Blender tool for exporting BRDF materials as O3DE Atom StandardPBR
"""
###########################################################################
# Main Code Block, runs this script as main (testing)
# -------------------------------------------------------------------------
if __name__ == '__main__':
"""Run this file as main"""
print('MaterialExporter.main() not implemented')
@@ -0,0 +1,11 @@
# coding:utf-8
#!/usr/bin/python
"""
Copyright (c) Contributors to the Open 3D Engine Project.
For complete copyright and license terms please see the LICENSE at the root of this distribution.
SPDX-License-Identifier: Apache-2.0 OR MIT
"""
# -------------------------------------------------------------------------
print('Not Implemented')
@@ -0,0 +1,11 @@
# coding:utf-8
#!/usr/bin/python
"""
Copyright (c) Contributors to the Open 3D Engine Project.
For complete copyright and license terms please see the LICENSE at the root of this distribution.
SPDX-License-Identifier: Apache-2.0 OR MIT
"""
# -------------------------------------------------------------------------
print('Not Implemented')
@@ -0,0 +1,9 @@
# coding:utf-8
#!/usr/bin/python
"""
Copyright (c) Contributors to the Open 3D Engine Project.
For complete copyright and license terms please see the LICENSE at the root of this distribution.
SPDX-License-Identifier: Apache-2.0 OR MIT
"""
# -------------------------------------------------------------------------
@@ -0,0 +1,9 @@
# coding:utf-8
#!/usr/bin/python
"""
Copyright (c) Contributors to the Open 3D Engine Project.
For complete copyright and license terms please see the LICENSE at the root of this distribution.
SPDX-License-Identifier: Apache-2.0 OR MIT
"""
# -------------------------------------------------------------------------
@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:083ab199e273431963fc5f80bb80b7d1b1d428f7b12a5180d7199a7431291982
size 311865
@@ -0,0 +1,36 @@
//Maya 2016 Project Definition
workspace -fr "fluidCache" "cache/nCache/fluid";
workspace -fr "images" "images";
workspace -fr "offlineEdit" "scenes/edits";
workspace -fr "furShadowMap" "renderData/fur/furShadowMap";
workspace -fr "iprImages" "renderData/iprImages";
workspace -fr "renderData" "renderData";
workspace -fr "scripts" "scripts";
workspace -fr "fileCache" "cache/nCache";
workspace -fr "eps" "data";
workspace -fr "shaders" "renderData/shaders";
workspace -fr "3dPaintTextures" "sourceimages/3dPaintTextures";
workspace -fr "translatorData" "data";
workspace -fr "mel" "scripts";
workspace -fr "furFiles" "renderData/fur/furFiles";
workspace -fr "OBJ" "data";
workspace -fr "particles" "cache/particles";
workspace -fr "scene" "scenes";
workspace -fr "furEqualMap" "renderData/fur/furEqualMap";
workspace -fr "sourceImages" "sourceimages";
workspace -fr "furImages" "renderData/fur/furImages";
workspace -fr "clips" "clips";
workspace -fr "depth" "renderData/depth";
workspace -fr "movie" "movies";
workspace -fr "audio" "sound";
workspace -fr "bifrostCache" "cache/bifrost";
workspace -fr "autoSave" "autosave";
workspace -fr "mayaAscii" "scenes";
workspace -fr "move" "data";
workspace -fr "sound" "sound";
workspace -fr "diskCache" "data";
workspace -fr "illustrator" "data";
workspace -fr "mayaBinary" "scenes";
workspace -fr "templates" "assets";
workspace -fr "furAttrMap" "renderData/fur/furAttrMap";
@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:646b6d93b2c672bbbbcb46af1bfcaf26ca37c8a0c2b218989b145417bb6b7c93
size 262272
@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:86209db0389b152c709d529e9d5705219b44bfbf712a26788a5c2ab0adc0c373
size 98452
@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:bd95898a04b81b80b095dbef34523f3b70a8c14bc9f82116f732ab648f25658b
size 2096788
@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:a85a15d5c60102f414b4ad03604dbd1c78e3d1c1fe445f60db158b2c069f792d
size 25165972
@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:1318f73ca32ec56dfeb0233679504f6fc723081f0cafa8e7e2d0517b878defd1
size 2000893

Some files were not shown because too many files have changed in this diff Show More