Merge branch 'development' into Prefabs/ProcessStackAddPrefabBug
This commit is contained in:
@@ -202,6 +202,7 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
|
||||
3rdParty::Qt::Gui
|
||||
3rdParty::Qt::Widgets
|
||||
AZ::AzTest
|
||||
AZ::AWSNativeSDKInit
|
||||
Gem::AWSCore.Static
|
||||
Gem::AWSCore.Editor.Static
|
||||
)
|
||||
|
||||
@@ -7,4 +7,4 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#define AWSCORE_BACKWARD_INCOMPATIBLE_CHANGE 0
|
||||
#define AWSCORE_BACKWARD_INCOMPATIBLE_CHANGE 1
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <AzTest/AzTest.h>
|
||||
|
||||
#include <AWSCoreSystemComponent.h>
|
||||
#include <AWSNativeSDKInit/AWSNativeSDKInit.h>
|
||||
#include <Configuration/AWSCoreConfiguration.h>
|
||||
#include <Credential/AWSCredentialManager.h>
|
||||
#include <Framework/AWSApiJob.h>
|
||||
@@ -103,6 +104,9 @@ public:
|
||||
|
||||
TEST_F(AWSCoreSystemComponentTest, ComponentActivateTest)
|
||||
{
|
||||
// Shutdown SDK which is init in fixture setup step
|
||||
AWSNativeSDKInit::InitializationManager::Shutdown();
|
||||
|
||||
EXPECT_FALSE(m_coreSystemsComponent->IsAWSApiInitialized());
|
||||
|
||||
// activate component
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
#include <AzCore/Settings/SettingsRegistry.h>
|
||||
#include <AzFramework/StringFunc/StringFunc.h>
|
||||
#include <AzTest/AzTest.h>
|
||||
|
||||
#include <Configuration/AWSCoreConfiguration.h>
|
||||
#include <TestFramework/AWSCoreFixture.h>
|
||||
@@ -39,12 +38,11 @@ class AWSCoreConfigurationTest
|
||||
: public AWSCoreFixture
|
||||
{
|
||||
public:
|
||||
void CreateTestSetRegFile(const AZStd::string& setregContent)
|
||||
AWSCoreConfigurationTest()
|
||||
{
|
||||
m_normalizedSetRegFilePath = AZStd::string::format("%s/%s",
|
||||
m_normalizedSetRegFolderPath.c_str(), AWSCore::AWSCoreConfiguration::AWSCoreConfigurationFileName);
|
||||
AzFramework::StringFunc::Path::Normalize(m_normalizedSetRegFilePath);
|
||||
CreateTestFile(m_normalizedSetRegFilePath, setregContent);
|
||||
m_setRegFilePath = (GetTestTempDirectoryPath() /
|
||||
AZ::SettingsRegistryInterface::RegistryFolder /
|
||||
AWSCore::AWSCoreConfiguration::AWSCoreConfigurationFileName).LexicallyNormal();
|
||||
}
|
||||
|
||||
void SetUp() override
|
||||
@@ -53,22 +51,13 @@ public:
|
||||
|
||||
m_awsCoreConfiguration = AZStd::make_unique<AWSCore::AWSCoreConfiguration>();
|
||||
|
||||
m_normalizedSourceProjectFolder = AZStd::string::format("%s/%s%s/", AZ::Test::GetCurrentExecutablePath().c_str(),
|
||||
"AWSResourceMappingManager", AZ::Uuid::CreateRandom().ToString<AZStd::string>(false, false).c_str());
|
||||
AzFramework::StringFunc::Path::Normalize(m_normalizedSourceProjectFolder);
|
||||
m_normalizedSetRegFolderPath = AZStd::string::format("%s/%s/",
|
||||
m_normalizedSourceProjectFolder.c_str(), AZ::SettingsRegistryInterface::RegistryFolder);
|
||||
AzFramework::StringFunc::Path::Normalize(m_normalizedSetRegFolderPath);
|
||||
|
||||
m_localFileIO->SetAlias("@projectroot@", m_normalizedSourceProjectFolder.c_str());
|
||||
|
||||
CreateTestSetRegFile(TEST_VALID_RESOURCE_MAPPING_SETREG);
|
||||
CreateFile(m_setRegFilePath.Native(), TEST_VALID_RESOURCE_MAPPING_SETREG);
|
||||
m_localFileIO->SetAlias("@projectroot@", GetTestTempDirectoryPath().Native().c_str());
|
||||
}
|
||||
|
||||
void TearDown() override
|
||||
{
|
||||
RemoveTestFile();
|
||||
RemoveTestDirectory();
|
||||
RemoveFile(m_setRegFilePath.Native());
|
||||
|
||||
m_awsCoreConfiguration.reset();
|
||||
|
||||
@@ -76,52 +65,12 @@ public:
|
||||
}
|
||||
|
||||
AZStd::unique_ptr<AWSCore::AWSCoreConfiguration> m_awsCoreConfiguration;
|
||||
AZStd::string m_normalizedSetRegFilePath;
|
||||
|
||||
private:
|
||||
AZStd::string m_normalizedSourceProjectFolder;
|
||||
AZStd::string m_normalizedSetRegFolderPath;
|
||||
|
||||
void CreateTestFile(const AZStd::string& filePath, const AZStd::string& fileContent)
|
||||
{
|
||||
AZ::IO::SystemFile file;
|
||||
if (!file.Open(filePath.c_str(),
|
||||
AZ::IO::SystemFile::OpenMode::SF_OPEN_CREATE | AZ::IO::SystemFile::SF_OPEN_CREATE_PATH | AZ::IO::SystemFile::SF_OPEN_WRITE_ONLY))
|
||||
{
|
||||
AZ_Assert(false, "Failed to open test file");
|
||||
}
|
||||
|
||||
if (file.Write(fileContent.c_str(), fileContent.size()) != fileContent.size())
|
||||
{
|
||||
AZ_Assert(false, "Failed to write test file");
|
||||
}
|
||||
file.Close();
|
||||
}
|
||||
|
||||
void RemoveTestFile()
|
||||
{
|
||||
if (!m_normalizedSetRegFilePath.empty())
|
||||
{
|
||||
AZ_Assert(AZ::IO::SystemFile::Delete(m_normalizedSetRegFilePath.c_str()),
|
||||
"Failed to delete test settings registry file at %s", m_normalizedSetRegFilePath.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void RemoveTestDirectory()
|
||||
{
|
||||
if (!m_normalizedSetRegFilePath.empty())
|
||||
{
|
||||
AZ_Assert(AZ::IO::SystemFile::DeleteDir(m_normalizedSetRegFolderPath.c_str()),
|
||||
"Failed to delete test settings registry folder at %s", m_normalizedSetRegFolderPath.c_str());
|
||||
AZ_Assert(AZ::IO::SystemFile::DeleteDir(m_normalizedSourceProjectFolder.c_str()),
|
||||
"Failed to delete test folder at %s", m_normalizedSourceProjectFolder.c_str());
|
||||
}
|
||||
}
|
||||
AZ::IO::Path m_setRegFilePath;
|
||||
};
|
||||
|
||||
TEST_F(AWSCoreConfigurationTest, InitConfig_NoSourceProjectFolderFound_ReturnEmptyConfigFilePath)
|
||||
{
|
||||
m_settingsRegistry->MergeSettingsFile(m_normalizedSetRegFilePath, AZ::SettingsRegistryInterface::Format::JsonMergePatch, {});
|
||||
m_settingsRegistry->MergeSettingsFile(m_setRegFilePath.Native(), AZ::SettingsRegistryInterface::Format::JsonMergePatch, {});
|
||||
m_localFileIO->ClearAlias("@projectroot@");
|
||||
|
||||
AZ_TEST_START_TRACE_SUPPRESSION;
|
||||
@@ -134,8 +83,8 @@ TEST_F(AWSCoreConfigurationTest, InitConfig_NoSourceProjectFolderFound_ReturnEmp
|
||||
|
||||
TEST_F(AWSCoreConfigurationTest, InitConfig_SettingsRegistryIsEmpty_ReturnEmptyConfigFilePath)
|
||||
{
|
||||
CreateTestSetRegFile(TEST_INVALID_RESOURCE_MAPPING_SETREG);
|
||||
m_settingsRegistry->MergeSettingsFile(m_normalizedSetRegFilePath, AZ::SettingsRegistryInterface::Format::JsonMergePatch, {});
|
||||
CreateFile(m_setRegFilePath.Native(), TEST_INVALID_RESOURCE_MAPPING_SETREG);
|
||||
m_settingsRegistry->MergeSettingsFile(m_setRegFilePath.Native(), AZ::SettingsRegistryInterface::Format::JsonMergePatch, {});
|
||||
m_awsCoreConfiguration->InitConfig();
|
||||
|
||||
auto actualConfigFilePath = m_awsCoreConfiguration->GetResourceMappingConfigFilePath();
|
||||
@@ -144,7 +93,7 @@ TEST_F(AWSCoreConfigurationTest, InitConfig_SettingsRegistryIsEmpty_ReturnEmptyC
|
||||
|
||||
TEST_F(AWSCoreConfigurationTest, InitConfig_LoadValidSettingsRegistry_ReturnNonEmptyConfigFilePath)
|
||||
{
|
||||
m_settingsRegistry->MergeSettingsFile(m_normalizedSetRegFilePath, AZ::SettingsRegistryInterface::Format::JsonMergePatch, {});
|
||||
m_settingsRegistry->MergeSettingsFile(m_setRegFilePath.Native(), AZ::SettingsRegistryInterface::Format::JsonMergePatch, {});
|
||||
m_awsCoreConfiguration->InitConfig();
|
||||
|
||||
auto actualConfigFilePath = m_awsCoreConfiguration->GetResourceMappingConfigFilePath();
|
||||
@@ -153,7 +102,7 @@ TEST_F(AWSCoreConfigurationTest, InitConfig_LoadValidSettingsRegistry_ReturnNonE
|
||||
|
||||
TEST_F(AWSCoreConfigurationTest, ReloadConfiguration_NoSourceProjectFolderFound_ReturnEmptyConfigFilePath)
|
||||
{
|
||||
m_settingsRegistry->MergeSettingsFile(m_normalizedSetRegFilePath, AZ::SettingsRegistryInterface::Format::JsonMergePatch, {});
|
||||
m_settingsRegistry->MergeSettingsFile(m_setRegFilePath.Native(), AZ::SettingsRegistryInterface::Format::JsonMergePatch, {});
|
||||
m_localFileIO->ClearAlias("@projectroot@");
|
||||
m_awsCoreConfiguration->ReloadConfiguration();
|
||||
|
||||
@@ -163,8 +112,8 @@ TEST_F(AWSCoreConfigurationTest, ReloadConfiguration_NoSourceProjectFolderFound_
|
||||
|
||||
TEST_F(AWSCoreConfigurationTest, ReloadConfiguration_LoadValidSettingsRegistryAfterInvalidOne_ReturnNonEmptyConfigFilePath)
|
||||
{
|
||||
CreateTestSetRegFile(TEST_INVALID_RESOURCE_MAPPING_SETREG);
|
||||
m_settingsRegistry->MergeSettingsFile(m_normalizedSetRegFilePath, AZ::SettingsRegistryInterface::Format::JsonMergePatch, {});
|
||||
CreateFile(m_setRegFilePath.Native(), TEST_INVALID_RESOURCE_MAPPING_SETREG);
|
||||
m_settingsRegistry->MergeSettingsFile(m_setRegFilePath.Native(), AZ::SettingsRegistryInterface::Format::JsonMergePatch, {});
|
||||
m_awsCoreConfiguration->InitConfig();
|
||||
|
||||
auto actualConfigFilePath = m_awsCoreConfiguration->GetResourceMappingConfigFilePath();
|
||||
@@ -172,7 +121,7 @@ TEST_F(AWSCoreConfigurationTest, ReloadConfiguration_LoadValidSettingsRegistryAf
|
||||
EXPECT_TRUE(actualConfigFilePath.empty());
|
||||
EXPECT_TRUE(actualProfileName == AWSCoreConfiguration::AWSCoreDefaultProfileName);
|
||||
|
||||
CreateTestSetRegFile(TEST_VALID_RESOURCE_MAPPING_SETREG);
|
||||
CreateFile(m_setRegFilePath.Native(), TEST_VALID_RESOURCE_MAPPING_SETREG);
|
||||
m_awsCoreConfiguration->ReloadConfiguration();
|
||||
|
||||
actualConfigFilePath = m_awsCoreConfiguration->GetResourceMappingConfigFilePath();
|
||||
@@ -183,7 +132,7 @@ TEST_F(AWSCoreConfigurationTest, ReloadConfiguration_LoadValidSettingsRegistryAf
|
||||
|
||||
TEST_F(AWSCoreConfigurationTest, ReloadConfiguration_LoadInvalidSettingsRegistryAfterValidOne_ReturnEmptyConfigFilePath)
|
||||
{
|
||||
m_settingsRegistry->MergeSettingsFile(m_normalizedSetRegFilePath, AZ::SettingsRegistryInterface::Format::JsonMergePatch, {});
|
||||
m_settingsRegistry->MergeSettingsFile(m_setRegFilePath.Native(), AZ::SettingsRegistryInterface::Format::JsonMergePatch, {});
|
||||
m_awsCoreConfiguration->InitConfig();
|
||||
|
||||
auto actualConfigFilePath = m_awsCoreConfiguration->GetResourceMappingConfigFilePath();
|
||||
@@ -191,7 +140,7 @@ TEST_F(AWSCoreConfigurationTest, ReloadConfiguration_LoadInvalidSettingsRegistry
|
||||
EXPECT_FALSE(actualConfigFilePath.empty());
|
||||
EXPECT_TRUE(actualProfileName != AWSCoreConfiguration::AWSCoreDefaultProfileName);
|
||||
|
||||
CreateTestSetRegFile(TEST_INVALID_RESOURCE_MAPPING_SETREG);
|
||||
CreateFile(m_setRegFilePath.Native(), TEST_INVALID_RESOURCE_MAPPING_SETREG);
|
||||
m_awsCoreConfiguration->ReloadConfiguration();
|
||||
|
||||
actualConfigFilePath = m_awsCoreConfiguration->GetResourceMappingConfigFilePath();
|
||||
|
||||
@@ -25,6 +25,11 @@ public:
|
||||
m_credentialHandler = AZStd::make_unique<AWSCVarCredentialHandler>();
|
||||
}
|
||||
|
||||
void TearDown() override
|
||||
{
|
||||
m_credentialHandler.reset();
|
||||
}
|
||||
|
||||
AZStd::unique_ptr<AWSCVarCredentialHandler> m_credentialHandler;
|
||||
};
|
||||
|
||||
|
||||
@@ -6,8 +6,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AzTest/AzTest.h>
|
||||
|
||||
#include <aws/core/auth/AWSCredentialsProvider.h>
|
||||
|
||||
#include <Credential/AWSCredentialBus.h>
|
||||
@@ -19,14 +17,10 @@ class TestCredentialHandlerOne
|
||||
: AWSCredentialRequestBus::Handler
|
||||
{
|
||||
public:
|
||||
TestCredentialHandlerOne()
|
||||
void ActivateHandler()
|
||||
{
|
||||
m_handlerCounter = 0;
|
||||
m_credentialsProvider = std::make_shared<Aws::Auth::AnonymousAWSCredentialsProvider>();
|
||||
}
|
||||
|
||||
void ActivateHandler()
|
||||
{
|
||||
AWSCredentialRequestBus::Handler::BusConnect();
|
||||
}
|
||||
|
||||
@@ -55,14 +49,10 @@ class TestCredentialHandlerTwo
|
||||
: AWSCredentialRequestBus::Handler
|
||||
{
|
||||
public:
|
||||
TestCredentialHandlerTwo()
|
||||
void ActivateHandler()
|
||||
{
|
||||
m_handlerCounter = 0;
|
||||
m_credentialsProvider = std::make_shared<Aws::Auth::AnonymousAWSCredentialsProvider>();
|
||||
}
|
||||
|
||||
void ActivateHandler()
|
||||
{
|
||||
AWSCredentialRequestBus::Handler::BusConnect();
|
||||
}
|
||||
|
||||
@@ -88,7 +78,7 @@ public:
|
||||
};
|
||||
|
||||
class AWSCredentialBusTest
|
||||
: public UnitTest::ScopedAllocatorSetupFixture
|
||||
: public AWSCoreFixture
|
||||
{
|
||||
public:
|
||||
AWSCredentialBusTest()
|
||||
@@ -99,6 +89,8 @@ public:
|
||||
|
||||
void SetUp() override
|
||||
{
|
||||
AWSCoreFixture::SetUpFixture();
|
||||
|
||||
m_handlerOne->ActivateHandler();
|
||||
m_handlerTwo->ActivateHandler();
|
||||
}
|
||||
@@ -107,6 +99,8 @@ public:
|
||||
{
|
||||
m_handlerOne->DeactivateHandler();
|
||||
m_handlerTwo->DeactivateHandler();
|
||||
|
||||
AWSCoreFixture::TearDownFixture();
|
||||
}
|
||||
|
||||
AZStd::unique_ptr<TestCredentialHandlerOne> m_handlerOne;
|
||||
|
||||
@@ -6,11 +6,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AzCore/UnitTest/TestTypes.h>
|
||||
#include <AzTest/AzTest.h>
|
||||
|
||||
#include <AWSCoreInternalBus.h>
|
||||
#include <Credential/AWSDefaultCredentialHandler.h>
|
||||
#include <TestFramework/AWSCoreFixture.h>
|
||||
|
||||
using namespace AWSCore;
|
||||
|
||||
@@ -18,13 +16,15 @@ static constexpr char AWSDEFAULTCREDENTIALHANDLERTEST_ALLOC_TAG[] = "AWSDefaultC
|
||||
static constexpr const char* AWS_ACCESS_KEY = "AWSACCESSKEY";
|
||||
static constexpr const char* AWS_SECRET_KEY = "AWSSECRETKEY";
|
||||
|
||||
class EnvironmentAWSCredentialsProviderMock : public Aws::Auth::EnvironmentAWSCredentialsProvider
|
||||
class EnvironmentAWSCredentialsProviderMock
|
||||
: public Aws::Auth::EnvironmentAWSCredentialsProvider
|
||||
{
|
||||
public:
|
||||
MOCK_METHOD0(GetAWSCredentials, Aws::Auth::AWSCredentials());
|
||||
};
|
||||
|
||||
class ProfileConfigFileAWSCredentialsProviderMock : public Aws::Auth::ProfileConfigFileAWSCredentialsProvider
|
||||
class ProfileConfigFileAWSCredentialsProviderMock
|
||||
: public Aws::Auth::ProfileConfigFileAWSCredentialsProvider
|
||||
{
|
||||
public:
|
||||
MOCK_METHOD0(GetAWSCredentials, Aws::Auth::AWSCredentials());
|
||||
@@ -44,7 +44,7 @@ public:
|
||||
};
|
||||
|
||||
class AWSDefaultCredentialHandlerTest
|
||||
: public UnitTest::ScopedAllocatorSetupFixture
|
||||
: public AWSCoreFixture
|
||||
, public AWSCoreInternalRequestBus::Handler
|
||||
{
|
||||
public:
|
||||
@@ -53,6 +53,8 @@ public:
|
||||
|
||||
void SetUp() override
|
||||
{
|
||||
AWSCoreFixture::SetUpFixture();
|
||||
|
||||
AWSCoreInternalRequestBus::Handler::BusConnect();
|
||||
m_environmentCredentialsProviderMock = Aws::MakeShared<EnvironmentAWSCredentialsProviderMock>(AWSDEFAULTCREDENTIALHANDLERTEST_ALLOC_TAG);
|
||||
m_profileCredentialsProviderMock = Aws::MakeShared<ProfileConfigFileAWSCredentialsProviderMock>(AWSDEFAULTCREDENTIALHANDLERTEST_ALLOC_TAG);
|
||||
@@ -68,6 +70,8 @@ public:
|
||||
m_profileCredentialsProviderMock.reset();
|
||||
m_environmentCredentialsProviderMock.reset();
|
||||
AWSCoreInternalRequestBus::Handler::BusDisconnect();
|
||||
|
||||
AWSCoreFixture::TearDownFixture();
|
||||
}
|
||||
|
||||
// AWSCoreInternalRequestBus interface implementation
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include <Editor/Attribution/AWSAttributionServiceApi.h>
|
||||
#include <Framework/JsonObjectHandler.h>
|
||||
|
||||
#include <AzCore/UnitTest/TestTypes.h>
|
||||
#include <TestFramework/AWSCoreFixture.h>
|
||||
|
||||
using namespace AWSCore;
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace AWSCoreUnitTest
|
||||
};
|
||||
|
||||
class AWSAttributionServiceApiTest
|
||||
: public UnitTest::ScopedAllocatorSetupFixture
|
||||
: public AWSCoreFixture
|
||||
{
|
||||
public:
|
||||
testing::NiceMock<JsonReaderMock> JsonReader;
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include <Editor/Attribution/AWSCoreAttributionMetric.h>
|
||||
#include <Credential/AWSCredentialBus.h>
|
||||
|
||||
#include <AzFramework/IO/LocalFileIO.h>
|
||||
#include <AzCore/std/smart_ptr/unique_ptr.h>
|
||||
#include <AzCore/std/smart_ptr/make_shared.h>
|
||||
#include <AzCore/base.h>
|
||||
@@ -23,7 +22,6 @@
|
||||
#include <AzCore/Jobs/JobManagerBus.h>
|
||||
#include <AzCore/Jobs/JobContext.h>
|
||||
#include <AzCore/Utils/Utils.h>
|
||||
#include <AzCore/UnitTest/TestTypes.h>
|
||||
#include <AzCore/Component/Entity.h>
|
||||
#include <AzCore/Module/ModuleManagerBus.h>
|
||||
#include <AzCore/PlatformId/PlatformId.h>
|
||||
@@ -167,7 +165,6 @@ namespace AWSAttributionUnitTest
|
||||
AZStd::unique_ptr<AZ::JobManager> m_jobManager;
|
||||
AZStd::array<char, AZ::IO::MaxPathLength> m_resolvedSettingsPath;
|
||||
ModuleManagerRequestBusMock m_moduleManagerRequestBusMock;
|
||||
AWSCredentialRquestsBusMock m_credentialRequestBusMock;
|
||||
|
||||
void SetUp() override
|
||||
{
|
||||
@@ -221,6 +218,7 @@ namespace AWSAttributionUnitTest
|
||||
TEST_F(AttributionManagerTest, MetricsSettings_ConsentShown_AttributionDisabled_SkipsSend)
|
||||
{
|
||||
// GIVEN
|
||||
AWSCredentialRquestsBusMock credentialRequestBusMock;
|
||||
AWSAttributionManagerMock manager;
|
||||
|
||||
CreateFile(m_resolvedSettingsPath.data(), R"({
|
||||
@@ -239,7 +237,7 @@ namespace AWSAttributionUnitTest
|
||||
|
||||
EXPECT_CALL(manager, SubmitMetric(testing::_)).Times(0);
|
||||
EXPECT_CALL(m_moduleManagerRequestBusMock, EnumerateModules(testing::_)).Times(0);
|
||||
EXPECT_CALL(m_credentialRequestBusMock, GetCredentialsProvider()).Times(1);
|
||||
EXPECT_CALL(credentialRequestBusMock, GetCredentialsProvider()).Times(1);
|
||||
|
||||
// WHEN
|
||||
manager.MetricCheck();
|
||||
@@ -255,6 +253,7 @@ namespace AWSAttributionUnitTest
|
||||
TEST_F(AttributionManagerTest, AttributionEnabled_ContentShown_NoPreviousTimeStamp_SendSuccess)
|
||||
{
|
||||
// GIVEN
|
||||
AWSCredentialRquestsBusMock credentialRequestBusMock;
|
||||
AWSAttributionManagerMock manager;
|
||||
|
||||
CreateFile(m_resolvedSettingsPath.data(), R"({
|
||||
@@ -272,7 +271,7 @@ namespace AWSAttributionUnitTest
|
||||
|
||||
EXPECT_CALL(manager, SubmitMetric(testing::_)).Times(1);
|
||||
EXPECT_CALL(m_moduleManagerRequestBusMock, EnumerateModules(testing::_)).Times(1);
|
||||
EXPECT_CALL(m_credentialRequestBusMock, GetCredentialsProvider()).Times(1);
|
||||
EXPECT_CALL(credentialRequestBusMock, GetCredentialsProvider()).Times(1);
|
||||
|
||||
// WHEN
|
||||
manager.MetricCheck();
|
||||
@@ -289,6 +288,7 @@ namespace AWSAttributionUnitTest
|
||||
TEST_F(AttributionManagerTest, AttributionEnabled_ContentShown_ValidPreviousTimeStamp_SendSuccess)
|
||||
{
|
||||
// GIVEN
|
||||
AWSCredentialRquestsBusMock credentialRequestBusMock;
|
||||
AWSAttributionManagerMock manager;
|
||||
|
||||
CreateFile(m_resolvedSettingsPath.data(), R"({
|
||||
@@ -308,7 +308,7 @@ namespace AWSAttributionUnitTest
|
||||
|
||||
EXPECT_CALL(manager, SubmitMetric(testing::_)).Times(1);
|
||||
EXPECT_CALL(m_moduleManagerRequestBusMock, EnumerateModules(testing::_)).Times(1);
|
||||
EXPECT_CALL(m_credentialRequestBusMock, GetCredentialsProvider()).Times(1);
|
||||
EXPECT_CALL(credentialRequestBusMock, GetCredentialsProvider()).Times(1);
|
||||
|
||||
// WHEN
|
||||
manager.MetricCheck();
|
||||
@@ -324,6 +324,7 @@ namespace AWSAttributionUnitTest
|
||||
TEST_F(AttributionManagerTest, AttributionEnabled_ContentShown_DelayNotSatisfied_SendFail)
|
||||
{
|
||||
// GIVEN
|
||||
AWSCredentialRquestsBusMock credentialRequestBusMock;
|
||||
AWSAttributionManagerMock manager;
|
||||
|
||||
CreateFile(m_resolvedSettingsPath.data(), R"({
|
||||
@@ -346,7 +347,7 @@ namespace AWSAttributionUnitTest
|
||||
|
||||
EXPECT_CALL(manager, SubmitMetric(testing::_)).Times(0);
|
||||
EXPECT_CALL(m_moduleManagerRequestBusMock, EnumerateModules(testing::_)).Times(0);
|
||||
EXPECT_CALL(m_credentialRequestBusMock, GetCredentialsProvider()).Times(1);
|
||||
EXPECT_CALL(credentialRequestBusMock, GetCredentialsProvider()).Times(1);
|
||||
|
||||
// WHEN
|
||||
manager.MetricCheck();
|
||||
@@ -362,6 +363,7 @@ namespace AWSAttributionUnitTest
|
||||
TEST_F(AttributionManagerTest, AttributionEnabledNotFound_ContentShown_SendFail)
|
||||
{
|
||||
// GIVEN
|
||||
AWSCredentialRquestsBusMock credentialRequestBusMock;
|
||||
AWSAttributionManagerMock manager;
|
||||
|
||||
CreateFile(m_resolvedSettingsPath.data(), R"({
|
||||
@@ -378,7 +380,7 @@ namespace AWSAttributionUnitTest
|
||||
|
||||
EXPECT_CALL(manager, SubmitMetric(testing::_)).Times(0);
|
||||
EXPECT_CALL(m_moduleManagerRequestBusMock, EnumerateModules(testing::_)).Times(0);
|
||||
EXPECT_CALL(m_credentialRequestBusMock, GetCredentialsProvider()).Times(1);
|
||||
EXPECT_CALL(credentialRequestBusMock, GetCredentialsProvider()).Times(1);
|
||||
|
||||
// WHEN
|
||||
manager.MetricCheck();
|
||||
@@ -394,12 +396,13 @@ namespace AWSAttributionUnitTest
|
||||
TEST_F(AttributionManagerTest, AttributionEnabledNotFound_ContentNotShown_SendFail)
|
||||
{
|
||||
// GIVEN
|
||||
AWSCredentialRquestsBusMock credentialRequestBusMock;
|
||||
AWSAttributionManagerMock manager;
|
||||
manager.Init();
|
||||
|
||||
EXPECT_CALL(manager, SubmitMetric(testing::_)).Times(0);
|
||||
EXPECT_CALL(m_moduleManagerRequestBusMock, EnumerateModules(testing::_)).Times(0);
|
||||
EXPECT_CALL(m_credentialRequestBusMock, GetCredentialsProvider()).Times(1);
|
||||
EXPECT_CALL(credentialRequestBusMock, GetCredentialsProvider()).Times(1);
|
||||
EXPECT_CALL(manager, ShowConsentDialog()).Times(1);
|
||||
|
||||
// WHEN
|
||||
|
||||
@@ -6,9 +6,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AzTest/AzTest.h>
|
||||
|
||||
#include <AWSNativeSDKInit/AWSNativeSDKInit.h>
|
||||
#include <aws/core/auth/AWSCredentialsProvider.h>
|
||||
#include <aws/s3/S3Client.h>
|
||||
|
||||
@@ -19,7 +16,7 @@
|
||||
using namespace AWSCore;
|
||||
|
||||
class AWSApiClientJobConfigTest
|
||||
: public UnitTest::ScopedAllocatorSetupFixture
|
||||
: public AWSCoreFixture
|
||||
, public AWSCredentialRequestBus::Handler
|
||||
{
|
||||
public:
|
||||
@@ -30,13 +27,9 @@ public:
|
||||
|
||||
void SetUp() override
|
||||
{
|
||||
AWSNativeSDKInit::InitializationManager::InitAwsApi();
|
||||
m_credentialHandlerCounter = 0;
|
||||
}
|
||||
AWSCoreFixture::SetUpFixture();
|
||||
|
||||
void TearDown() override
|
||||
{
|
||||
AWSNativeSDKInit::InitializationManager::Shutdown();
|
||||
m_credentialHandlerCounter = 0;
|
||||
}
|
||||
|
||||
// AWSCredentialRequestBus interface implementation
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
#include <AzCore/Jobs/JobManager.h>
|
||||
#include <AzCore/Jobs/JobContext.h>
|
||||
#include <AzTest/AzTest.h>
|
||||
|
||||
#include <aws/core/auth/AWSCredentialsProvider.h>
|
||||
|
||||
@@ -20,14 +19,14 @@
|
||||
using namespace AWSCore;
|
||||
|
||||
class AwsApiJobConfigTest
|
||||
: public UnitTest::ScopedAllocatorSetupFixture
|
||||
: public AWSCoreFixture
|
||||
, AWSCredentialRequestBus::Handler
|
||||
, AWSCoreRequestBus::Handler
|
||||
{
|
||||
public:
|
||||
void SetUp() override
|
||||
{
|
||||
AZ::AllocatorInstance<AZ::ThreadPoolAllocator>::Create();
|
||||
AWSCoreFixture::SetUpFixture();
|
||||
|
||||
m_credentialsHandler = std::make_shared<Aws::Auth::AnonymousAWSCredentialsProvider>();
|
||||
AZ::JobManagerDesc jobDesc;
|
||||
@@ -45,7 +44,7 @@ public:
|
||||
m_jobManager.reset();
|
||||
m_credentialsHandler.reset();
|
||||
|
||||
AZ::AllocatorInstance<AZ::ThreadPoolAllocator>::Destroy();
|
||||
AWSCoreFixture::TearDownFixture();
|
||||
}
|
||||
|
||||
// AWSCredentialRequestBus interface implementation
|
||||
|
||||
@@ -6,24 +6,24 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AzTest/AzTest.h>
|
||||
|
||||
#include <Framework/HttpRequestJob.h>
|
||||
#include <TestFramework/AWSCoreFixture.h>
|
||||
|
||||
using namespace AWSCore;
|
||||
|
||||
class HttpRequestJobTest
|
||||
: public UnitTest::ScopedAllocatorSetupFixture
|
||||
: public AWSCoreFixture
|
||||
{
|
||||
void SetUp() override
|
||||
{
|
||||
AWSCoreFixture::SetUpFixture();
|
||||
HttpRequestJob::StaticInit();
|
||||
}
|
||||
|
||||
void TearDown() override
|
||||
{
|
||||
HttpRequestJob::StaticShutdown();
|
||||
AWSCoreFixture::TearDownFixture();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -6,8 +6,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AzTest/AzTest.h>
|
||||
|
||||
#include <aws/core/utils/memory/stl/AWSStringStream.h>
|
||||
|
||||
#include <TestFramework/AWSCoreFixture.h>
|
||||
@@ -18,7 +16,7 @@ using OBJECT_TYPE = TestObject<AZStd::string>;
|
||||
using ARRAY_TYPE = AZStd::vector<AZStd::string>;
|
||||
using ARRAY_OF_ARRAY_TYPE = AZStd::vector<AZStd::vector<AZStd::string>>;
|
||||
using ARRAY_OF_OBJECT_TYPE = AZStd::vector<TestObject<AZStd::string>>;
|
||||
using JsonReaderTest = UnitTest::ScopedAllocatorSetupFixture;
|
||||
using JsonReaderTest = AWSCoreFixture;
|
||||
|
||||
template<class ValueType>
|
||||
void TestJsonReaderSuccess(const ValueType& expectedValue, const char* valueString)
|
||||
|
||||
@@ -6,8 +6,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AzTest/AzTest.h>
|
||||
|
||||
#include <aws/core/utils/memory/stl/AWSString.h>
|
||||
#include <aws/core/utils/memory/stl/AWSStringStream.h>
|
||||
|
||||
@@ -17,7 +15,7 @@ using namespace AWSCoreTestingUtils;
|
||||
|
||||
using OBJECT_TYPE = TestObject<AZStd::string>;
|
||||
using ARRAY_TYPE = AZStd::vector<AZStd::string>;
|
||||
using JsonWriterTest = UnitTest::ScopedAllocatorSetupFixture;
|
||||
using JsonWriterTest = AWSCoreFixture;
|
||||
|
||||
template<class ValueType>
|
||||
void TestJsonWriterSuccess(const ValueType& actualValue, const char* valueString)
|
||||
|
||||
@@ -6,15 +6,13 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AzTest/AzTest.h>
|
||||
|
||||
#include <Framework/RequestBuilder.h>
|
||||
#include <TestFramework/AWSCoreFixture.h>
|
||||
|
||||
using namespace AWSCore;
|
||||
using namespace AWSCoreTestingUtils;
|
||||
|
||||
using RequestBuilderTest = UnitTest::ScopedAllocatorSetupFixture;
|
||||
using RequestBuilderTest = AWSCoreFixture;
|
||||
|
||||
TEST_F(RequestBuilderTest, WriteJsonBodyParameter_UseTestJsonBody_GetExpectedValue)
|
||||
{
|
||||
|
||||
@@ -6,8 +6,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AzTest/AzTest.h>
|
||||
|
||||
#include <AWSCoreBus.h>
|
||||
#include <Framework/ServiceClientJobConfig.h>
|
||||
#include <ResourceMapping/AWSResourceMappingBus.h>
|
||||
@@ -19,17 +17,21 @@ static constexpr const char TEST_EXPECTED_FEATURE_SERVICE_URL[] = "https://featu
|
||||
static constexpr const char TEST_EXPECTED_CUSTOM_SERVICE_URL[] = "https://custom.service.com";
|
||||
|
||||
class ServiceClientJobConfigTest
|
||||
: public UnitTest::ScopedAllocatorSetupFixture
|
||||
: public AWSCoreFixture
|
||||
, AWSResourceMappingRequestBus::Handler
|
||||
{
|
||||
void SetUp() override
|
||||
{
|
||||
AWSCoreFixture::SetUpFixture();
|
||||
|
||||
AWSResourceMappingRequestBus::Handler::BusConnect();
|
||||
}
|
||||
|
||||
void TearDown() override
|
||||
{
|
||||
AWSResourceMappingRequestBus::Handler::BusDisconnect();
|
||||
|
||||
AWSCoreFixture::TearDownFixture();
|
||||
}
|
||||
|
||||
// AWSResourceMappingRequestBus interface implementation
|
||||
|
||||
@@ -6,12 +6,10 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AzTest/AzTest.h>
|
||||
|
||||
#include <Framework/ServiceJobUtil.h>
|
||||
#include <TestFramework/AWSCoreFixture.h>
|
||||
|
||||
using ServiceJobUtilTest = UnitTest::ScopedAllocatorSetupFixture;
|
||||
using ServiceJobUtilTest = AWSCoreFixture;
|
||||
|
||||
TEST_F(ServiceJobUtilTest, DetermineRegionFromRequestUrl_DefaultUrlFormat_Success)
|
||||
{
|
||||
|
||||
@@ -6,15 +6,13 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AzTest/AzTest.h>
|
||||
|
||||
#include <AWSCoreBus.h>
|
||||
#include <Framework/ServiceRequestJob.h>
|
||||
#include <TestFramework/AWSCoreFixture.h>
|
||||
|
||||
using namespace AWSCore;
|
||||
|
||||
using ServiceRequestJobTest = UnitTest::ScopedAllocatorSetupFixture;
|
||||
using ServiceRequestJobTest = AWSCoreFixture;
|
||||
|
||||
#define TEST_SERVICE_REQUEST(SERVICE_NAME, METHOD, PATH) \
|
||||
static const char* Path() { return PATH; } \
|
||||
|
||||
@@ -6,14 +6,12 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AzTest/AzTest.h>
|
||||
|
||||
#include <Framework/Util.h>
|
||||
#include <TestFramework/AWSCoreFixture.h>
|
||||
|
||||
using namespace AWSCoreTestingUtils;
|
||||
|
||||
using FrameworkUtilTest = UnitTest::ScopedAllocatorSetupFixture;
|
||||
using FrameworkUtilTest = AWSCoreFixture;
|
||||
|
||||
TEST_F(FrameworkUtilTest, ToAwsString_UseAzString_GetExpectedAwsString)
|
||||
{
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
#include <AzCore/Settings/SettingsRegistry.h>
|
||||
#include <AzFramework/StringFunc/StringFunc.h>
|
||||
#include <AzTest/AzTest.h>
|
||||
|
||||
#include <Configuration/AWSCoreConfiguration.h>
|
||||
#include <ResourceMapping/AWSResourceMappingConstants.h>
|
||||
@@ -112,31 +111,21 @@ public:
|
||||
m_resourceMappingManager = AZStd::make_unique<AWSCore::AWSResourceMappingManager>();
|
||||
}
|
||||
|
||||
void CreateTestConfigFile(const AZStd::string& configContent)
|
||||
{
|
||||
m_normalizedConfigFilePath = AZStd::string::format("%s/%s", m_normalizedConfigFolderPath.c_str(), "test_aws_resource_mappings.json");
|
||||
AzFramework::StringFunc::Path::Normalize(m_normalizedConfigFilePath);
|
||||
CreateTestFile(m_normalizedConfigFilePath, configContent);
|
||||
}
|
||||
|
||||
void SetUp() override
|
||||
{
|
||||
AWSCoreFixture::SetUpFixture(false);
|
||||
|
||||
m_normalizedSourceProjectFolder = AZStd::string::format("%s/%s%s/", AZ::Test::GetCurrentExecutablePath().c_str(),
|
||||
"AWSResourceMappingManager", AZ::Uuid::CreateRandom().ToString<AZStd::string>(false, false).c_str());
|
||||
AzFramework::StringFunc::Path::Normalize(m_normalizedSourceProjectFolder);
|
||||
m_normalizedConfigFolderPath = AZStd::string::format("%s/%s/",
|
||||
m_normalizedSourceProjectFolder.c_str(), AWSCore::AWSCoreConfiguration::AWSCoreResourceMappingConfigFolderName);
|
||||
AzFramework::StringFunc::Path::Normalize(m_normalizedConfigFolderPath);
|
||||
m_configFilePath = (GetTestTempDirectoryPath() /
|
||||
AWSCore::AWSCoreConfiguration::AWSCoreResourceMappingConfigFolderName /
|
||||
"test_aws_resource_mappings.json").LexicallyNormal();
|
||||
AWSCoreInternalRequestBus::Handler::BusConnect();
|
||||
}
|
||||
|
||||
void TearDown() override
|
||||
{
|
||||
AWSCoreInternalRequestBus::Handler::BusDisconnect();
|
||||
RemoveTestFile();
|
||||
RemoveTestDirectory();
|
||||
RemoveFile(m_configFilePath.Native());
|
||||
m_configFilePath.clear();
|
||||
|
||||
m_reloadConfigurationCounter = 0;
|
||||
m_resourceMappingManager->DeactivateManager();
|
||||
@@ -147,57 +136,17 @@ public:
|
||||
|
||||
// AWSCoreInternalRequestBus interface implementation
|
||||
AZStd::string GetProfileName() const override { return ""; }
|
||||
AZStd::string GetResourceMappingConfigFilePath() const override { return m_normalizedConfigFilePath; }
|
||||
AZStd::string GetResourceMappingConfigFilePath() const override { return m_configFilePath.Native(); }
|
||||
void ReloadConfiguration() override { m_reloadConfigurationCounter++; }
|
||||
|
||||
AZStd::unique_ptr<AWSCore::AWSResourceMappingManager> m_resourceMappingManager;
|
||||
AZ::u8 m_reloadConfigurationCounter;
|
||||
|
||||
private:
|
||||
AZStd::string m_normalizedSourceProjectFolder;
|
||||
AZStd::string m_normalizedConfigFolderPath;
|
||||
AZStd::string m_normalizedConfigFilePath;
|
||||
|
||||
void CreateTestFile(const AZStd::string& filePath, const AZStd::string& fileContent)
|
||||
{
|
||||
AZ::IO::SystemFile file;
|
||||
if (!file.Open(filePath.c_str(),
|
||||
AZ::IO::SystemFile::OpenMode::SF_OPEN_CREATE | AZ::IO::SystemFile::SF_OPEN_CREATE_PATH | AZ::IO::SystemFile::SF_OPEN_WRITE_ONLY))
|
||||
{
|
||||
AZ_Assert(false, "Failed to open test file");
|
||||
}
|
||||
|
||||
if (file.Write(fileContent.c_str(), fileContent.size()) != fileContent.size())
|
||||
{
|
||||
AZ_Assert(false, "Failed to write test file");
|
||||
}
|
||||
file.Close();
|
||||
}
|
||||
|
||||
void RemoveTestFile()
|
||||
{
|
||||
if (!m_normalizedConfigFilePath.empty())
|
||||
{
|
||||
AZ_Assert(AZ::IO::SystemFile::Delete(m_normalizedConfigFilePath.c_str()),
|
||||
"Failed to delete test config file at %s", m_normalizedConfigFilePath.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void RemoveTestDirectory()
|
||||
{
|
||||
if (!m_normalizedConfigFilePath.empty())
|
||||
{
|
||||
AZ_Assert(AZ::IO::SystemFile::DeleteDir(m_normalizedConfigFolderPath.c_str()),
|
||||
"Failed to delete test config folder at %s", m_normalizedConfigFolderPath.c_str());
|
||||
AZ_Assert(AZ::IO::SystemFile::DeleteDir(m_normalizedSourceProjectFolder.c_str()),
|
||||
"Failed to delete test folder at %s", m_normalizedSourceProjectFolder.c_str());
|
||||
}
|
||||
}
|
||||
AZ::IO::Path m_configFilePath;
|
||||
};
|
||||
|
||||
TEST_F(AWSResourceMappingManagerTest, ActivateManager_ParseInvalidConfigFile_ConfigDataIsEmpty)
|
||||
{
|
||||
CreateTestConfigFile(TEST_INVALID_RESOURCE_MAPPING_CONFIG_FILE);
|
||||
CreateFile(m_configFilePath.Native(), TEST_INVALID_RESOURCE_MAPPING_CONFIG_FILE);
|
||||
m_resourceMappingManager->ActivateManager();
|
||||
|
||||
AZStd::string actualAccountId;
|
||||
@@ -212,7 +161,7 @@ TEST_F(AWSResourceMappingManagerTest, ActivateManager_ParseInvalidConfigFile_Con
|
||||
|
||||
TEST_F(AWSResourceMappingManagerTest, ActivateManager_ParseValidConfigFile_ConfigDataIsNotEmpty)
|
||||
{
|
||||
CreateTestConfigFile(TEST_VALID_RESOURCE_MAPPING_CONFIG_FILE);
|
||||
CreateFile(m_configFilePath.Native(), TEST_VALID_RESOURCE_MAPPING_CONFIG_FILE);
|
||||
m_resourceMappingManager->ActivateManager();
|
||||
|
||||
AZStd::string actualAccountId;
|
||||
@@ -227,7 +176,7 @@ TEST_F(AWSResourceMappingManagerTest, ActivateManager_ParseValidConfigFile_Confi
|
||||
|
||||
TEST_F(AWSResourceMappingManagerTest, ActivateManager_ParseTemplateConfigFile_ConfigDataIsNotEmpty)
|
||||
{
|
||||
CreateTestConfigFile(TEST_TEMPLATE_RESOURCE_MAPPING_CONFIG_FILE);
|
||||
CreateFile(m_configFilePath.Native(), TEST_TEMPLATE_RESOURCE_MAPPING_CONFIG_FILE);
|
||||
m_resourceMappingManager->ActivateManager();
|
||||
|
||||
AZStd::string actualAccountId;
|
||||
@@ -242,7 +191,7 @@ TEST_F(AWSResourceMappingManagerTest, ActivateManager_ParseTemplateConfigFile_Co
|
||||
|
||||
TEST_F(AWSResourceMappingManagerTest, ActivateManager_ParseValidConfigFile_ConfigDataIsNotEmptyWithMultithreadCalls)
|
||||
{
|
||||
CreateTestConfigFile(TEST_VALID_RESOURCE_MAPPING_CONFIG_FILE);
|
||||
CreateFile(m_configFilePath.Native(), TEST_VALID_RESOURCE_MAPPING_CONFIG_FILE);
|
||||
m_resourceMappingManager->ActivateManager();
|
||||
|
||||
constexpr int testThreadNumber = 10;
|
||||
@@ -267,7 +216,7 @@ TEST_F(AWSResourceMappingManagerTest, ActivateManager_ParseValidConfigFile_Confi
|
||||
|
||||
TEST_F(AWSResourceMappingManagerTest, ActivateManager_ParseValidConfigFile_GlobalAccountIdEmpty)
|
||||
{
|
||||
CreateTestConfigFile(TEST_VALID_EMPTY_ACCOUNTID_RESOURCE_MAPPING_CONFIG_FILE);
|
||||
CreateFile(m_configFilePath.Native(), TEST_VALID_EMPTY_ACCOUNTID_RESOURCE_MAPPING_CONFIG_FILE);
|
||||
m_resourceMappingManager->ActivateManager();
|
||||
|
||||
AZStd::string actualAccountId;
|
||||
@@ -282,7 +231,7 @@ TEST_F(AWSResourceMappingManagerTest, ActivateManager_ParseValidConfigFile_Globa
|
||||
|
||||
TEST_F(AWSResourceMappingManagerTest, DeactivateManager_AfterActivatingWithValidConfigFile_ConfigDataGetCleanedUp)
|
||||
{
|
||||
CreateTestConfigFile(TEST_VALID_RESOURCE_MAPPING_CONFIG_FILE);
|
||||
CreateFile(m_configFilePath.Native(), TEST_VALID_RESOURCE_MAPPING_CONFIG_FILE);
|
||||
m_resourceMappingManager->ActivateManager();
|
||||
|
||||
AZStd::string actualAccountId;
|
||||
@@ -302,7 +251,7 @@ TEST_F(AWSResourceMappingManagerTest, DeactivateManager_AfterActivatingWithValid
|
||||
|
||||
TEST_F(AWSResourceMappingManagerTest, GetDefaultAccountId_AfterParsingValidConfigFile_GetExpectedDefaultAccountId)
|
||||
{
|
||||
CreateTestConfigFile(TEST_VALID_RESOURCE_MAPPING_CONFIG_FILE);
|
||||
CreateFile(m_configFilePath.Native(), TEST_VALID_RESOURCE_MAPPING_CONFIG_FILE);
|
||||
m_resourceMappingManager->ActivateManager();
|
||||
|
||||
AZStd::string actualAccountId;
|
||||
@@ -313,7 +262,7 @@ TEST_F(AWSResourceMappingManagerTest, GetDefaultAccountId_AfterParsingValidConfi
|
||||
|
||||
TEST_F(AWSResourceMappingManagerTest, GetDefaultRegion_AfterParsingValidConfigFile_GetExpectedDefaultRegion)
|
||||
{
|
||||
CreateTestConfigFile(TEST_VALID_RESOURCE_MAPPING_CONFIG_FILE);
|
||||
CreateFile(m_configFilePath.Native(), TEST_VALID_RESOURCE_MAPPING_CONFIG_FILE);
|
||||
m_resourceMappingManager->ActivateManager();
|
||||
|
||||
AZStd::string actualRegion;
|
||||
@@ -324,7 +273,7 @@ TEST_F(AWSResourceMappingManagerTest, GetDefaultRegion_AfterParsingValidConfigFi
|
||||
|
||||
TEST_F(AWSResourceMappingManagerTest, GetResourceAccountId_AfterParsingValidConfigFile_GetExpectedAccountId)
|
||||
{
|
||||
CreateTestConfigFile(TEST_VALID_RESOURCE_MAPPING_CONFIG_FILE);
|
||||
CreateFile(m_configFilePath.Native(), TEST_VALID_RESOURCE_MAPPING_CONFIG_FILE);
|
||||
m_resourceMappingManager->ActivateManager();
|
||||
|
||||
AZStd::string actualAccountId;
|
||||
@@ -341,7 +290,7 @@ TEST_F(AWSResourceMappingManagerTest, GetResourceAccountId_AfterParsingValidConf
|
||||
|
||||
TEST_F(AWSResourceMappingManagerTest, GetResourceAccountId_QueryNonexistResourceMappingKeyName_GetEmptyAccountId)
|
||||
{
|
||||
CreateTestConfigFile(TEST_VALID_RESOURCE_MAPPING_CONFIG_FILE);
|
||||
CreateFile(m_configFilePath.Native(), TEST_VALID_RESOURCE_MAPPING_CONFIG_FILE);
|
||||
m_resourceMappingManager->ActivateManager();
|
||||
|
||||
AZStd::string actualAccountId;
|
||||
@@ -352,7 +301,7 @@ TEST_F(AWSResourceMappingManagerTest, GetResourceAccountId_QueryNonexistResource
|
||||
|
||||
TEST_F(AWSResourceMappingManagerTest, GetResourceNameId_AfterParsingValidConfigFile_GetExpectedNameId)
|
||||
{
|
||||
CreateTestConfigFile(TEST_VALID_RESOURCE_MAPPING_CONFIG_FILE);
|
||||
CreateFile(m_configFilePath.Native(), TEST_VALID_RESOURCE_MAPPING_CONFIG_FILE);
|
||||
m_resourceMappingManager->ActivateManager();
|
||||
|
||||
AZStd::string actualNameId;
|
||||
@@ -369,7 +318,7 @@ TEST_F(AWSResourceMappingManagerTest, GetResourceNameId_AfterParsingValidConfigF
|
||||
|
||||
TEST_F(AWSResourceMappingManagerTest, GetResourceNameId_QueryNonexistResourceMappingKeyName_GetEmptyNameId)
|
||||
{
|
||||
CreateTestConfigFile(TEST_VALID_RESOURCE_MAPPING_CONFIG_FILE);
|
||||
CreateFile(m_configFilePath.Native(), TEST_VALID_RESOURCE_MAPPING_CONFIG_FILE);
|
||||
m_resourceMappingManager->ActivateManager();
|
||||
|
||||
AZStd::string actualNameId;
|
||||
@@ -380,7 +329,7 @@ TEST_F(AWSResourceMappingManagerTest, GetResourceNameId_QueryNonexistResourceMap
|
||||
|
||||
TEST_F(AWSResourceMappingManagerTest, GetResourceRegion_AfterParsingValidConfigFile_GetExpectedRegion)
|
||||
{
|
||||
CreateTestConfigFile(TEST_VALID_RESOURCE_MAPPING_CONFIG_FILE);
|
||||
CreateFile(m_configFilePath.Native(), TEST_VALID_RESOURCE_MAPPING_CONFIG_FILE);
|
||||
m_resourceMappingManager->ActivateManager();
|
||||
|
||||
AZStd::string actualRegion;
|
||||
@@ -397,7 +346,7 @@ TEST_F(AWSResourceMappingManagerTest, GetResourceRegion_AfterParsingValidConfigF
|
||||
|
||||
TEST_F(AWSResourceMappingManagerTest, GetResourceRegion_QueryNonexistResourceMappingKeyName_GetEmptyRegion)
|
||||
{
|
||||
CreateTestConfigFile(TEST_VALID_RESOURCE_MAPPING_CONFIG_FILE);
|
||||
CreateFile(m_configFilePath.Native(), TEST_VALID_RESOURCE_MAPPING_CONFIG_FILE);
|
||||
m_resourceMappingManager->ActivateManager();
|
||||
|
||||
AZStd::string actualRegion;
|
||||
@@ -408,7 +357,7 @@ TEST_F(AWSResourceMappingManagerTest, GetResourceRegion_QueryNonexistResourceMap
|
||||
|
||||
TEST_F(AWSResourceMappingManagerTest, GetResourceType_AfterParsingValidConfigFile_GetExpectedType)
|
||||
{
|
||||
CreateTestConfigFile(TEST_VALID_RESOURCE_MAPPING_CONFIG_FILE);
|
||||
CreateFile(m_configFilePath.Native(), TEST_VALID_RESOURCE_MAPPING_CONFIG_FILE);
|
||||
m_resourceMappingManager->ActivateManager();
|
||||
|
||||
AZStd::string actualType;
|
||||
@@ -425,7 +374,7 @@ TEST_F(AWSResourceMappingManagerTest, GetResourceType_AfterParsingValidConfigFil
|
||||
|
||||
TEST_F(AWSResourceMappingManagerTest, GetResourceType_QueryNonexistResourceMappingKeyName_GetEmptyType)
|
||||
{
|
||||
CreateTestConfigFile(TEST_VALID_RESOURCE_MAPPING_CONFIG_FILE);
|
||||
CreateFile(m_configFilePath.Native(), TEST_VALID_RESOURCE_MAPPING_CONFIG_FILE);
|
||||
m_resourceMappingManager->ActivateManager();
|
||||
|
||||
AZStd::string actualType;
|
||||
@@ -436,7 +385,7 @@ TEST_F(AWSResourceMappingManagerTest, GetResourceType_QueryNonexistResourceMappi
|
||||
|
||||
TEST_F(AWSResourceMappingManagerTest, GetServiceUrl_PassingEmptyServiceName_GetEmptyUrl)
|
||||
{
|
||||
CreateTestConfigFile(TEST_VALID_RESOURCE_MAPPING_CONFIG_FILE);
|
||||
CreateFile(m_configFilePath.Native(), TEST_VALID_RESOURCE_MAPPING_CONFIG_FILE);
|
||||
m_resourceMappingManager->ActivateManager();
|
||||
|
||||
AZStd::string actualServiceUrl;
|
||||
@@ -447,7 +396,7 @@ TEST_F(AWSResourceMappingManagerTest, GetServiceUrl_PassingEmptyServiceName_GetE
|
||||
|
||||
TEST_F(AWSResourceMappingManagerTest, GetServiceUrl_PassingEmptyRESTApiIdAndStage_GetEmptyUrl)
|
||||
{
|
||||
CreateTestConfigFile(TEST_VALID_RESOURCE_MAPPING_CONFIG_FILE);
|
||||
CreateFile(m_configFilePath.Native(), TEST_VALID_RESOURCE_MAPPING_CONFIG_FILE);
|
||||
m_resourceMappingManager->ActivateManager();
|
||||
|
||||
AZStd::string actualServiceUrl;
|
||||
@@ -458,7 +407,7 @@ TEST_F(AWSResourceMappingManagerTest, GetServiceUrl_PassingEmptyRESTApiIdAndStag
|
||||
|
||||
TEST_F(AWSResourceMappingManagerTest, GetServiceUrl_RESTApiIdAndStageHaveInconsistentRegion_GetEmptyUrl)
|
||||
{
|
||||
CreateTestConfigFile(TEST_VALID_RESOURCE_MAPPING_CONFIG_FILE);
|
||||
CreateFile(m_configFilePath.Native(), TEST_VALID_RESOURCE_MAPPING_CONFIG_FILE);
|
||||
m_resourceMappingManager->ActivateManager();
|
||||
|
||||
AZStd::string actualServiceUrl;
|
||||
@@ -469,7 +418,7 @@ TEST_F(AWSResourceMappingManagerTest, GetServiceUrl_RESTApiIdAndStageHaveInconsi
|
||||
|
||||
TEST_F(AWSResourceMappingManagerTest, ReloadConfigFile_ParseValidConfigFileAfterParsingInvalid_ConfigDataGetParsed)
|
||||
{
|
||||
CreateTestConfigFile(TEST_INVALID_RESOURCE_MAPPING_CONFIG_FILE);
|
||||
CreateFile(m_configFilePath.Native(), TEST_INVALID_RESOURCE_MAPPING_CONFIG_FILE);
|
||||
m_resourceMappingManager->ActivateManager();
|
||||
|
||||
AZStd::string actualAccountId;
|
||||
@@ -481,7 +430,7 @@ TEST_F(AWSResourceMappingManagerTest, ReloadConfigFile_ParseValidConfigFileAfter
|
||||
EXPECT_TRUE(actualRegion.empty());
|
||||
EXPECT_TRUE(m_resourceMappingManager->GetStatus() == AWSResourceMappingManager::Status::Error);
|
||||
|
||||
CreateTestConfigFile(TEST_VALID_RESOURCE_MAPPING_CONFIG_FILE);
|
||||
CreateFile(m_configFilePath.Native(), TEST_VALID_RESOURCE_MAPPING_CONFIG_FILE);
|
||||
m_resourceMappingManager->ReloadConfigFile();
|
||||
|
||||
AWSResourceMappingRequestBus::BroadcastResult(actualAccountId, &AWSResourceMappingRequests::GetDefaultAccountId);
|
||||
@@ -494,7 +443,7 @@ TEST_F(AWSResourceMappingManagerTest, ReloadConfigFile_ParseValidConfigFileAfter
|
||||
|
||||
TEST_F(AWSResourceMappingManagerTest, ReloadConfigFile_ReloadConfigFileNameAndParseValidConfigFile_ConfigDataGetParsed)
|
||||
{
|
||||
CreateTestConfigFile(TEST_VALID_RESOURCE_MAPPING_CONFIG_FILE);
|
||||
CreateFile(m_configFilePath.Native(), TEST_VALID_RESOURCE_MAPPING_CONFIG_FILE);
|
||||
m_resourceMappingManager->ReloadConfigFile(true);
|
||||
|
||||
EXPECT_EQ(m_reloadConfigurationCounter, 1);
|
||||
@@ -505,6 +454,7 @@ TEST_F(AWSResourceMappingManagerTest, ReloadConfigFile_ReloadConfigFileNameAndPa
|
||||
|
||||
TEST_F(AWSResourceMappingManagerTest, ReloadConfigFile_MissingSetRegFile_ConfigDataIsNotParsed)
|
||||
{
|
||||
m_configFilePath.clear();
|
||||
m_resourceMappingManager->ReloadConfigFile(true);
|
||||
|
||||
EXPECT_EQ(m_reloadConfigurationCounter, 1);
|
||||
|
||||
@@ -6,8 +6,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AzTest/AzTest.h>
|
||||
|
||||
#include <ResourceMapping/AWSResourceMappingUtils.h>
|
||||
#include <TestFramework/AWSCoreFixture.h>
|
||||
|
||||
@@ -18,7 +16,7 @@ static constexpr const char TEST_VALID_RESTAPI_REGION[] = "us-west-2";
|
||||
static constexpr const char TEST_VALID_RESTAPI_CHINA_REGION[] = "cn-north-1";
|
||||
static constexpr const char TEST_VALID_RESTAPI_STAGE[] = "prod";
|
||||
|
||||
using AWSResourceMappingUtilsTest = UnitTest::ScopedAllocatorSetupFixture;
|
||||
using AWSResourceMappingUtilsTest = AWSCoreFixture;
|
||||
|
||||
TEST_F(AWSResourceMappingUtilsTest, FormatRESTApiUrl_PassingValidArguments_ReturnExpectedResult)
|
||||
{
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
*/
|
||||
|
||||
#include <AzCore/RTTI/BehaviorContext.h>
|
||||
#include <AzTest/AzTest.h>
|
||||
|
||||
#include <ScriptCanvas/AWSScriptBehaviorDynamoDB.h>
|
||||
#include <TestFramework/AWSCoreFixture.h>
|
||||
@@ -32,7 +31,7 @@ public:
|
||||
MOCK_METHOD1(OnGetItemError, void(const AZStd::string&));
|
||||
};
|
||||
|
||||
using AWSScriptBehaviorDynamoDBTest = UnitTest::ScopedAllocatorSetupFixture;
|
||||
using AWSScriptBehaviorDynamoDBTest = AWSCoreFixture;
|
||||
|
||||
TEST_F(AWSScriptBehaviorDynamoDBTest, GetItemRaw_CallWithEmptyTableName_InvokeOnError)
|
||||
{
|
||||
|
||||
@@ -7,14 +7,14 @@
|
||||
*/
|
||||
|
||||
#include <AzCore/RTTI/BehaviorContext.h>
|
||||
#include <AzTest/AzTest.h>
|
||||
|
||||
#include <ScriptCanvas/AWSScriptBehaviorLambda.h>
|
||||
#include <TestFramework/AWSCoreFixture.h>
|
||||
|
||||
using namespace AWSCore;
|
||||
|
||||
class AWSScriptBehaviorLambdaNotificationBusHandlerMock : public AWSScriptBehaviorLambdaNotificationBusHandler
|
||||
class AWSScriptBehaviorLambdaNotificationBusHandlerMock
|
||||
: public AWSScriptBehaviorLambdaNotificationBusHandler
|
||||
{
|
||||
public:
|
||||
AWSScriptBehaviorLambdaNotificationBusHandlerMock()
|
||||
@@ -31,7 +31,7 @@ public:
|
||||
MOCK_METHOD1(OnInvokeError, void(const AZStd::string&));
|
||||
};
|
||||
|
||||
using AWSScriptBehaviorLambdaTest = UnitTest::ScopedAllocatorSetupFixture;
|
||||
using AWSScriptBehaviorLambdaTest = AWSCoreFixture;
|
||||
|
||||
TEST_F(AWSScriptBehaviorLambdaTest, InvokeRaw_CallWithEmptyFunctionName_InvokeOnError)
|
||||
{
|
||||
|
||||
@@ -145,17 +145,18 @@ TEST_F(AWSScriptBehaviorS3Test, GetObjectRaw_CallWithOutfileDirectoryNoExist_Inv
|
||||
AWSScriptBehaviorS3::GetObjectRaw("dummyBucket", "dummyObject", "dummyRegion", dummyDirectory);
|
||||
}
|
||||
|
||||
#if defined(AZ_DEBUG_BUILD) || defined(AZ_PROFILE_BUILD)
|
||||
// The preparation step for this test case does not work in release mode
|
||||
TEST_F(AWSScriptBehaviorS3Test, GetObjectRaw_CallWithOutfileIsReadOnly_InvokeOnError)
|
||||
{
|
||||
AWSScriptBehaviorS3NotificationBusHandlerMock s3HandlerMock;
|
||||
EXPECT_CALL(s3HandlerMock, OnGetObjectError(::testing::_)).Times(1);
|
||||
AZStd::string randomTestFile = AZStd::string::format("%s/test%s.txt",
|
||||
AZ::Test::GetCurrentExecutablePath().c_str(), AZ::Uuid::CreateRandom().ToString<AZStd::string>(false, false).c_str());
|
||||
AzFramework::StringFunc::Path::Normalize(randomTestFile);
|
||||
CreateReadOnlyTestFile(randomTestFile);
|
||||
AWSScriptBehaviorS3::GetObjectRaw("dummyBucket", "dummyObject", "dummyRegion", randomTestFile);
|
||||
RemoveReadOnlyTestFile(randomTestFile);
|
||||
AZ::IO::Path randomTestFilePath = (GetTestTempDirectoryPath() / "random_test.txt").LexicallyNormal();
|
||||
CreateReadOnlyTestFile(randomTestFilePath.Native());
|
||||
AWSScriptBehaviorS3::GetObjectRaw("dummyBucket", "dummyObject", "dummyRegion", randomTestFilePath.Native());
|
||||
RemoveReadOnlyTestFile(randomTestFilePath.Native());
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST_F(AWSScriptBehaviorS3Test, GetObject_NoBucketNameInResourceMappingFound_InvokeOnError)
|
||||
{
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#include <AzCore/Component/ComponentApplication.h>
|
||||
#include <AzCore/Serialization/EditContext.h>
|
||||
#include <AzCore/Serialization/SerializeContext.h>
|
||||
#include <AzTest/AzTest.h>
|
||||
|
||||
#include <ScriptCanvas/AWSScriptBehaviorsComponent.h>
|
||||
#include <TestFramework/AWSCoreFixture.h>
|
||||
@@ -17,11 +16,12 @@
|
||||
using namespace AWSCore;
|
||||
|
||||
class AWSScriptBehaviorsComponentTest
|
||||
: public UnitTest::ScopedAllocatorSetupFixture
|
||||
: public AWSCoreFixture
|
||||
{
|
||||
public:
|
||||
void SetUp() override
|
||||
{
|
||||
AWSCoreFixture::SetUpFixture();
|
||||
m_serializeContext = AZStd::make_unique<AZ::SerializeContext>();
|
||||
m_serializeContext->CreateEditContext();
|
||||
m_behaviorContext = AZStd::make_unique<AZ::BehaviorContext>();
|
||||
@@ -39,6 +39,7 @@ public:
|
||||
m_componentDescriptor.reset();
|
||||
m_behaviorContext.reset();
|
||||
m_serializeContext.reset();
|
||||
AWSCoreFixture::TearDownFixture();
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
#include <Framework/JsonObjectHandler.h>
|
||||
#include <Framework/JsonWriter.h>
|
||||
|
||||
#include <AWSNativeSDKInit/AWSNativeSDKInit.h>
|
||||
|
||||
namespace AWSCoreTestingUtils
|
||||
{
|
||||
static const AZStd::string STRING_VALUE{"s"};
|
||||
@@ -135,6 +137,8 @@ public:
|
||||
{
|
||||
m_app = AZStd::make_unique<AZ::ComponentApplication>();
|
||||
}
|
||||
|
||||
AWSNativeSDKInit::InitializationManager::InitAwsApi();
|
||||
}
|
||||
|
||||
void TearDown() override
|
||||
@@ -144,6 +148,8 @@ public:
|
||||
|
||||
void TearDownFixture(bool mockSettingsRegistry = true)
|
||||
{
|
||||
AWSNativeSDKInit::InitializationManager::Shutdown();
|
||||
|
||||
if (mockSettingsRegistry)
|
||||
{
|
||||
AZ::SettingsRegistry::Unregister(m_settingsRegistry.get());
|
||||
@@ -171,7 +177,7 @@ public:
|
||||
bool CreateFile(const AZStd::string& filePath, const AZStd::string& content)
|
||||
{
|
||||
AZ::IO::HandleType fileHandle;
|
||||
if (!m_localFileIO->Open(filePath.c_str(), AZ::IO::OpenMode::ModeWrite | AZ::IO::OpenMode::ModeText, fileHandle))
|
||||
if (!m_localFileIO->Open(filePath.c_str(), AZ::IO::OpenMode::ModeCreatePath | AZ::IO::OpenMode::ModeWrite | AZ::IO::OpenMode::ModeText, fileHandle))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -197,6 +203,13 @@ private:
|
||||
AZ::IO::FileIOBase* m_otherFileIO = nullptr;
|
||||
|
||||
protected:
|
||||
AZ::IO::Path GetTestTempDirectoryPath()
|
||||
{
|
||||
AZ::IO::Path testTempDirPath{ m_testTempDirectory.GetDirectory() };
|
||||
return testTempDirPath;
|
||||
}
|
||||
|
||||
AZ::Test::ScopedAutoTempDirectory m_testTempDirectory;
|
||||
AZStd::unique_ptr<AZ::SettingsRegistryImpl> m_settingsRegistry;
|
||||
AZStd::unique_ptr<AZ::ComponentApplication> m_app;
|
||||
};
|
||||
|
||||
@@ -1,35 +1,40 @@
|
||||
|
||||
# Welcome to the AWS Core Resource Mapping Tool project!
|
||||
|
||||
## Setup aws config and credential
|
||||
Resource mapping tool is using boto3 to interact with aws services:
|
||||
## Setup aws config and credentials
|
||||
The Resource Mapping Tool uses boto3 to interact with aws services:
|
||||
* Read boto3
|
||||
[Configuration](https://boto3.amazonaws.com/v1/documentation/api/latest/guide/configuration.html) to setup default aws region.
|
||||
* Read boto3
|
||||
[Credentials](https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html) to setup default profile or credential keys.
|
||||
|
||||
Or follow **AWS CLI** configuration which can be reused by boto3 lib:
|
||||
Or follow **AWS CLI** configuration directions which can be reused by the boto3 lib:
|
||||
* Follow
|
||||
[Quick configuration with aws configure](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-quickstart.html#cli-configure-quickstart-config)
|
||||
|
||||
## Python Environment Setup Options
|
||||
### 1. Engine python environment (Including Editor)
|
||||
1. In order to use engine python environment, it requires to link Qt binaries for this tool.
|
||||
### 1. Use Engine python environment (Including Editor)
|
||||
1. In order to use the Open 3D Engine's python environment, this tool requires linking the Qt binaries.
|
||||
Follow cmake instructions to configure your project, for example:
|
||||
```
|
||||
$ cmake -B <BUILD_FOLDER> -S . -G "Visual Studio 16 2019" -DLY_PROJECTS=<PROJECT_NAME>
|
||||
```
|
||||
|
||||
2. At this point, double check engine python environment gets setup under *<ENGINE_ROOT_PATH>/python/runtime* directory
|
||||
2. At this point, double check that the Open 3D Engine's python environment gets set up under *<ENGINE_ROOT_PATH>/python/runtime* directory
|
||||
|
||||
3. Build project with **AWSCore.Editor** (or **AWSCore.ResourceMappintTool**, or **Editor**) target to generate required Qt binaries.
|
||||
3. Build the project with the **AWSCore.Editor** (or **AWSCore.ResourceMappingTool**, or **Editor**) target to generate the required Qt binaries.
|
||||
* Windows
|
||||
```
|
||||
$ cmake --build <BUILD_FOLDER> --target AWSCore.Editor --config <CONFIG> /m
|
||||
```
|
||||
* Linux
|
||||
```
|
||||
$ cmake --build <BUILD_FOLDER> --target AWSCore.Editor --config <CONFIG> -j <NUM_JOBS>
|
||||
```
|
||||
|
||||
4. At this point, double check Qt binaries gets generated under *<BUILD_FOLDER>/bin/<CONFIG_FOLDER>/AWSCoreEditorQtBin* directory
|
||||
4. At this point, double check the Qt binaries have been generated under *<BUILD_FOLDER>/bin/<CONFIG_FOLDER>/AWSCoreEditorQtBin* directory
|
||||
|
||||
5. Launch resource mapping tool under engine root folder:
|
||||
5. Launch the Resource Mapping Tool from the engine root folder:
|
||||
* Windows
|
||||
* release mode
|
||||
```
|
||||
@@ -49,10 +54,9 @@ Follow cmake instructions to configure your project, for example:
|
||||
$ python/python.sh Gems/AWSCore/Code/Tools/ResourceMappingTool/resource_mapping_tool.py --binaries_path <PATH_TO_BUILD_FOLDER>/bin/debug/AWSCoreEditorQtBin
|
||||
```
|
||||
|
||||
* Note - Editor is integrated with the same engine python environment to launch Resource Mapping Tool. If it is failed to launch the tool
|
||||
in Editor, please follow above steps to make sure expected scripts/binaries are present.
|
||||
* Note - the engine Editor is integrated with the same python environment used to launch the Resource Mapping Tool. If the tool fails to launch from the Editor, please double check that you have completed all of the above steps and that the expected scripts and binaries are present in the expected directories.
|
||||
|
||||
### 2. Python virtual environment
|
||||
### 2. Use a separate python virtual environment
|
||||
This project is set up like a standard Python project. The initialization
|
||||
process also creates a virtualenv within this project, stored under the `.env`
|
||||
directory. To create the virtualenv it assumes that there is a `python3`
|
||||
@@ -105,7 +109,23 @@ you can create the virtualenv manually.
|
||||
* `--config-path` **[Optional]** Path to resource mapping config directory,
|
||||
if not provided tool will use current directory.
|
||||
* `--debug` **[Optional]** Execute on debug mode to enable DEBUG logging level.
|
||||
* `--log-path` **[Optional]** Path to resource mapping tool logging directory,
|
||||
* `--log-path` **[Optional]** Path to Resource Mapping Tool logging directory,
|
||||
if not provided tool will store logging under tool source code directory.
|
||||
* `--profile` **[Optional]** Named AWS profile to use for querying AWS resources,
|
||||
if not provided tool will use `default` aws profile.
|
||||
if not provided tool will use `default` aws profile.
|
||||
|
||||
|
||||
## Running tests
|
||||
|
||||
How to run the unit tests for the project:
|
||||
|
||||
1. If not already activated, activate the project's python environment as explained above.
|
||||
2. Use `pytest` to run one or more tests (command paths formatted as if run from this directory):
|
||||
* Run all the tests
|
||||
```
|
||||
python -m pytest -vv .
|
||||
```
|
||||
* Run a specific test file or directory:
|
||||
```
|
||||
python -m pytest tests\unit\model\test_basic_resource_attributes.py
|
||||
```
|
||||
@@ -1,2 +1,5 @@
|
||||
PySide2>=5.15.2
|
||||
boto3>=1.17.30
|
||||
pytest>=5.3.2
|
||||
|
||||
|
||||
|
||||
@@ -123,6 +123,10 @@ namespace ImageProcessingAtomEditor
|
||||
{
|
||||
readableString = "iOS";
|
||||
}
|
||||
else if (platformStrLowerCase == "salem")
|
||||
{
|
||||
readableString = "Salem";
|
||||
}
|
||||
else if (platformStrLowerCase == "jasper")
|
||||
{
|
||||
readableString = "Jasper";
|
||||
|
||||
@@ -82,8 +82,7 @@ namespace AZ
|
||||
// Register Shader Asset Builder
|
||||
AssetBuilderSDK::AssetBuilderDesc shaderAssetBuilderDescriptor;
|
||||
shaderAssetBuilderDescriptor.m_name = "Shader Asset Builder";
|
||||
shaderAssetBuilderDescriptor.m_version = 108; // The Build Time Stamp of ShaderAsset And ShaderVariantAsset Should Be Based On GetTimeUTCMilliSecond()
|
||||
// .shader file changes trigger rebuilds
|
||||
shaderAssetBuilderDescriptor.m_version = 109; // Modify Metal shader platform to permit the precise keyword to fix depth bitwise mismatch between passes
|
||||
shaderAssetBuilderDescriptor.m_patterns.push_back(AssetBuilderSDK::AssetBuilderPattern( AZStd::string::format("*.%s", RPI::ShaderSourceData::Extension), AssetBuilderSDK::AssetBuilderPattern::PatternType::Wildcard));
|
||||
shaderAssetBuilderDescriptor.m_busId = azrtti_typeid<ShaderAssetBuilder>();
|
||||
shaderAssetBuilderDescriptor.m_createJobFunction = AZStd::bind(&ShaderAssetBuilder::CreateJobs, &m_shaderAssetBuilder, AZStd::placeholders::_1, AZStd::placeholders::_2);
|
||||
|
||||
@@ -492,6 +492,14 @@ namespace AZ
|
||||
{
|
||||
platformId = AzFramework::PlatformId::IOS;
|
||||
}
|
||||
else if (platformIdentifier == "salem")
|
||||
{
|
||||
platformId = AzFramework::PlatformId::SALEM;
|
||||
}
|
||||
else if (platformIdentifier == "jasper")
|
||||
{
|
||||
platformId = AzFramework::PlatformId::JASPER;
|
||||
}
|
||||
else if (platformIdentifier == "server")
|
||||
{
|
||||
platformId = AzFramework::PlatformId::SERVER;
|
||||
|
||||
@@ -1652,6 +1652,12 @@
|
||||
"file": "EnhancedPBR_SubsurfaceState.lua"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Lua",
|
||||
"args": {
|
||||
"file": "EnhancedPBR_Anisotropy.lua"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Lua",
|
||||
"args": {
|
||||
|
||||
@@ -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
|
||||
--
|
||||
--
|
||||
--
|
||||
----------------------------------------------------------------------------------------------------
|
||||
|
||||
function GetMaterialPropertyDependencies()
|
||||
return {
|
||||
"anisotropy.enableAnisotropy"
|
||||
, "anisotropy.factor"
|
||||
, "anisotropy.anisotropyAngle"
|
||||
}
|
||||
end
|
||||
|
||||
function GetShaderOptionDependencies()
|
||||
return {"o_enableAnisotropy"}
|
||||
end
|
||||
|
||||
function Process(context)
|
||||
local enableAnisotropy = context:GetMaterialPropertyValue_bool("anisotropy.enableAnisotropy")
|
||||
end
|
||||
|
||||
function ProcessEditor(context)
|
||||
|
||||
local enableAnisotropy = context:GetMaterialPropertyValue_bool("anisotropy.enableAnisotropy")
|
||||
|
||||
local visibility
|
||||
if(enableAnisotropy) then
|
||||
visibility = MaterialPropertyVisibility_Enabled
|
||||
else
|
||||
visibility = MaterialPropertyVisibility_Hidden
|
||||
end
|
||||
|
||||
context:SetMaterialPropertyVisibility("anisotropy.factor", visibility)
|
||||
context:SetMaterialPropertyVisibility("anisotropy.anisotropyAngle", visibility)
|
||||
end
|
||||
@@ -1084,6 +1084,12 @@
|
||||
"file": "Skin_WrinkleMaps.lua"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Lua",
|
||||
"args": {
|
||||
"file": "Skin_SpecularF0.lua"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Lua",
|
||||
"args": {
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
--------------------------------------------------------------------------------------
|
||||
--
|
||||
-- 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
|
||||
--
|
||||
--
|
||||
--
|
||||
----------------------------------------------------------------------------------------------------
|
||||
|
||||
function GetMaterialPropertyDependencies()
|
||||
return {
|
||||
"specularF0.enableMultiScatterCompensation"
|
||||
}
|
||||
end
|
||||
|
||||
function GetShaderOptionDependencies()
|
||||
return {
|
||||
"o_specularF0_enableMultiScatterCompensation"
|
||||
}
|
||||
end
|
||||
|
||||
function Process(context)
|
||||
local enableMultiScatterCompensation = context:GetMaterialPropertyValue_bool("specularF0.enableMultiScatterCompensation")
|
||||
end
|
||||
|
||||
function ProcessEditor(context)
|
||||
context:SetMaterialPropertyVisibility("specularF0.enableMultiScatterCompensation", MaterialPropertyVisibility_Hidden)
|
||||
end
|
||||
@@ -58,6 +58,15 @@ function UpdateTextureDependentPropertyVisibility(context, textureMapPropertyNam
|
||||
end
|
||||
end
|
||||
|
||||
function UpdateNormalStrengthPropertyVisibility(context, textureMapPropertyName, useTexturePropertyName)
|
||||
local textureMap = context:GetMaterialPropertyValue_Image(textureMapPropertyName)
|
||||
local useTexture = context:GetMaterialPropertyValue_bool(useTexturePropertyName)
|
||||
|
||||
if(textureMap == nil) or (not useTexture) then
|
||||
context:SetMaterialPropertyVisibility("clearCoat.normalStrength", MaterialPropertyVisibility_Hidden)
|
||||
end
|
||||
end
|
||||
|
||||
function ProcessEditor(context)
|
||||
local enable = context:GetMaterialPropertyValue_bool("clearCoat.enable")
|
||||
|
||||
@@ -79,10 +88,12 @@ function ProcessEditor(context)
|
||||
context:SetMaterialPropertyVisibility("clearCoat.normalMap", mainVisibility)
|
||||
context:SetMaterialPropertyVisibility("clearCoat.useNormalMap", mainVisibility)
|
||||
context:SetMaterialPropertyVisibility("clearCoat.normalMapUv", mainVisibility)
|
||||
context:SetMaterialPropertyVisibility("clearCoat.normalStrength", mainVisibility)
|
||||
|
||||
if(enable) then
|
||||
UpdateTextureDependentPropertyVisibility(context, "clearCoat.influenceMap", "clearCoat.useInfluenceMap", "clearCoat.influenceMapUv")
|
||||
UpdateTextureDependentPropertyVisibility(context, "clearCoat.roughnessMap", "clearCoat.useRoughnessMap", "clearCoat.roughnessMapUv")
|
||||
UpdateTextureDependentPropertyVisibility(context, "clearCoat.normalMap", "clearCoat.useNormalMap", "clearCoat.normalMapUv")
|
||||
UpdateNormalStrengthPropertyVisibility(context, "clearCoat.normalMap", "clearCoat.useNormalMap")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -29,7 +29,7 @@ struct VSInput
|
||||
struct VSDepthOutput
|
||||
{
|
||||
// "centroid" is needed for SV_Depth to compile
|
||||
linear centroid float4 m_position : SV_Position;
|
||||
precise linear centroid float4 m_position : SV_Position;
|
||||
float2 m_uv[UvSetCount] : UV1;
|
||||
|
||||
// only used for parallax depth calculation
|
||||
|
||||
@@ -62,7 +62,7 @@ struct VSOutput
|
||||
{
|
||||
// Base fields (required by the template azsli file)...
|
||||
// "centroid" is needed for SV_Depth to compile
|
||||
linear centroid float4 m_position : SV_Position;
|
||||
precise linear centroid float4 m_position : SV_Position;
|
||||
float3 m_normal: NORMAL;
|
||||
float3 m_tangent : TANGENT;
|
||||
float3 m_bitangent : BITANGENT;
|
||||
|
||||
@@ -91,6 +91,10 @@ function ProcessEditor(context)
|
||||
if(mainVisibility == MaterialPropertyVisibility_Enabled) then
|
||||
local alphaSource = context:GetMaterialPropertyValue_enum("opacity.alphaSource")
|
||||
|
||||
if (opacityMode == OpacityMode_Cutout and alphaSource == AlphaSource_None) then
|
||||
context:SetMaterialPropertyVisibility("opacity.factor", MaterialPropertyVisibility_Hidden)
|
||||
end
|
||||
|
||||
if(alphaSource ~= AlphaSource_Split) then
|
||||
context:SetMaterialPropertyVisibility("opacity.textureMap", MaterialPropertyVisibility_Hidden)
|
||||
context:SetMaterialPropertyVisibility("opacity.textureMapUv", MaterialPropertyVisibility_Hidden)
|
||||
|
||||
@@ -26,6 +26,54 @@
|
||||
"Name": "DepthStencilInputOutput",
|
||||
"SlotType": "InputOutput",
|
||||
"ScopeAttachmentUsage": "DepthStencil"
|
||||
},
|
||||
{
|
||||
"Name": "IrradianceOutput",
|
||||
"SlotType": "InputOutput",
|
||||
"ScopeAttachmentUsage": "RenderTarget",
|
||||
"LoadStoreAction": {
|
||||
"ClearValue": {
|
||||
"Value": [
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0
|
||||
]
|
||||
},
|
||||
"LoadAction": "Clear"
|
||||
}
|
||||
}
|
||||
],
|
||||
"ImageAttachments": [
|
||||
{
|
||||
"Name": "IrradianceImage",
|
||||
"SizeSource": {
|
||||
"Source": {
|
||||
"Pass": "This",
|
||||
"Attachment": "NormalInput"
|
||||
},
|
||||
"Multipliers": {
|
||||
"WidthMultiplier": 0.25,
|
||||
"HeightMultiplier": 0.25
|
||||
}
|
||||
},
|
||||
"MultisampleSource": {
|
||||
"Pass": "This",
|
||||
"Attachment": "NormalInput"
|
||||
},
|
||||
"ImageDescriptor": {
|
||||
"Format": "R16G16B16A16_FLOAT",
|
||||
"SharedQueueMask": "Graphics"
|
||||
}
|
||||
}
|
||||
],
|
||||
"Connections": [
|
||||
{
|
||||
"LocalSlot": "IrradianceOutput",
|
||||
"AttachmentRef": {
|
||||
"Pass": "This",
|
||||
"Attachment": "IrradianceImage"
|
||||
}
|
||||
}
|
||||
],
|
||||
"PassRequests": [
|
||||
@@ -78,7 +126,7 @@
|
||||
{
|
||||
"LocalSlot": "Output",
|
||||
"AttachmentRef": {
|
||||
"Pass": "DiffuseProbeGridDownsamplePass",
|
||||
"Pass": "Parent",
|
||||
"Attachment": "IrradianceOutput"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"ClassData": {
|
||||
"PassTemplate": {
|
||||
"Name": "DiffuseProbeGridDownsamplePassTemplate",
|
||||
"PassClass": "FullScreenTriangle",
|
||||
"PassClass": "DiffuseProbeGridDownsamplePass",
|
||||
"Slots": [
|
||||
{
|
||||
"Name": "NormalInput",
|
||||
@@ -38,24 +38,6 @@
|
||||
"LoadStoreAction": {
|
||||
"LoadAction": "DontCare"
|
||||
}
|
||||
},
|
||||
{
|
||||
// Note: this is attached here to ensure that the image is cleared,
|
||||
// but it is not used as an output from the shader
|
||||
"Name": "IrradianceOutput",
|
||||
"SlotType": "Output",
|
||||
"ScopeAttachmentUsage": "RenderTarget",
|
||||
"LoadStoreAction": {
|
||||
"ClearValue": {
|
||||
"Value": [
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0
|
||||
]
|
||||
},
|
||||
"LoadAction": "Clear"
|
||||
}
|
||||
}
|
||||
],
|
||||
"ImageAttachments": [
|
||||
@@ -103,27 +85,6 @@
|
||||
"Format": "R16G16B16A16_FLOAT",
|
||||
"SharedQueueMask": "Graphics"
|
||||
}
|
||||
},
|
||||
{
|
||||
"Name": "IrradianceImage",
|
||||
"SizeSource": {
|
||||
"Source": {
|
||||
"Pass": "This",
|
||||
"Attachment": "NormalInput"
|
||||
},
|
||||
"Multipliers": {
|
||||
"WidthMultiplier": 0.25,
|
||||
"HeightMultiplier": 0.25
|
||||
}
|
||||
},
|
||||
"MultisampleSource": {
|
||||
"Pass": "This",
|
||||
"Attachment": "NormalInput"
|
||||
},
|
||||
"ImageDescriptor": {
|
||||
"Format": "R16G16B16A16_FLOAT",
|
||||
"SharedQueueMask": "Graphics"
|
||||
}
|
||||
}
|
||||
],
|
||||
"Connections": [
|
||||
@@ -140,13 +101,6 @@
|
||||
"Pass": "This",
|
||||
"Attachment": "DownsampledDepthImage"
|
||||
}
|
||||
},
|
||||
{
|
||||
"LocalSlot": "IrradianceOutput",
|
||||
"AttachmentRef": {
|
||||
"Pass": "This",
|
||||
"Attachment": "IrradianceImage"
|
||||
}
|
||||
}
|
||||
],
|
||||
"PassData": {
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ static const float MinRoughnessA = 0.0005f;
|
||||
|
||||
class BasePbrSurfaceData
|
||||
{
|
||||
float3 position; //!< Position in world-space
|
||||
precise float3 position; //!< Position in world-space
|
||||
float3 normal; //!< Normal in world-space
|
||||
float3 albedo; //!< Albedo color of the non-metallic material, will be multiplied against the diffuse lighting value
|
||||
float3 specularF0; //!< Fresnel f0 spectral value of the surface
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ class Surface
|
||||
|
||||
// ------- BasePbrSurfaceData -------
|
||||
|
||||
float3 position; //!< Position in world-space
|
||||
precise float3 position; //!< Position in world-space
|
||||
float3 normal; //!< Normal in world-space
|
||||
float3 vertexNormal; //!< Vertex normal in world-space
|
||||
float3 albedo; //!< Albedo color of the non-metallic material, will be multiplied against the diffuse lighting value
|
||||
|
||||
+49
-3
@@ -10,6 +10,7 @@
|
||||
|
||||
#include <scenesrg.srgi>
|
||||
#include <viewsrg.srgi>
|
||||
#include <Atom/RPI/Math.azsli>
|
||||
#include "Shadow.azsli"
|
||||
#include "ShadowmapAtlasLib.azsli"
|
||||
#include "BicubicPcfFilters.azsli"
|
||||
@@ -25,6 +26,10 @@
|
||||
enum class ShadowFilterMethod {None, Pcf, Esm, EsmPcf};
|
||||
option ShadowFilterMethod o_directional_shadow_filtering_method = ShadowFilterMethod::None;
|
||||
option bool o_directional_shadow_receiver_plane_bias_enable = true;
|
||||
option bool o_blend_between_cascades_enable = false;
|
||||
|
||||
static const float CascadeBlendArea = 0.015f; // might be worth exposing this as a slider.
|
||||
|
||||
|
||||
// DirectionalLightShadow calculates lit ratio for a directional light.
|
||||
class DirectionalLightShadow
|
||||
@@ -98,6 +103,8 @@ class DirectionalLightShadow
|
||||
|
||||
float SamplePcfBicubic(float3 shadowCoord, uint indexOfCascade);
|
||||
|
||||
float CalculateCascadeBlendAmount(const float3 texCoord);
|
||||
|
||||
uint m_lightIndex;
|
||||
float3 m_shadowCoords[ViewSrg::MaxCascadeCount];
|
||||
float m_slopeBias[ViewSrg::MaxCascadeCount];
|
||||
@@ -174,6 +181,7 @@ bool2 DirectionalLightShadow::IsShadowed(float3 shadowCoord, uint indexOfCascade
|
||||
const uint cascadeCount = ViewSrg::m_directionalLightShadows[m_lightIndex].m_cascadeCount;
|
||||
Texture2DArray<float> shadowmap = PassSrg::m_directionalLightShadowmap;
|
||||
|
||||
[branch]
|
||||
if (shadowCoord.x >= 0. && shadowCoord.x * size < size - PixelMargin &&
|
||||
shadowCoord.y >= 0. && shadowCoord.y * size < size - PixelMargin)
|
||||
{
|
||||
@@ -213,20 +221,46 @@ float DirectionalLightShadow::GetVisibilityFromLightPcf()
|
||||
static const float PixelMargin = 1.5; // avoiding artifact between cascade levels.
|
||||
static const float DepthMargin = 1e-8; // avoiding artifact when near depth bounds.
|
||||
|
||||
bool cascadeFound = false;
|
||||
int currentCascadeIndex = 0;
|
||||
|
||||
const uint size = ViewSrg::m_directionalLightShadows[m_lightIndex].m_shadowmapSize;
|
||||
const uint cascadeCount = ViewSrg::m_directionalLightShadows[m_lightIndex].m_cascadeCount;
|
||||
for (uint indexOfCascade = 0; indexOfCascade < cascadeCount; ++indexOfCascade)
|
||||
{
|
||||
const float3 shadowCoord = m_shadowCoords[indexOfCascade];
|
||||
|
||||
|
||||
if (shadowCoord.x >= 0. && shadowCoord.x * size < size - PixelMargin &&
|
||||
shadowCoord.y >= 0. && shadowCoord.y * size < size - PixelMargin &&
|
||||
shadowCoord.z < 1. - DepthMargin)
|
||||
{
|
||||
m_debugInfo.m_cascadeIndex = indexOfCascade;
|
||||
return SamplePcfBicubic(shadowCoord, indexOfCascade);
|
||||
currentCascadeIndex = m_debugInfo.m_cascadeIndex = indexOfCascade;
|
||||
cascadeFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
[branch]
|
||||
if (cascadeFound)
|
||||
{
|
||||
float lit = SamplePcfBicubic(m_shadowCoords[currentCascadeIndex], currentCascadeIndex);
|
||||
|
||||
if(o_blend_between_cascades_enable)
|
||||
{
|
||||
const float blendBetweenCascadesAmount = CalculateCascadeBlendAmount(m_shadowCoords[currentCascadeIndex].xyz);
|
||||
|
||||
const int nextCascadeIndex = currentCascadeIndex + 1;
|
||||
[branch]
|
||||
if (blendBetweenCascadesAmount < 1.0f && nextCascadeIndex < cascadeCount)
|
||||
{
|
||||
const float nextLit = SamplePcfBicubic(m_shadowCoords[nextCascadeIndex], nextCascadeIndex);
|
||||
lit = lerp(nextLit, lit, blendBetweenCascadesAmount);
|
||||
}
|
||||
}
|
||||
|
||||
return lit;
|
||||
}
|
||||
|
||||
m_debugInfo.m_cascadeIndex = cascadeCount;
|
||||
return 1.;
|
||||
}
|
||||
@@ -244,6 +278,8 @@ float DirectionalLightShadow::GetVisibilityFromLightEsm()
|
||||
const float distanceMin = ViewSrg::m_esmsDirectional[indexOfCascade].m_lightDistanceOfCameraViewFrustum;
|
||||
bool2 checkedShadowed = IsShadowed(shadowCoord, indexOfCascade);
|
||||
const float depthDiff = shadowCoord.z - distanceMin;
|
||||
|
||||
[branch]
|
||||
if (checkedShadowed.x && depthDiff >= 0)
|
||||
{
|
||||
const float distanceWithinCameraView = depthDiff / (1. - distanceMin);
|
||||
@@ -274,6 +310,8 @@ float DirectionalLightShadow::GetVisibilityFromLightEsmPcf()
|
||||
const float distanceMin = ViewSrg::m_esmsDirectional[indexOfCascade].m_lightDistanceOfCameraViewFrustum;
|
||||
bool2 checkedShadowed = IsShadowed(shadowCoord, indexOfCascade);
|
||||
const float depthDiff = shadowCoord.z - distanceMin;
|
||||
|
||||
[branch]
|
||||
if (checkedShadowed.x && depthDiff >= 0)
|
||||
{
|
||||
const float distanceWithinCameraView = depthDiff / (1. - distanceMin);
|
||||
@@ -319,6 +357,7 @@ float DirectionalLightShadow::SamplePcfBicubic(float3 shadowCoord, uint indexOfC
|
||||
param.samplerState = SceneSrg::m_hwPcfSampler;
|
||||
param.receiverPlaneDepthBias = o_directional_shadow_receiver_plane_bias_enable ? ComputeReceiverPlaneDepthBias(m_shadowPosDX[indexOfCascade], m_shadowPosDY[indexOfCascade]) : 0;
|
||||
|
||||
[branch]
|
||||
if (filteringSampleCount <= 4)
|
||||
{
|
||||
return SampleShadowMapBicubic_4Tap(param);
|
||||
@@ -420,3 +459,10 @@ float3 DirectionalLightShadow::AddDebugColoring(
|
||||
}
|
||||
return color;
|
||||
}
|
||||
|
||||
float DirectionalLightShadow::CalculateCascadeBlendAmount(const float3 texCoord)
|
||||
{
|
||||
const float distanceToOneMin = min3(1.0f - texCoord);
|
||||
const float currentPixelsBlendBandLocation = min(min(texCoord.x, texCoord.y), distanceToOneMin);
|
||||
return currentPixelsBlendBandLocation / CascadeBlendArea;
|
||||
}
|
||||
|
||||
@@ -13,4 +13,5 @@
|
||||
#ifdef AZ_COLLECTING_PARTIAL_SRGS
|
||||
#include <Atom/RPI/ShaderResourceGroups/DefaultSceneSrg.azsli>
|
||||
#include <Atom/Feature/Common/Assets/ShaderResourceGroups/SceneSrg.azsli>
|
||||
#include <Terrain/Assets/Shaders/Terrain/SceneSrg.azsli> // Temporary until gem partial view srgs can be included automatically.
|
||||
#endif
|
||||
|
||||
@@ -12,5 +12,4 @@
|
||||
|
||||
#ifdef AZ_COLLECTING_PARTIAL_SRGS
|
||||
#include <Atom/Feature/Common/Assets/ShaderResourceGroups/ViewSrg.azsli>
|
||||
#include <Terrain/Assets/Shaders/Terrain/ViewSrg.azsli> // Temporary until gem partial view srgs can be included automatically.
|
||||
#endif
|
||||
|
||||
@@ -368,16 +368,19 @@ void CullDecals(uint groupIndex, TileLightData tileLightData, float3 aabb_center
|
||||
float3 decalPosition = WorldToView_Point(decal.m_position);
|
||||
|
||||
// just wrapping a bounding sphere around a cube for now to get a minor perf boost. i.e. the sphere radius is sqrt(x*x + y*y + z*z)
|
||||
// ATOM-4224 - try AABB-AABB and implement depth binning for the decals
|
||||
float maxHalfSize = max(max(decal.m_halfSize.x, decal.m_halfSize.y), decal.m_halfSize.z);
|
||||
float boundingSphereRadiusSqr = maxHalfSize * maxHalfSize * 3;
|
||||
// ATOM-4224 - try AABB-AABB
|
||||
float boundingSphereRadiusSqr = dot(decal.m_halfSize, decal.m_halfSize);
|
||||
|
||||
bool potentiallyIntersects = TestSphereVsAabb(decalPosition, boundingSphereRadiusSqr, aabb_center, aabb_extents);
|
||||
|
||||
if (potentiallyIntersects)
|
||||
{
|
||||
// Implement and profile fine-grained light culling testing
|
||||
// ATOM-3732
|
||||
MarkLightAsVisibleInSharedMemory(decalIndex, 0xFFFF);
|
||||
uint inside = 0;
|
||||
float2 minmax = ComputePointLightMinMaxZ(sqrt(boundingSphereRadiusSqr), decalPosition);
|
||||
if (IsObjectInsideTile(tileLightData, minmax, inside))
|
||||
{
|
||||
MarkLightAsVisibleInSharedMemory(decalIndex, inside);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,61 +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
|
||||
*
|
||||
*/
|
||||
|
||||
#include <Atom/RPI/ShaderResourceGroups/DefaultDrawSrg.azsli>
|
||||
#include <Atom/Features/PostProcessing/FullscreenPixelInfo.azsli>
|
||||
#include <Atom/Features/PostProcessing/FullscreenVertex.azsli>
|
||||
|
||||
ShaderResourceGroup PassSrg : SRG_PerPass
|
||||
{
|
||||
Texture2D m_sourceTexture;
|
||||
|
||||
Sampler TextureSampler
|
||||
{
|
||||
MinFilter = Point;
|
||||
MagFilter = Point;
|
||||
MipFilter = Point;
|
||||
AddressU = Clamp;
|
||||
AddressV = Clamp;
|
||||
AddressW = Clamp;
|
||||
};
|
||||
}
|
||||
|
||||
float4 RestoreNormalMap(float4 normalMapSample)
|
||||
{
|
||||
float4 restoredNormal;
|
||||
|
||||
// [GFX TODO][ATOM-2404] For some reason, the image build pipeline swaps the R and G channels so we swap them back here.
|
||||
restoredNormal.xy = normalMapSample.yx;
|
||||
|
||||
// The image build pipeline drops the B channel so we have to reconstruct it here.
|
||||
restoredNormal.z = sqrt(1 - dot(restoredNormal.xy, restoredNormal.xy));
|
||||
|
||||
restoredNormal.xyz = restoredNormal.xyz * 0.5 + 0.5;
|
||||
restoredNormal.a = 1;
|
||||
|
||||
return restoredNormal;
|
||||
}
|
||||
|
||||
option bool o_isNormal;
|
||||
|
||||
PSOutput MainPS(VSOutput IN)
|
||||
{
|
||||
PSOutput OUT;
|
||||
|
||||
if(o_isNormal)
|
||||
{
|
||||
float4 sampledValue = PassSrg::m_sourceTexture.SampleLevel(PassSrg::TextureSampler, IN.m_texCoord, 0);
|
||||
OUT.m_color = RestoreNormalMap(sampledValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
OUT.m_color = PassSrg::m_sourceTexture.SampleLevel(PassSrg::TextureSampler, IN.m_texCoord, 0);
|
||||
}
|
||||
|
||||
return OUT;
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
{
|
||||
"Source" : "RenderTexture.azsl",
|
||||
|
||||
"DepthStencilState" : {
|
||||
"Depth" : { "Enable" : false }
|
||||
},
|
||||
|
||||
"ProgramSettings":
|
||||
{
|
||||
"EntryPoints":
|
||||
[
|
||||
{
|
||||
"name": "MainVS",
|
||||
"type": "Vertex"
|
||||
},
|
||||
{
|
||||
"name": "MainPS",
|
||||
"type": "Fragment"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
{
|
||||
"Shader" : "RenderTexture.shader",
|
||||
"Variants" : [
|
||||
{
|
||||
"StableId": 1,
|
||||
"Options": {
|
||||
"o_isNormal": "false"
|
||||
}
|
||||
},
|
||||
{
|
||||
"StableId": 2,
|
||||
"Options": {
|
||||
"o_isNormal": "true"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -366,8 +366,6 @@ set(FILES
|
||||
Shaders/LightCulling/LightCullingRemap.shader
|
||||
Shaders/LightCulling/LightCullingTilePrepare.azsl
|
||||
Shaders/LightCulling/LightCullingTilePrepare.shader
|
||||
Shaders/LuxCore/RenderTexture.azsl
|
||||
Shaders/LuxCore/RenderTexture.shader
|
||||
Shaders/MorphTargets/MorphTargetCS.azsl
|
||||
Shaders/MorphTargets/MorphTargetCS.shader
|
||||
Shaders/MorphTargets/MorphTargetSRG.azsli
|
||||
|
||||
@@ -40,7 +40,6 @@ ly_add_target(
|
||||
Gem::Atom_Feature_Common.Public
|
||||
Gem::ImGui.imguilib
|
||||
3rdParty::TIFF
|
||||
#3rdParty::lux_core # AZ_TRAIT_LUXCORE_SUPPORTED is disabled in every platform, Issue #3915 will remove
|
||||
RUNTIME_DEPENDENCIES
|
||||
Gem::ImGui.imguilib
|
||||
)
|
||||
@@ -91,11 +90,16 @@ ly_add_target(
|
||||
AZ::AzFramework
|
||||
Gem::Atom_Feature_Common.Static
|
||||
Gem::Atom_Feature_Common.Public
|
||||
#3rdParty::lux_core # AZ_TRAIT_LUXCORE_SUPPORTED is disabled in every platform, Issue #3915 will remove
|
||||
)
|
||||
|
||||
if(PAL_TRAIT_BUILD_HOST_TOOLS)
|
||||
|
||||
set(runtime_dependencies_tools ${pal_source_dir}/runtime_dependencies_tools.cmake)
|
||||
foreach(pal_tools_platform ${LY_PAL_TOOLS_ENABLED})
|
||||
ly_get_list_relative_pal_filename(pal_runtime_dependencies_source_dir ${CMAKE_CURRENT_LIST_DIR}/Source/Platform/${pal_tools_platform})
|
||||
list(APPEND runtime_dependencies_tools ${pal_runtime_dependencies_source_dir}/runtime_dependencies_tools.cmake)
|
||||
endforeach()
|
||||
|
||||
ly_add_target(
|
||||
NAME Atom_Feature_Common.Editor GEM_MODULE
|
||||
|
||||
@@ -103,7 +107,7 @@ if(PAL_TRAIT_BUILD_HOST_TOOLS)
|
||||
FILES_CMAKE
|
||||
atom_feature_common_editor_files.cmake
|
||||
PLATFORM_INCLUDE_FILES
|
||||
${pal_source_dir}/runtime_dependencies_tools.cmake
|
||||
${runtime_dependencies_tools}
|
||||
INCLUDE_DIRECTORIES
|
||||
PRIVATE
|
||||
.
|
||||
@@ -136,7 +140,7 @@ if(PAL_TRAIT_BUILD_HOST_TOOLS)
|
||||
FILES_CMAKE
|
||||
atom_feature_common_builders_files.cmake
|
||||
PLATFORM_INCLUDE_FILES
|
||||
${pal_source_dir}/runtime_dependencies_tools.cmake
|
||||
${runtime_dependencies_tools}
|
||||
INCLUDE_DIRECTORIES
|
||||
PRIVATE
|
||||
Source/Builders
|
||||
|
||||
+3
@@ -163,6 +163,9 @@ namespace AZ
|
||||
|
||||
//! Reduces acne by biasing the shadowmap lookup along the geometric normal.
|
||||
virtual void SetNormalShadowBias(LightHandle handle, float normalShadowBias) = 0;
|
||||
|
||||
//! Sets whether or not blending between shadow map cascades is enabled.
|
||||
virtual void SetCascadeBlendingEnabled(LightHandle handle, bool enable) = 0;
|
||||
};
|
||||
} // namespace Render
|
||||
} // namespace AZ
|
||||
|
||||
@@ -1,63 +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
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <Atom/RPI.Reflect/Model/ModelAsset.h>
|
||||
#include <Atom/RPI.Reflect/Image/Image.h>
|
||||
#include <Atom/RPI.Public/Material/Material.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
namespace Render
|
||||
{
|
||||
enum LuxCoreTextureType
|
||||
{
|
||||
Default = 0,
|
||||
IBL,
|
||||
Albedo,
|
||||
Normal
|
||||
};
|
||||
|
||||
class LuxCoreRequests
|
||||
: public EBusTraits
|
||||
{
|
||||
|
||||
public:
|
||||
/// Overrides the default AZ::EBusTraits handler policy to allow one listener only.
|
||||
static const EBusHandlerPolicy HandlerPolicy = EBusHandlerPolicy::Single;
|
||||
virtual ~LuxCoreRequests() {}
|
||||
virtual void SetCameraEntityID(AZ::EntityId id) = 0;
|
||||
virtual void AddMesh(Data::Asset<RPI::ModelAsset> modelAsset) = 0;
|
||||
virtual void AddMaterial(Data::Instance<RPI::Material> material) = 0;
|
||||
virtual void AddTexture(Data::Instance<RPI::Image> texture, LuxCoreTextureType type) = 0;
|
||||
virtual void AddObject(Data::Asset<RPI::ModelAsset> modelAsset, Data::InstanceId materialInstanceId) = 0;
|
||||
virtual bool CheckTextureStatus() = 0;
|
||||
virtual void RenderInLuxCore() = 0;
|
||||
virtual void ClearLuxCore() = 0;
|
||||
virtual void ClearObject() = 0;
|
||||
};
|
||||
|
||||
typedef AZ::EBus<LuxCoreRequests> LuxCoreRequestsBus;
|
||||
|
||||
class LuxCoreNotification
|
||||
: public EBusTraits
|
||||
{
|
||||
public:
|
||||
static const EBusAddressPolicy AddressPolicy = EBusAddressPolicy::ById;
|
||||
/**
|
||||
* Overrides the default AZ::EBusTraits ID type so that AssetId are
|
||||
* used to access the addresses of the bus.
|
||||
*/
|
||||
typedef Data::AssetId BusIdType;
|
||||
virtual ~LuxCoreNotification() {}
|
||||
|
||||
virtual void OnRenderPrepare() {}
|
||||
};
|
||||
typedef AZ::EBus<LuxCoreNotification> LuxCoreNotificationBus;
|
||||
}
|
||||
}
|
||||
@@ -1,51 +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
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/Memory/SystemAllocator.h>
|
||||
|
||||
#include <Atom/RPI.Public/Pass/AttachmentReadback.h>
|
||||
#include <Atom/RPI.Public/Pass/ParentPass.h>
|
||||
#include <Atom/RPI.Reflect/Image/Image.h>
|
||||
|
||||
#include <Atom/Feature/LuxCore/RenderTexturePass.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
namespace Render
|
||||
{
|
||||
class LuxCoreTexturePass final
|
||||
: public RPI::ParentPass
|
||||
{
|
||||
public:
|
||||
AZ_RTTI(LuxCoreTexturePass, "{A6CA80C0-63A6-4686-A627-B5D1DA04B627}", ParentPass);
|
||||
AZ_CLASS_ALLOCATOR(LuxCoreTexturePass, SystemAllocator, 0);
|
||||
|
||||
static RPI::Ptr<LuxCoreTexturePass> Create(const RPI::PassDescriptor& descriptor);
|
||||
|
||||
LuxCoreTexturePass(const RPI::PassDescriptor& descriptor);
|
||||
~LuxCoreTexturePass();
|
||||
|
||||
void SetSourceTexture(Data::Instance<AZ::RPI::Image> image, RHI::Format format);
|
||||
void SetIsNormalTexture(bool isNormal);
|
||||
void SetReadbackCallback(RPI::AttachmentReadback::CallbackFunction callbackFunciton);
|
||||
|
||||
protected:
|
||||
// Pass behavior overrides
|
||||
void CreateChildPassesInternal() final;
|
||||
void BuildInternal() final;
|
||||
void FrameBeginInternal(FramePrepareParams params) final;
|
||||
|
||||
private:
|
||||
|
||||
RPI::Ptr<RPI::Pass> m_renderTargetPass = nullptr;
|
||||
AZStd::shared_ptr<RPI::AttachmentReadback> m_readback = nullptr;
|
||||
bool m_attachmentReadbackComplete = false;
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,55 +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
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <Atom/RPI.Public/Pass/FullscreenTrianglePass.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
namespace Render
|
||||
{
|
||||
/*
|
||||
* A simple pass to render a texture to an attachment render target
|
||||
* The attachment size and format will be configure as the same as the input texture
|
||||
*/
|
||||
class RenderTexturePass final
|
||||
: public RPI::FullscreenTrianglePass
|
||||
{
|
||||
|
||||
AZ_RPI_PASS(RenderTexturePass);
|
||||
|
||||
public:
|
||||
AZ_RTTI(RenderTexturePass, "{476A4E41-08D7-456C-B324-E0493A321FE7}", FullscreenTrianglePass);
|
||||
AZ_CLASS_ALLOCATOR(RenderTexturePass, SystemAllocator, 0);
|
||||
virtual ~RenderTexturePass();
|
||||
|
||||
static RPI::Ptr<RenderTexturePass> Create(const RPI::PassDescriptor& descriptor);
|
||||
|
||||
// Set the source image
|
||||
void SetPassSrgImage(AZ::Data::Instance<AZ::RPI::Image> image, RHI::Format format);
|
||||
|
||||
RHI::AttachmentId GetRenderTargetId();
|
||||
|
||||
void InitShaderVariant(bool isNormal);
|
||||
|
||||
protected:
|
||||
RenderTexturePass(const RPI::PassDescriptor& descriptor);
|
||||
|
||||
private:
|
||||
|
||||
void BuildInternal() override;
|
||||
void FrameBeginInternal(FramePrepareParams params) override;
|
||||
|
||||
void UpdataAttachment();
|
||||
|
||||
RHI::ShaderInputImageIndex m_textureIndex;
|
||||
RHI::Size m_attachmentSize;
|
||||
RHI::Format m_attachmentFormat;
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -74,11 +74,6 @@
|
||||
|
||||
#include <Atom/RPI.Public/Pass/PassSystemInterface.h>
|
||||
|
||||
#if AZ_TRAIT_LUXCORE_SUPPORTED
|
||||
#include <Atom/Feature/LuxCore/RenderTexturePass.h>
|
||||
#include <Atom/Feature/LuxCore/LuxCoreTexturePass.h>
|
||||
#endif
|
||||
|
||||
#include <Checkerboard/CheckerboardPass.h>
|
||||
#include <Checkerboard/CheckerboardColorResolvePass.h>
|
||||
|
||||
@@ -97,6 +92,7 @@
|
||||
#include <DiffuseGlobalIllumination/DiffuseProbeGridBorderUpdatePass.h>
|
||||
#include <DiffuseGlobalIllumination/DiffuseProbeGridRelocationPass.h>
|
||||
#include <DiffuseGlobalIllumination/DiffuseProbeGridClassificationPass.h>
|
||||
#include <DiffuseGlobalIllumination/DiffuseProbeGridDownsamplePass.h>
|
||||
#include <DiffuseGlobalIllumination/DiffuseProbeGridRenderPass.h>
|
||||
#include <DiffuseGlobalIllumination/DiffuseProbeGridFeatureProcessor.h>
|
||||
#include <DiffuseGlobalIllumination/DiffuseGlobalIlluminationFeatureProcessor.h>
|
||||
@@ -220,11 +216,6 @@ namespace AZ
|
||||
passSystem->AddPassCreator(Name("DisplayMapperFullScreenPass"), &DisplayMapperFullScreenPass::Create);
|
||||
passSystem->AddPassCreator(Name("OutputTransformPass"), &OutputTransformPass::Create);
|
||||
passSystem->AddPassCreator(Name("EyeAdaptationPass"), &EyeAdaptationPass::Create);
|
||||
// Add RenderTexture and LuxCoreTexture pass
|
||||
#if AZ_TRAIT_LUXCORE_SUPPORTED
|
||||
passSystem->AddPassCreator(Name("RenderTexturePass"), &RenderTexturePass::Create);
|
||||
passSystem->AddPassCreator(Name("LuxCoreTexturePass"), &LuxCoreTexturePass::Create);
|
||||
#endif
|
||||
passSystem->AddPassCreator(Name("ImGuiPass"), &ImGuiPass::Create);
|
||||
passSystem->AddPassCreator(Name("LightCullingPass"), &LightCullingPass::Create);
|
||||
passSystem->AddPassCreator(Name("LightCullingRemapPass"), &LightCullingRemap::Create);
|
||||
@@ -285,6 +276,7 @@ namespace AZ
|
||||
passSystem->AddPassCreator(Name("DiffuseProbeGridBorderUpdatePass"), &Render::DiffuseProbeGridBorderUpdatePass::Create);
|
||||
passSystem->AddPassCreator(Name("DiffuseProbeGridRelocationPass"), &Render::DiffuseProbeGridRelocationPass::Create);
|
||||
passSystem->AddPassCreator(Name("DiffuseProbeGridClassificationPass"), &Render::DiffuseProbeGridClassificationPass::Create);
|
||||
passSystem->AddPassCreator(Name("DiffuseProbeGridDownsamplePass"), &Render::DiffuseProbeGridDownsamplePass::Create);
|
||||
passSystem->AddPassCreator(Name("DiffuseProbeGridRenderPass"), &Render::DiffuseProbeGridRenderPass::Create);
|
||||
|
||||
passSystem->AddPassCreator(Name("LuminanceHistogramGeneratorPass"), &LuminanceHistogramGeneratorPass::Create);
|
||||
|
||||
@@ -12,10 +12,6 @@
|
||||
|
||||
#include <Atom/RPI.Public/Pass/PassSystemInterface.h>
|
||||
|
||||
#if AZ_TRAIT_LUXCORE_SUPPORTED
|
||||
#include "LuxCore/LuxCoreRenderer.h"
|
||||
#endif
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
namespace Render
|
||||
@@ -50,11 +46,6 @@ namespace AZ
|
||||
RPI::PassSystemInterface::OnReadyLoadTemplatesEvent::Handler m_loadTemplatesHandler;
|
||||
|
||||
AZStd::unique_ptr<ModelReloaderSystem> m_modelReloaderSystem;
|
||||
|
||||
#if AZ_TRAIT_LUXCORE_SUPPORTED
|
||||
// LuxCore
|
||||
LuxCoreRenderer m_luxCore;
|
||||
#endif
|
||||
};
|
||||
} // namespace Render
|
||||
} // namespace AZ
|
||||
|
||||
+10
-3
@@ -198,13 +198,15 @@ namespace AZ
|
||||
|
||||
if (m_shadowingLightHandle.IsValid())
|
||||
{
|
||||
uint32_t shadowFilterMethod = m_shadowData.at(nullptr).GetData(m_shadowingLightHandle.GetIndex()).m_shadowFilterMethod;
|
||||
const uint32_t shadowFilterMethod = m_shadowData.at(nullptr).GetData(m_shadowingLightHandle.GetIndex()).m_shadowFilterMethod;
|
||||
RPI::ShaderSystemInterface::Get()->SetGlobalShaderOption(m_directionalShadowFilteringMethodName, AZ::RPI::ShaderOptionValue{shadowFilterMethod});
|
||||
RPI::ShaderSystemInterface::Get()->SetGlobalShaderOption(m_directionalShadowReceiverPlaneBiasEnableName, AZ::RPI::ShaderOptionValue{ m_shadowProperties.GetData(m_shadowingLightHandle.GetIndex()).m_isReceiverPlaneBiasEnabled });
|
||||
RPI::ShaderSystemInterface::Get()->SetGlobalShaderOption(m_directionalShadowReceiverPlaneBiasEnableName, AZ::RPI::ShaderOptionValue{ m_shadowProperties.GetData(m_shadowingLightHandle.GetIndex()).m_isReceiverPlaneBiasEnabled });
|
||||
|
||||
const uint32_t cascadeCount = m_shadowData.at(nullptr).GetData(m_shadowingLightHandle.GetIndex()).m_cascadeCount;
|
||||
ShadowProperty& property = m_shadowProperties.GetData(m_shadowingLightHandle.GetIndex());
|
||||
|
||||
RPI::ShaderSystemInterface::Get()->SetGlobalShaderOption(m_BlendBetweenCascadesEnableName, AZ::RPI::ShaderOptionValue{cascadeCount > 1 && m_shadowProperties.GetData(m_shadowingLightHandle.GetIndex()).m_blendBetwenCascades });
|
||||
|
||||
ShadowProperty& property = m_shadowProperties.GetData(m_shadowingLightHandle.GetIndex());
|
||||
bool segmentsNeedUpdate = property.m_segments.empty();
|
||||
for (const auto& passIt : m_cascadedShadowmapsPasses)
|
||||
{
|
||||
@@ -577,6 +579,11 @@ namespace AZ
|
||||
m_shadowProperties.GetData(handle.GetIndex()).m_isReceiverPlaneBiasEnabled = enable;
|
||||
}
|
||||
|
||||
void DirectionalLightFeatureProcessor::SetCascadeBlendingEnabled(LightHandle handle, bool enable)
|
||||
{
|
||||
m_shadowProperties.GetData(handle.GetIndex()).m_blendBetwenCascades = enable;
|
||||
}
|
||||
|
||||
void DirectionalLightFeatureProcessor::SetShadowBias(LightHandle handle, float bias)
|
||||
{
|
||||
for (auto& it : m_shadowData)
|
||||
|
||||
@@ -176,6 +176,8 @@ namespace AZ
|
||||
// If true, this will reduce the shadow acne introduced by large pcf kernels by estimating the angle of the triangle being shaded
|
||||
// with the ddx/ddy functions.
|
||||
bool m_isReceiverPlaneBiasEnabled = true;
|
||||
|
||||
bool m_blendBetwenCascades = false;
|
||||
};
|
||||
|
||||
static void Reflect(ReflectContext* context);
|
||||
@@ -215,6 +217,7 @@ namespace AZ
|
||||
void SetShadowFilterMethod(LightHandle handle, ShadowFilterMethod method) override;
|
||||
void SetFilteringSampleCount(LightHandle handle, uint16_t count) override;
|
||||
void SetShadowReceiverPlaneBiasEnabled(LightHandle handle, bool enable) override;
|
||||
void SetCascadeBlendingEnabled(LightHandle handle, bool enable) override;
|
||||
void SetShadowBias(LightHandle handle, float bias) override;
|
||||
void SetNormalShadowBias(LightHandle handle, float normalShadowBias) override;
|
||||
|
||||
@@ -367,6 +370,7 @@ namespace AZ
|
||||
Name m_lightTypeName = Name("directional");
|
||||
Name m_directionalShadowFilteringMethodName = Name("o_directional_shadow_filtering_method");
|
||||
Name m_directionalShadowReceiverPlaneBiasEnableName = Name("o_directional_shadow_receiver_plane_bias_enable");
|
||||
Name m_BlendBetweenCascadesEnableName = Name("o_blend_between_cascades_enable");
|
||||
static constexpr const char* FeatureProcessorName = "DirectionalLightFeatureProcessor";
|
||||
};
|
||||
} // namespace Render
|
||||
|
||||
@@ -101,6 +101,13 @@ namespace AZ
|
||||
void EsmShadowmapsPass::UpdateChildren()
|
||||
{
|
||||
const RPI::PassAttachmentBinding& inputBinding = GetInputBinding(0);
|
||||
|
||||
if (!inputBinding.m_attachment)
|
||||
{
|
||||
AZ_Assert(false, "[EsmShadowmapsPass %s] requires an input attachment", GetPathName().GetCStr());
|
||||
return;
|
||||
}
|
||||
|
||||
AZ_Assert(inputBinding.m_attachment->m_descriptor.m_type == RHI::AttachmentType::Image, "[EsmShadowmapsPass %s] input attachment requires an image attachment", GetPathName().GetCStr());
|
||||
m_shadowmapImageSize = inputBinding.m_attachment->m_descriptor.m_image.m_size;
|
||||
m_shadowmapArraySize = inputBinding.m_attachment->m_descriptor.m_image.m_arraySize;
|
||||
|
||||
+24
-3
@@ -9,6 +9,7 @@
|
||||
#include <AzCore/Serialization/SerializeContext.h>
|
||||
#include <Atom/RPI.Public/RPIUtils.h>
|
||||
#include <Atom/RPI.Public/Scene.h>
|
||||
#include <Atom/RPI.Public/Pass/ParentPass.h>
|
||||
#include <Atom/RPI.Public/Pass/PassFilter.h>
|
||||
#include <Atom/RPI.Public/Pass/FullscreenTrianglePass.h>
|
||||
#include <DiffuseGlobalIllumination/DiffuseGlobalIlluminationFeatureProcessor.h>
|
||||
@@ -90,10 +91,11 @@ namespace AZ
|
||||
downsamplePassFilter,
|
||||
[sizeMultiplier](RPI::Pass* pass) -> RPI::PassFilterExecutionFlow
|
||||
{
|
||||
for (uint32_t outputIndex = 0; outputIndex < pass->GetOutputCount(); ++outputIndex)
|
||||
// update the downsample pass size multipliers
|
||||
for (uint32_t attachmentIndex = 0; attachmentIndex < pass->GetOutputCount(); ++attachmentIndex)
|
||||
{
|
||||
RPI::Ptr<RPI::PassAttachment> outputAttachment = pass->GetOutputBinding(outputIndex).m_attachment;
|
||||
RPI::PassAttachmentSizeMultipliers& sizeMultipliers = outputAttachment->m_sizeMultipliers;
|
||||
RPI::Ptr<RPI::PassAttachment> attachment = pass->GetOutputBinding(attachmentIndex).m_attachment;
|
||||
RPI::PassAttachmentSizeMultipliers& sizeMultipliers = attachment->m_sizeMultipliers;
|
||||
|
||||
sizeMultipliers.m_widthMultiplier = sizeMultiplier;
|
||||
sizeMultipliers.m_heightMultiplier = sizeMultiplier;
|
||||
@@ -105,6 +107,25 @@ namespace AZ
|
||||
downsamplePass->GetShaderResourceGroup()->SetConstant(
|
||||
outputImageScaleShaderInput, aznumeric_cast<uint32_t>(1.0f / sizeMultiplier));
|
||||
|
||||
// update the parent pass IrradianceImage size multiplier
|
||||
RPI::ParentPass* parentPass = pass->GetParent();
|
||||
RPI::Ptr<RPI::PassAttachment> irradianceImageAttachment;
|
||||
for (uint32_t attachmentIndex = 0; attachmentIndex < parentPass->GetInputOutputCount(); ++attachmentIndex)
|
||||
{
|
||||
RPI::Ptr<RPI::PassAttachment> attachment = parentPass->GetInputOutputBinding(attachmentIndex).m_attachment;
|
||||
if (attachment->m_name == Name("IrradianceImage"))
|
||||
{
|
||||
irradianceImageAttachment = attachment;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
AZ_Assert(irradianceImageAttachment != nullptr, "Unable to find IrradianceImage attachment");
|
||||
|
||||
RPI::PassAttachmentSizeMultipliers& sizeMultipliers = irradianceImageAttachment->m_sizeMultipliers;
|
||||
sizeMultipliers.m_widthMultiplier = sizeMultiplier;
|
||||
sizeMultipliers.m_heightMultiplier = sizeMultiplier;
|
||||
|
||||
// handle all downsample passes
|
||||
return RPI::PassFilterExecutionFlow::ContinueVisitingPasses;
|
||||
});
|
||||
|
||||
+10
-1
@@ -13,6 +13,7 @@
|
||||
#include <Atom/RPI.Public/Pass/PassUtils.h>
|
||||
#include <Atom/RPI.Public/RenderPipeline.h>
|
||||
#include <Atom/RPI.Public/RPIUtils.h>
|
||||
#include <Atom_Feature_Traits_Platform.h>
|
||||
#include <DiffuseGlobalIllumination/DiffuseProbeGridFeatureProcessor.h>
|
||||
#include <DiffuseGlobalIllumination/DiffuseProbeGridBlendDistancePass.h>
|
||||
#include <RayTracing/RayTracingFeatureProcessor.h>
|
||||
@@ -30,7 +31,15 @@ namespace AZ
|
||||
DiffuseProbeGridBlendDistancePass::DiffuseProbeGridBlendDistancePass(const RPI::PassDescriptor& descriptor)
|
||||
: RPI::RenderPass(descriptor)
|
||||
{
|
||||
LoadShader();
|
||||
if (!AZ_TRAIT_DIFFUSE_GI_PASSES_SUPPORTED)
|
||||
{
|
||||
// GI is not supported on this platform
|
||||
SetEnabled(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
LoadShader();
|
||||
}
|
||||
}
|
||||
|
||||
void DiffuseProbeGridBlendDistancePass::LoadShader()
|
||||
|
||||
+10
-1
@@ -13,6 +13,7 @@
|
||||
#include <Atom/RPI.Public/Pass/PassUtils.h>
|
||||
#include <Atom/RPI.Public/RenderPipeline.h>
|
||||
#include <Atom/RPI.Public/RPIUtils.h>
|
||||
#include <Atom_Feature_Traits_Platform.h>
|
||||
#include <DiffuseGlobalIllumination/DiffuseProbeGridFeatureProcessor.h>
|
||||
#include <DiffuseGlobalIllumination/DiffuseProbeGridBlendIrradiancePass.h>
|
||||
#include <RayTracing/RayTracingFeatureProcessor.h>
|
||||
@@ -30,7 +31,15 @@ namespace AZ
|
||||
DiffuseProbeGridBlendIrradiancePass::DiffuseProbeGridBlendIrradiancePass(const RPI::PassDescriptor& descriptor)
|
||||
: RPI::RenderPass(descriptor)
|
||||
{
|
||||
LoadShader();
|
||||
if (!AZ_TRAIT_DIFFUSE_GI_PASSES_SUPPORTED)
|
||||
{
|
||||
// GI is not supported on this platform
|
||||
SetEnabled(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
LoadShader();
|
||||
}
|
||||
}
|
||||
|
||||
void DiffuseProbeGridBlendIrradiancePass::LoadShader()
|
||||
|
||||
+19
-10
@@ -13,6 +13,7 @@
|
||||
#include <Atom/RPI.Public/Pass/PassUtils.h>
|
||||
#include <Atom/RPI.Public/RenderPipeline.h>
|
||||
#include <Atom/RPI.Public/RPIUtils.h>
|
||||
#include <Atom_Feature_Traits_Platform.h>
|
||||
#include <DiffuseGlobalIllumination/DiffuseProbeGridFeatureProcessor.h>
|
||||
#include <DiffuseGlobalIllumination/DiffuseProbeGridBorderUpdatePass.h>
|
||||
#include <RayTracing/RayTracingFeatureProcessor.h>
|
||||
@@ -30,17 +31,25 @@ namespace AZ
|
||||
DiffuseProbeGridBorderUpdatePass::DiffuseProbeGridBorderUpdatePass(const RPI::PassDescriptor& descriptor)
|
||||
: RPI::RenderPass(descriptor)
|
||||
{
|
||||
LoadShader("Shaders/DiffuseGlobalIllumination/DiffuseProbeGridBorderUpdateRow.azshader",
|
||||
m_rowShader,
|
||||
m_rowPipelineState,
|
||||
m_rowSrgLayout,
|
||||
m_rowDispatchArgs);
|
||||
if (!AZ_TRAIT_DIFFUSE_GI_PASSES_SUPPORTED)
|
||||
{
|
||||
// GI is not supported on this platform
|
||||
SetEnabled(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
LoadShader("Shaders/DiffuseGlobalIllumination/DiffuseProbeGridBorderUpdateRow.azshader",
|
||||
m_rowShader,
|
||||
m_rowPipelineState,
|
||||
m_rowSrgLayout,
|
||||
m_rowDispatchArgs);
|
||||
|
||||
LoadShader("Shaders/DiffuseGlobalIllumination/DiffuseProbeGridBorderUpdateColumn.azshader",
|
||||
m_columnShader,
|
||||
m_columnPipelineState,
|
||||
m_columnSrgLayout,
|
||||
m_columnDispatchArgs);
|
||||
LoadShader("Shaders/DiffuseGlobalIllumination/DiffuseProbeGridBorderUpdateColumn.azshader",
|
||||
m_columnShader,
|
||||
m_columnPipelineState,
|
||||
m_columnSrgLayout,
|
||||
m_columnDispatchArgs);
|
||||
}
|
||||
}
|
||||
|
||||
void DiffuseProbeGridBorderUpdatePass::LoadShader(AZStd::string shaderFilePath,
|
||||
|
||||
+10
-1
@@ -17,6 +17,7 @@
|
||||
#include <Atom/RPI.Reflect/Pass/PassTemplate.h>
|
||||
#include <Atom/RPI.Public/View.h>
|
||||
#include <Atom/RPI.Public/Scene.h>
|
||||
#include <Atom_Feature_Traits_Platform.h>
|
||||
#include <DiffuseGlobalIllumination/DiffuseProbeGridFeatureProcessor.h>
|
||||
#include <DiffuseGlobalIllumination/DiffuseProbeGridClassificationPass.h>
|
||||
#include <RayTracing/RayTracingFeatureProcessor.h>
|
||||
@@ -34,7 +35,15 @@ namespace AZ
|
||||
DiffuseProbeGridClassificationPass::DiffuseProbeGridClassificationPass(const RPI::PassDescriptor& descriptor)
|
||||
: RPI::RenderPass(descriptor)
|
||||
{
|
||||
LoadShader();
|
||||
if (!AZ_TRAIT_DIFFUSE_GI_PASSES_SUPPORTED)
|
||||
{
|
||||
// GI is not supported on this platform
|
||||
SetEnabled(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
LoadShader();
|
||||
}
|
||||
}
|
||||
|
||||
void DiffuseProbeGridClassificationPass::LoadShader()
|
||||
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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 "DiffuseProbeGridDownsamplePass.h"
|
||||
#include <DiffuseGlobalIllumination/DiffuseProbeGridFeatureProcessor.h>
|
||||
#include <Atom/RPI.Public/RenderPipeline.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
namespace Render
|
||||
{
|
||||
RPI::Ptr<DiffuseProbeGridDownsamplePass> DiffuseProbeGridDownsamplePass::Create(const RPI::PassDescriptor& descriptor)
|
||||
{
|
||||
RPI::Ptr<DiffuseProbeGridDownsamplePass> pass = aznew DiffuseProbeGridDownsamplePass(descriptor);
|
||||
return AZStd::move(pass);
|
||||
}
|
||||
|
||||
DiffuseProbeGridDownsamplePass::DiffuseProbeGridDownsamplePass(const RPI::PassDescriptor& descriptor)
|
||||
: RPI::FullscreenTrianglePass(descriptor)
|
||||
{
|
||||
}
|
||||
|
||||
bool DiffuseProbeGridDownsamplePass::IsEnabled() const
|
||||
{
|
||||
if (!Base::IsEnabled())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
RPI::Scene* scene = m_pipeline->GetScene();
|
||||
if (!scene)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// only enabled if there are DiffuseProbeGrids present in the scene
|
||||
DiffuseProbeGridFeatureProcessor* diffuseProbeGridFeatureProcessor = scene->GetFeatureProcessor<DiffuseProbeGridFeatureProcessor>();
|
||||
return (diffuseProbeGridFeatureProcessor && !diffuseProbeGridFeatureProcessor->GetProbeGrids().empty());
|
||||
}
|
||||
|
||||
} // namespace RPI
|
||||
} // namespace AZ
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* 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 <Atom/RPI.Public/Pass/Pass.h>
|
||||
#include <Atom/RPI.Public/Pass/FullscreenTrianglePass.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
namespace Render
|
||||
{
|
||||
//! This pass downsamples the scene for use by the DiffuseProbeGridRenderPass.
|
||||
class DiffuseProbeGridDownsamplePass
|
||||
: public RPI::FullscreenTrianglePass
|
||||
{
|
||||
using Base = RPI::FullscreenTrianglePass;
|
||||
AZ_RPI_PASS(DiffuseProbeGridDownsamplePass);
|
||||
|
||||
public:
|
||||
AZ_RTTI(Render::DiffuseProbeGridDownsamplePass, "{B3331B68-F974-44D6-806B-2CFFB4B6B563}", Base);
|
||||
AZ_CLASS_ALLOCATOR(Render::DiffuseProbeGridDownsamplePass, SystemAllocator, 0);
|
||||
|
||||
//! Creates a new pass without a PassTemplate
|
||||
static RPI::Ptr<DiffuseProbeGridDownsamplePass> Create(const RPI::PassDescriptor& descriptor);
|
||||
|
||||
private:
|
||||
explicit DiffuseProbeGridDownsamplePass(const RPI::PassDescriptor& descriptor);
|
||||
|
||||
// Pass behavior overrides...
|
||||
bool IsEnabled() const override;
|
||||
};
|
||||
} // namespace RPI
|
||||
} // namespace AZ
|
||||
+3
-2
@@ -19,6 +19,7 @@
|
||||
#include <Atom/RPI.Public/Pass/PassUtils.h>
|
||||
#include <Atom/RPI.Public/RPIUtils.h>
|
||||
#include <Atom/RPI.Public/View.h>
|
||||
#include <Atom_Feature_Traits_Platform.h>
|
||||
#include <Atom/Feature/TransformService/TransformServiceFeatureProcessor.h>
|
||||
#include <DiffuseGlobalIllumination/DiffuseProbeGridFeatureProcessor.h>
|
||||
#include <DiffuseGlobalIllumination/DiffuseProbeGridRayTracingPass.h>
|
||||
@@ -38,9 +39,9 @@ namespace AZ
|
||||
: RPI::RenderPass(descriptor)
|
||||
{
|
||||
RHI::Ptr<RHI::Device> device = RHI::RHISystemInterface::Get()->GetDevice();
|
||||
if (device->GetFeatures().m_rayTracing == false)
|
||||
if (device->GetFeatures().m_rayTracing == false || !AZ_TRAIT_DIFFUSE_GI_PASSES_SUPPORTED)
|
||||
{
|
||||
// raytracing is not supported on this platform
|
||||
// raytracing or GI is not supported on this platform
|
||||
SetEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
+10
-1
@@ -17,6 +17,7 @@
|
||||
#include <Atom/RPI.Reflect/Pass/PassTemplate.h>
|
||||
#include <Atom/RPI.Public/View.h>
|
||||
#include <Atom/RPI.Public/Scene.h>
|
||||
#include <Atom_Feature_Traits_Platform.h>
|
||||
#include <DiffuseGlobalIllumination/DiffuseProbeGridFeatureProcessor.h>
|
||||
#include <DiffuseGlobalIllumination/DiffuseProbeGridRelocationPass.h>
|
||||
#include <RayTracing/RayTracingFeatureProcessor.h>
|
||||
@@ -34,7 +35,15 @@ namespace AZ
|
||||
DiffuseProbeGridRelocationPass::DiffuseProbeGridRelocationPass(const RPI::PassDescriptor& descriptor)
|
||||
: RPI::RenderPass(descriptor)
|
||||
{
|
||||
LoadShader();
|
||||
if (!AZ_TRAIT_DIFFUSE_GI_PASSES_SUPPORTED)
|
||||
{
|
||||
// GI is not supported on this platform
|
||||
SetEnabled(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
LoadShader();
|
||||
}
|
||||
}
|
||||
|
||||
void DiffuseProbeGridRelocationPass::LoadShader()
|
||||
|
||||
+8
@@ -11,6 +11,7 @@
|
||||
#include <Atom/RPI.Public/Image/ImageSystemInterface.h>
|
||||
#include <Atom/RPI.Public/RenderPipeline.h>
|
||||
#include <Atom/RPI.Public/RPIUtils.h>
|
||||
#include <Atom_Feature_Traits_Platform.h>
|
||||
#include <DiffuseGlobalIllumination/DiffuseProbeGridRenderPass.h>
|
||||
#include <DiffuseGlobalIllumination/DiffuseProbeGridFeatureProcessor.h>
|
||||
#include <RayTracing/RayTracingFeatureProcessor.h>
|
||||
@@ -27,6 +28,13 @@ namespace AZ
|
||||
DiffuseProbeGridRenderPass::DiffuseProbeGridRenderPass(const RPI::PassDescriptor& descriptor)
|
||||
: Base(descriptor)
|
||||
{
|
||||
if (!AZ_TRAIT_DIFFUSE_GI_PASSES_SUPPORTED)
|
||||
{
|
||||
// GI is not supported on this platform
|
||||
SetEnabled(false);
|
||||
return;
|
||||
}
|
||||
|
||||
// create the shader resource group
|
||||
// Note: the shader may not be available on all platforms
|
||||
AZStd::string shaderFilePath = "Shaders/DiffuseGlobalIllumination/DiffuseProbeGridRender.azshader";
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <Atom/RPI.Public/RPIUtils.h>
|
||||
#include <Atom/RPI.Public/Scene.h>
|
||||
|
||||
#include <Atom_Feature_Traits_Platform.h>
|
||||
#include <Atom/Feature/ImGui/SystemBus.h>
|
||||
|
||||
namespace AZ
|
||||
@@ -460,6 +461,9 @@ namespace AZ
|
||||
{
|
||||
auto imguiContextScope = ImguiContextScope(m_imguiContext);
|
||||
auto& io = ImGui::GetIO();
|
||||
#if defined(AZ_TRAIT_IMGUI_INI_FILENAME)
|
||||
io.IniFilename = AZ_TRAIT_IMGUI_INI_FILENAME;
|
||||
#endif
|
||||
|
||||
// ImGui IO Setup
|
||||
{
|
||||
|
||||
@@ -1,139 +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
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include <Atom_Feature_Traits_Platform.h>
|
||||
#if AZ_TRAIT_LUXCORE_SUPPORTED
|
||||
|
||||
#include "LuxCoreMaterial.h"
|
||||
#include <Atom/Feature/LuxCore/LuxCoreBus.h>
|
||||
|
||||
#include <Atom/RPI.Reflect/Material/MaterialPropertiesLayout.h>
|
||||
#include <Atom/RPI.Reflect/Material/MaterialPropertyDescriptor.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
namespace Render
|
||||
{
|
||||
LuxCoreMaterial::LuxCoreMaterial(const AZ::Data::Instance<AZ::RPI::Material>& material)
|
||||
{
|
||||
Init(material);
|
||||
}
|
||||
|
||||
LuxCoreMaterial::LuxCoreMaterial(const LuxCoreMaterial &material)
|
||||
{
|
||||
Init(material.m_material);
|
||||
}
|
||||
|
||||
LuxCoreMaterial::~LuxCoreMaterial()
|
||||
{
|
||||
if (m_material)
|
||||
{
|
||||
m_material = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void LuxCoreMaterial::Init(const AZ::Data::Instance<AZ::RPI::Material>& material)
|
||||
{
|
||||
m_material = material;
|
||||
m_luxCoreMaterialName = "scene.materials." + m_material->GetId().ToString<AZStd::string>();
|
||||
m_luxCoreMaterial = m_luxCoreMaterial << luxrays::Property(std::string(m_luxCoreMaterialName.data()) + ".type")("disney");
|
||||
|
||||
ParseProperty(s_pbrColorGroup, ".basecolor");
|
||||
ParseProperty(s_pbrMetallicGroup, ".metallic");
|
||||
ParseProperty(s_pbrRoughnessGroup, ".roughness");
|
||||
ParseProperty(s_pbrSpecularGroup, ".specular");
|
||||
ParseProperty(s_pbrNormalGroup, ".bumptex");
|
||||
}
|
||||
|
||||
bool LuxCoreMaterial::ParseTexture(const char* group, AZStd::string propertyName)
|
||||
{
|
||||
AZ::RPI::MaterialPropertyIndex propertyIndex;
|
||||
|
||||
propertyIndex = m_material->FindPropertyIndex(MakePbrPropertyName(group, s_pbrUseTextureProperty));
|
||||
bool useTexture = m_material->GetPropertyValue<bool>(propertyIndex);
|
||||
|
||||
if (useTexture)
|
||||
{
|
||||
propertyIndex = m_material->FindPropertyIndex(MakePbrPropertyName(group, s_pbrTextureProperty));
|
||||
Data::Instance<RPI::Image> texture = m_material->GetPropertyValue<Data::Instance<RPI::Image>>(propertyIndex);
|
||||
|
||||
if (texture)
|
||||
{
|
||||
if (group == s_pbrNormalGroup)
|
||||
{
|
||||
AZ::Render::LuxCoreRequestsBus::Broadcast(&AZ::Render::LuxCoreRequestsBus::Events::AddTexture, texture, LuxCoreTextureType::Normal);
|
||||
}
|
||||
else if (group == s_pbrColorGroup)
|
||||
{
|
||||
AZ::Render::LuxCoreRequestsBus::Broadcast(&AZ::Render::LuxCoreRequestsBus::Events::AddTexture, texture, LuxCoreTextureType::Albedo);
|
||||
}
|
||||
else
|
||||
{
|
||||
AZ::Render::LuxCoreRequestsBus::Broadcast(&AZ::Render::LuxCoreRequestsBus::Events::AddTexture, texture, LuxCoreTextureType::Default);
|
||||
}
|
||||
|
||||
AZStd::string materialProperty = m_luxCoreMaterialName + propertyName;
|
||||
m_luxCoreMaterial = m_luxCoreMaterial << luxrays::Property(std::string(materialProperty.data()))(std::string(texture->GetAssetId().ToString<AZStd::string>().data()));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
AZ::Name LuxCoreMaterial::MakePbrPropertyName(const char* groupName, const char* propertyName) const
|
||||
{
|
||||
return AZ::Name{AZStd::string::format("%s.%s", groupName, propertyName)};
|
||||
}
|
||||
|
||||
void LuxCoreMaterial::ParseProperty(const char* group, AZStd::string propertyName)
|
||||
{
|
||||
if (!ParseTexture(group, propertyName))
|
||||
{
|
||||
if (group == s_pbrNormalGroup)
|
||||
{
|
||||
// Normal should always be texture
|
||||
return;
|
||||
}
|
||||
else if (group == s_pbrColorGroup)
|
||||
{
|
||||
AZ::RPI::MaterialPropertyIndex propertyIndex;
|
||||
propertyIndex = m_material->FindPropertyIndex(MakePbrPropertyName(s_pbrColorGroup, s_pbrColorProperty));
|
||||
Color color = m_material->GetPropertyValue<Color>(propertyIndex);
|
||||
propertyIndex = m_material->FindPropertyIndex(MakePbrPropertyName(s_pbrColorGroup, s_pbrFactorProperty));
|
||||
float factor = m_material->GetPropertyValue<float>(propertyIndex);
|
||||
|
||||
AZStd::string materialProperty = m_luxCoreMaterialName + propertyName;
|
||||
m_luxCoreMaterial = m_luxCoreMaterial << luxrays::Property(std::string(materialProperty.data()))(float(color.GetR())* factor, float(color.GetG())*factor, float(color.GetB())*factor);
|
||||
}
|
||||
else
|
||||
{
|
||||
AZ::RPI::MaterialPropertyIndex propertyIndex;
|
||||
propertyIndex = m_material->FindPropertyIndex(MakePbrPropertyName(group, s_pbrFactorProperty));
|
||||
float factor = m_material->GetPropertyValue<float>(propertyIndex);
|
||||
|
||||
AZStd::string materialProperty = m_luxCoreMaterialName + propertyName;
|
||||
m_luxCoreMaterial = m_luxCoreMaterial << luxrays::Property(std::string(materialProperty.data()))(factor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
luxrays::Properties LuxCoreMaterial::GetLuxCoreMaterialProperties()
|
||||
{
|
||||
return m_luxCoreMaterial;
|
||||
}
|
||||
|
||||
AZ::Data::InstanceId LuxCoreMaterial::GetMaterialId()
|
||||
{
|
||||
return m_material->GetId();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,61 +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
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <Atom_Feature_Traits_Platform.h>
|
||||
#if AZ_TRAIT_LUXCORE_SUPPORTED
|
||||
|
||||
#include <Atom/RPI.Public/Material/Material.h>
|
||||
#include "LuxCoreTexture.h"
|
||||
|
||||
#include <luxcore/luxcore.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
namespace Render
|
||||
{
|
||||
// Manage mapping between Atom PBR material and LuxCore Disney material
|
||||
class LuxCoreMaterial final
|
||||
{
|
||||
public:
|
||||
LuxCoreMaterial() = default;
|
||||
LuxCoreMaterial(const AZ::Data::Instance<AZ::RPI::Material>& material);
|
||||
LuxCoreMaterial(const LuxCoreMaterial &material);
|
||||
~LuxCoreMaterial();
|
||||
|
||||
luxrays::Properties GetLuxCoreMaterialProperties();
|
||||
AZ::Data::InstanceId GetMaterialId();
|
||||
private:
|
||||
|
||||
static constexpr const char* s_pbrColorGroup = "baseColor";
|
||||
static constexpr const char* s_pbrMetallicGroup = "metallic";
|
||||
static constexpr const char* s_pbrRoughnessGroup = "roughness";
|
||||
static constexpr const char* s_pbrSpecularGroup = "specularF0";
|
||||
static constexpr const char* s_pbrNormalGroup = "normal";
|
||||
static constexpr const char* s_pbrOpacityGroup = "opacity";
|
||||
|
||||
static constexpr const char* s_pbrColorProperty = "color";
|
||||
static constexpr const char* s_pbrFactorProperty = "factor";
|
||||
static constexpr const char* s_pbrUseTextureProperty = "useTexture";
|
||||
static constexpr const char* s_pbrTextureProperty = "textureMap";
|
||||
|
||||
void ParseProperty(const char* group, AZStd::string propertyName);
|
||||
bool ParseTexture(const char* group, AZStd::string propertyName);
|
||||
AZ::Name MakePbrPropertyName(const char* groupName, const char* propertyName) const;
|
||||
|
||||
void Init(const AZ::Data::Instance<AZ::RPI::Material>& material);
|
||||
|
||||
AZStd::string m_luxCoreMaterialName;
|
||||
luxrays::Properties m_luxCoreMaterial;
|
||||
|
||||
AZ::Data::Instance<AZ::RPI::Material> m_material = nullptr;
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,135 +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
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include <Atom_Feature_Traits_Platform.h>
|
||||
#if AZ_TRAIT_LUXCORE_SUPPORTED
|
||||
|
||||
#include "LuxCoreMesh.h"
|
||||
#include <luxcore/luxcore.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
namespace Render
|
||||
{
|
||||
LuxCoreMesh::LuxCoreMesh(AZ::Data::Asset<AZ::RPI::ModelAsset> modelAsset)
|
||||
{
|
||||
Init(modelAsset);
|
||||
}
|
||||
|
||||
LuxCoreMesh::LuxCoreMesh(const LuxCoreMesh &model)
|
||||
{
|
||||
Init(model.m_modelAsset);
|
||||
}
|
||||
|
||||
LuxCoreMesh::~LuxCoreMesh()
|
||||
{
|
||||
if (m_position)
|
||||
{
|
||||
delete m_position;
|
||||
m_position = nullptr;
|
||||
}
|
||||
|
||||
if (m_normal)
|
||||
{
|
||||
delete m_normal;
|
||||
m_normal = nullptr;
|
||||
}
|
||||
|
||||
if (m_uv)
|
||||
{
|
||||
delete m_uv;
|
||||
m_uv = nullptr;
|
||||
}
|
||||
|
||||
if (m_index)
|
||||
{
|
||||
delete m_index;
|
||||
m_index = nullptr;
|
||||
}
|
||||
|
||||
if (m_modelAsset)
|
||||
{
|
||||
m_modelAsset.Reset();
|
||||
}
|
||||
}
|
||||
|
||||
void LuxCoreMesh::Init(AZ::Data::Asset<AZ::RPI::ModelAsset> modelAsset)
|
||||
{
|
||||
m_modelAsset = modelAsset;
|
||||
// [TODO ATOM-3547] Multiple meshes handling
|
||||
AZ::RPI::ModelLodAsset::Mesh mesh = m_modelAsset->GetLodAssets()[0]->GetMeshes()[0];
|
||||
|
||||
// index data
|
||||
AZStd::array_view<uint8_t> indexBuffer = mesh.GetIndexBufferAssetView().GetBufferAsset()->GetBuffer();
|
||||
m_index = luxcore::Scene::AllocTrianglesBuffer(mesh.GetIndexCount() / 3);
|
||||
memcpy(m_index, indexBuffer.data(), indexBuffer.size());
|
||||
|
||||
// vertices data
|
||||
for (AZ::RPI::ModelLodAsset::Mesh::StreamBufferInfo streamBufferInfo : mesh.GetStreamBufferInfoList())
|
||||
{
|
||||
AZStd::array_view<uint8_t> dataBuffer = streamBufferInfo.m_bufferAssetView.GetBufferAsset()->GetBuffer();
|
||||
|
||||
if (streamBufferInfo.m_semantic == RHI::ShaderSemantic{ "POSITION" })
|
||||
{
|
||||
m_position = luxcore::Scene::AllocVerticesBuffer(mesh.GetVertexCount());
|
||||
memcpy(m_position, dataBuffer.data(), dataBuffer.size());
|
||||
}
|
||||
else if (streamBufferInfo.m_semantic == RHI::ShaderSemantic{ "NORMAL" })
|
||||
{
|
||||
m_normal = new float[mesh.GetVertexCount() * 3];
|
||||
memcpy(m_normal, dataBuffer.data(), dataBuffer.size());
|
||||
}
|
||||
else if (streamBufferInfo.m_semantic == RHI::ShaderSemantic{ "UV", 0 })
|
||||
{
|
||||
m_uv = new float[mesh.GetVertexCount() * 2];
|
||||
memcpy(m_uv, dataBuffer.data(), dataBuffer.size());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
uint32_t LuxCoreMesh::GetVertexCount()
|
||||
{
|
||||
// [TODO ATOM-3547] Multiple meshes handling
|
||||
return m_modelAsset->GetLodAssets()[0]->GetMeshes()[0].GetVertexCount();
|
||||
}
|
||||
|
||||
uint32_t LuxCoreMesh::GetTriangleCount()
|
||||
{
|
||||
// [TODO ATOM-3547] Multiple meshes handling
|
||||
return (m_modelAsset->GetLodAssets()[0]->GetMeshes()[0].GetIndexCount() / 3);
|
||||
}
|
||||
|
||||
AZ::Data::AssetId LuxCoreMesh::GetMeshId()
|
||||
{
|
||||
return m_modelAsset->GetId();
|
||||
}
|
||||
|
||||
const float* LuxCoreMesh::GetPositionData()
|
||||
{
|
||||
return m_position;
|
||||
}
|
||||
|
||||
const float* LuxCoreMesh::GetNormalData()
|
||||
{
|
||||
return m_normal;
|
||||
}
|
||||
|
||||
const float* LuxCoreMesh::GetUVData()
|
||||
{
|
||||
return m_uv;
|
||||
}
|
||||
|
||||
const unsigned int* LuxCoreMesh::GetIndexData()
|
||||
{
|
||||
return m_index;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,49 +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
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <Atom_Feature_Traits_Platform.h>
|
||||
#if AZ_TRAIT_LUXCORE_SUPPORTED
|
||||
|
||||
#include <Atom/RPI.Reflect/Model/ModelAsset.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
namespace Render
|
||||
{
|
||||
// Extract vertex and index data from source model
|
||||
class LuxCoreMesh final
|
||||
{
|
||||
public:
|
||||
LuxCoreMesh() = default;
|
||||
LuxCoreMesh(AZ::Data::Asset<AZ::RPI::ModelAsset> modelAsset);
|
||||
LuxCoreMesh(const LuxCoreMesh &mesh);
|
||||
~LuxCoreMesh();
|
||||
|
||||
AZ::Data::AssetId GetMeshId();
|
||||
const float* GetPositionData();
|
||||
const float* GetNormalData();
|
||||
const float* GetUVData();
|
||||
const unsigned int* GetIndexData();
|
||||
|
||||
uint32_t GetVertexCount();
|
||||
uint32_t GetTriangleCount();
|
||||
|
||||
private:
|
||||
void Init(AZ::Data::Asset<AZ::RPI::ModelAsset> modelAsset);
|
||||
|
||||
float* m_position = nullptr;
|
||||
float* m_normal = nullptr;
|
||||
float* m_uv = nullptr;
|
||||
unsigned int* m_index = nullptr;
|
||||
AZ::Data::Asset<AZ::RPI::ModelAsset> m_modelAsset;
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,57 +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
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include <Atom_Feature_Traits_Platform.h>
|
||||
#if AZ_TRAIT_LUXCORE_SUPPORTED
|
||||
|
||||
#include "LuxCoreObject.h"
|
||||
#include <AzCore/std/string/conversions.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
namespace Render
|
||||
{
|
||||
LuxCoreObject::LuxCoreObject(AZStd::string modelAssetId, AZStd::string materialInstanceId)
|
||||
{
|
||||
Init(modelAssetId, materialInstanceId);
|
||||
}
|
||||
|
||||
LuxCoreObject::LuxCoreObject(const LuxCoreObject &object)
|
||||
{
|
||||
Init(object.m_modelAssetId, object.m_materialInstanceId);
|
||||
}
|
||||
|
||||
LuxCoreObject::~LuxCoreObject()
|
||||
{
|
||||
}
|
||||
|
||||
luxrays::Properties LuxCoreObject::GetLuxCoreObjectProperties()
|
||||
{
|
||||
return m_luxCoreObject;
|
||||
}
|
||||
|
||||
void LuxCoreObject::Init(AZStd::string modelAssetId, AZStd::string materialInstanceId)
|
||||
{
|
||||
m_modelAssetId = modelAssetId;
|
||||
m_materialInstanceId = materialInstanceId;
|
||||
|
||||
static std::atomic_int ObjectId { 0 };
|
||||
const int localObjectId = ObjectId++;
|
||||
|
||||
m_luxCoreObjectName = "scene.objects." + AZStd::to_string(localObjectId);
|
||||
AZStd::string shapePropertyName = m_luxCoreObjectName + ".shape";
|
||||
AZStd::string materialPropertyName = m_luxCoreObjectName + ".material";
|
||||
|
||||
m_luxCoreObject = m_luxCoreObject << luxrays::Property(std::string(shapePropertyName.data()))(std::string(modelAssetId.data()));
|
||||
m_luxCoreObject = m_luxCoreObject << luxrays::Property(std::string(materialPropertyName.data()))(std::string(materialInstanceId.data()));
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,41 +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
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <Atom_Feature_Traits_Platform.h>
|
||||
#if AZ_TRAIT_LUXCORE_SUPPORTED
|
||||
|
||||
#include <AzCore/std/string/string.h>
|
||||
#include <luxcore/luxcore.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
namespace Render
|
||||
{
|
||||
// Object holds mesh and material in LuxCore
|
||||
class LuxCoreObject final
|
||||
{
|
||||
public:
|
||||
LuxCoreObject(AZStd::string modelAssetId, AZStd::string materialInstanceId);
|
||||
LuxCoreObject(const LuxCoreObject &object);
|
||||
~LuxCoreObject();
|
||||
|
||||
luxrays::Properties GetLuxCoreObjectProperties();
|
||||
|
||||
private:
|
||||
|
||||
void Init(AZStd::string modelAssetId, AZStd::string materialInstanceId);
|
||||
AZStd::string m_luxCoreObjectName;
|
||||
luxrays::Properties m_luxCoreObject;
|
||||
|
||||
AZStd::string m_modelAssetId;
|
||||
AZStd::string m_materialInstanceId;
|
||||
};
|
||||
};
|
||||
};
|
||||
#endif
|
||||
@@ -1,308 +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
|
||||
*
|
||||
*/
|
||||
#include <Atom_Feature_Traits_Platform.h>
|
||||
#if AZ_TRAIT_LUXCORE_SUPPORTED
|
||||
|
||||
#include "LuxCoreRenderer.h"
|
||||
|
||||
#include <AzCore/Component/TransformBus.h>
|
||||
#include <AzFramework/Components/CameraBus.h>
|
||||
#include <AzCore/std/containers/compressed_pair.h>
|
||||
#include <AzCore/Utils/Utils.h>
|
||||
#include <AzFramework/API/ApplicationAPI.h>
|
||||
|
||||
#include <luxcore/luxcore.h>
|
||||
|
||||
namespace LuxCoreUI
|
||||
{
|
||||
void LaunchLuxCoreUI(const AZStd::string& luxCoreExeFullPath, const AZStd::string& commandLine);
|
||||
}
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
namespace Render
|
||||
{
|
||||
LuxCoreRenderer::LuxCoreRenderer()
|
||||
{
|
||||
LuxCoreRequestsBus::Handler::BusConnect();
|
||||
}
|
||||
|
||||
LuxCoreRenderer::~LuxCoreRenderer()
|
||||
{
|
||||
LuxCoreRequestsBus::Handler::BusDisconnect();
|
||||
ClearLuxCore();
|
||||
}
|
||||
|
||||
void LuxCoreRenderer::SetCameraEntityID(AZ::EntityId id)
|
||||
{
|
||||
m_cameraEntityId = id;
|
||||
}
|
||||
|
||||
void LuxCoreRenderer::AddMesh(Data::Asset<RPI::ModelAsset> modelAsset)
|
||||
{
|
||||
AZStd::string meshId = modelAsset->GetId().ToString<AZStd::string>();
|
||||
m_meshs.emplace(AZStd::piecewise_construct_t{},
|
||||
AZStd::forward_as_tuple(meshId),
|
||||
AZStd::forward_as_tuple(modelAsset));
|
||||
}
|
||||
|
||||
void LuxCoreRenderer::AddMaterial(Data::Instance<RPI::Material> material)
|
||||
{
|
||||
AZStd::string materialId = material->GetId().ToString<AZStd::string>();
|
||||
m_materials.emplace(AZStd::piecewise_construct_t{},
|
||||
AZStd::forward_as_tuple(materialId),
|
||||
AZStd::forward_as_tuple(material));
|
||||
}
|
||||
|
||||
void LuxCoreRenderer::AddTexture(Data::Instance<RPI::Image> image, LuxCoreTextureType type)
|
||||
{
|
||||
AZStd::string textureId = image->GetAssetId().ToString<AZStd::string>();
|
||||
m_textures.emplace(AZStd::piecewise_construct_t{},
|
||||
AZStd::forward_as_tuple(textureId),
|
||||
AZStd::forward_as_tuple(image, type));
|
||||
}
|
||||
|
||||
void LuxCoreRenderer::AddObject(AZ::Data::Asset<AZ::RPI::ModelAsset> modelAsset, AZ::Data::InstanceId materialInstanceId)
|
||||
{
|
||||
m_objects.emplace_back(modelAsset->GetId().ToString<AZStd::string>(), materialInstanceId.ToString<AZStd::string>());
|
||||
}
|
||||
|
||||
bool LuxCoreRenderer::CheckTextureStatus()
|
||||
{
|
||||
for (auto it = m_textures.begin(); it != m_textures.end(); ++it)
|
||||
{
|
||||
if (!it->second.IsTextureReady())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void LuxCoreRenderer::ClearLuxCore()
|
||||
{
|
||||
m_meshs.clear();
|
||||
m_materials.clear();
|
||||
m_textures.clear();
|
||||
m_objects.clear();
|
||||
}
|
||||
|
||||
void LuxCoreRenderer::ClearObject()
|
||||
{
|
||||
m_objects.clear();
|
||||
}
|
||||
|
||||
void LuxCoreRenderer::RenderInLuxCore()
|
||||
{
|
||||
luxcore::Init();
|
||||
luxcore::Scene *luxCoreScene = luxcore::Scene::Create();
|
||||
|
||||
const char* folderName = "luxcoredata";
|
||||
if (!AZ::IO::FileIOBase::GetInstance()->Exists(folderName))
|
||||
{
|
||||
AZ::IO::FileIOBase::GetInstance()->CreatePath(folderName);
|
||||
}
|
||||
|
||||
char resolvedPath[1024];
|
||||
AZ::IO::FileIOBase::GetInstance()->ResolvePath(folderName, resolvedPath, 1024);
|
||||
|
||||
// Camera transform
|
||||
if (!m_cameraEntityId.IsValid())
|
||||
{
|
||||
AZ_Assert(false, "Please set camera entity id");
|
||||
return;
|
||||
}
|
||||
|
||||
AZ::Transform cameraTransform = AZ::Transform::CreateIdentity();
|
||||
AZ::Vector4 cameraUp, cameraFwd, cameraOrig, cameraTarget;
|
||||
AZ::TransformBus::EventResult(cameraTransform, m_cameraEntityId, &AZ::TransformBus::Events::GetWorldTM);
|
||||
|
||||
const AZ::Matrix4x4 rotationMatrix = AZ::Matrix4x4::CreateFromTransform(cameraTransform);
|
||||
|
||||
cameraFwd = rotationMatrix.GetColumn(1);
|
||||
cameraUp = rotationMatrix.GetColumn(2);
|
||||
cameraOrig = rotationMatrix.GetColumn(3);
|
||||
cameraTarget = cameraOrig + cameraFwd;
|
||||
|
||||
// Camera parameter
|
||||
float nearClip, farClip, fieldOfView;
|
||||
Camera::CameraRequestBus::EventResult(fieldOfView, m_cameraEntityId, &Camera::CameraRequestBus::Events::GetFovDegrees);
|
||||
Camera::CameraRequestBus::EventResult(nearClip, m_cameraEntityId, &Camera::CameraRequestBus::Events::GetNearClipDistance);
|
||||
Camera::CameraRequestBus::EventResult(farClip, m_cameraEntityId, &Camera::CameraRequestBus::Events::GetFarClipDistance);
|
||||
|
||||
// Set Camera
|
||||
luxCoreScene->Parse(
|
||||
luxrays::Property("scene.camera.lookat.orig")((float)cameraOrig.GetX(), (float)cameraOrig.GetY(), (float)cameraOrig.GetZ()) <<
|
||||
luxrays::Property("scene.camera.lookat.target")((float)cameraTarget.GetX(), (float)cameraTarget.GetY(), (float)cameraTarget.GetZ()) <<
|
||||
luxrays::Property("scene.camera.up")((float)cameraUp.GetX(), (float)cameraUp.GetY(), (float)cameraUp.GetZ()) <<
|
||||
luxrays::Property("scene.camera.fieldofview")(fieldOfView) <<
|
||||
luxrays::Property("scene.camera.cliphither")(nearClip) <<
|
||||
luxrays::Property("scene.camera.clipyon")(farClip) <<
|
||||
luxrays::Property("scene.camera.type")("perspective"));
|
||||
|
||||
// Set Texture
|
||||
try {
|
||||
for (auto it = m_textures.begin(); it != m_textures.end(); ++it)
|
||||
{
|
||||
if (it->second.GetRawDataPointer() != nullptr)
|
||||
{
|
||||
if (it->second.IsIBLTexture())
|
||||
{
|
||||
luxCoreScene->DefineImageMap<float>(std::string(it->first.data()), static_cast<float*>(it->second.GetRawDataPointer()), 1.f, it->second.GetTextureChannels(), it->second.GetTextureWidth(), it->second.GetTextureHeight());
|
||||
}
|
||||
else
|
||||
{
|
||||
luxCoreScene->DefineImageMap<uint8_t>(std::string(it->first.data()), static_cast<uint8_t*>(it->second.GetRawDataPointer()), 1.f, it->second.GetTextureChannels(), it->second.GetTextureWidth(), it->second.GetTextureHeight());
|
||||
}
|
||||
|
||||
luxCoreScene->Parse(
|
||||
|
||||
it->second.GetLuxCoreTextureProperties()
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
AZ_Assert(false, "texture data is nullptr!!!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (const std::runtime_error& e)
|
||||
{
|
||||
(void)e;
|
||||
AZ_Assert(false, "%s", e.what());
|
||||
return;
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
(void)e;
|
||||
AZ_Assert(false, "%s", e.what());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Set Material
|
||||
try {
|
||||
for (auto it = m_materials.begin(); it != m_materials.end(); ++it)
|
||||
{
|
||||
luxCoreScene->Parse(
|
||||
it->second.GetLuxCoreMaterialProperties()
|
||||
);
|
||||
}
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
(void)e;
|
||||
AZ_Assert(false, "%s", e.what());
|
||||
return;
|
||||
}
|
||||
|
||||
// Set Model
|
||||
try {
|
||||
for (auto it = m_meshs.begin(); it != m_meshs.end(); ++it)
|
||||
{
|
||||
luxCoreScene->DefineMesh(std::string(it->second.GetMeshId().ToString<AZStd::string>().data()),
|
||||
it->second.GetVertexCount(),
|
||||
it->second.GetTriangleCount(),
|
||||
const_cast<float*>(it->second.GetPositionData()),
|
||||
const_cast<unsigned int*>(it->second.GetIndexData()),
|
||||
const_cast<float*>(it->second.GetNormalData()),
|
||||
const_cast<float*>(it->second.GetUVData()),
|
||||
NULL,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
(void)e;
|
||||
AZ_Assert(false, "%s", e.what());
|
||||
return;
|
||||
}
|
||||
|
||||
// Objects
|
||||
try {
|
||||
for (auto it = m_objects.begin(); it != m_objects.end(); ++it)
|
||||
{
|
||||
luxCoreScene->Parse(
|
||||
it->GetLuxCoreObjectProperties()
|
||||
);
|
||||
}
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
(void)e;
|
||||
AZ_Assert(false, "%s", e.what());
|
||||
return;
|
||||
}
|
||||
|
||||
// RenderConfig
|
||||
luxcore::RenderConfig *config = luxcore::RenderConfig::Create(
|
||||
luxrays::Property("path.pathdepth.total")(7) <<
|
||||
luxrays::Property("path.pathdepth.diffuse")(5) <<
|
||||
luxrays::Property("path.pathdepth.glossy")(5) <<
|
||||
luxrays::Property("path.pathdepth.specular")(6) <<
|
||||
luxrays::Property("path.hybridbackforward.enable")(0) <<
|
||||
luxrays::Property("path.hybridbackforward.partition")(0) <<
|
||||
luxrays::Property("path.hybridbackforward.glossinessthreshold ")(0.05) <<
|
||||
luxrays::Property("path.forceblackbackground.enable")(0) <<
|
||||
luxrays::Property("film.noiseestimation.warmup")(8) <<
|
||||
luxrays::Property("film.noiseestimation.step")(32) <<
|
||||
luxrays::Property("film.width")(1920) <<
|
||||
luxrays::Property("film.height")(1080) <<
|
||||
luxrays::Property("film.filter.type")("BLACKMANHARRIS") <<
|
||||
luxrays::Property("film.filter.width")(1.5) <<
|
||||
luxrays::Property("film.imagepipelines.0.0.type")("NOP") <<
|
||||
luxrays::Property("film.imagepipelines.0.1.type")("GAMMA_CORRECTION") <<
|
||||
luxrays::Property("film.imagepipelines.0.1.value")(2.2f) <<
|
||||
luxrays::Property("film.imagepipelines.0.radiancescales.0.enabled")(1) <<
|
||||
luxrays::Property("film.imagepipelines.0.radiancescales.0.globalscale")(1) <<
|
||||
luxrays::Property("film.imagepipelines.0.radiancescales.0.rgbscale")(1, 1, 1) <<
|
||||
luxrays::Property("film.outputs.0.type")("RGB_IMAGEPIPELINE") <<
|
||||
luxrays::Property("film.outputs.0.index")(0) <<
|
||||
luxrays::Property("film.outputs.0.filename")("RGB_IMAGEPIPELINE_0.png") <<
|
||||
luxrays::Property("sampler.type")("SOBOL") <<
|
||||
luxrays::Property("renderengine.type")("PATHCPU") <<
|
||||
luxrays::Property("renderengine.seed")(1) <<
|
||||
luxrays::Property("lightstrategy.type")("LOG_POWER") <<
|
||||
luxrays::Property("scene.epsilon.min")(9.9999997473787516e-06f) <<
|
||||
luxrays::Property("scene.epsilon.max")(0.10000000149011612f) <<
|
||||
luxrays::Property("scene.epsilon.max")(0.10000000149011612f) <<
|
||||
luxrays::Property("batch.haltthreshold")(0.01953125f) <<
|
||||
luxrays::Property("batch.haltthreshold.warmup")(64) <<
|
||||
luxrays::Property("batch.haltthreshold.step")(64) <<
|
||||
luxrays::Property("batch.haltthreshold.filter.enable")(1) <<
|
||||
luxrays::Property("batch.haltthreshold.stoprendering.enable")(1) <<
|
||||
luxrays::Property("batch.haltspp")(0) <<
|
||||
luxrays::Property("batch.halttime")(0) <<
|
||||
luxrays::Property("filesaver.renderengine.type")("PATHCPU") <<
|
||||
luxrays::Property("filesaver.format")("TXT"),
|
||||
luxCoreScene);
|
||||
|
||||
|
||||
// Export
|
||||
try {
|
||||
config->Export(resolvedPath);
|
||||
}
|
||||
catch (const std::runtime_error& e)
|
||||
{
|
||||
(void)e;
|
||||
AZ_Assert(false, "%s", e.what());
|
||||
return;
|
||||
}
|
||||
|
||||
// Run luxcoreui.exe
|
||||
AZ::IO::FixedMaxPath luxCoreExeFullPath = AZ::Utils::GetEnginePath();
|
||||
luxCoreExeFullPath /= AZ_TRAIT_LUXCORE_EXEPATH;
|
||||
|
||||
AZStd::string commandLine = "-o " + AZStd::string(resolvedPath) + "/render.cfg";
|
||||
|
||||
LuxCoreUI::LaunchLuxCoreUI(luxCoreExeFullPath.String(), commandLine);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,56 +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
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <Atom_Feature_Traits_Platform.h>
|
||||
#if AZ_TRAIT_LUXCORE_SUPPORTED
|
||||
|
||||
#include <Atom/Feature/LuxCore/LuxCoreBus.h>
|
||||
#include "LuxCoreMaterial.h"
|
||||
#include "LuxCoreMesh.h"
|
||||
#include "LuxCoreObject.h"
|
||||
#include "LuxCoreTexture.h"
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
namespace Render
|
||||
{
|
||||
// Hold all converted data, write scene and render file to disk when command received
|
||||
// Can be extend to do real-time rendering in the future
|
||||
class LuxCoreRenderer
|
||||
: public LuxCoreRequestsBus::Handler
|
||||
{
|
||||
public:
|
||||
LuxCoreRenderer();
|
||||
~LuxCoreRenderer();
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// LuxCoreRequestsBus
|
||||
void SetCameraEntityID(AZ::EntityId id);
|
||||
void AddMesh( Data::Asset<RPI::ModelAsset> modelAsset);
|
||||
void AddMaterial(Data::Instance<RPI::Material> material);
|
||||
void AddTexture(Data::Instance<RPI::Image> image, LuxCoreTextureType type);
|
||||
void AddObject(AZ::Data::Asset<AZ::RPI::ModelAsset> modelAsset, AZ::Data::InstanceId materialInstanceId);
|
||||
bool CheckTextureStatus();
|
||||
void RenderInLuxCore();
|
||||
void ClearLuxCore();
|
||||
void ClearObject();
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private:
|
||||
AZ::EntityId m_cameraEntityId;
|
||||
AZ::Transform m_cameraTransform;
|
||||
|
||||
AZStd::unordered_map<AZStd::string, LuxCoreMesh> m_meshs;
|
||||
AZStd::unordered_map<AZStd::string, LuxCoreMaterial> m_materials;
|
||||
AZStd::unordered_map<AZStd::string, LuxCoreTexture> m_textures;
|
||||
AZStd::vector<LuxCoreObject> m_objects;
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,158 +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
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include <Atom_Feature_Traits_Platform.h>
|
||||
#if AZ_TRAIT_LUXCORE_SUPPORTED
|
||||
|
||||
#include "LuxCoreTexture.h"
|
||||
#include <Atom/Feature/LuxCore/LuxCoreTexturePass.h>
|
||||
#include <Atom/RPI.Public/Scene.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
namespace Render
|
||||
{
|
||||
LuxCoreTexture::LuxCoreTexture(AZ::Data::Instance<AZ::RPI::Image> image, LuxCoreTextureType type)
|
||||
{
|
||||
Init(image, type);
|
||||
}
|
||||
|
||||
LuxCoreTexture::LuxCoreTexture(const LuxCoreTexture &texture)
|
||||
{
|
||||
Init(texture.m_texture, texture.m_type);
|
||||
}
|
||||
|
||||
LuxCoreTexture::~LuxCoreTexture()
|
||||
{
|
||||
if (m_rtPipeline)
|
||||
{
|
||||
m_rtPipeline->RemoveFromScene();
|
||||
m_rtPipeline = nullptr;
|
||||
}
|
||||
|
||||
if (m_texture)
|
||||
{
|
||||
m_texture = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void LuxCoreTexture::Init(AZ::Data::Instance<AZ::RPI::Image> image, LuxCoreTextureType type)
|
||||
{
|
||||
m_textureAssetId = image->GetAssetId();
|
||||
m_texture = image;
|
||||
m_type = type;
|
||||
|
||||
if (m_type == LuxCoreTextureType::IBL)
|
||||
{
|
||||
m_luxCoreTextureName = "scene.lights." + m_textureAssetId.ToString<AZStd::string>();
|
||||
m_luxCoreTexture = m_luxCoreTexture << luxrays::Property(std::string(m_luxCoreTextureName.data()) + ".type")("infinite");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_luxCoreTextureName = "scene.textures." + m_textureAssetId.ToString<AZStd::string>();
|
||||
m_luxCoreTexture = m_luxCoreTexture << luxrays::Property(std::string(m_luxCoreTextureName.data()) + ".type")("imagemap");
|
||||
}
|
||||
|
||||
m_luxCoreTexture = m_luxCoreTexture << luxrays::Property(std::string(m_luxCoreTextureName.data()) + ".file")(std::string(m_textureAssetId.ToString<AZStd::string>().data()));
|
||||
m_textureChannels = 4;
|
||||
|
||||
AddRenderTargetPipeline();
|
||||
}
|
||||
|
||||
void LuxCoreTexture::AddRenderTargetPipeline()
|
||||
{
|
||||
// Render Texture pipeline
|
||||
AZ::RPI::RenderPipelineDescriptor pipelineDesc;
|
||||
pipelineDesc.m_name = m_textureAssetId.ToString<AZStd::string>();
|
||||
pipelineDesc.m_rootPassTemplate = "LuxCoreTexturePassTemplate";
|
||||
m_rtPipeline = AZ::RPI::RenderPipeline::CreateRenderPipeline(pipelineDesc);
|
||||
|
||||
// Set source texture
|
||||
AZ::RPI::Pass* rootPass = m_rtPipeline->GetRootPass().get();
|
||||
AZ_Assert(rootPass != nullptr, "Failed to get root pass for render target pipeline");
|
||||
LuxCoreTexturePass* parentPass = static_cast<LuxCoreTexturePass*>(rootPass);
|
||||
|
||||
// Setup call back to save read back data to m_textureData
|
||||
RPI::AttachmentReadback::CallbackFunction callback =
|
||||
[this](const AZ::RPI::AttachmentReadback::ReadbackResult& readbackResult)
|
||||
{
|
||||
RHI::ImageSubresourceLayout imageLayout = RHI::GetImageSubresourceLayout(readbackResult.m_imageDescriptor.m_size,
|
||||
readbackResult.m_imageDescriptor.m_format);
|
||||
m_textureData.resize_no_construct(imageLayout.m_bytesPerImage);
|
||||
memcpy(m_textureData.data(), readbackResult.m_dataBuffer->data(), imageLayout.m_bytesPerImage);
|
||||
|
||||
m_textureReadbackComplete = true;
|
||||
};
|
||||
parentPass->SetReadbackCallback(callback);
|
||||
|
||||
switch (m_type)
|
||||
{
|
||||
case LuxCoreTextureType::Default:
|
||||
// assume a 8 bits linear texture
|
||||
parentPass->SetSourceTexture(m_texture, RHI::Format::R8G8B8A8_UNORM);
|
||||
break;
|
||||
case LuxCoreTextureType::IBL:
|
||||
// assume its a float image if its an IBL source
|
||||
parentPass->SetSourceTexture(m_texture, RHI::Format::R32G32B32A32_FLOAT);
|
||||
break;
|
||||
case LuxCoreTextureType::Albedo:
|
||||
// albedo texture is in sRGB space
|
||||
parentPass->SetSourceTexture(m_texture, RHI::Format::R8G8B8A8_UNORM_SRGB);
|
||||
break;
|
||||
case LuxCoreTextureType::Normal:
|
||||
// Normal texture needs special handling
|
||||
parentPass->SetIsNormalTexture(true);
|
||||
parentPass->SetSourceTexture(m_texture, RHI::Format::R8G8B8A8_UNORM);
|
||||
break;
|
||||
}
|
||||
|
||||
const auto mainScene = AZ::RPI::RPISystemInterface::Get()->GetSceneByName(AZ::Name("RPI"));
|
||||
if (mainScene)
|
||||
{
|
||||
mainScene->AddRenderPipeline(m_rtPipeline);
|
||||
}
|
||||
}
|
||||
|
||||
bool LuxCoreTexture::IsIBLTexture()
|
||||
{
|
||||
return m_type == LuxCoreTextureType::IBL;
|
||||
}
|
||||
|
||||
void* LuxCoreTexture::GetRawDataPointer()
|
||||
{
|
||||
return (void*)m_textureData.data();
|
||||
}
|
||||
|
||||
unsigned int LuxCoreTexture::GetTextureWidth()
|
||||
{
|
||||
return m_texture->GetRHIImage()->GetDescriptor().m_size.m_width;
|
||||
}
|
||||
|
||||
unsigned int LuxCoreTexture::GetTextureHeight()
|
||||
{
|
||||
return m_texture->GetRHIImage()->GetDescriptor().m_size.m_height;
|
||||
}
|
||||
|
||||
unsigned int LuxCoreTexture::GetTextureChannels()
|
||||
{
|
||||
return m_textureChannels;
|
||||
}
|
||||
|
||||
luxrays::Properties LuxCoreTexture::GetLuxCoreTextureProperties()
|
||||
{
|
||||
return m_luxCoreTexture;
|
||||
}
|
||||
|
||||
bool LuxCoreTexture::IsTextureReady()
|
||||
{
|
||||
return m_textureReadbackComplete;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,62 +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
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <Atom_Feature_Traits_Platform.h>
|
||||
#if AZ_TRAIT_LUXCORE_SUPPORTED
|
||||
|
||||
#include <Atom/RPI.Public/RenderPipeline.h>
|
||||
#include <Atom/RPI.Reflect/Image/Image.h>
|
||||
#include <Atom/Feature/LuxCore/LuxCoreBus.h>
|
||||
#include <luxcore/luxcore.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
namespace Render
|
||||
{
|
||||
// Build a pipeline to get raw data from runtime texture
|
||||
class LuxCoreTexture final
|
||||
{
|
||||
public:
|
||||
LuxCoreTexture() = default;
|
||||
LuxCoreTexture( AZ::Data::Instance<AZ::RPI::Image> image, LuxCoreTextureType type);
|
||||
LuxCoreTexture(const LuxCoreTexture &texture);
|
||||
~LuxCoreTexture();
|
||||
|
||||
void* GetRawDataPointer();
|
||||
|
||||
unsigned int GetTextureWidth();
|
||||
unsigned int GetTextureHeight();
|
||||
unsigned int GetTextureChannels();
|
||||
|
||||
void Init(AZ::Data::Instance<AZ::RPI::Image> image, LuxCoreTextureType type);
|
||||
|
||||
void AddRenderTargetPipeline();
|
||||
luxrays::Properties GetLuxCoreTextureProperties();
|
||||
bool IsIBLTexture();
|
||||
bool IsTextureReady();
|
||||
|
||||
private:
|
||||
AZStd::string m_luxCoreTextureName;
|
||||
luxrays::Properties m_luxCoreTexture;
|
||||
|
||||
AZ::RPI::RenderPipelinePtr m_rtPipeline = nullptr;
|
||||
|
||||
AZStd::vector<uint8_t> m_textureData;
|
||||
AZ::Data::Instance<AZ::RPI::Image> m_texture;
|
||||
unsigned int m_textureChannels = 4;
|
||||
|
||||
Data::AssetId m_textureAssetId;
|
||||
LuxCoreTextureType m_type = LuxCoreTextureType::Default;
|
||||
|
||||
bool m_textureReadbackComplete = false;
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,90 +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
|
||||
*
|
||||
*/
|
||||
|
||||
#include <Atom/Feature/LuxCore/LuxCoreTexturePass.h>
|
||||
#include <Atom/RPI.Public/Pass/PassSystemInterface.h>
|
||||
|
||||
#include <Atom/RHI/RHISystemInterface.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
namespace Render
|
||||
{
|
||||
RPI::Ptr<LuxCoreTexturePass> LuxCoreTexturePass::Create(const RPI::PassDescriptor& descriptor)
|
||||
{
|
||||
RPI::Ptr<LuxCoreTexturePass> pass = aznew LuxCoreTexturePass(descriptor);
|
||||
return pass;
|
||||
}
|
||||
|
||||
LuxCoreTexturePass::LuxCoreTexturePass(const RPI::PassDescriptor& descriptor)
|
||||
: ParentPass(descriptor)
|
||||
{
|
||||
RPI::PassSystemInterface* passSystem = RPI::PassSystemInterface::Get();
|
||||
|
||||
// Create render target pass
|
||||
RPI::PassRequest request;
|
||||
request.m_templateName = "RenderTextureTemplate";
|
||||
request.m_passName = "RenderTarget";
|
||||
m_renderTargetPass = passSystem->CreatePassFromRequest(&request);
|
||||
AZ_Assert(m_renderTargetPass, "render target pass is invalid");
|
||||
|
||||
// Create readback
|
||||
m_readback = AZStd::make_shared<AZ::RPI::AttachmentReadback>(AZ::RHI::ScopeId{ Uuid::CreateRandom().ToString<AZStd::string>() });
|
||||
}
|
||||
|
||||
LuxCoreTexturePass::~LuxCoreTexturePass()
|
||||
{
|
||||
m_renderTargetPass = nullptr;
|
||||
m_readback = nullptr;
|
||||
}
|
||||
|
||||
void LuxCoreTexturePass::SetSourceTexture(AZ::Data::Instance<AZ::RPI::Image> image, RHI::Format format)
|
||||
{
|
||||
static_cast<RenderTexturePass*>(m_renderTargetPass.get())->SetPassSrgImage(image, format);
|
||||
}
|
||||
|
||||
void LuxCoreTexturePass::CreateChildPassesInternal()
|
||||
{
|
||||
AddChild(m_renderTargetPass);
|
||||
}
|
||||
|
||||
void LuxCoreTexturePass::BuildInternal()
|
||||
{
|
||||
ParentPass::BuildInternal();
|
||||
}
|
||||
|
||||
void LuxCoreTexturePass::FrameBeginInternal(FramePrepareParams params)
|
||||
{
|
||||
if (!m_attachmentReadbackComplete && m_readback != nullptr)
|
||||
{
|
||||
// Set up read back attachment before children prepare
|
||||
if (m_readback->IsReady())
|
||||
{
|
||||
if (m_renderTargetPass)
|
||||
{
|
||||
m_attachmentReadbackComplete = m_renderTargetPass->ReadbackAttachment(m_readback, AZ::Name("RenderTargetOutput"));
|
||||
}
|
||||
}
|
||||
}
|
||||
ParentPass::FrameBeginInternal(params);
|
||||
}
|
||||
|
||||
void LuxCoreTexturePass::SetIsNormalTexture(bool isNormal)
|
||||
{
|
||||
static_cast<RenderTexturePass*>(m_renderTargetPass.get())->InitShaderVariant(isNormal);
|
||||
}
|
||||
|
||||
void LuxCoreTexturePass::SetReadbackCallback(RPI::AttachmentReadback::CallbackFunction callbackFunciton)
|
||||
{
|
||||
if (m_readback != nullptr)
|
||||
{
|
||||
m_readback->SetCallback(callbackFunciton);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,90 +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
|
||||
*
|
||||
*/
|
||||
|
||||
#include <Atom/Feature/LuxCore/RenderTexturePass.h>
|
||||
#include <Atom/Feature/LuxCore/LuxCoreBus.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
namespace Render
|
||||
{
|
||||
RPI::Ptr<RenderTexturePass> RenderTexturePass::Create(const RPI::PassDescriptor& descriptor)
|
||||
{
|
||||
RPI::Ptr<RenderTexturePass> pass = aznew RenderTexturePass(descriptor);
|
||||
return pass;
|
||||
}
|
||||
|
||||
RenderTexturePass::RenderTexturePass(const RPI::PassDescriptor& descriptor)
|
||||
: FullscreenTrianglePass(descriptor)
|
||||
{
|
||||
m_textureIndex = m_shaderResourceGroup->FindShaderInputImageIndex(Name("m_sourceTexture"));
|
||||
}
|
||||
|
||||
RenderTexturePass::~RenderTexturePass()
|
||||
{
|
||||
}
|
||||
|
||||
void RenderTexturePass::SetPassSrgImage(AZ::Data::Instance<AZ::RPI::Image> image, RHI::Format format)
|
||||
{
|
||||
m_attachmentSize = image->GetRHIImage()->GetDescriptor().m_size;
|
||||
m_attachmentFormat = format;
|
||||
m_shaderResourceGroup->SetImage(m_textureIndex, image);
|
||||
QueueForBuildAndInitialization();
|
||||
}
|
||||
|
||||
void RenderTexturePass::BuildInternal()
|
||||
{
|
||||
UpdataAttachment();
|
||||
FullscreenTrianglePass::BuildInternal();
|
||||
}
|
||||
|
||||
void RenderTexturePass::FrameBeginInternal(FramePrepareParams params)
|
||||
{
|
||||
FullscreenTrianglePass::FrameBeginInternal(params);
|
||||
}
|
||||
|
||||
void RenderTexturePass::UpdataAttachment()
|
||||
{
|
||||
// [GFX TODO][ATOM-2470] stop caring about attachment
|
||||
RPI::Ptr<RPI::PassAttachment> attachment = m_ownedAttachments.front();
|
||||
if (!attachment)
|
||||
{
|
||||
AZ_Assert(false, "[RenderTexturePass %s] Cannot find any image attachment.", GetPathName().GetCStr());
|
||||
return;
|
||||
}
|
||||
AZ_Assert(attachment->m_descriptor.m_type == RHI::AttachmentType::Image, "[RenderTexturePass %s] requires an image attachment", GetPathName().GetCStr());
|
||||
|
||||
RPI::PassAttachmentBinding& binding = GetOutputBinding(0);
|
||||
binding.m_attachment = attachment;
|
||||
|
||||
RHI::ImageDescriptor& imageDescriptor = attachment->m_descriptor.m_image;
|
||||
imageDescriptor.m_size = m_attachmentSize;
|
||||
imageDescriptor.m_format = m_attachmentFormat;
|
||||
}
|
||||
|
||||
RHI::AttachmentId RenderTexturePass::GetRenderTargetId()
|
||||
{
|
||||
return m_ownedAttachments.front()->GetAttachmentId();
|
||||
}
|
||||
|
||||
void RenderTexturePass::InitShaderVariant(bool isNormal)
|
||||
{
|
||||
auto shaderOption = m_shader->CreateShaderOptionGroup();
|
||||
RPI::ShaderOptionValue isNormalOption{ isNormal };
|
||||
shaderOption.SetValue(AZ::Name("o_isNormal"), isNormalOption);
|
||||
|
||||
RPI::ShaderVariantSearchResult result = m_shader->FindVariantStableId(shaderOption.GetShaderVariantId());
|
||||
m_shaderVariantStableId = result.GetStableId();
|
||||
|
||||
if (!result.IsFullyBaked() && m_drawShaderResourceGroup->HasShaderVariantKeyFallbackEntry())
|
||||
{
|
||||
m_drawShaderResourceGroup->SetShaderVariantKeyFallbackValue(shaderOption.GetShaderVariantId().m_key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,5 +7,5 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#define AZ_TRAIT_LUXCORE_SUPPORTED 0
|
||||
#define AZ_TRAIT_LUXCORE_EXEPATH UNUSED_TRAIT
|
||||
#define AZ_TRAIT_DIFFUSE_GI_PASSES_SUPPORTED 1
|
||||
|
||||
|
||||
-6
@@ -5,9 +5,3 @@
|
||||
# SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
#
|
||||
#
|
||||
|
||||
set_source_files_properties(
|
||||
Source/LuxCore/LuxCoreRenderer.cpp
|
||||
PROPERTIES
|
||||
COMPILE_OPTIONS -fexceptions
|
||||
)
|
||||
|
||||
-6
@@ -5,9 +5,3 @@
|
||||
# SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
#
|
||||
#
|
||||
|
||||
set_source_files_properties(
|
||||
Source/LuxCore/LuxCoreRenderer.cpp
|
||||
PROPERTIES
|
||||
COMPILE_OPTIONS /EHsc
|
||||
)
|
||||
|
||||
@@ -7,5 +7,5 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#define AZ_TRAIT_LUXCORE_SUPPORTED 0
|
||||
#define AZ_TRAIT_LUXCORE_EXEPATH UNUSED_TRAIT
|
||||
#define AZ_TRAIT_DIFFUSE_GI_PASSES_SUPPORTED 1
|
||||
|
||||
|
||||
@@ -7,5 +7,5 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#define AZ_TRAIT_LUXCORE_SUPPORTED 0
|
||||
#define AZ_TRAIT_LUXCORE_EXEPATH UNUSED_TRAIT
|
||||
#define AZ_TRAIT_DIFFUSE_GI_PASSES_SUPPORTED 1
|
||||
|
||||
|
||||
@@ -7,5 +7,5 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#define AZ_TRAIT_LUXCORE_SUPPORTED 0
|
||||
#define AZ_TRAIT_LUXCORE_EXEPATH "Gems/Atom/Feature/Common/External/LuxCore2.2/win64/dll/luxcoreui.exe"
|
||||
#define AZ_TRAIT_DIFFUSE_GI_PASSES_SUPPORTED 1
|
||||
|
||||
|
||||
@@ -1,45 +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
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AzCore/std/string/string.h>
|
||||
#include <AzCore/std/string/conversions.h>
|
||||
#include <AzCore/PlatformIncl.h>
|
||||
|
||||
namespace LuxCoreUI
|
||||
{
|
||||
void LaunchLuxCoreUI(const AZStd::string& luxCoreExeFullPath, const AZStd::string& commandLine)
|
||||
{
|
||||
STARTUPINFO si;
|
||||
PROCESS_INFORMATION pi;
|
||||
|
||||
ZeroMemory(&si, sizeof(si));
|
||||
si.cb = sizeof(si);
|
||||
ZeroMemory(&pi, sizeof(pi));
|
||||
|
||||
AZStd::wstring luxCoreExeFullPathW;
|
||||
AZStd::to_wstring(luxCoreExeFullPathW, luxCoreExeFullPath.c_str());
|
||||
AZStd::wstring commandLineW;
|
||||
AZStd::to_wstring(commandLineW, commandLine.c_str());
|
||||
|
||||
// start the program up
|
||||
CreateProcessW(luxCoreExeFullPathW.c_str(), // the path
|
||||
commandLineW.data(), // Command line
|
||||
NULL, // Process handle not inheritable
|
||||
NULL, // Thread handle not inheritable
|
||||
FALSE, // Set handle inheritance to FALSE
|
||||
0, // No creation flags
|
||||
NULL, // Use parent's environment block
|
||||
NULL, // Use parent's starting directory
|
||||
&si, // Pointer to STARTUPINFO structure
|
||||
&pi // Pointer to PROCESS_INFORMATION structure (removed extra parentheses)
|
||||
);
|
||||
// Close process and thread handles.
|
||||
CloseHandle(pi.hProcess);
|
||||
CloseHandle(pi.hThread);
|
||||
}
|
||||
}
|
||||
@@ -9,5 +9,4 @@
|
||||
set(FILES
|
||||
Atom_Feature_Traits_Platform.h
|
||||
Atom_Feature_Traits_Windows.h
|
||||
LaunchLuxCoreUI_Windows.cpp
|
||||
)
|
||||
|
||||
@@ -7,5 +7,5 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#define AZ_TRAIT_LUXCORE_SUPPORTED 0
|
||||
#define AZ_TRAIT_LUXCORE_EXEPATH UNUSED_TRAIT
|
||||
#define AZ_TRAIT_DIFFUSE_GI_PASSES_SUPPORTED 1
|
||||
|
||||
|
||||
@@ -24,14 +24,14 @@ namespace AZ
|
||||
{
|
||||
m_elementSize = descriptor.m_elementSize;
|
||||
m_elementCount = 0;
|
||||
|
||||
|
||||
m_bufferIndex = descriptor.m_srgLayout->FindShaderInputBufferIndex(Name(descriptor.m_bufferSrgName));
|
||||
AZ_Error(ClassName, m_bufferIndex.IsValid(), "Unable to find %s in view shader resource group.", descriptor.m_bufferSrgName.c_str());
|
||||
AZ_Error(ClassName, m_bufferIndex.IsValid(), "Unable to find %s in %s shader resource group.", descriptor.m_bufferSrgName.c_str(), descriptor.m_srgLayout->GetName().GetCStr());
|
||||
|
||||
if (!descriptor.m_elementCountSrgName.empty())
|
||||
{
|
||||
m_elementCountIndex = descriptor.m_srgLayout->FindShaderInputConstantIndex(Name(descriptor.m_elementCountSrgName));
|
||||
AZ_Error(ClassName, m_elementCountIndex.IsValid(), "Unable to find %s in view shader resource group.", descriptor.m_elementCountSrgName.c_str());
|
||||
AZ_Error(ClassName, m_elementCountIndex.IsValid(), "Unable to find %s in %s shader resource group.", descriptor.m_elementCountSrgName.c_str(), descriptor.m_srgLayout->GetName().GetCStr());
|
||||
}
|
||||
|
||||
if (m_bufferIndex.IsValid())
|
||||
|
||||
@@ -46,9 +46,6 @@ set(FILES
|
||||
Include/Atom/Feature/Utils/MultiSparseVector.h
|
||||
Include/Atom/Feature/Utils/ProfilingCaptureBus.h
|
||||
Include/Atom/Feature/Utils/SparseVector.h
|
||||
Include/Atom/Feature/LuxCore/LuxCoreBus.h
|
||||
Include/Atom/Feature/LuxCore/LuxCoreTexturePass.h
|
||||
Include/Atom/Feature/LuxCore/RenderTexturePass.h
|
||||
Source/CommonModule.cpp
|
||||
Source/CommonSystemComponent.cpp
|
||||
Source/FrameCaptureSystemComponent.cpp
|
||||
@@ -133,6 +130,8 @@ set(FILES
|
||||
Source/DiffuseGlobalIllumination/DiffuseProbeGridRelocationPass.h
|
||||
Source/DiffuseGlobalIllumination/DiffuseProbeGridClassificationPass.cpp
|
||||
Source/DiffuseGlobalIllumination/DiffuseProbeGridClassificationPass.h
|
||||
Source/DiffuseGlobalIllumination/DiffuseProbeGridDownsamplePass.cpp
|
||||
Source/DiffuseGlobalIllumination/DiffuseProbeGridDownsamplePass.h
|
||||
Source/DiffuseGlobalIllumination/DiffuseProbeGridRenderPass.cpp
|
||||
Source/DiffuseGlobalIllumination/DiffuseProbeGridRenderPass.h
|
||||
Source/DiffuseGlobalIllumination/DiffuseProbeGrid.cpp
|
||||
@@ -315,18 +314,6 @@ set(FILES
|
||||
Source/SkyBox/SkyBoxFogSettings.cpp
|
||||
Source/TransformService/TransformServiceFeatureProcessor.cpp
|
||||
Source/Utils/GpuBufferHandler.cpp
|
||||
Source/LuxCore/LuxCoreTexturePass.cpp
|
||||
Source/LuxCore/RenderTexturePass.cpp
|
||||
Source/LuxCore/LuxCoreMaterial.cpp
|
||||
Source/LuxCore/LuxCoreMaterial.h
|
||||
Source/LuxCore/LuxCoreMesh.cpp
|
||||
Source/LuxCore/LuxCoreMesh.h
|
||||
Source/LuxCore/LuxCoreObject.cpp
|
||||
Source/LuxCore/LuxCoreObject.h
|
||||
Source/LuxCore/LuxCoreRenderer.cpp
|
||||
Source/LuxCore/LuxCoreRenderer.h
|
||||
Source/LuxCore/LuxCoreTexture.cpp
|
||||
Source/LuxCore/LuxCoreTexture.h
|
||||
)
|
||||
|
||||
set(SKIP_UNITY_BUILD_INCLUSION_FILES
|
||||
|
||||
@@ -91,13 +91,15 @@ namespace AZ
|
||||
m_pageAllocator = &pageAllocator;
|
||||
m_descriptor = descriptor;
|
||||
m_descriptor.m_addressBase = 0;
|
||||
m_descriptor.m_capacityInBytes = m_pageAllocator->GetPageSize();
|
||||
if (m_descriptor.m_capacityInBytes == 0)
|
||||
{
|
||||
m_descriptor.m_capacityInBytes = m_pageAllocator->GetPageSize();
|
||||
}
|
||||
}
|
||||
|
||||
template <class Traits>
|
||||
typename MemorySubAllocator<Traits>::memory_allocation MemorySubAllocator<Traits>::Allocate(size_t sizeInBytes, size_t alignmentInBytes)
|
||||
{
|
||||
AZ_PROFILE_FUNCTION(RHI);
|
||||
if (RHI::AlignUp(sizeInBytes, alignmentInBytes) > m_descriptor.m_capacityInBytes)
|
||||
{
|
||||
return memory_allocation();
|
||||
|
||||
@@ -33,6 +33,13 @@ if(aftermath_header)
|
||||
set(PAL_TRAIT_AFTERMATH_AVAILABLE TRUE)
|
||||
endif()
|
||||
|
||||
ly_add_source_properties(
|
||||
SOURCES
|
||||
Source/RHI.Builders/ShaderPlatformInterfaceSystemComponent.cpp
|
||||
PROPERTY COMPILE_DEFINITIONS
|
||||
VALUES ${LY_PAL_TOOLS_DEFINES}
|
||||
)
|
||||
|
||||
# Disable windows OS version check until infra can upgrade all our jenkins nodes
|
||||
# if(NOT CMAKE_SYSTEM_VERSION VERSION_GREATER_EQUAL "10.0.17763")
|
||||
# message(FATAL_ERROR "Windows DX12 RHI implementation requires an OS version and SDK matching windows 10 build 1809 or greater")
|
||||
|
||||
@@ -53,14 +53,14 @@ namespace Aftermath
|
||||
#endif
|
||||
}
|
||||
|
||||
void SetAftermathEventMarker( [[maybe_unused]] void* cntxHandle, [[maybe_unused]] const AZStd::string& markerData, [[maybe_unused]] bool isAftermathInitialized)
|
||||
void SetAftermathEventMarker( [[maybe_unused]] void* cntxHandle, [[maybe_unused]] const char* markerData, [[maybe_unused]] bool isAftermathInitialized)
|
||||
{
|
||||
#if defined(USE_NSIGHT_AFTERMATH)
|
||||
if (isAftermathInitialized)
|
||||
{
|
||||
GFSDK_Aftermath_Result result = GFSDK_Aftermath_SetEventMarker(
|
||||
static_cast<GFSDK_Aftermath_ContextHandle>(cntxHandle), static_cast<const void*>(markerData.c_str()),
|
||||
static_cast<unsigned int>(markerData.size()) + 1);
|
||||
static_cast<GFSDK_Aftermath_ContextHandle>(cntxHandle), static_cast<const void*>(markerData),
|
||||
static_cast<unsigned int>(strlen(markerData) + 1);
|
||||
AssertOnError(result);
|
||||
}
|
||||
#endif
|
||||
|
||||
+9
-9
@@ -15,15 +15,15 @@
|
||||
#include <AzCore/Serialization/SerializeContext.h>
|
||||
|
||||
#if defined(AZ_TOOLS_EXPAND_FOR_RESTRICTED_PLATFORMS)
|
||||
#if defined(TOOLS_SUPPORT_JASPER)
|
||||
#include <Platform/Jasper/RHI.Builders/ShaderPlatformInterface_Jasper.h>
|
||||
#endif
|
||||
#if defined(TOOLS_SUPPORT_PROVO)
|
||||
#include <Platform/Provo/RHI.Builders/ShaderPlatformInterface_Provo.h>
|
||||
#endif
|
||||
#if defined(TOOLS_SUPPORT_SALEM)
|
||||
#include <Platform/Salem/RHI.Builders/ShaderPlatformInterface_Salem.h>
|
||||
#endif
|
||||
# if defined(TOOLS_SUPPORT_JASPER)
|
||||
# include AZ_RESTRICTED_FILE_EXPLICIT(RHI.Builders/ShaderPlatformInterface, Jasper)
|
||||
# endif
|
||||
# if defined(TOOLS_SUPPORT_PROVO)
|
||||
# include AZ_RESTRICTED_FILE_EXPLICIT(RHI.Builders/ShaderPlatformInterface, Provo)
|
||||
# endif
|
||||
# if defined(TOOLS_SUPPORT_SALEM)
|
||||
# include AZ_RESTRICTED_FILE_EXPLICIT(RHI.Builders/ShaderPlatformInterface, Salem)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <Atom/RHI.Reflect/DX12/Base.h>
|
||||
|
||||
@@ -85,7 +85,7 @@ namespace AZ
|
||||
return m_hardwareQueueClass;
|
||||
}
|
||||
|
||||
void CommandListBase::SetAftermathEventMarker(const AZStd::string& markerData)
|
||||
void CommandListBase::SetAftermathEventMarker(const char* markerData)
|
||||
{
|
||||
auto& device = static_cast<Device&>(GetDevice());
|
||||
Aftermath::SetAftermathEventMarker(m_aftermathCommandListContext, markerData, device.IsAftermathInitialized());
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user