Merge branch 'main' into amzn-mike/lyn-2249-disable-cancel
This commit is contained in:
@@ -117,7 +117,8 @@ class EditorTestHelper:
|
||||
# Set the viewport back to whatever size it was at the start and restore the pane layout
|
||||
general.set_viewport_size(int(self.viewport_size.x), int(self.viewport_size.y))
|
||||
general.set_viewport_expansion_policy("AutoExpand")
|
||||
general.set_view_pane_layout(self.viewport_layout)
|
||||
# Temporarily disabling reset of view pane layout: LYN-3120
|
||||
# general.set_view_pane_layout(self.viewport_layout)
|
||||
general.update_viewport()
|
||||
|
||||
self.log("test finished")
|
||||
|
||||
+2
@@ -53,6 +53,8 @@ class TestAltitudeFilterFilterStageToggle(EditorTestHelper):
|
||||
use_terrain=False,
|
||||
)
|
||||
|
||||
general.set_current_view_position(512.0, 480.0, 38.0)
|
||||
|
||||
# Create basic vegetation entity
|
||||
position = math.Vector3(512.0, 512.0, 32.0)
|
||||
asset_path = os.path.join("Slices", "PinkFlower.dynamicslice")
|
||||
|
||||
+2
@@ -59,6 +59,8 @@ class TestAreaComponentsSliceCreationAndVisibilityToggle(EditorTestHelper):
|
||||
use_terrain=False,
|
||||
)
|
||||
|
||||
general.set_current_view_position(512.0, 480.0, 38.0)
|
||||
|
||||
# 2) C2627900 Verifies if a slice containing the Vegetation Layer Spawner component can be created.
|
||||
# 2.1) Create basic vegetation entity
|
||||
position = math.Vector3(512.0, 512.0, 32.0)
|
||||
|
||||
+2
@@ -63,6 +63,8 @@ class TestDistanceBetweenFilterComponentOverrides(EditorTestHelper):
|
||||
use_terrain=False,
|
||||
)
|
||||
|
||||
general.set_current_view_position(512.0, 480.0, 38.0)
|
||||
|
||||
# 2) Create a new entity with required vegetation area components
|
||||
spawner_center_point = math.Vector3(520.0, 520.0, 32.0)
|
||||
asset_path = os.path.join("Slices", "1m_cube.dynamicslice")
|
||||
|
||||
+2
@@ -61,6 +61,8 @@ class TestDistanceBetweenFilterComponent(EditorTestHelper):
|
||||
use_terrain=False,
|
||||
)
|
||||
|
||||
general.set_current_view_position(512.0, 480.0, 38.0)
|
||||
|
||||
# 2) Create a new entity with required vegetation area components
|
||||
spawner_center_point = math.Vector3(520.0, 520.0, 32.0)
|
||||
asset_path = os.path.join("Slices", "1m_cube.dynamicslice")
|
||||
|
||||
+1
@@ -43,6 +43,7 @@ class TestDynamicSliceInstanceSpawner(EditorTestHelper):
|
||||
use_terrain=False,
|
||||
)
|
||||
general.idle_wait(1.0)
|
||||
general.set_current_view_position(512.0, 480.0, 38.0)
|
||||
|
||||
# Grab the UUID that we need for creating an Dynamic Slice Instance Spawner
|
||||
dynamic_slice_spawner_uuid = azlmbr.math.Uuid_CreateString('{BBA5CC1E-B4CA-4792-89F7-93711E98FBD1}', 0)
|
||||
|
||||
+2
@@ -65,6 +65,8 @@ class TestDynamicSliceInstanceSpawnerEmbeddedEditor(EditorTestHelper):
|
||||
use_terrain=False,
|
||||
)
|
||||
|
||||
general.set_current_view_position(512.0, 480.0, 38.0)
|
||||
|
||||
# 2) Create a new entity with required vegetation area components and Script Canvas component for launcher test
|
||||
center_point = math.Vector3(512.0, 512.0, 32.0)
|
||||
asset_path = os.path.join("Slices", "PinkFlower.dynamicslice")
|
||||
|
||||
+2
@@ -65,6 +65,8 @@ class TestDynamicSliceInstanceSpawnerExternalEditor(EditorTestHelper):
|
||||
use_terrain=False,
|
||||
)
|
||||
|
||||
general.set_current_view_position(512.0, 480.0, 38.0)
|
||||
|
||||
# 2) Create a new entity with required vegetation area components and switch the Vegetation Asset List Source
|
||||
# Type to External
|
||||
entity_position = math.Vector3(512.0, 512.0, 32.0)
|
||||
|
||||
+1
@@ -43,6 +43,7 @@ class TestEmptyInstanceSpawner(EditorTestHelper):
|
||||
use_terrain=False,
|
||||
)
|
||||
general.idle_wait(1.0)
|
||||
general.set_current_view_position(512.0, 480.0, 38.0)
|
||||
|
||||
# Grab the UUID that we need for creating an Empty Spawner
|
||||
empty_spawner_uuid = azlmbr.math.Uuid_CreateString('{23C40FD4-A55F-4BD3-BE5B-DC5423F217C2}', 0)
|
||||
|
||||
+2
@@ -60,6 +60,8 @@ class TestLayerSpawnerInheritBehavior(EditorTestHelper):
|
||||
use_terrain=False,
|
||||
)
|
||||
|
||||
general.set_current_view_position(512.0, 480.0, 38.0)
|
||||
|
||||
# Create Emitter entity and add the required components
|
||||
position = math.Vector3(512.0, 512.0, 32.0)
|
||||
emitter_entity = dynveg.create_surface_entity("emitter_entity", position, 16.0, 16.0, 1.0)
|
||||
|
||||
+3
@@ -61,6 +61,9 @@ class test_MeshBlocker_InstancesBlockedByMesh(EditorTestHelper):
|
||||
use_terrain=False,
|
||||
)
|
||||
|
||||
general.set_current_view_position(500.49, 498.69, 46.66)
|
||||
general.set_current_view_rotation(-42.05, 0.00, -36.33)
|
||||
|
||||
# Create entity with components "Vegetation Layer Spawner", "Vegetation Asset List", "Box Shape"
|
||||
entity_position = math.Vector3(512.0, 512.0, 32.0)
|
||||
asset_path = os.path.join("Slices", "PurpleFlower.dynamicslice")
|
||||
|
||||
+1
-1
@@ -90,7 +90,7 @@ class TestRotationModifierOverrides_InstancesRotateWithinRange(EditorTestHelper)
|
||||
terrain_texture_resolution=4096,
|
||||
use_terrain=False,
|
||||
)
|
||||
general.run_console("e_WaterOcean=0")
|
||||
general.set_current_view_position(512.0, 480.0, 38.0)
|
||||
|
||||
# 2) Create vegetation entity and add components
|
||||
entity_position = math.Vector3(512.0, 512.0, 32.0)
|
||||
|
||||
+1
-1
@@ -103,7 +103,7 @@ class TestRotationModifier_InstancesRotateWithinRange(EditorTestHelper):
|
||||
terrain_texture_resolution=4096,
|
||||
use_terrain=False,
|
||||
)
|
||||
general.run_console("e_WaterOcean=0")
|
||||
general.set_current_view_position(512.0, 480.0, 38.0)
|
||||
|
||||
# 2) Set up vegetation entities
|
||||
asset_path = os.path.join("Slices", "PurpleFlower.dynamicslice")
|
||||
|
||||
+3
@@ -17,6 +17,7 @@ import azlmbr.paths
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.entity as EntityId
|
||||
import azlmbr.components as components
|
||||
import azlmbr.legacy.general as general
|
||||
|
||||
sys.path.append(os.path.join(azlmbr.paths.devroot, "AutomatedTesting", "Gem", "PythonTests"))
|
||||
import automatedtesting_shared.hydra_editor_utils as hydra
|
||||
@@ -48,6 +49,8 @@ class TestSlopeFilterFilterStageToggle(EditorTestHelper):
|
||||
use_terrain=False,
|
||||
)
|
||||
|
||||
general.set_current_view_position(512.0, 480.0, 38.0)
|
||||
|
||||
# Create basic vegetation entity
|
||||
position = math.Vector3(512.0, 512.0, 32.0)
|
||||
asset_path = os.path.join("Slices", "PinkFlower.dynamicslice")
|
||||
|
||||
+2
@@ -103,6 +103,8 @@ class TestExclusiveSurfaceMasksTag(EditorTestHelper):
|
||||
use_terrain=False,
|
||||
)
|
||||
|
||||
general.set_current_view_position(512.0, 480.0, 38.0)
|
||||
|
||||
# 2) Create entity with components "Vegetation Layer Spawner", "Vegetation Asset List", "Box Shape"
|
||||
entity_position = math.Vector3(512.0, 512.0, 32.0)
|
||||
asset_path = os.path.join("Slices", "PurpleFlower.dynamicslice")
|
||||
|
||||
+2
@@ -104,6 +104,8 @@ class TestInclusiveSurfaceMasksTag(EditorTestHelper):
|
||||
use_terrain=False,
|
||||
)
|
||||
|
||||
general.set_current_view_position(512.0, 480.0, 38.0)
|
||||
|
||||
# 2) Create entity with components "Vegetation Layer Spawner", "Vegetation Asset List", "Box Shape"
|
||||
entity_position = math.Vector3(512.0, 512.0, 32.0)
|
||||
asset_path = os.path.join("Slices", "PurpleFlower.dynamicslice")
|
||||
|
||||
+3
@@ -15,6 +15,7 @@ import azlmbr.math as math
|
||||
import azlmbr.paths
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.legacy.general as general
|
||||
|
||||
sys.path.append(os.path.join(azlmbr.paths.devroot, "AutomatedTesting", "Gem", "PythonTests"))
|
||||
import automatedtesting_shared.hydra_editor_utils as hydra
|
||||
@@ -52,6 +53,8 @@ class TestSystemSettingsSectorPointDensity(EditorTestHelper):
|
||||
use_terrain=False,
|
||||
)
|
||||
|
||||
general.set_current_view_position(512.0, 480.0, 38.0)
|
||||
|
||||
# Create basic vegetation entity
|
||||
position = math.Vector3(512.0, 512.0, 32.0)
|
||||
asset_path = os.path.join("Slices", "PinkFlower.dynamicslice")
|
||||
|
||||
+3
@@ -15,6 +15,7 @@ import azlmbr.math as math
|
||||
import azlmbr.paths
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.legacy.general as general
|
||||
|
||||
sys.path.append(os.path.join(azlmbr.paths.devroot, "AutomatedTesting", "Gem", "PythonTests"))
|
||||
import automatedtesting_shared.hydra_editor_utils as hydra
|
||||
@@ -48,6 +49,8 @@ class TestSystemSettingsSectorSize(EditorTestHelper):
|
||||
use_terrain=False,
|
||||
)
|
||||
|
||||
general.set_current_view_position(512.0, 480.0, 38.0)
|
||||
|
||||
# Create basic vegetation entity
|
||||
position = math.Vector3(512.0, 512.0, 32.0)
|
||||
asset_path = os.path.join("Slices", "PinkFlower.dynamicslice")
|
||||
|
||||
@@ -63,13 +63,13 @@ namespace AZ
|
||||
static AssetTrackingImpl* GetSharedInstance();
|
||||
static ThreadData& GetSharedThreadData();
|
||||
|
||||
using MasterAssets = AZStd::unordered_map<AssetTrackingId, AssetMasterInfo, AZStd::hash<AssetTrackingId>, AZStd::equal_to<AssetTrackingId>, AZStdAssetTrackingAllocator>;
|
||||
using PrimaryAssets = AZStd::unordered_map<AssetTrackingId, AssetPrimaryInfo, AZStd::hash<AssetTrackingId>, AZStd::equal_to<AssetTrackingId>, AZStdAssetTrackingAllocator>;
|
||||
using ThreadData = ThreadData;
|
||||
using mutex_type = AZStd::mutex;
|
||||
using lock_type = AZStd::lock_guard<mutex_type>;
|
||||
|
||||
mutex_type m_mutex;
|
||||
MasterAssets m_masterAssets;
|
||||
PrimaryAssets m_primaryAssets;
|
||||
AssetTreeNodeBase* m_assetRoot = nullptr;
|
||||
AssetAllocationTableBase* m_allocationTable = nullptr;
|
||||
bool m_performingAnalysis = false;
|
||||
@@ -118,7 +118,7 @@ namespace AZ
|
||||
auto& threadData = GetSharedThreadData();
|
||||
AssetTreeNodeBase* parentAsset = threadData.m_currentAssetStack.empty() ? nullptr : threadData.m_currentAssetStack.back();
|
||||
AssetTreeNodeBase* childAsset;
|
||||
AssetMasterInfo* assetMasterInfo;
|
||||
AssetPrimaryInfo* assetPrimaryInfo;
|
||||
|
||||
if (!parentAsset)
|
||||
{
|
||||
@@ -128,22 +128,22 @@ namespace AZ
|
||||
{
|
||||
lock_type lock(m_mutex);
|
||||
|
||||
// Locate or create the master record for this asset
|
||||
auto masterItr = m_masterAssets.find(assetId);
|
||||
// Locate or create the primary record for this asset
|
||||
auto primaryItr = m_primaryAssets.find(assetId);
|
||||
|
||||
if (masterItr != m_masterAssets.end())
|
||||
if (primaryItr != m_primaryAssets.end())
|
||||
{
|
||||
assetMasterInfo = &masterItr->second;
|
||||
assetPrimaryInfo = &primaryItr->second;
|
||||
}
|
||||
else
|
||||
{
|
||||
auto insertResult = m_masterAssets.emplace(assetId, AssetMasterInfo());
|
||||
assetMasterInfo = &insertResult.first->second;
|
||||
assetMasterInfo->m_id = &insertResult.first->first;
|
||||
auto insertResult = m_primaryAssets.emplace(assetId, AssetPrimaryInfo());
|
||||
assetPrimaryInfo = &insertResult.first->second;
|
||||
assetPrimaryInfo->m_id = &insertResult.first->first;
|
||||
}
|
||||
|
||||
// Add this asset to the stack for this thread's context
|
||||
childAsset = parentAsset->FindOrAddChild(assetId, assetMasterInfo);
|
||||
childAsset = parentAsset->FindOrAddChild(assetId, assetPrimaryInfo);
|
||||
}
|
||||
|
||||
threadData.m_currentAssetStack.push_back(childAsset);
|
||||
@@ -304,7 +304,7 @@ namespace AZ
|
||||
char* pos = buffer;
|
||||
for (auto itr = assetStack.rbegin(); itr != assetStack.rend(); ++itr)
|
||||
{
|
||||
pos += azsnprintf(pos, BUFFER_SIZE - (pos - buffer), "%s\n", (*itr)->GetAssetMasterInfo()->m_id->m_id.c_str());
|
||||
pos += azsnprintf(pos, BUFFER_SIZE - (pos - buffer), "%s\n", (*itr)->GetAssetPrimaryInfo()->m_id->m_id.c_str());
|
||||
|
||||
if (pos >= buffer + BUFFER_SIZE)
|
||||
{
|
||||
|
||||
@@ -79,9 +79,9 @@ namespace AZ
|
||||
AssetTrackingString m_id;
|
||||
};
|
||||
|
||||
// Master information about an asset.
|
||||
// Primary information about an asset.
|
||||
// Currently just contains the ID of the asset, but in the future may carry additional information about that asset (such as where in code it was initialized).
|
||||
struct AssetMasterInfo
|
||||
struct AssetPrimaryInfo
|
||||
{
|
||||
const AssetTrackingId* m_id;
|
||||
};
|
||||
@@ -90,8 +90,8 @@ namespace AZ
|
||||
class AssetTreeNodeBase
|
||||
{
|
||||
public:
|
||||
virtual const AssetMasterInfo* GetAssetMasterInfo() const = 0;
|
||||
virtual AssetTreeNodeBase* FindOrAddChild(const AssetTrackingId& id, const AssetMasterInfo* info) = 0;
|
||||
virtual const AssetPrimaryInfo* GetAssetPrimaryInfo() const = 0;
|
||||
virtual AssetTreeNodeBase* FindOrAddChild(const AssetTrackingId& id, const AssetPrimaryInfo* info) = 0;
|
||||
};
|
||||
|
||||
// Base class for an asset tree. Implemented by the template AssetTree<>.
|
||||
|
||||
@@ -29,18 +29,18 @@ namespace AZ
|
||||
class AssetTreeNode : public AssetTreeNodeBase
|
||||
{
|
||||
public:
|
||||
AssetTreeNode(const AssetMasterInfo* masterInfo = nullptr, AssetTreeNode* parent = nullptr) :
|
||||
m_masterInfo(masterInfo),
|
||||
AssetTreeNode(const AssetPrimaryInfo* primaryInfo = nullptr, AssetTreeNode* parent = nullptr) :
|
||||
m_primaryinfo(primaryInfo),
|
||||
m_parent(parent)
|
||||
{
|
||||
}
|
||||
|
||||
const AssetMasterInfo* GetAssetMasterInfo() const override
|
||||
const AssetPrimaryInfo* GetAssetPrimaryInfo() const override
|
||||
{
|
||||
return m_masterInfo;
|
||||
return m_primaryinfo;
|
||||
}
|
||||
|
||||
AssetTreeNodeBase* FindOrAddChild(const AssetTrackingId& id, const AssetMasterInfo* info) override
|
||||
AssetTreeNodeBase* FindOrAddChild(const AssetTrackingId& id, const AssetPrimaryInfo* info) override
|
||||
{
|
||||
AssetTreeNodeBase* result = nullptr;
|
||||
auto childItr = m_children.find(id);
|
||||
@@ -61,7 +61,7 @@ namespace AZ
|
||||
|
||||
using AssetMap = AssetTrackingMap<AssetTrackingId, AssetTreeNode>;
|
||||
|
||||
const AssetMasterInfo* m_masterInfo;
|
||||
const AssetPrimaryInfo* m_primaryinfo;
|
||||
AssetTreeNode* m_parent;
|
||||
AssetMap m_children;
|
||||
AssetDataT m_data;
|
||||
|
||||
@@ -146,8 +146,8 @@ namespace AZ
|
||||
->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::All)
|
||||
->Method("GetTranslated", &Aabb::GetTranslated)
|
||||
->Method("GetSurfaceArea", &Aabb::GetSurfaceArea)
|
||||
->Method("GetTransformedObb", &Aabb::GetTransformedObb)
|
||||
->Method("GetTransformedAabb", &Aabb::GetTransformedAabb)
|
||||
->Method("GetTransformedObb", static_cast<Obb(Aabb::*)(const Transform&) const>(&Aabb::GetTransformedObb))
|
||||
->Method("GetTransformedAabb", static_cast<Aabb(Aabb::*)(const Transform&) const>(&Aabb::GetTransformedAabb))
|
||||
->Method("ApplyTransform", &Aabb::ApplyTransform)
|
||||
->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::All)
|
||||
->Method("Clone", [](const Aabb& rhs) -> Aabb { return rhs; })
|
||||
@@ -195,6 +195,20 @@ namespace AZ
|
||||
}
|
||||
|
||||
|
||||
Obb Aabb::GetTransformedObb(const Matrix3x4& matrix3x4) const
|
||||
{
|
||||
Matrix3x4 matrixNoScale = matrix3x4;
|
||||
const AZ::Vector3 scale = matrixNoScale.ExtractScale();
|
||||
const AZ::Quaternion rotation = AZ::Quaternion::CreateFromMatrix3x4(matrixNoScale);
|
||||
|
||||
return Obb::CreateFromPositionRotationAndHalfLengths(
|
||||
matrix3x4 * GetCenter(),
|
||||
rotation,
|
||||
0.5f * scale * GetExtents()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
void Aabb::ApplyTransform(const Transform& transform)
|
||||
{
|
||||
Vector3 a, b, axisCoeffs;
|
||||
@@ -224,4 +238,17 @@ namespace AZ
|
||||
m_min = newMin;
|
||||
m_max = newMax;
|
||||
}
|
||||
|
||||
|
||||
void Aabb::ApplyMatrix3x4(const Matrix3x4& matrix3x4)
|
||||
{
|
||||
const AZ::Vector3 extents = GetExtents();
|
||||
const AZ::Vector3 center = matrix3x4 * GetCenter();
|
||||
AZ::Vector3 newHalfExtents(
|
||||
0.5f * matrix3x4.GetRowAsVector3(0).GetAbs().Dot(extents),
|
||||
0.5f * matrix3x4.GetRowAsVector3(1).GetAbs().Dot(extents),
|
||||
0.5f * matrix3x4.GetRowAsVector3(2).GetAbs().Dot(extents));
|
||||
m_min = center - newHalfExtents;
|
||||
m_max = center + newHalfExtents;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,11 +129,21 @@ namespace AZ
|
||||
|
||||
void ApplyTransform(const Transform& transform);
|
||||
|
||||
void ApplyMatrix3x4(const Matrix3x4& matrix3x4);
|
||||
|
||||
void MultiplyByScale(const Vector3& scale);
|
||||
|
||||
//! Transforms an Aabb and returns the resulting Obb.
|
||||
class Obb GetTransformedObb(const Transform& transform) const;
|
||||
[[nodiscard]] Obb GetTransformedObb(const Transform& transform) const;
|
||||
|
||||
//! Transforms an Aabb and returns the resulting Obb.
|
||||
[[nodiscard]] Obb GetTransformedObb(const Matrix3x4& matrix3x4) const;
|
||||
|
||||
//! Returns a new AABB containing the transformed AABB.
|
||||
Aabb GetTransformedAabb(const Transform& transform) const;
|
||||
[[nodiscard]] Aabb GetTransformedAabb(const Transform& transform) const;
|
||||
|
||||
//! Returns a new AABB containing the transformed AABB.
|
||||
[[nodiscard]] Aabb GetTransformedAabb(const Matrix3x4& matrix3x4) const;
|
||||
|
||||
//! Checks if this aabb is equal to another within a floating point tolerance.
|
||||
bool IsClose(const Aabb& rhs, float tolerance = Constants::Tolerance) const;
|
||||
|
||||
@@ -292,6 +292,14 @@ namespace AZ
|
||||
}
|
||||
|
||||
|
||||
AZ_MATH_INLINE void Aabb::MultiplyByScale(const Vector3& scale)
|
||||
{
|
||||
m_min *= scale;
|
||||
m_max *= scale;
|
||||
AZ_MATH_ASSERT(IsValid(), "Min must be less than Max");
|
||||
}
|
||||
|
||||
|
||||
AZ_MATH_INLINE Aabb Aabb::GetTransformedAabb(const Transform& transform) const
|
||||
{
|
||||
Aabb aabb = Aabb::CreateFromMinMax(m_min, m_max);
|
||||
@@ -300,6 +308,14 @@ namespace AZ
|
||||
}
|
||||
|
||||
|
||||
AZ_MATH_INLINE Aabb Aabb::GetTransformedAabb(const Matrix3x4& matrix3x4) const
|
||||
{
|
||||
Aabb aabb = Aabb::CreateFromMinMax(m_min, m_max);
|
||||
aabb.ApplyMatrix3x4(matrix3x4);
|
||||
return aabb;
|
||||
}
|
||||
|
||||
|
||||
AZ_MATH_INLINE bool Aabb::IsClose(const Aabb& rhs, float tolerance) const
|
||||
{
|
||||
return m_min.IsClose(rhs.m_min, tolerance) && m_max.IsClose(rhs.m_max, tolerance);
|
||||
|
||||
@@ -105,7 +105,7 @@ namespace UnitTest
|
||||
|
||||
EXPECT_EQ(&rootAsset, &m_env->m_tree.GetRoot());
|
||||
ASSERT_NE(itr, rootAsset.m_children.end());
|
||||
EXPECT_EQ(itr->second.m_masterInfo->m_id->m_id, "TestScopedAllocation.1");
|
||||
EXPECT_EQ(itr->second.m_primaryinfo->m_id->m_id, "TestScopedAllocation.1");
|
||||
|
||||
EXPECT_EQ(&itr->second, m_env->m_table.FindAllocation(TEST_POINTER));
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include <AzCore/Math/Vector3.h>
|
||||
#include <AzCore/Math/Transform.h>
|
||||
#include <AzCore/UnitTest/TestTypes.h>
|
||||
#include <AZTestShared/Math/MathTestHelpers.h>
|
||||
|
||||
using namespace AZ;
|
||||
|
||||
@@ -385,4 +386,77 @@ namespace UnitTest
|
||||
EXPECT_TRUE(aabb.GetMin().IsClose(transAabb.GetMin()));
|
||||
EXPECT_TRUE(aabb.GetMax().IsClose(transAabb.GetMax()));
|
||||
}
|
||||
|
||||
TEST(MATH_AabbTransform, GetTransformedObbMatrix3x4)
|
||||
{
|
||||
Vector3 min(-1.0f, -2.0f, -3.0f);
|
||||
Vector3 max(4.0f, 3.0f, 2.0f);
|
||||
Aabb aabb = Aabb::CreateFromMinMax(min, max);
|
||||
|
||||
Quaternion rotation(0.46f, 0.26f, 0.58f, 0.62f);
|
||||
Vector3 translation(5.0f, 7.0f, 9.0f);
|
||||
|
||||
Matrix3x4 matrix3x4 = Matrix3x4::CreateFromQuaternionAndTranslation(rotation, translation);
|
||||
|
||||
matrix3x4.MultiplyByScale(Vector3(0.5f, 1.5f, 2.0f));
|
||||
|
||||
Obb obb = aabb.GetTransformedObb(matrix3x4);
|
||||
|
||||
EXPECT_THAT(obb.GetRotation(), IsClose(rotation));
|
||||
EXPECT_THAT(obb.GetHalfLengths(), IsClose(Vector3(1.25f, 3.75f, 5.0f)));
|
||||
EXPECT_THAT(obb.GetPosition(), IsClose(Vector3(3.928f, 7.9156f, 9.3708f)));
|
||||
}
|
||||
|
||||
TEST(MATH_AabbTransform, GetTransformedAabbMatrix3x4)
|
||||
{
|
||||
Vector3 min(2.0f, 3.0f, 5.0f);
|
||||
Vector3 max(6.0f, 5.0f, 11.0f);
|
||||
Aabb aabb = Aabb::CreateFromMinMax(min, max);
|
||||
|
||||
Quaternion rotation(0.34f, 0.46f, 0.58f, 0.58f);
|
||||
Vector3 translation(-3.0f, -4.0f, -5.0f);
|
||||
|
||||
Matrix3x4 matrix3x4 = Matrix3x4::CreateFromQuaternionAndTranslation(rotation, translation);
|
||||
|
||||
matrix3x4.MultiplyByScale(Vector3(1.2f, 0.8f, 2.0f));
|
||||
|
||||
Aabb transformedAabb = aabb.GetTransformedAabb(matrix3x4);
|
||||
|
||||
EXPECT_THAT(transformedAabb.GetMin(), IsClose(Vector3(4.1488f, -0.01216f, -0.31904f)));
|
||||
EXPECT_THAT(transformedAabb.GetMax(), IsClose(Vector3(16.3216f, 6.54272f, 5.98112f)));
|
||||
}
|
||||
|
||||
TEST(MATH_AabbTransform, GetTransformedObbFitsInsideTransformedAabb)
|
||||
{
|
||||
Vector3 min(4.0f, 3.0f, 1.0f);
|
||||
Vector3 max(7.0f, 6.0f, 8.0f);
|
||||
Aabb aabb = Aabb::CreateFromMinMax(min, max);
|
||||
|
||||
Quaternion rotation(0.40f, 0.40f, 0.64f, 0.52f);
|
||||
Vector3 translation(-2.0f, 4.0f, -3.0f);
|
||||
|
||||
Matrix3x4 matrix3x4 = Matrix3x4::CreateFromQuaternionAndTranslation(rotation, translation);
|
||||
|
||||
matrix3x4.MultiplyByScale(Vector3(2.2f, 0.6f, 1.4f));
|
||||
|
||||
Aabb transformedAabb = aabb.GetTransformedAabb(matrix3x4);
|
||||
Obb transformedObb = aabb.GetTransformedObb(matrix3x4);
|
||||
Aabb aabbContainingTransformedObb = Aabb::CreateFromObb(transformedObb);
|
||||
|
||||
EXPECT_THAT(transformedAabb.GetMin(), IsClose(aabbContainingTransformedObb.GetMin()));
|
||||
EXPECT_THAT(transformedAabb.GetMax(), IsClose(aabbContainingTransformedObb.GetMax()));
|
||||
}
|
||||
|
||||
TEST(MATH_AabbTransform, MultiplyByScale)
|
||||
{
|
||||
Vector3 min(2.0f, 6.0f, 8.0f);
|
||||
Vector3 max(6.0f, 9.0f, 10.0f);
|
||||
Aabb aabb = Aabb::CreateFromMinMax(min, max);
|
||||
|
||||
Vector3 scale(0.5f, 2.0f, 1.5f);
|
||||
aabb.MultiplyByScale(scale);
|
||||
|
||||
EXPECT_THAT(aabb.GetMin(), IsClose(Vector3(1.0f, 12.0f, 12.0f)));
|
||||
EXPECT_THAT(aabb.GetMax(), IsClose(Vector3(3.0f, 18.0f, 15.0f)));
|
||||
}
|
||||
}
|
||||
|
||||
+14
-3
@@ -29,6 +29,20 @@ namespace AzFramework::AssetSystem::Platform
|
||||
bool LaunchAssetProcessor(AZStd::string_view executableDirectory, AZStd::string_view engineRoot,
|
||||
AZStd::string_view projectPath)
|
||||
{
|
||||
AZ::IO::FixedMaxPath assetProcessorPath{ executableDirectory };
|
||||
assetProcessorPath /= "AssetProcessor";
|
||||
|
||||
if (!AZ::IO::SystemFile::Exists(assetProcessorPath.c_str()))
|
||||
{
|
||||
// Check for existence of one under a "bin" directory, i.e. engineRoot is an SDK structure.
|
||||
assetProcessorPath = AZ::IO::FixedMaxPath{engineRoot} / "bin" / AZ_BUILD_CONFIGURATION_TYPE / "AssetProcessor";
|
||||
|
||||
if (!AZ::IO::SystemFile::Exists(assetProcessorPath.c_str()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
pid_t firstChildPid = fork();
|
||||
if (firstChildPid == 0)
|
||||
{
|
||||
@@ -47,9 +61,6 @@ namespace AzFramework::AssetSystem::Platform
|
||||
pid_t secondChildPid = fork();
|
||||
if (secondChildPid == 0)
|
||||
{
|
||||
AZ::IO::FixedMaxPath assetProcessorPath{ executableDirectory };
|
||||
assetProcessorPath /= "AssetProcessor";
|
||||
|
||||
AZStd::array args {
|
||||
assetProcessorPath.c_str(), assetProcessorPath.c_str(), "--start-hidden",
|
||||
static_cast<const char*>(nullptr), static_cast<const char*>(nullptr), static_cast<const char*>(nullptr)
|
||||
|
||||
+13
@@ -11,6 +11,7 @@
|
||||
*/
|
||||
|
||||
#include <AzCore/IO/Path/Path.h>
|
||||
#include <AzCore/IO/SystemFile.h>
|
||||
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
@@ -20,6 +21,7 @@ namespace AzFramework::AssetSystem::Platform
|
||||
{
|
||||
void AllowAssetProcessorToForeground()
|
||||
{}
|
||||
|
||||
bool LaunchAssetProcessor(AZStd::string_view executableDirectory, AZStd::string_view engineRoot,
|
||||
AZStd::string_view projectPath)
|
||||
{
|
||||
@@ -29,6 +31,17 @@ namespace AzFramework::AssetSystem::Platform
|
||||
assetProcessorPath /= "../../../AssetProcessor.app";
|
||||
assetProcessorPath = assetProcessorPath.LexicallyNormal();
|
||||
|
||||
if (!AZ::IO::SystemFile::Exists(assetProcessorPath.c_str()))
|
||||
{
|
||||
// Check for existence of one under a "bin" directory, i.e. engineRoot is an SDK structure.
|
||||
assetProcessorPath = AZ::IO::FixedMaxPath{engineRoot} / "bin" / AZ_BUILD_CONFIGURATION_TYPE / "AssetProcessor.app";
|
||||
|
||||
if (!AZ::IO::SystemFile::Exists(assetProcessorPath.c_str()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
auto fullLaunchCommand = AZ::IO::FixedMaxPathString::format(R"(open -g "%s" --args --start-hidden)", assetProcessorPath.c_str());
|
||||
// Add the engine path to the launch command if not empty
|
||||
if (!engineRoot.empty())
|
||||
|
||||
+12
@@ -12,6 +12,7 @@
|
||||
|
||||
#include <AzCore/PlatformIncl.h>
|
||||
#include <AzCore/IO/Path/Path.h>
|
||||
#include <AzCore/IO/SystemFile.h>
|
||||
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
|
||||
|
||||
#include <Psapi.h>
|
||||
@@ -67,6 +68,17 @@ namespace AzFramework::AssetSystem::Platform
|
||||
AZ::IO::FixedMaxPath assetProcessorPath{ executableDirectory };
|
||||
assetProcessorPath /= "AssetProcessor.exe";
|
||||
|
||||
if (!AZ::IO::SystemFile::Exists(assetProcessorPath.c_str()))
|
||||
{
|
||||
// Check for existence of one under a "bin" directory, i.e. engineRoot is an SDK structure.
|
||||
assetProcessorPath = AZ::IO::FixedMaxPath{engineRoot} / "bin" / AZ_BUILD_CONFIGURATION_TYPE / "AssetProcessor.exe";
|
||||
|
||||
if (!AZ::IO::SystemFile::Exists(assetProcessorPath.c_str()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
auto fullLaunchCommand = AZ::IO::FixedMaxPathString::format(R"("%s" --start-hidden)", assetProcessorPath.c_str());
|
||||
|
||||
// Add the engine path to the launch command if not empty
|
||||
|
||||
@@ -216,7 +216,6 @@ protected:
|
||||
void OnSliceInstantiationFailed(const AZ::Data::AssetId& sliceAssetId, const AzFramework::SliceInstantiationTicket& /*ticket*/) override;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
QString m_strMasterCDFolder;
|
||||
bool m_bLoadFailed;
|
||||
QColor m_waterColor;
|
||||
XmlNodeRef m_fogTemplate;
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace
|
||||
const float kTangentDelta = 0.01f;
|
||||
const float kAspectRatio = 1.777778f;
|
||||
const int kReserveCount = 7; // x,y,z,rot_x,rot_y,rot_z,fov
|
||||
const QString kMasterCameraName = "MasterCamera";
|
||||
const QString kPrimaryCameraName = "PrimaryCamera";
|
||||
} // namespace
|
||||
|
||||
|
||||
@@ -169,10 +169,10 @@ CExportManager::CExportManager()
|
||||
, m_numberOfExportFrames(0)
|
||||
, m_pivotEntityObject(0)
|
||||
, m_bBakedKeysSequenceExport(true)
|
||||
, m_animTimeExportMasterSequenceCurrentTime(0.0f)
|
||||
, m_animTimeExportPrimarySequenceCurrentTime(0.0f)
|
||||
, m_animKeyTimeExport(true)
|
||||
, m_soundKeyTimeExport(true)
|
||||
, m_bExportOnlyMasterCamera(false)
|
||||
, m_bExportOnlyPrimaryCamera(false)
|
||||
{
|
||||
RegisterExporter(new COBJExporter());
|
||||
RegisterExporter(new COCMExporter());
|
||||
@@ -773,14 +773,14 @@ bool CExportManager::ShowFBXExportDialog()
|
||||
return false;
|
||||
}
|
||||
|
||||
SetFBXExportSettings(fpsDialog.GetExportCoordsLocalToTheSelectedObject(), fpsDialog.GetExportOnlyMasterCamera(), fpsDialog.GetFPS());
|
||||
SetFBXExportSettings(fpsDialog.GetExportCoordsLocalToTheSelectedObject(), fpsDialog.GetExportOnlyPrimaryCamera(), fpsDialog.GetFPS());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CExportManager::ProcessObjectsForExport()
|
||||
{
|
||||
Export::CObject* pObj = new Export::CObject(kMasterCameraName.toUtf8().data());
|
||||
Export::CObject* pObj = new Export::CObject(kPrimaryCameraName.toUtf8().data());
|
||||
pObj->entityType = Export::eCamera;
|
||||
m_data.m_objects.push_back(pObj);
|
||||
|
||||
@@ -808,13 +808,13 @@ bool CExportManager::ProcessObjectsForExport()
|
||||
Export::CObject* pObj2 = m_data.m_objects[objectID];
|
||||
CBaseObject* pObject = 0;
|
||||
|
||||
if (QString::compare(pObj2->name, kMasterCameraName) == 0)
|
||||
if (QString::compare(pObj2->name, kPrimaryCameraName) == 0)
|
||||
{
|
||||
pObject = GetIEditor()->GetObjectManager()->FindObject(GetIEditor()->GetViewManager()->GetCameraObjectId());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_bExportOnlyMasterCamera && pObj2->entityType != Export::eCameraTarget)
|
||||
if (m_bExportOnlyPrimaryCamera && pObj2->entityType != Export::eCameraTarget)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -952,7 +952,7 @@ void CExportManager::FillAnimTimeNode(XmlNodeRef writeNode, CTrackViewAnimNode*
|
||||
if (numAllTracks > 0)
|
||||
{
|
||||
XmlNodeRef objNode = writeNode->createNode(CleanXMLText(pObjectNode->GetName()).toUtf8().data());
|
||||
writeNode->setAttr("time", m_animTimeExportMasterSequenceCurrentTime);
|
||||
writeNode->setAttr("time", m_animTimeExportPrimarySequenceCurrentTime);
|
||||
|
||||
for (unsigned int trackID = 0; trackID < numAllTracks; ++trackID)
|
||||
{
|
||||
@@ -1020,7 +1020,7 @@ void CExportManager::FillAnimTimeNode(XmlNodeRef writeNode, CTrackViewAnimNode*
|
||||
|
||||
XmlNodeRef keyNode = subNode->createNode(keyContentName.toUtf8().data());
|
||||
|
||||
float keyGlobalTime = m_animTimeExportMasterSequenceCurrentTime + keyTime;
|
||||
float keyGlobalTime = m_animTimeExportPrimarySequenceCurrentTime + keyTime;
|
||||
keyNode->setAttr("keyTime", keyGlobalTime);
|
||||
|
||||
if (keyStartTime > 0)
|
||||
@@ -1123,13 +1123,13 @@ bool CExportManager::AddObjectsFromSequence(CTrackViewSequence* pSequence, XmlNo
|
||||
const QString sequenceName = pSubSequence->GetName();
|
||||
XmlNodeRef subSeqNode2 = seqNode->createNode(sequenceName.toUtf8().data());
|
||||
|
||||
if (sequenceName == m_animTimeExportMasterSequenceName)
|
||||
if (sequenceName == m_animTimeExportPrimarySequenceName)
|
||||
{
|
||||
m_animTimeExportMasterSequenceCurrentTime = sequenceKey.time;
|
||||
m_animTimeExportPrimarySequenceCurrentTime = sequenceKey.time;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_animTimeExportMasterSequenceCurrentTime += sequenceKey.time;
|
||||
m_animTimeExportPrimarySequenceCurrentTime += sequenceKey.time;
|
||||
}
|
||||
|
||||
AddObjectsFromSequence(pSubSequence, subSeqNode2);
|
||||
@@ -1336,7 +1336,7 @@ bool CExportManager::Export(const char* defaultName, const char* defaultExt, con
|
||||
{
|
||||
m_numberOfExportFrames = pSequence->GetTimeRange().end * m_FBXBakedExportFPS;
|
||||
|
||||
if (!m_bExportOnlyMasterCamera)
|
||||
if (!m_bExportOnlyPrimaryCamera)
|
||||
{
|
||||
AddObjectsFromSequence(pSequence);
|
||||
}
|
||||
@@ -1365,10 +1365,10 @@ bool CExportManager::Export(const char* defaultName, const char* defaultExt, con
|
||||
return returnRes;
|
||||
}
|
||||
|
||||
void CExportManager::SetFBXExportSettings(bool bLocalCoordsToSelectedObject, bool bExportOnlyMasterCamera, const float fps)
|
||||
void CExportManager::SetFBXExportSettings(bool bLocalCoordsToSelectedObject, bool bExportOnlyPrimaryCamera, const float fps)
|
||||
{
|
||||
m_bExportLocalCoords = bLocalCoordsToSelectedObject;
|
||||
m_bExportOnlyMasterCamera = bExportOnlyMasterCamera;
|
||||
m_bExportOnlyPrimaryCamera = bExportOnlyPrimaryCamera;
|
||||
m_FBXBakedExportFPS = fps;
|
||||
}
|
||||
|
||||
@@ -1439,10 +1439,10 @@ void CExportManager::SaveNodeKeysTimeToXML()
|
||||
if (dlg.exec())
|
||||
{
|
||||
m_animTimeNode = XmlHelpers::CreateXmlNode(pSequence->GetName());
|
||||
m_animTimeExportMasterSequenceName = pSequence->GetName();
|
||||
m_animTimeExportPrimarySequenceName = pSequence->GetName();
|
||||
|
||||
m_data.Clear();
|
||||
m_animTimeExportMasterSequenceCurrentTime = 0.0;
|
||||
m_animTimeExportPrimarySequenceCurrentTime = 0.0;
|
||||
|
||||
AddObjectsFromSequence(pSequence, m_animTimeNode);
|
||||
|
||||
|
||||
@@ -171,7 +171,7 @@ private:
|
||||
|
||||
bool AddObjectsFromSequence(CTrackViewSequence* pSequence, XmlNodeRef seqNode = 0);
|
||||
bool IsDuplicateObjectBeingAdded(const QString& newObject);
|
||||
void SetFBXExportSettings(bool bLocalCoordsToSelectedObject, bool bExportOnlyMasterCamera, const float fps);
|
||||
void SetFBXExportSettings(bool bLocalCoordsToSelectedObject, bool bExportOnlyPrimaryCamera, const float fps);
|
||||
bool ProcessObjectsForExport();
|
||||
|
||||
bool ShowFBXExportDialog();
|
||||
@@ -193,13 +193,13 @@ private:
|
||||
|
||||
float m_FBXBakedExportFPS;
|
||||
bool m_bExportLocalCoords;
|
||||
bool m_bExportOnlyMasterCamera;
|
||||
bool m_bExportOnlyPrimaryCamera;
|
||||
int m_numberOfExportFrames;
|
||||
CEntityObject* m_pivotEntityObject;
|
||||
bool m_bBakedKeysSequenceExport;
|
||||
|
||||
QString m_animTimeExportMasterSequenceName;
|
||||
float m_animTimeExportMasterSequenceCurrentTime;
|
||||
QString m_animTimeExportPrimarySequenceName;
|
||||
float m_animTimeExportPrimarySequenceCurrentTime;
|
||||
XmlNodeRef m_animTimeNode;
|
||||
|
||||
bool m_animKeyTimeExport;
|
||||
|
||||
@@ -55,9 +55,9 @@ bool CFBXExporterDialog::GetExportCoordsLocalToTheSelectedObject() const
|
||||
return m_ui->m_exportLocalCoordsCheckbox->isChecked();
|
||||
}
|
||||
|
||||
bool CFBXExporterDialog::GetExportOnlyMasterCamera() const
|
||||
bool CFBXExporterDialog::GetExportOnlyPrimaryCamera() const
|
||||
{
|
||||
return m_ui->m_exportOnlyMasterCameraCheckBox->isChecked();
|
||||
return m_ui->m_exportOnlyPrimaryCameraCheckBox->isChecked();
|
||||
}
|
||||
|
||||
void CFBXExporterDialog::SetExportLocalCoordsCheckBoxEnable(bool checked)
|
||||
@@ -100,7 +100,7 @@ int CFBXExporterDialog::exec()
|
||||
if (m_bDisplayOnlyFPSSetting)
|
||||
{
|
||||
m_ui->m_exportLocalCoordsCheckbox->setEnabled(false);
|
||||
m_ui->m_exportOnlyMasterCameraCheckBox->setEnabled(false);
|
||||
m_ui->m_exportOnlyPrimaryCameraCheckBox->setEnabled(false);
|
||||
}
|
||||
|
||||
m_ui->m_fpsCombo->addItem("24");
|
||||
|
||||
@@ -36,7 +36,7 @@ public:
|
||||
|
||||
float GetFPS() const;
|
||||
bool GetExportCoordsLocalToTheSelectedObject() const;
|
||||
bool GetExportOnlyMasterCamera() const;
|
||||
bool GetExportOnlyPrimaryCamera() const;
|
||||
void SetExportLocalCoordsCheckBoxEnable(bool checked);
|
||||
|
||||
int exec() override;
|
||||
@@ -44,7 +44,7 @@ public:
|
||||
protected:
|
||||
void OnFPSChange();
|
||||
void SetExportLocalToTheSelectedObjectCheckBox();
|
||||
void SetExportOnlyMasterCameraCheckBox();
|
||||
void SetExportOnlyPrimaryCameraCheckBox();
|
||||
|
||||
void accept() override;
|
||||
|
||||
|
||||
@@ -49,9 +49,9 @@
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="m_exportOnlyMasterCameraCheckBox">
|
||||
<widget class="QCheckBox" name="m_exportOnlyPrimaryCameraCheckBox">
|
||||
<property name="text">
|
||||
<string>Export Only Master Camera</string>
|
||||
<string>Export Only Primary Camera</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
@@ -20,7 +20,7 @@ class CEditorMock
|
||||
: public IEditor
|
||||
{
|
||||
public:
|
||||
// GMock does not work with a variadic function (https://github.com/google/googlemock/blob/master/googlemock/docs/FrequentlyAskedQuestions.md)
|
||||
// GMock does not work with a variadic function
|
||||
void ExecuteCommand(const char* sCommand, ...) override
|
||||
{
|
||||
va_list args;
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace AZ
|
||||
{
|
||||
namespace FbxSceneBuilder
|
||||
{
|
||||
const char* AssImpUvMapImporter::m_defaultNodeName = "UVMap";
|
||||
const char* AssImpUvMapImporter::m_defaultNodeName = "UV";
|
||||
|
||||
AssImpUvMapImporter::AssImpUvMapImporter()
|
||||
{
|
||||
@@ -44,7 +44,7 @@ namespace AZ
|
||||
SerializeContext* serializeContext = azrtti_cast<SerializeContext*>(context);
|
||||
if (serializeContext)
|
||||
{
|
||||
serializeContext->Class<AssImpUvMapImporter, SceneCore::LoadingComponent>()->Version(2); // LYN-2576
|
||||
serializeContext->Class<AssImpUvMapImporter, SceneCore::LoadingComponent>()->Version(3); // LYN-2506
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,7 +84,13 @@ namespace AZ
|
||||
AZStd::shared_ptr<SceneData::GraphData::MeshVertexUVData> uvMap =
|
||||
AZStd::make_shared<AZ::SceneData::GraphData::MeshVertexUVData>();
|
||||
uvMap->ReserveContainerSpace(vertexCount);
|
||||
|
||||
AZStd::string name(AZStd::string::format("%s%d", m_defaultNodeName, texCoordIndex));
|
||||
if (mesh->mTextureCoordsNames[texCoordIndex].length)
|
||||
{
|
||||
name = mesh->mTextureCoordsNames[texCoordIndex].C_Str();
|
||||
}
|
||||
|
||||
uvMap->SetCustomName(name.c_str());
|
||||
|
||||
for (int v = 0; v < mesh->mNumVertices; ++v)
|
||||
|
||||
@@ -86,7 +86,7 @@ namespace AZ
|
||||
|
||||
if (sourceFileExists && !updateMaterial)
|
||||
{
|
||||
// Don't write to the cache if there's a source material as this will be the master material.
|
||||
// Don't write to the cache if there's a source material as this will be the primary material.
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ namespace AZ
|
||||
NoneCheckable, // No nodes can be checked.
|
||||
OnlyFilterTypesCheckable // Only nodes in the filter type list can be checked.
|
||||
};
|
||||
// Updates the tree to include/exclude check boxes and the master selection. Call "BuildTree()" to rebuild the tree.
|
||||
// Updates the tree to include/exclude check boxes and the primary selection. Call "BuildTree()" to rebuild the tree.
|
||||
virtual void MakeCheckable(CheckableOption option);
|
||||
// Add a type to filter for. Filter types are used to determine if a check box is added and/or to be shown if
|
||||
// the type is an end point. See "IncludeEndPoints" and "MakeCheckable" for more details.
|
||||
|
||||
@@ -308,7 +308,7 @@ namespace AssetMemoryAnalyzer
|
||||
AZStd::function<void(AssetInfo*, AssetTreeNode*, int)> recurse;
|
||||
recurse = [&recurse](AssetInfo* outAsset, AssetTreeNode* inAsset, int depth)
|
||||
{
|
||||
outAsset->m_id = inAsset->m_masterInfo ? inAsset->m_masterInfo->m_id->m_id.c_str() : nullptr;
|
||||
outAsset->m_id = inAsset->m_primaryinfo ? inAsset->m_primaryinfo->m_id->m_id.c_str() : nullptr;
|
||||
|
||||
// For every code point in this asset node, record its allocations
|
||||
for (auto& codePointInfo : inAsset->m_data.m_codePointsToAllocations)
|
||||
|
||||
BIN
Binary file not shown.
@@ -405,12 +405,20 @@ namespace AZ
|
||||
void ShaderVariantAssetBuilder::ProcessJob(const AssetBuilderSDK::ProcessJobRequest& request, AssetBuilderSDK::ProcessJobResponse& response) const
|
||||
{
|
||||
const auto& jobParameters = request.m_jobDescription.m_jobParameters;
|
||||
|
||||
if (jobParameters.find(ShaderVariantLoadErrorParam) != jobParameters.end())
|
||||
{
|
||||
AZ_Error(ShaderVariantAssetBuilderName, false, "Error during CreateJobs: %s", jobParameters.at(ShaderVariantLoadErrorParam).c_str());
|
||||
response.m_resultCode = AssetBuilderSDK::ProcessJobResult_Failed;
|
||||
return;
|
||||
}
|
||||
|
||||
if (jobParameters.find(ShouldExitEarlyFromProcessJobParam) != jobParameters.end())
|
||||
{
|
||||
AZ_TracePrintf(ShaderVariantAssetBuilderName, "Doing nothing on behalf of [%s] because it's been overridden by game project.", jobParameters.at(ShaderVariantLoadErrorParam).c_str());
|
||||
response.m_resultCode = AssetBuilderSDK::ProcessJobResult_Success;
|
||||
return;
|
||||
}
|
||||
|
||||
if (jobParameters.find(ShouldExitEarlyFromProcessJobParam) != jobParameters.end())
|
||||
{
|
||||
|
||||
-32
@@ -401,38 +401,6 @@
|
||||
"step": 0.1
|
||||
}
|
||||
],
|
||||
"ambientOcclusion": [
|
||||
{
|
||||
"id": "enable",
|
||||
"displayName": "Enable",
|
||||
"description": "Whether to enable the ambient occlusion feature.",
|
||||
"type": "Bool",
|
||||
"defaultValue": false
|
||||
},
|
||||
{
|
||||
"id": "factor",
|
||||
"displayName": "Factor",
|
||||
"description": "Strength factor for scaling the values",
|
||||
"type": "Float",
|
||||
"defaultValue": 1.0,
|
||||
"min": 0.0,
|
||||
"max": 2.0,
|
||||
"connection": {
|
||||
"type": "ShaderInput",
|
||||
"id": "m_ambientOcclusionFactor"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "textureMap",
|
||||
"displayName": "Texture Map",
|
||||
"description": "Texture map for defining ambient occlusion area.",
|
||||
"type": "Image",
|
||||
"connection": {
|
||||
"type": "ShaderInput",
|
||||
"id": "m_ambientOcclusionMap"
|
||||
}
|
||||
}
|
||||
],
|
||||
"emissive": [
|
||||
{
|
||||
"id": "enable",
|
||||
|
||||
@@ -49,9 +49,9 @@
|
||||
"description": "Properties for configuring UV transforms."
|
||||
},
|
||||
{
|
||||
"id": "ambientOcclusion",
|
||||
"displayName": "Ambient Occlusion",
|
||||
"description": "Properties for baked AO texture."
|
||||
"id": "occlusion",
|
||||
"displayName": "Occlusion",
|
||||
"description": "Properties for baked textures that represent geometric occlusion of light."
|
||||
},
|
||||
{
|
||||
"id": "emissive",
|
||||
@@ -780,47 +780,89 @@
|
||||
"step": 0.1
|
||||
}
|
||||
],
|
||||
"ambientOcclusion": [
|
||||
"occlusion": [
|
||||
{
|
||||
"id": "enable",
|
||||
"displayName": "Enable",
|
||||
"description": "Whether to enable the ambient occlusion feature.",
|
||||
"type": "Bool",
|
||||
"defaultValue": false
|
||||
},
|
||||
{
|
||||
"id": "factor",
|
||||
"displayName": "Factor",
|
||||
"description": "Strength factor for scaling the values",
|
||||
"type": "Float",
|
||||
"defaultValue": 1.0,
|
||||
"min": 0.0,
|
||||
"max": 2.0,
|
||||
"connection": {
|
||||
"type": "ShaderInput",
|
||||
"id": "m_ambientOcclusionFactor"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "textureMap",
|
||||
"displayName": "Texture Map",
|
||||
"description": "Texture map for defining ambient occlusion area.",
|
||||
"id": "diffuseTextureMap",
|
||||
"displayName": "Diffuse AO",
|
||||
"description": "Texture map for defining occlusion area for diffuse ambient lighting.",
|
||||
"type": "Image",
|
||||
"connection": {
|
||||
"type": "ShaderInput",
|
||||
"id": "m_ambientOcclusionMap"
|
||||
"id": "m_diffuseOcclusionMap"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "textureMapUv",
|
||||
"displayName": "UV",
|
||||
"description": "Ambient occlusion texture map UV set",
|
||||
"id": "diffuseUseTexture",
|
||||
"displayName": " Use Texture",
|
||||
"description": "Whether to use the Diffuse AO texture map.",
|
||||
"type": "Bool",
|
||||
"defaultValue": true
|
||||
},
|
||||
{
|
||||
"id": "diffuseTextureMapUv",
|
||||
"displayName": " UV",
|
||||
"description": "Diffuse AO texture map UV set.",
|
||||
"type": "Enum",
|
||||
"enumValues": [ "UV0", "UV1" ],
|
||||
"defaultValue": "UV0",
|
||||
"enumIsUv": true,
|
||||
"defaultValue": "Tiled",
|
||||
"connection": {
|
||||
"type": "ShaderInput",
|
||||
"id": "m_ambientOcclusionMapUvIndex"
|
||||
"id": "m_diffuseOcclusionMapUvIndex"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "diffuseFactor",
|
||||
"displayName": " Factor",
|
||||
"description": "Strength factor for scaling the values of Diffuse AO",
|
||||
"type": "Float",
|
||||
"defaultValue": 1.0,
|
||||
"min": 0.0,
|
||||
"softMax": 2.0,
|
||||
"connection": {
|
||||
"type": "ShaderInput",
|
||||
"id": "m_diffuseOcclusionFactor"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "specularTextureMap",
|
||||
"displayName": "Specular Cavity",
|
||||
"description": "Texture map for defining occlusion area for specular lighting.",
|
||||
"type": "Image",
|
||||
"connection": {
|
||||
"type": "ShaderInput",
|
||||
"id": "m_specularOcclusionMap"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "specularUseTexture",
|
||||
"displayName": " Use Texture",
|
||||
"description": "Whether to use the Specular Cavity texture map.",
|
||||
"type": "Bool",
|
||||
"defaultValue": true
|
||||
},
|
||||
{
|
||||
"id": "specularTextureMapUv",
|
||||
"displayName": " UV",
|
||||
"description": "Specular Cavity texture map UV set.",
|
||||
"type": "Enum",
|
||||
"enumIsUv": true,
|
||||
"defaultValue": "Tiled",
|
||||
"connection": {
|
||||
"type": "ShaderInput",
|
||||
"id": "m_specularOcclusionMapUvIndex"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "specularFactor",
|
||||
"displayName": " Factor",
|
||||
"description": "Strength factor for scaling the values of Specular Cavity",
|
||||
"type": "Float",
|
||||
"defaultValue": 1.0,
|
||||
"min": 0.0,
|
||||
"softMax": 2.0,
|
||||
"connection": {
|
||||
"type": "ShaderInput",
|
||||
"id": "m_specularOcclusionFactor"
|
||||
}
|
||||
}
|
||||
],
|
||||
@@ -1641,17 +1683,21 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
// See the comment above for details.
|
||||
"type": "UseTexture",
|
||||
"args": {
|
||||
"textureProperty": "ambientOcclusion.textureMap",
|
||||
"dependentProperties": ["ambientOcclusion.textureMapUv"],
|
||||
"useTextureProperty": "ambientOcclusion.enable",
|
||||
"shaderTags": [
|
||||
"ForwardPass",
|
||||
"ForwardPass_EDS"
|
||||
],
|
||||
"shaderOption": "o_ambientOcclusion_useTexture"
|
||||
"textureProperty": "occlusion.diffuseTextureMap",
|
||||
"useTextureProperty": "occlusion.diffuseUseTexture",
|
||||
"dependentProperties": ["occlusion.diffuseTextureMapUv", "occlusion.diffuseFactor"],
|
||||
"shaderOption": "o_diffuseOcclusion_useTexture"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "UseTexture",
|
||||
"args": {
|
||||
"textureProperty": "occlusion.specularTextureMap",
|
||||
"useTextureProperty": "occlusion.specularUseTexture",
|
||||
"dependentProperties": ["occlusion.specularTextureMapUv", "occlusion.specularFactor"],
|
||||
"shaderOption": "o_specularOcclusion_useTexture"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -1712,31 +1758,6 @@
|
||||
"shaderOption": "o_transmission_useTexture"
|
||||
}
|
||||
},
|
||||
{
|
||||
// Controls visibility for properties in the editor.
|
||||
// @param actions - a list of actions that are executed in order. visibility will be set when triggerProperty hits the triggerValue.
|
||||
// @param affectedProperties - the properties that are affected by actions.
|
||||
"type": "UpdatePropertyVisibility",
|
||||
"args": {
|
||||
"actions": [
|
||||
{
|
||||
"triggerProperty": "ambientOcclusion.enable",
|
||||
"triggerValue": true,
|
||||
"visibility": "Enabled"
|
||||
},
|
||||
{
|
||||
"triggerProperty": "ambientOcclusion.enable",
|
||||
"triggerValue": false,
|
||||
"visibility": "Disabled"
|
||||
}
|
||||
],
|
||||
"affectedProperties": [
|
||||
"ambientOcclusion.factor",
|
||||
"ambientOcclusion.textureMap",
|
||||
"ambientOcclusion.textureMapUv"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
// Controls visibility for properties in the editor.
|
||||
// @param actions - a list of actions that are executed in order. visibility will be set when triggerProperty hits the triggerValue.
|
||||
|
||||
@@ -213,9 +213,9 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float
|
||||
float3 emissive = GetEmissiveInput(MaterialSrg::m_emissiveMap, MaterialSrg::m_sampler, emissiveUv, MaterialSrg::m_emissiveIntensity, MaterialSrg::m_emissiveColor.rgb, o_emissiveEnabled, o_emissive_useTexture);
|
||||
|
||||
// ------- Occlusion -------
|
||||
|
||||
float2 occlusionUv = IN.m_uv[MaterialSrg::m_ambientOcclusionMapUvIndex];
|
||||
float occlusion = GetOcclusionInput(MaterialSrg::m_ambientOcclusionMap, MaterialSrg::m_sampler, occlusionUv, MaterialSrg::m_ambientOcclusionFactor, o_ambientOcclusion_useTexture);
|
||||
|
||||
float diffuseAmbientOcclusion = GetOcclusionInput(MaterialSrg::m_diffuseOcclusionMap, MaterialSrg::m_sampler, IN.m_uv[MaterialSrg::m_diffuseOcclusionMapUvIndex], MaterialSrg::m_diffuseOcclusionFactor, o_diffuseOcclusion_useTexture);
|
||||
float specularOcclusion = GetOcclusionInput(MaterialSrg::m_specularOcclusionMap, MaterialSrg::m_sampler, IN.m_uv[MaterialSrg::m_specularOcclusionMapUvIndex], MaterialSrg::m_specularOcclusionFactor, o_specularOcclusion_useTexture);
|
||||
|
||||
// ------- Subsurface -------
|
||||
|
||||
@@ -252,7 +252,7 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float
|
||||
PbrLightingOutput lightingOutput = PbrLighting(IN,
|
||||
baseColor, metallic, roughness, specularF0Factor,
|
||||
normal, IN.m_tangent, IN.m_bitangent, anisotropy,
|
||||
emissive, occlusion, transmissionTintThickness, MaterialSrg::m_transmissionParams, clearCoatFactor, clearCoatRoughness, clearCoatNormal, alpha, o_opacity_mode);
|
||||
emissive, diffuseAmbientOcclusion, specularOcclusion, transmissionTintThickness, MaterialSrg::m_transmissionParams, clearCoatFactor, clearCoatRoughness, clearCoatNormal, alpha, o_opacity_mode);
|
||||
|
||||
// ------- Opacity -------
|
||||
|
||||
|
||||
@@ -12,19 +12,23 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
// This file provides utilities for common handling of inputs for ambient occlusion maps for PBR materials.
|
||||
// This file provides utilities for common handling of inputs for baked occlusion maps for PBR materials.
|
||||
|
||||
// These macros can be used to declare common shader inputs for this feature.
|
||||
// Use the COMMON_SRG_INPUTS_* macro in your material SRG definition, and use the COMMON_OPTIONS_* macro at the global scope in your shader. Then you can pass these variables to the Get*Input() function below.
|
||||
// You can optionally provide a prefix for the set of inputs which corresponds to a prefix string supplied by the .materialtype file. This is common for multi-layered material types.
|
||||
|
||||
#define COMMON_SRG_INPUTS_OCCLUSION(prefix) \
|
||||
float prefix##m_ambientOcclusionFactor; \
|
||||
Texture2D prefix##m_ambientOcclusionMap; \
|
||||
uint prefix##m_ambientOcclusionMapUvIndex;
|
||||
float prefix##m_diffuseOcclusionFactor; \
|
||||
Texture2D prefix##m_diffuseOcclusionMap; \
|
||||
uint prefix##m_diffuseOcclusionMapUvIndex; \
|
||||
float prefix##m_specularOcclusionFactor; \
|
||||
Texture2D prefix##m_specularOcclusionMap; \
|
||||
uint prefix##m_specularOcclusionMapUvIndex;
|
||||
|
||||
#define COMMON_OPTIONS_OCCLUSION(prefix) \
|
||||
option bool prefix##o_ambientOcclusion_useTexture;
|
||||
option bool prefix##o_diffuseOcclusion_useTexture; \
|
||||
option bool prefix##o_specularOcclusion_useTexture;
|
||||
|
||||
float GetOcclusionInput(Texture2D map, sampler mapSampler, float2 uv, float factor, bool useTexture)
|
||||
{
|
||||
|
||||
@@ -272,6 +272,11 @@ PbrLightingOutput SkinPS_Common(VSOutput IN)
|
||||
float roughness = GetRoughnessInput(MaterialSrg::m_roughnessMap, MaterialSrg::m_sampler, roughnessUv, MaterialSrg::m_roughnessFactor,
|
||||
MaterialSrg::m_roughnessLowerBound, MaterialSrg::m_roughnessUpperBound, o_roughness_useTexture);
|
||||
|
||||
// ------- Occlusion -------
|
||||
|
||||
float diffuseAmbientOcclusion = GetOcclusionInput(MaterialSrg::m_diffuseOcclusionMap, MaterialSrg::m_sampler, IN.m_uv[MaterialSrg::m_diffuseOcclusionMapUvIndex], MaterialSrg::m_diffuseOcclusionFactor, o_diffuseOcclusion_useTexture);
|
||||
float specularOcclusion = GetOcclusionInput(MaterialSrg::m_specularOcclusionMap, MaterialSrg::m_sampler, IN.m_uv[MaterialSrg::m_specularOcclusionMapUvIndex], MaterialSrg::m_specularOcclusionFactor, o_specularOcclusion_useTexture);
|
||||
|
||||
// ------- Specular -------
|
||||
|
||||
float2 specularUv = IN.m_uv[MaterialSrg::m_specularF0MapUvIndex];
|
||||
@@ -300,7 +305,6 @@ PbrLightingOutput SkinPS_Common(VSOutput IN)
|
||||
|
||||
float metallic = 0;
|
||||
float3 emissive = float3(0,0,0);
|
||||
float occlusion = 1;
|
||||
float2 anisotropy = float2(0,0);
|
||||
float clearCoatFactor = 0.0;
|
||||
float clearCoatRoughness = 0.0;
|
||||
@@ -309,7 +313,7 @@ PbrLightingOutput SkinPS_Common(VSOutput IN)
|
||||
|
||||
PbrLightingOutput lightingOutput = PbrLighting(IN, baseColor, metallic, roughness, specularF0Factor,
|
||||
normalWS, tangents[0], bitangents[0], anisotropy,
|
||||
emissive, occlusion, transmissionTintThickness, MaterialSrg::m_transmissionParams, clearCoatFactor, clearCoatRoughness, clearCoatNormal, alpha, o_opacity_mode);
|
||||
emissive, diffuseAmbientOcclusion, specularOcclusion, transmissionTintThickness, MaterialSrg::m_transmissionParams, clearCoatFactor, clearCoatRoughness, clearCoatNormal, alpha, o_opacity_mode);
|
||||
|
||||
// ------- Preparing output -------
|
||||
|
||||
|
||||
@@ -24,9 +24,9 @@
|
||||
"description": "Properties related to configuring surface normal."
|
||||
},
|
||||
{
|
||||
"id": "ambientOcclusion",
|
||||
"displayName": "Ambient Occlusion",
|
||||
"description": "Properties for baked AO texture."
|
||||
"id": "occlusion",
|
||||
"displayName": "Occlusion",
|
||||
"description": "Properties for baked textures that represent geometric occlusion of light."
|
||||
},
|
||||
{
|
||||
"id": "subsurfaceScattering",
|
||||
@@ -383,48 +383,89 @@
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
"ambientOcclusion": [
|
||||
"occlusion": [
|
||||
{
|
||||
"id": "enable",
|
||||
"displayName": "Enable",
|
||||
"description": "Whether to enable the ambient occlusion feature.",
|
||||
"type": "Bool",
|
||||
"defaultValue": false
|
||||
},
|
||||
{
|
||||
"id": "textureMap",
|
||||
"displayName": "Texture Map",
|
||||
"description": "Texture map for defining ambient occlusion area.",
|
||||
"id": "diffuseTextureMap",
|
||||
"displayName": "Diffuse AO",
|
||||
"description": "Texture map for defining occlusion area for diffuse ambient lighting.",
|
||||
"type": "Image",
|
||||
"connection": {
|
||||
"type": "ShaderInput",
|
||||
"id": "m_ambientOcclusionMap"
|
||||
"id": "m_diffuseOcclusionMap"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "textureMapUv",
|
||||
"displayName": "UV",
|
||||
"description": "Ambient occlusion texture map UV set",
|
||||
"id": "diffuseUseTexture",
|
||||
"displayName": " Use Texture",
|
||||
"description": "Whether to use the Diffuse AO texture map.",
|
||||
"type": "Bool",
|
||||
"defaultValue": true
|
||||
},
|
||||
{
|
||||
"id": "diffuseTextureMapUv",
|
||||
"displayName": " UV",
|
||||
"description": "Diffuse AO texture map UV set.",
|
||||
"type": "Enum",
|
||||
"enumIsUv": true,
|
||||
"defaultValue": "Unwrapped",
|
||||
"defaultValue": "Tiled",
|
||||
"connection": {
|
||||
"type": "ShaderInput",
|
||||
"id": "m_ambientOcclusionMapUvIndex"
|
||||
"id": "m_diffuseOcclusionMapUvIndex"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "factor",
|
||||
"displayName": "Factor",
|
||||
"description": "Strength factor for scaling the values",
|
||||
"id": "diffuseFactor",
|
||||
"displayName": " Factor",
|
||||
"description": "Strength factor for scaling the values of Diffuse AO",
|
||||
"type": "Float",
|
||||
"defaultValue": 1.0,
|
||||
"min": 0.0,
|
||||
"max": 2.0,
|
||||
"softMax": 2.0,
|
||||
"connection": {
|
||||
"type": "ShaderInput",
|
||||
"id": "m_ambientOcclusionFactor"
|
||||
"id": "m_diffuseOcclusionFactor"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "specularTextureMap",
|
||||
"displayName": "Specular Cavity",
|
||||
"description": "Texture map for defining occlusion area for specular lighting.",
|
||||
"type": "Image",
|
||||
"connection": {
|
||||
"type": "ShaderInput",
|
||||
"id": "m_specularOcclusionMap"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "specularUseTexture",
|
||||
"displayName": " Use Texture",
|
||||
"description": "Whether to use the Specular Cavity texture map.",
|
||||
"type": "Bool",
|
||||
"defaultValue": true
|
||||
},
|
||||
{
|
||||
"id": "specularTextureMapUv",
|
||||
"displayName": " UV",
|
||||
"description": "Specular Cavity texture map UV set.",
|
||||
"type": "Enum",
|
||||
"enumIsUv": true,
|
||||
"defaultValue": "Tiled",
|
||||
"connection": {
|
||||
"type": "ShaderInput",
|
||||
"id": "m_specularOcclusionMapUvIndex"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "specularFactor",
|
||||
"displayName": " Factor",
|
||||
"description": "Strength factor for scaling the values of Specular Cavity",
|
||||
"type": "Float",
|
||||
"defaultValue": 1.0,
|
||||
"min": 0.0,
|
||||
"softMax": 2.0,
|
||||
"connection": {
|
||||
"type": "ShaderInput",
|
||||
"id": "m_specularOcclusionFactor"
|
||||
}
|
||||
}
|
||||
],
|
||||
@@ -1021,9 +1062,21 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Lua",
|
||||
"type": "UseTexture",
|
||||
"args": {
|
||||
"file": "StandardPBR_AoState.lua"
|
||||
"textureProperty": "occlusion.diffuseTextureMap",
|
||||
"useTextureProperty": "occlusion.diffuseUseTexture",
|
||||
"dependentProperties": ["occlusion.diffuseTextureMapUv", "occlusion.diffuseFactor"],
|
||||
"shaderOption": "o_diffuseOcclusion_useTexture"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "UseTexture",
|
||||
"args": {
|
||||
"textureProperty": "occlusion.specularTextureMap",
|
||||
"useTextureProperty": "occlusion.specularUseTexture",
|
||||
"dependentProperties": ["occlusion.specularTextureMapUv", "occlusion.specularFactor"],
|
||||
"shaderOption": "o_specularOcclusion_useTexture"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
+240
-87
@@ -73,9 +73,9 @@
|
||||
"description": "Properties for configuring gloss clear coat"
|
||||
},
|
||||
{
|
||||
"id": "layer1_ambientOcclusion",
|
||||
"displayName": "Layer 1: Ambient Occlusion",
|
||||
"description": "Properties for baked AO texture."
|
||||
"id": "layer1_occlusion",
|
||||
"displayName": "Layer 1: Occlusion",
|
||||
"description": "Properties for baked textures for diffuse and specular occlusion of ambient lighting."
|
||||
},
|
||||
{
|
||||
"id": "layer1_emissive",
|
||||
@@ -126,9 +126,9 @@
|
||||
"description": "Properties for configuring gloss clear coat"
|
||||
},
|
||||
{
|
||||
"id": "layer2_ambientOcclusion",
|
||||
"displayName": "Layer 2: Ambient Occlusion",
|
||||
"description": "Properties for baked AO texture."
|
||||
"id": "layer2_occlusion",
|
||||
"displayName": "Layer 2: Occlusion",
|
||||
"description": "Properties for baked textures for diffuse and specular occlusion of ambient lighting."
|
||||
},
|
||||
{
|
||||
"id": "layer2_emissive",
|
||||
@@ -179,9 +179,9 @@
|
||||
"description": "Properties for configuring gloss clear coat"
|
||||
},
|
||||
{
|
||||
"id": "layer3_ambientOcclusion",
|
||||
"displayName": "Layer 3: Ambient Occlusion",
|
||||
"description": "Properties for baked AO texture."
|
||||
"id": "layer3_occlusion",
|
||||
"displayName": "Layer 3: Occlusion",
|
||||
"description": "Properties for baked textures for diffuse and specular occlusion of ambient lighting."
|
||||
},
|
||||
{
|
||||
"id": "layer3_emissive",
|
||||
@@ -1169,47 +1169,89 @@
|
||||
}
|
||||
}
|
||||
],
|
||||
"layer1_ambientOcclusion": [
|
||||
"layer1_occlusion": [
|
||||
{
|
||||
"id": "enable",
|
||||
"displayName": "Enable",
|
||||
"description": "Whether to enable the ambient occlusion feature.",
|
||||
"type": "Bool",
|
||||
"defaultValue": false
|
||||
},
|
||||
{
|
||||
"id": "textureMap",
|
||||
"displayName": "Texture Map",
|
||||
"description": "Texture map for defining ambient occlusion area.",
|
||||
"id": "diffuseTextureMap",
|
||||
"displayName": "Diffuse AO",
|
||||
"description": "Texture map for defining occlusion area for diffuse ambient lighting.",
|
||||
"type": "Image",
|
||||
"connection": {
|
||||
"type": "ShaderInput",
|
||||
"id": "m_layer1_m_ambientOcclusionMap"
|
||||
"id": "m_layer1_m_diffuseOcclusionMap"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "textureMapUv",
|
||||
"displayName": "UV",
|
||||
"description": "Ambient occlusion texture map UV set",
|
||||
"id": "diffuseUseTexture",
|
||||
"displayName": " Use Texture",
|
||||
"description": "Whether to use the Diffuse AO texture map.",
|
||||
"type": "Bool",
|
||||
"defaultValue": true
|
||||
},
|
||||
{
|
||||
"id": "diffuseTextureMapUv",
|
||||
"displayName": " UV",
|
||||
"description": "Diffuse AO texture map UV set.",
|
||||
"type": "Enum",
|
||||
"enumIsUv": true,
|
||||
"defaultValue": "Tiled",
|
||||
"connection": {
|
||||
"type": "ShaderInput",
|
||||
"id": "m_layer1_m_ambientOcclusionMapUvIndex"
|
||||
"id": "m_layer1_m_diffuseOcclusionMapUvIndex"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "factor",
|
||||
"displayName": "Factor",
|
||||
"description": "Strength factor for scaling the values",
|
||||
"id": "diffuseFactor",
|
||||
"displayName": " Factor",
|
||||
"description": "Strength factor for scaling the values of Diffuse AO",
|
||||
"type": "Float",
|
||||
"defaultValue": 1.0,
|
||||
"min": 0.0,
|
||||
"max": 2.0,
|
||||
"softMax": 2.0,
|
||||
"connection": {
|
||||
"type": "ShaderInput",
|
||||
"id": "m_layer1_m_ambientOcclusionFactor"
|
||||
"id": "m_layer1_m_diffuseOcclusionFactor"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "specularTextureMap",
|
||||
"displayName": "Specular Cavity",
|
||||
"description": "Texture map for defining occlusion area for specular lighting.",
|
||||
"type": "Image",
|
||||
"connection": {
|
||||
"type": "ShaderInput",
|
||||
"id": "m_layer1_m_specularOcclusionMap"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "specularUseTexture",
|
||||
"displayName": " Use Texture",
|
||||
"description": "Whether to use the Specular Cavity texture map.",
|
||||
"type": "Bool",
|
||||
"defaultValue": true
|
||||
},
|
||||
{
|
||||
"id": "specularTextureMapUv",
|
||||
"displayName": " UV",
|
||||
"description": "Specular Cavity texture map UV set.",
|
||||
"type": "Enum",
|
||||
"enumIsUv": true,
|
||||
"defaultValue": "Tiled",
|
||||
"connection": {
|
||||
"type": "ShaderInput",
|
||||
"id": "m_layer1_m_specularOcclusionMapUvIndex"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "specularFactor",
|
||||
"displayName": " Factor",
|
||||
"description": "Strength factor for scaling the values of Specular Cavity",
|
||||
"type": "Float",
|
||||
"defaultValue": 1.0,
|
||||
"min": 0.0,
|
||||
"softMax": 2.0,
|
||||
"connection": {
|
||||
"type": "ShaderInput",
|
||||
"id": "m_layer1_m_specularOcclusionFactor"
|
||||
}
|
||||
}
|
||||
],
|
||||
@@ -1820,47 +1862,89 @@
|
||||
}
|
||||
}
|
||||
],
|
||||
"layer2_ambientOcclusion": [
|
||||
"layer2_occlusion": [
|
||||
{
|
||||
"id": "enable",
|
||||
"displayName": "Enable",
|
||||
"description": "Whether to enable the ambient occlusion feature.",
|
||||
"type": "Bool",
|
||||
"defaultValue": false
|
||||
},
|
||||
{
|
||||
"id": "textureMap",
|
||||
"displayName": "Texture Map",
|
||||
"description": "Texture map for defining ambient occlusion area.",
|
||||
"id": "diffuseTextureMap",
|
||||
"displayName": "Diffuse AO",
|
||||
"description": "Texture map for defining occlusion area for diffuse ambient lighting.",
|
||||
"type": "Image",
|
||||
"connection": {
|
||||
"type": "ShaderInput",
|
||||
"id": "m_layer2_m_ambientOcclusionMap"
|
||||
"id": "m_layer2_m_diffuseOcclusionMap"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "textureMapUv",
|
||||
"displayName": "UV",
|
||||
"description": "Ambient occlusion texture map UV set",
|
||||
"id": "diffuseUseTexture",
|
||||
"displayName": " Use Texture",
|
||||
"description": "Whether to use the Diffuse AO texture map.",
|
||||
"type": "Bool",
|
||||
"defaultValue": true
|
||||
},
|
||||
{
|
||||
"id": "diffuseTextureMapUv",
|
||||
"displayName": " UV",
|
||||
"description": "Diffuse AO texture map UV set.",
|
||||
"type": "Enum",
|
||||
"enumIsUv": true,
|
||||
"defaultValue": "Tiled",
|
||||
"connection": {
|
||||
"type": "ShaderInput",
|
||||
"id": "m_layer2_m_ambientOcclusionMapUvIndex"
|
||||
"id": "m_layer2_m_diffuseOcclusionMapUvIndex"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "factor",
|
||||
"displayName": "Factor",
|
||||
"description": "Strength factor for scaling the values",
|
||||
"id": "diffuseFactor",
|
||||
"displayName": " Factor",
|
||||
"description": "Strength factor for scaling the values of Diffuse AO",
|
||||
"type": "Float",
|
||||
"defaultValue": 1.0,
|
||||
"min": 0.0,
|
||||
"max": 2.0,
|
||||
"softMax": 2.0,
|
||||
"connection": {
|
||||
"type": "ShaderInput",
|
||||
"id": "m_layer2_m_ambientOcclusionFactor"
|
||||
"id": "m_layer2_m_diffuseOcclusionFactor"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "specularTextureMap",
|
||||
"displayName": "Specular Cavity",
|
||||
"description": "Texture map for defining occlusion area for specular lighting.",
|
||||
"type": "Image",
|
||||
"connection": {
|
||||
"type": "ShaderInput",
|
||||
"id": "m_layer2_m_specularOcclusionMap"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "specularUseTexture",
|
||||
"displayName": " Use Texture",
|
||||
"description": "Whether to use the Specular Cavity texture map.",
|
||||
"type": "Bool",
|
||||
"defaultValue": true
|
||||
},
|
||||
{
|
||||
"id": "specularTextureMapUv",
|
||||
"displayName": " UV",
|
||||
"description": "Specular Cavity texture map UV set.",
|
||||
"type": "Enum",
|
||||
"enumIsUv": true,
|
||||
"defaultValue": "Tiled",
|
||||
"connection": {
|
||||
"type": "ShaderInput",
|
||||
"id": "m_layer2_m_specularOcclusionMapUvIndex"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "specularFactor",
|
||||
"displayName": " Factor",
|
||||
"description": "Strength factor for scaling the values of Specular Cavity",
|
||||
"type": "Float",
|
||||
"defaultValue": 1.0,
|
||||
"min": 0.0,
|
||||
"softMax": 2.0,
|
||||
"connection": {
|
||||
"type": "ShaderInput",
|
||||
"id": "m_layer2_m_specularOcclusionFactor"
|
||||
}
|
||||
}
|
||||
],
|
||||
@@ -2471,47 +2555,89 @@
|
||||
}
|
||||
}
|
||||
],
|
||||
"layer3_ambientOcclusion": [
|
||||
"layer3_occlusion": [
|
||||
{
|
||||
"id": "enable",
|
||||
"displayName": "Enable",
|
||||
"description": "Whether to enable the ambient occlusion feature.",
|
||||
"type": "Bool",
|
||||
"defaultValue": false
|
||||
},
|
||||
{
|
||||
"id": "textureMap",
|
||||
"displayName": "Texture Map",
|
||||
"description": "Texture map for defining ambient occlusion area.",
|
||||
"id": "diffuseTextureMap",
|
||||
"displayName": "Diffuse AO",
|
||||
"description": "Texture map for defining occlusion area for diffuse ambient lighting.",
|
||||
"type": "Image",
|
||||
"connection": {
|
||||
"type": "ShaderInput",
|
||||
"id": "m_layer3_m_ambientOcclusionMap"
|
||||
"id": "m_layer3_m_diffuseOcclusionMap"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "textureMapUv",
|
||||
"displayName": "UV",
|
||||
"description": "Ambient occlusion texture map UV set",
|
||||
"id": "diffuseUseTexture",
|
||||
"displayName": " Use Texture",
|
||||
"description": "Whether to use the Diffuse AO texture map.",
|
||||
"type": "Bool",
|
||||
"defaultValue": true
|
||||
},
|
||||
{
|
||||
"id": "diffuseTextureMapUv",
|
||||
"displayName": " UV",
|
||||
"description": "Diffuse AO texture map UV set.",
|
||||
"type": "Enum",
|
||||
"enumIsUv": true,
|
||||
"defaultValue": "Tiled",
|
||||
"connection": {
|
||||
"type": "ShaderInput",
|
||||
"id": "m_layer3_m_ambientOcclusionMapUvIndex"
|
||||
"id": "m_layer3_m_diffuseOcclusionMapUvIndex"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "factor",
|
||||
"displayName": "Factor",
|
||||
"description": "Strength factor for scaling the values",
|
||||
"id": "diffuseFactor",
|
||||
"displayName": " Factor",
|
||||
"description": "Strength factor for scaling the values of Diffuse AO",
|
||||
"type": "Float",
|
||||
"defaultValue": 1.0,
|
||||
"min": 0.0,
|
||||
"max": 2.0,
|
||||
"softMax": 2.0,
|
||||
"connection": {
|
||||
"type": "ShaderInput",
|
||||
"id": "m_layer3_m_ambientOcclusionFactor"
|
||||
"id": "m_layer3_m_diffuseOcclusionFactor"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "specularTextureMap",
|
||||
"displayName": "Specular Cavity",
|
||||
"description": "Texture map for defining occlusion area for specular lighting.",
|
||||
"type": "Image",
|
||||
"connection": {
|
||||
"type": "ShaderInput",
|
||||
"id": "m_layer3_m_specularOcclusionMap"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "specularUseTexture",
|
||||
"displayName": " Use Texture",
|
||||
"description": "Whether to use the Specular Cavity texture map.",
|
||||
"type": "Bool",
|
||||
"defaultValue": true
|
||||
},
|
||||
{
|
||||
"id": "specularTextureMapUv",
|
||||
"displayName": " UV",
|
||||
"description": "Specular Cavity texture map UV set.",
|
||||
"type": "Enum",
|
||||
"enumIsUv": true,
|
||||
"defaultValue": "Tiled",
|
||||
"connection": {
|
||||
"type": "ShaderInput",
|
||||
"id": "m_layer3_m_specularOcclusionMapUvIndex"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "specularFactor",
|
||||
"displayName": " Factor",
|
||||
"description": "Strength factor for scaling the values of Specular Cavity",
|
||||
"type": "Float",
|
||||
"defaultValue": 1.0,
|
||||
"min": 0.0,
|
||||
"softMax": 2.0,
|
||||
"connection": {
|
||||
"type": "ShaderInput",
|
||||
"id": "m_layer3_m_specularOcclusionFactor"
|
||||
}
|
||||
}
|
||||
],
|
||||
@@ -2894,12 +3020,21 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Lua",
|
||||
"type": "UseTexture",
|
||||
"args": {
|
||||
"file": "StandardPBR_AoState.lua",
|
||||
"propertyNamePrefix": "layer1_",
|
||||
"srgNamePrefix": "m_layer1_",
|
||||
"optionsNamePrefix": "o_layer1_"
|
||||
"textureProperty": "layer1_occlusion.diffuseTextureMap",
|
||||
"useTextureProperty": "layer1_occlusion.diffuseUseTexture",
|
||||
"dependentProperties": ["layer1_occlusion.diffuseTextureMapUv", "layer1_occlusion.diffuseFactor"],
|
||||
"shaderOption": "o_layer1_o_diffuseOcclusion_useTexture"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "UseTexture",
|
||||
"args": {
|
||||
"textureProperty": "layer1_occlusion.specularTextureMap",
|
||||
"useTextureProperty": "layer1_occlusion.specularUseTexture",
|
||||
"dependentProperties": ["layer1_occlusion.specularTextureMapUv", "layer1_occlusion.specularFactor"],
|
||||
"shaderOption": "o_layer1_o_specularOcclusion_useTexture"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -3022,12 +3157,21 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Lua",
|
||||
"type": "UseTexture",
|
||||
"args": {
|
||||
"file": "StandardPBR_AoState.lua",
|
||||
"propertyNamePrefix": "layer2_",
|
||||
"srgNamePrefix": "m_layer2_",
|
||||
"optionsNamePrefix": "o_layer2_"
|
||||
"textureProperty": "layer2_occlusion.diffuseTextureMap",
|
||||
"useTextureProperty": "layer2_occlusion.diffuseUseTexture",
|
||||
"dependentProperties": ["layer2_occlusion.diffuseTextureMapUv", "layer2_occlusion.diffuseFactor"],
|
||||
"shaderOption": "o_layer2_o_diffuseOcclusion_useTexture"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "UseTexture",
|
||||
"args": {
|
||||
"textureProperty": "layer2_occlusion.specularTextureMap",
|
||||
"useTextureProperty": "layer2_occlusion.specularUseTexture",
|
||||
"dependentProperties": ["layer2_occlusion.specularTextureMapUv", "layer2_occlusion.specularFactor"],
|
||||
"shaderOption": "o_layer2_o_specularOcclusion_useTexture"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -3150,12 +3294,21 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Lua",
|
||||
"type": "UseTexture",
|
||||
"args": {
|
||||
"file": "StandardPBR_AoState.lua",
|
||||
"propertyNamePrefix": "layer3_",
|
||||
"srgNamePrefix": "m_layer3_",
|
||||
"optionsNamePrefix": "o_layer3_"
|
||||
"textureProperty": "layer3_occlusion.diffuseTextureMap",
|
||||
"useTextureProperty": "layer3_occlusion.diffuseUseTexture",
|
||||
"dependentProperties": ["layer3_occlusion.diffuseTextureMapUv", "layer3_occlusion.diffuseFactor"],
|
||||
"shaderOption": "o_layer3_o_diffuseOcclusion_useTexture"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "UseTexture",
|
||||
"args": {
|
||||
"textureProperty": "layer3_occlusion.specularTextureMap",
|
||||
"useTextureProperty": "layer3_occlusion.specularUseTexture",
|
||||
"dependentProperties": ["layer3_occlusion.specularTextureMapUv", "layer3_occlusion.specularFactor"],
|
||||
"shaderOption": "o_layer3_o_specularOcclusion_useTexture"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
+10
-5
@@ -268,10 +268,15 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float
|
||||
|
||||
// ------- Occlusion -------
|
||||
|
||||
float layer1_occlusion = GetOcclusionInput(MaterialSrg::m_layer1_m_ambientOcclusionMap, MaterialSrg::m_sampler, uvLayer1[MaterialSrg::m_layer1_m_ambientOcclusionMapUvIndex], MaterialSrg::m_layer1_m_ambientOcclusionFactor, o_layer1_o_ambientOcclusion_useTexture);
|
||||
float layer2_occlusion = GetOcclusionInput(MaterialSrg::m_layer2_m_ambientOcclusionMap, MaterialSrg::m_sampler, uvLayer2[MaterialSrg::m_layer2_m_ambientOcclusionMapUvIndex], MaterialSrg::m_layer2_m_ambientOcclusionFactor, o_layer2_o_ambientOcclusion_useTexture);
|
||||
float layer3_occlusion = GetOcclusionInput(MaterialSrg::m_layer3_m_ambientOcclusionMap, MaterialSrg::m_sampler, uvLayer3[MaterialSrg::m_layer3_m_ambientOcclusionMapUvIndex], MaterialSrg::m_layer3_m_ambientOcclusionFactor, o_layer3_o_ambientOcclusion_useTexture);
|
||||
float occlusion = BlendLayers(layer1_occlusion, layer2_occlusion, layer3_occlusion, blendMaskValues);
|
||||
float layer1_diffuseAmbientOcclusion = GetOcclusionInput(MaterialSrg::m_layer1_m_diffuseOcclusionMap, MaterialSrg::m_sampler, uvLayer1[MaterialSrg::m_layer1_m_diffuseOcclusionMapUvIndex], MaterialSrg::m_layer1_m_diffuseOcclusionFactor, o_layer1_o_diffuseOcclusion_useTexture);
|
||||
float layer2_diffuseAmbientOcclusion = GetOcclusionInput(MaterialSrg::m_layer2_m_diffuseOcclusionMap, MaterialSrg::m_sampler, uvLayer2[MaterialSrg::m_layer2_m_diffuseOcclusionMapUvIndex], MaterialSrg::m_layer2_m_diffuseOcclusionFactor, o_layer2_o_diffuseOcclusion_useTexture);
|
||||
float layer3_diffuseAmbientOcclusion = GetOcclusionInput(MaterialSrg::m_layer3_m_diffuseOcclusionMap, MaterialSrg::m_sampler, uvLayer3[MaterialSrg::m_layer3_m_diffuseOcclusionMapUvIndex], MaterialSrg::m_layer3_m_diffuseOcclusionFactor, o_layer3_o_diffuseOcclusion_useTexture);
|
||||
float diffuseAmbientOcclusion = BlendLayers(layer1_diffuseAmbientOcclusion, layer2_diffuseAmbientOcclusion, layer3_diffuseAmbientOcclusion, blendMaskValues);
|
||||
|
||||
float layer1_specularOcclusion = GetOcclusionInput(MaterialSrg::m_layer1_m_specularOcclusionMap, MaterialSrg::m_sampler, uvLayer1[MaterialSrg::m_layer1_m_specularOcclusionMapUvIndex], MaterialSrg::m_layer1_m_specularOcclusionFactor, o_layer1_o_specularOcclusion_useTexture);
|
||||
float layer2_specularOcclusion = GetOcclusionInput(MaterialSrg::m_layer2_m_specularOcclusionMap, MaterialSrg::m_sampler, uvLayer2[MaterialSrg::m_layer2_m_specularOcclusionMapUvIndex], MaterialSrg::m_layer2_m_specularOcclusionFactor, o_layer2_o_specularOcclusion_useTexture);
|
||||
float layer3_specularOcclusion = GetOcclusionInput(MaterialSrg::m_layer3_m_specularOcclusionMap, MaterialSrg::m_sampler, uvLayer3[MaterialSrg::m_layer3_m_specularOcclusionMapUvIndex], MaterialSrg::m_layer3_m_specularOcclusionFactor, o_layer3_o_specularOcclusion_useTexture);
|
||||
float specularOcclusion = BlendLayers(layer1_specularOcclusion, layer2_specularOcclusion, layer3_specularOcclusion, blendMaskValues);
|
||||
|
||||
// ------- Subsurface -------
|
||||
|
||||
@@ -350,7 +355,7 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float
|
||||
PbrLightingOutput lightingOutput = PbrLighting(IN,
|
||||
baseColor, metallic, roughness, specularF0Factor,
|
||||
normalWS, tangents[0], bitangents[0], anisotropy,
|
||||
emissive, occlusion, transmissionTintThickness, MaterialSrg::m_transmissionParams, clearCoatFactor, clearCoatRoughness, clearCoatNormal, alpha, o_opacity_mode);
|
||||
emissive, diffuseAmbientOcclusion, specularOcclusion, transmissionTintThickness, MaterialSrg::m_transmissionParams, clearCoatFactor, clearCoatRoughness, clearCoatNormal, alpha, o_opacity_mode);
|
||||
|
||||
// ------- Opacity -------
|
||||
|
||||
|
||||
@@ -44,9 +44,9 @@
|
||||
"description": "Properties for configuring UV transforms."
|
||||
},
|
||||
{
|
||||
"id": "ambientOcclusion",
|
||||
"displayName": "Ambient Occlusion",
|
||||
"description": "Properties for baked AO texture."
|
||||
"id": "occlusion",
|
||||
"displayName": "Occlusion",
|
||||
"description": "Properties for baked textures that represent geometric occlusion of light."
|
||||
},
|
||||
{
|
||||
"id": "emissive",
|
||||
@@ -724,47 +724,89 @@
|
||||
"step": 0.1
|
||||
}
|
||||
],
|
||||
"ambientOcclusion": [
|
||||
"occlusion": [
|
||||
{
|
||||
"id": "enable",
|
||||
"displayName": "Enable",
|
||||
"description": "Whether to enable the ambient occlusion feature.",
|
||||
"type": "Bool",
|
||||
"defaultValue": false
|
||||
},
|
||||
{
|
||||
"id": "textureMap",
|
||||
"displayName": "Texture Map",
|
||||
"description": "Texture map for defining ambient occlusion area.",
|
||||
"id": "diffuseTextureMap",
|
||||
"displayName": "Diffuse AO",
|
||||
"description": "Texture map for defining occlusion area for diffuse ambient lighting.",
|
||||
"type": "Image",
|
||||
"connection": {
|
||||
"type": "ShaderInput",
|
||||
"id": "m_ambientOcclusionMap"
|
||||
"id": "m_diffuseOcclusionMap"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "textureMapUv",
|
||||
"displayName": "UV",
|
||||
"description": "Ambient occlusion texture map UV set",
|
||||
"id": "diffuseUseTexture",
|
||||
"displayName": " Use Texture",
|
||||
"description": "Whether to use the Diffuse AO texture map.",
|
||||
"type": "Bool",
|
||||
"defaultValue": true
|
||||
},
|
||||
{
|
||||
"id": "diffuseTextureMapUv",
|
||||
"displayName": " UV",
|
||||
"description": "Diffuse AO texture map UV set.",
|
||||
"type": "Enum",
|
||||
"enumIsUv": true,
|
||||
"defaultValue": "Tiled",
|
||||
"connection": {
|
||||
"type": "ShaderInput",
|
||||
"id": "m_ambientOcclusionMapUvIndex"
|
||||
"id": "m_diffuseOcclusionMapUvIndex"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "factor",
|
||||
"displayName": "Factor",
|
||||
"description": "Strength factor for scaling the values",
|
||||
"id": "diffuseFactor",
|
||||
"displayName": " Factor",
|
||||
"description": "Strength factor for scaling the values of Diffuse AO",
|
||||
"type": "Float",
|
||||
"defaultValue": 1.0,
|
||||
"min": 0.0,
|
||||
"max": 2.0,
|
||||
"softMax": 2.0,
|
||||
"connection": {
|
||||
"type": "ShaderInput",
|
||||
"id": "m_ambientOcclusionFactor"
|
||||
"id": "m_diffuseOcclusionFactor"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "specularTextureMap",
|
||||
"displayName": "Specular Cavity",
|
||||
"description": "Texture map for defining occlusion area for specular lighting.",
|
||||
"type": "Image",
|
||||
"connection": {
|
||||
"type": "ShaderInput",
|
||||
"id": "m_specularOcclusionMap"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "specularUseTexture",
|
||||
"displayName": " Use Texture",
|
||||
"description": "Whether to use the Specular Cavity texture map.",
|
||||
"type": "Bool",
|
||||
"defaultValue": true
|
||||
},
|
||||
{
|
||||
"id": "specularTextureMapUv",
|
||||
"displayName": " UV",
|
||||
"description": "Specular Cavity texture map UV set.",
|
||||
"type": "Enum",
|
||||
"enumIsUv": true,
|
||||
"defaultValue": "Tiled",
|
||||
"connection": {
|
||||
"type": "ShaderInput",
|
||||
"id": "m_specularOcclusionMapUvIndex"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "specularFactor",
|
||||
"displayName": " Factor",
|
||||
"description": "Strength factor for scaling the values of Specular Cavity",
|
||||
"type": "Float",
|
||||
"defaultValue": 1.0,
|
||||
"min": 0.0,
|
||||
"softMax": 2.0,
|
||||
"connection": {
|
||||
"type": "ShaderInput",
|
||||
"id": "m_specularOcclusionFactor"
|
||||
}
|
||||
}
|
||||
],
|
||||
@@ -1270,9 +1312,21 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Lua",
|
||||
"type": "UseTexture",
|
||||
"args": {
|
||||
"file": "StandardPBR_AoState.lua"
|
||||
"textureProperty": "occlusion.diffuseTextureMap",
|
||||
"useTextureProperty": "occlusion.diffuseUseTexture",
|
||||
"dependentProperties": ["occlusion.diffuseTextureMapUv", "occlusion.diffuseFactor"],
|
||||
"shaderOption": "o_diffuseOcclusion_useTexture"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "UseTexture",
|
||||
"args": {
|
||||
"textureProperty": "occlusion.specularTextureMap",
|
||||
"useTextureProperty": "occlusion.specularUseTexture",
|
||||
"dependentProperties": ["occlusion.specularTextureMapUv", "occlusion.specularFactor"],
|
||||
"shaderOption": "o_specularOcclusion_useTexture"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
--------------------------------------------------------------------------------------
|
||||
--
|
||||
-- All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
-- its licensors.
|
||||
--
|
||||
-- For complete copyright and license terms please see the LICENSE at the root of this
|
||||
-- distribution (the "License"). All use of this software is governed by the License,
|
||||
-- or, if provided, by the license below or the license accompanying this file. Do not
|
||||
-- remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
--
|
||||
--
|
||||
----------------------------------------------------------------------------------------------------
|
||||
|
||||
function GetMaterialPropertyDependencies()
|
||||
return {"ambientOcclusion.enable", "ambientOcclusion.textureMap"}
|
||||
end
|
||||
|
||||
function GetShaderOptionDependencies()
|
||||
return {"o_ambientOcclusion_useTexture"}
|
||||
end
|
||||
|
||||
function Process(context)
|
||||
local enableAo = context:GetMaterialPropertyValue_bool("ambientOcclusion.enable")
|
||||
local textureMap = context:GetMaterialPropertyValue_image("ambientOcclusion.textureMap")
|
||||
|
||||
context:SetShaderOptionValue_bool("o_ambientOcclusion_useTexture", enableAo and textureMap ~= nil)
|
||||
end
|
||||
|
||||
function ProcessEditor(context)
|
||||
local enableAo = context:GetMaterialPropertyValue_bool("ambientOcclusion.enable")
|
||||
|
||||
if(not enableAo) then
|
||||
context:SetMaterialPropertyVisibility("ambientOcclusion.factor", MaterialPropertyVisibility_Hidden)
|
||||
context:SetMaterialPropertyVisibility("ambientOcclusion.textureMap", MaterialPropertyVisibility_Hidden)
|
||||
context:SetMaterialPropertyVisibility("ambientOcclusion.textureMapUv", MaterialPropertyVisibility_Hidden)
|
||||
else
|
||||
context:SetMaterialPropertyVisibility("ambientOcclusion.textureMap", MaterialPropertyVisibility_Enabled)
|
||||
local textureMap = context:GetMaterialPropertyValue_image("ambientOcclusion.textureMap")
|
||||
if(textureMap == nil) then
|
||||
context:SetMaterialPropertyVisibility("ambientOcclusion.factor", MaterialPropertyVisibility_Hidden)
|
||||
context:SetMaterialPropertyVisibility("ambientOcclusion.textureMapUv", MaterialPropertyVisibility_Hidden)
|
||||
else
|
||||
context:SetMaterialPropertyVisibility("ambientOcclusion.factor", MaterialPropertyVisibility_Enabled)
|
||||
context:SetMaterialPropertyVisibility("ambientOcclusion.textureMapUv", MaterialPropertyVisibility_Enabled)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -212,9 +212,9 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float
|
||||
lightingData.emissiveLighting = GetEmissiveInput(MaterialSrg::m_emissiveMap, MaterialSrg::m_sampler, emissiveUv, MaterialSrg::m_emissiveIntensity, MaterialSrg::m_emissiveColor.rgb, o_emissiveEnabled, o_emissive_useTexture);
|
||||
|
||||
// ------- Occlusion -------
|
||||
|
||||
float2 occlusionUv = IN.m_uv[MaterialSrg::m_ambientOcclusionMapUvIndex];
|
||||
lightingData.occlusion = GetOcclusionInput(MaterialSrg::m_ambientOcclusionMap, MaterialSrg::m_sampler, occlusionUv, MaterialSrg::m_ambientOcclusionFactor, o_ambientOcclusion_useTexture);
|
||||
|
||||
lightingData.diffuseAmbientOcclusion = GetOcclusionInput(MaterialSrg::m_diffuseOcclusionMap, MaterialSrg::m_sampler, IN.m_uv[MaterialSrg::m_diffuseOcclusionMapUvIndex], MaterialSrg::m_diffuseOcclusionFactor, o_diffuseOcclusion_useTexture);
|
||||
lightingData.specularOcclusion = GetOcclusionInput(MaterialSrg::m_specularOcclusionMap, MaterialSrg::m_sampler, IN.m_uv[MaterialSrg::m_specularOcclusionMapUvIndex], MaterialSrg::m_specularOcclusionFactor, o_specularOcclusion_useTexture);
|
||||
|
||||
// ------- Clearcoat -------
|
||||
|
||||
|
||||
@@ -180,6 +180,13 @@
|
||||
"Attachment": "SpecularF0Output"
|
||||
}
|
||||
},
|
||||
{
|
||||
"LocalSlot": "AlbedoInput",
|
||||
"AttachmentRef": {
|
||||
"Pass": "ForwardMSAAPass",
|
||||
"Attachment": "AlbedoOutput"
|
||||
}
|
||||
},
|
||||
{
|
||||
"LocalSlot": "ClearCoatNormalInput",
|
||||
"AttachmentRef": {
|
||||
|
||||
@@ -27,6 +27,12 @@
|
||||
"SlotType": "Input",
|
||||
"ScopeAttachmentUsage": "Shader"
|
||||
},
|
||||
{
|
||||
// This is needed for the alpha channel which has specularOcclusion factor
|
||||
"Name": "AlbedoInput",
|
||||
"SlotType": "Input",
|
||||
"ScopeAttachmentUsage": "Shader"
|
||||
},
|
||||
{
|
||||
"Name": "ClearCoatNormalInput",
|
||||
"SlotType": "Input",
|
||||
|
||||
@@ -17,6 +17,11 @@
|
||||
"SlotType": "Input",
|
||||
"ScopeAttachmentUsage": "Shader"
|
||||
},
|
||||
{
|
||||
"Name": "AlbedoInput",
|
||||
"SlotType": "Input",
|
||||
"ScopeAttachmentUsage": "Shader"
|
||||
},
|
||||
{
|
||||
"Name": "ClearCoatNormalInput",
|
||||
"SlotType": "Input",
|
||||
@@ -127,6 +132,13 @@
|
||||
"Attachment": "SpecularF0Input"
|
||||
}
|
||||
},
|
||||
{
|
||||
"LocalSlot": "AlbedoInput",
|
||||
"AttachmentRef": {
|
||||
"Pass": "Parent",
|
||||
"Attachment": "AlbedoInput"
|
||||
}
|
||||
},
|
||||
{
|
||||
"LocalSlot": "ClearCoatNormalInput",
|
||||
"AttachmentRef": {
|
||||
|
||||
@@ -12,19 +12,19 @@
|
||||
|
||||
struct ForwardPassOutput
|
||||
{
|
||||
// m_diffuseColor.a should be encoded with subsurface scattering's strength factor and quality factor if enabled
|
||||
float4 m_diffuseColor : SV_Target0;
|
||||
float4 m_specularColor : SV_Target1;
|
||||
float4 m_albedo : SV_Target2;
|
||||
float4 m_specularF0 : SV_Target3;
|
||||
float4 m_normal : SV_Target4;
|
||||
float4 m_clearCoatNormal : SV_Target5;
|
||||
float4 m_diffuseColor : SV_Target0; //!< RGB = Diffuse Lighting, A = Blend Alpha (for blended surfaces) OR A = special encoding of surfaceScatteringFactor, m_subsurfaceScatteringQuality, o_enableSubsurfaceScattering
|
||||
float4 m_specularColor : SV_Target1; //!< RGB = Specular Lighting, A = Unused
|
||||
float4 m_albedo : SV_Target2; //!< RGB = Surface albedo pre-multiplied by other factors that will be multiplied later by diffuse GI, A = specularOcclusion
|
||||
float4 m_specularF0 : SV_Target3; //!< RGB = Specular F0, A = roughness
|
||||
float4 m_normal : SV_Target4; //!< RGB10 = EncodeNormalSignedOctahedron(worldNormal), A2 = multiScatterCompensationEnabled
|
||||
float4 m_clearCoatNormal : SV_Target5; //!< RG = EncodeNormalSphereMap(clearCoatNormal), B = clearCoatFactor, A = clearCoatRoughness
|
||||
float3 m_scatterDistance : SV_Target6;
|
||||
};
|
||||
|
||||
struct ForwardPassOutputWithDepth
|
||||
{
|
||||
// m_diffuseColor.a should be encoded with subsurface scattering's strength factor and quality factor if enabled
|
||||
// See above for descriptions of special encodings
|
||||
|
||||
float4 m_diffuseColor : SV_Target0;
|
||||
float4 m_specularColor : SV_Target1;
|
||||
float4 m_albedo : SV_Target2;
|
||||
|
||||
+6
-2
@@ -47,8 +47,10 @@ class LightingData
|
||||
// Normal . View
|
||||
float NdotV;
|
||||
|
||||
// Occlusion factors
|
||||
// 0 = dark, 1 = light
|
||||
float occlusion;
|
||||
float diffuseAmbientOcclusion;
|
||||
float specularOcclusion;
|
||||
|
||||
void Init(float3 positionWS, float3 normal, float roughnessLinear);
|
||||
void CalculateMultiscatterCompensation(float3 specularF0, bool enabled);
|
||||
@@ -62,7 +64,8 @@ void LightingData::Init(float3 positionWS, float3 normal, float roughnessLinear)
|
||||
translucentBackLighting = 0;
|
||||
multiScatterCompensation = 1.0f;
|
||||
emissiveLighting = float3(0.0f, 0.0f, 0.0f);
|
||||
occlusion = 1.0f;
|
||||
diffuseAmbientOcclusion = 1.0f;
|
||||
specularOcclusion = 1.0f;
|
||||
|
||||
dirToCamera = normalize(ViewSrg::m_worldPosition.xyz - positionWS);
|
||||
|
||||
@@ -79,6 +82,7 @@ void LightingData::CalculateMultiscatterCompensation(float3 specularF0, bool ena
|
||||
|
||||
void LightingData::FinalizeLighting(float3 transmissionTint)
|
||||
{
|
||||
specularLighting *= specularOcclusion;
|
||||
specularLighting += emissiveLighting;
|
||||
|
||||
// Transmitted light
|
||||
|
||||
+2
-5
@@ -45,8 +45,8 @@ PbrLightingOutput GetPbrLightingOutput(Surface surface, LightingData lightingDat
|
||||
|
||||
// albedo, specularF0, roughness, and normals for later passes (specular IBL, Diffuse GI, SSR, AO, etc)
|
||||
lightingOutput.m_specularF0 = float4(surface.specularF0, surface.roughnessLinear);
|
||||
lightingOutput.m_albedo.rgb = surface.albedo * lightingData.diffuseResponse;
|
||||
lightingOutput.m_albedo.a = lightingData.occlusion;
|
||||
lightingOutput.m_albedo.rgb = surface.albedo * lightingData.diffuseResponse * lightingData.diffuseAmbientOcclusion;
|
||||
lightingOutput.m_albedo.a = lightingData.specularOcclusion;
|
||||
lightingOutput.m_normal.rgb = EncodeNormalSignedOctahedron(surface.normal);
|
||||
lightingOutput.m_normal.a = o_specularF0_enableMultiScatterCompensation ? 1.0f : 0.0f;
|
||||
|
||||
@@ -58,6 +58,3 @@ PbrLightingOutput GetPbrLightingOutput(Surface surface, LightingData lightingDat
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -66,7 +66,8 @@ PbrLightingOutput PbrLighting( VSOutput IN,
|
||||
float3 vtxBitangent,
|
||||
float2 anisotropy, // angle and factor
|
||||
float3 emissive,
|
||||
float occlusion,
|
||||
float diffuseAmbientOcclusion,
|
||||
float specularOcclusion,
|
||||
float4 transmissionTintThickness,
|
||||
float4 transmissionParams,
|
||||
float clearCoatFactor,
|
||||
@@ -108,7 +109,8 @@ PbrLightingOutput PbrLighting( VSOutput IN,
|
||||
lightingData.Init(surface.position, surface.normal, surface.roughnessLinear);
|
||||
|
||||
lightingData.emissiveLighting = emissive;
|
||||
lightingData.occlusion = occlusion;
|
||||
lightingData.diffuseAmbientOcclusion = diffuseAmbientOcclusion;
|
||||
lightingData.specularOcclusion = specularOcclusion;
|
||||
|
||||
// Directional light shadow coordinates
|
||||
lightingData.shadowCoords = shadowCoords;
|
||||
@@ -191,7 +193,7 @@ PbrLightingOutput MakeDebugOutput(VSOutput IN, float3 debugColor, float3 normalW
|
||||
|
||||
PbrLightingOutput lightingOutput = PbrLighting(IN, baseColor, metallic, roughness, specularF0Factor,
|
||||
normal, IN.m_tangent, IN.m_bitangent, anisotropy,
|
||||
emissive, occlusion, transmissionTintThickness, transmissionParams, clearCoatFactor, clearCoatRoughness, clearCoatNormal, alpha, OpacityMode::Opaque);
|
||||
emissive, occlusion, occlusion, transmissionTintThickness, transmissionParams, clearCoatFactor, clearCoatRoughness, clearCoatNormal, alpha, OpacityMode::Opaque);
|
||||
|
||||
return lightingOutput;
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ void ApplyIBL(Surface surface, inout LightingData lightingData)
|
||||
|
||||
// Adjust IBL lighting by exposure.
|
||||
float iblExposureFactor = pow(2.0, SceneSrg::m_iblExposure);
|
||||
lightingData.diffuseLighting += (iblDiffuse * iblExposureFactor * lightingData.occlusion);
|
||||
lightingData.diffuseLighting += (iblDiffuse * iblExposureFactor * lightingData.diffuseAmbientOcclusion);
|
||||
lightingData.specularLighting += (iblSpecular * iblExposureFactor);
|
||||
}
|
||||
}
|
||||
|
||||
+4
-8
@@ -24,7 +24,7 @@ ShaderResourceGroup PassSrg : SRG_PerPass
|
||||
Texture2DMS<float4> m_downsampledProbeIrradiance;
|
||||
Texture2DMS<float> m_downsampledDepth;
|
||||
Texture2DMS<float4> m_downsampledNormal;
|
||||
Texture2DMS<float4> m_albedo; // RGB8 = Albedo, A = Occlusion
|
||||
Texture2DMS<float4> m_albedo; // RGB8 = Albedo with pre-multiplied factors, A = Unused here
|
||||
Texture2DMS<float4> m_normal; // RGB10 = Normal (Encoded), A2 = Flags
|
||||
Texture2DMS<float> m_depth;
|
||||
|
||||
@@ -118,7 +118,7 @@ float3 SampleProbeIrradiance(uint sampleIndex, uint2 probeIrradianceCoords, floa
|
||||
}
|
||||
|
||||
// retrieve irradiance from the global IBL diffuse cubemap
|
||||
float3 SampleGlobalIBL(uint sampleIndex, uint2 screenCoords, float depth, float3 normal, float3 albedo)
|
||||
float3 SampleGlobalIBL(uint sampleIndex, uint2 screenCoords, float depth, float3 normal)
|
||||
{
|
||||
uint2 dimensions;
|
||||
uint samples;
|
||||
@@ -160,23 +160,19 @@ PSOutput MainPS(VSOutput IN, in uint sampleIndex : SV_SampleIndex)
|
||||
float4 encodedNormal = PassSrg::m_normal.Load(screenCoords, sampleIndex);
|
||||
float3 normal = DecodeNormalSignedOctahedron(encodedNormal.rgb);
|
||||
float4 albedo = PassSrg::m_albedo.Load(screenCoords, sampleIndex);
|
||||
float occlusion = albedo.a;
|
||||
float useProbeIrradiance = PassSrg::m_downsampledProbeIrradiance.Load(probeIrradianceCoords, sampleIndex).a;
|
||||
|
||||
float3 diffuse = float3(0.0f, 0.0f, 0.0f);
|
||||
if (useProbeIrradiance > 0.0f)
|
||||
{
|
||||
float3 irradiance = SampleProbeIrradiance(sampleIndex, probeIrradianceCoords, depth, normal, albedo, ImageScale);
|
||||
diffuse = (albedo.rgb / PI) * irradiance * occlusion;
|
||||
diffuse = (albedo.rgb / PI) * irradiance;
|
||||
}
|
||||
else
|
||||
{
|
||||
float3 irradiance = SampleGlobalIBL(sampleIndex, screenCoords, depth, normal, albedo);
|
||||
float3 irradiance = SampleGlobalIBL(sampleIndex, screenCoords, depth, normal);
|
||||
diffuse = albedo * irradiance;
|
||||
|
||||
// apply ambient occlusion to indirect diffuse
|
||||
diffuse *= occlusion;
|
||||
|
||||
// adjust IBL lighting by exposure.
|
||||
float iblExposureFactor = pow(2.0, SceneSrg::m_iblExposure);
|
||||
diffuse *= iblExposureFactor;
|
||||
|
||||
+4
-8
@@ -27,7 +27,7 @@ ShaderResourceGroup PassSrg : SRG_PerPass
|
||||
Texture2D<float4> m_downsampledProbeIrradiance;
|
||||
Texture2D<float> m_downsampledDepth;
|
||||
Texture2D<float4> m_downsampledNormal;
|
||||
Texture2D<float4> m_albedo; // RGB8 = Albedo, A = Occlusion
|
||||
Texture2D<float4> m_albedo; // RGB8 = Albedo with pre-multiplied factors, A = Unused here
|
||||
Texture2D<float4> m_normal; // RGB10 = Normal (Encoded), A2 = Flags
|
||||
Texture2D<float> m_depth;
|
||||
|
||||
@@ -121,7 +121,7 @@ float3 SampleProbeIrradiance(uint2 probeIrradianceCoords, float depth, float3 no
|
||||
}
|
||||
|
||||
// retrieve irradiance from the global IBL diffuse cubemap
|
||||
float3 SampleGlobalIBL(uint2 screenCoords, float depth, float3 normal, float3 albedo)
|
||||
float3 SampleGlobalIBL(uint2 screenCoords, float depth, float3 normal)
|
||||
{
|
||||
uint2 dimensions;
|
||||
PassSrg::m_depth.GetDimensions(dimensions.x, dimensions.y);
|
||||
@@ -162,23 +162,19 @@ PSOutput MainPS(VSOutput IN)
|
||||
float4 encodedNormal = PassSrg::m_normal.Load(int3(screenCoords, 0));
|
||||
float3 normal = DecodeNormalSignedOctahedron(encodedNormal.rgb);
|
||||
float4 albedo = PassSrg::m_albedo.Load(int3(screenCoords, 0));
|
||||
float occlusion = albedo.a;
|
||||
float useProbeIrradiance = PassSrg::m_downsampledProbeIrradiance.Load(int3(probeIrradianceCoords,0)).a;
|
||||
|
||||
float3 diffuse = float3(0.0f, 0.0f, 0.0f);
|
||||
if (useProbeIrradiance > 0.0f)
|
||||
{
|
||||
float3 irradiance = SampleProbeIrradiance(probeIrradianceCoords, depth, normal, albedo, ImageScale);
|
||||
diffuse = (albedo.rgb / PI) * irradiance * occlusion;
|
||||
diffuse = (albedo.rgb / PI) * irradiance;
|
||||
}
|
||||
else
|
||||
{
|
||||
float3 irradiance = SampleGlobalIBL(screenCoords, depth, normal, albedo);
|
||||
float3 irradiance = SampleGlobalIBL(screenCoords, depth, normal);
|
||||
diffuse = albedo * irradiance;
|
||||
|
||||
// apply ambient occlusion to indirect diffuse
|
||||
diffuse *= occlusion;
|
||||
|
||||
// adjust IBL lighting by exposure.
|
||||
float iblExposureFactor = pow(2.0, SceneSrg::m_iblExposure);
|
||||
diffuse *= iblExposureFactor;
|
||||
|
||||
+3
-7
@@ -21,7 +21,7 @@
|
||||
|
||||
ShaderResourceGroup PassSrg : SRG_PerPass
|
||||
{
|
||||
Texture2DMS<float4> m_albedo; // RGB8 = Albedo, A = Occlusion
|
||||
Texture2DMS<float4> m_albedo; // RGB8 = Albedo with pre-multiplied factors, A = Unused here
|
||||
Texture2DMS<float4> m_normal; // RGB10 = Normal (Encoded), A2 = Flags
|
||||
Texture2DMS<float> m_depth;
|
||||
}
|
||||
@@ -41,7 +41,7 @@ VSOutput MainVS(VSInput input)
|
||||
}
|
||||
|
||||
// retrieve irradiance from the global IBL diffuse cubemap
|
||||
float3 SampleGlobalIBL(uint sampleIndex, uint2 screenCoords, float depth, float3 normal, float3 albedo)
|
||||
float3 SampleGlobalIBL(uint sampleIndex, uint2 screenCoords, float depth, float3 normal)
|
||||
{
|
||||
uint2 dimensions;
|
||||
uint samples;
|
||||
@@ -76,14 +76,10 @@ PSOutput MainPS(VSOutput IN, in uint sampleIndex : SV_SampleIndex)
|
||||
float4 encodedNormal = PassSrg::m_normal.Load(screenCoords, sampleIndex);
|
||||
float3 normal = DecodeNormalSignedOctahedron(encodedNormal.rgb);
|
||||
float4 albedo = PassSrg::m_albedo.Load(screenCoords, sampleIndex);
|
||||
float occlusion = albedo.a;
|
||||
|
||||
float3 irradiance = SampleGlobalIBL(sampleIndex, screenCoords, depth, normal, albedo);
|
||||
float3 irradiance = SampleGlobalIBL(sampleIndex, screenCoords, depth, normal);
|
||||
float3 diffuse = albedo * irradiance;
|
||||
|
||||
// apply ambient occlusion to indirect diffuse
|
||||
diffuse *= occlusion;
|
||||
|
||||
// adjust IBL lighting by exposure.
|
||||
float iblExposureFactor = pow(2.0, SceneSrg::m_iblExposure);
|
||||
diffuse *= iblExposureFactor;
|
||||
|
||||
+3
-7
@@ -24,7 +24,7 @@
|
||||
|
||||
ShaderResourceGroup PassSrg : SRG_PerPass
|
||||
{
|
||||
Texture2D<float4> m_albedo; // RGB8 = Albedo, A = Occlusion
|
||||
Texture2D<float4> m_albedo; // RGB8 = Albedo with pre-multiplied factors, A = Unused here
|
||||
Texture2D<float4> m_normal; // RGB10 = Normal (Encoded), A2 = Flags
|
||||
Texture2D<float> m_depth;
|
||||
}
|
||||
@@ -44,7 +44,7 @@ VSOutput MainVS(VSInput input)
|
||||
}
|
||||
|
||||
// retrieve irradiance from the global IBL diffuse cubemap
|
||||
float3 SampleGlobalIBL(uint sampleIndex, uint2 screenCoords, float depth, float3 normal, float3 albedo)
|
||||
float3 SampleGlobalIBL(uint sampleIndex, uint2 screenCoords, float depth, float3 normal)
|
||||
{
|
||||
uint2 dimensions;
|
||||
PassSrg::m_depth.GetDimensions(dimensions.x, dimensions.y);
|
||||
@@ -78,14 +78,10 @@ PSOutput MainPS(VSOutput IN, in uint sampleIndex : SV_SampleIndex)
|
||||
float4 encodedNormal = PassSrg::m_normal.Load(int3(screenCoords, 0));
|
||||
float3 normal = DecodeNormalSignedOctahedron(encodedNormal.rgb);
|
||||
float4 albedo = PassSrg::m_albedo.Load(int3(screenCoords, 0));
|
||||
float occlusion = albedo.a;
|
||||
|
||||
float3 irradiance = SampleGlobalIBL(sampleIndex, screenCoords, depth, normal, albedo);
|
||||
float3 irradiance = SampleGlobalIBL(sampleIndex, screenCoords, depth, normal);
|
||||
float3 diffuse = albedo * irradiance;
|
||||
|
||||
// apply ambient occlusion to indirect diffuse
|
||||
diffuse *= occlusion;
|
||||
|
||||
// adjust IBL lighting by exposure.
|
||||
float iblExposureFactor = pow(2.0, SceneSrg::m_iblExposure);
|
||||
diffuse *= iblExposureFactor;
|
||||
|
||||
@@ -43,8 +43,9 @@
|
||||
ShaderResourceGroup PassSrg : SRG_PerPass
|
||||
{
|
||||
Texture2DMS<float> m_depth;
|
||||
Texture2DMS<float4> m_normal; // RGB10 = Normal (Encoded), A2 = Flags
|
||||
Texture2DMS<float4> m_normal; // RGB10 = EncodeNormalSignedOctahedron(worldNormal), A2 = multiScatterCompensationEnabled
|
||||
Texture2DMS<float4> m_specularF0; // RGB8 = SpecularF0, A8 = Roughness
|
||||
Texture2DMS<float4> m_albedo; // RGB = Not used here, A = specularOcclusion
|
||||
Texture2DMS<float4> m_clearCoatNormal; // R16G16 = Normal (Packed), B16A16 = (factor, perceptual roughness)
|
||||
Texture2DMS<float> m_blendWeight;
|
||||
Texture2D<float2> m_brdfMap;
|
||||
@@ -80,6 +81,9 @@ PSOutput MainPS(VSOutput IN, in uint sampleIndex : SV_SampleIndex)
|
||||
float4 encodedNormal = PassSrg::m_normal.Load(IN.m_position.xy, sampleIndex);
|
||||
float3 normal = DecodeNormalSignedOctahedron(encodedNormal.rgb);
|
||||
bool multiScatterCompensationEnabled = (encodedNormal.a > 0.0f);
|
||||
|
||||
float4 albedo = PassSrg::m_albedo.Load(IN.m_position.xy, sampleIndex);
|
||||
float specularOcclusion = albedo.a;
|
||||
|
||||
// reconstruct world space position from the depth at this location in screenspace
|
||||
float3 positionWS = ReconstructWorldPositionFromDepth(IN.m_position.xy, sampleIndex).xyz;
|
||||
@@ -136,6 +140,9 @@ PSOutput MainPS(VSOutput IN, in uint sampleIndex : SV_SampleIndex)
|
||||
// apply exposure setting
|
||||
specular *= pow(2.0, SceneSrg::m_iblExposure);
|
||||
|
||||
// maybe attenuate the specular
|
||||
specular *= specularOcclusion;
|
||||
|
||||
PSOutput OUT;
|
||||
OUT.m_color = float4(specular, 1.0f);
|
||||
return OUT;
|
||||
|
||||
@@ -41,7 +41,6 @@ set(FILES
|
||||
Materials/Types/StandardMultilayerPBR_Shadowmap_WithPS.azsl
|
||||
Materials/Types/StandardMultilayerPBR_Shadowmap_WithPS.shader
|
||||
Materials/Types/StandardPBR.materialtype
|
||||
Materials/Types/StandardPBR_AoState.lua
|
||||
Materials/Types/StandardPBR_ClearCoatEnableFeature.lua
|
||||
Materials/Types/StandardPBR_ClearCoatState.lua
|
||||
Materials/Types/StandardPBR_Common.azsli
|
||||
|
||||
@@ -145,8 +145,10 @@ namespace AZ
|
||||
const MaterialAssignmentMap& GetMaterialAssignmentMap(const MeshHandle& meshHandle) const override;
|
||||
void ConnectModelChangeEventHandler(const MeshHandle& meshHandle, ModelChangedEvent::Handler& handler) override;
|
||||
|
||||
void SetTransform(const MeshHandle& meshHandle, const AZ::Transform& transform) override;
|
||||
void SetTransform(const MeshHandle& meshHandle, const AZ::Transform& transform,
|
||||
const AZ::Vector3& nonUniformScale = AZ::Vector3::CreateOne()) override;
|
||||
Transform GetTransform(const MeshHandle& meshHandle) override;
|
||||
Vector3 GetNonUniformScale(const MeshHandle& meshHandle) override;
|
||||
|
||||
void SetSortKey(const MeshHandle& meshHandle, RHI::DrawItemSortKey sortKey) override;
|
||||
RHI::DrawItemSortKey GetSortKey(const MeshHandle& meshHandle) override;
|
||||
|
||||
+4
-1
@@ -62,9 +62,12 @@ namespace AZ
|
||||
//! Connects a handler to any changes to an RPI::Model. Changes include loading and reloading.
|
||||
virtual void ConnectModelChangeEventHandler(const MeshHandle& meshHandle, ModelChangedEvent::Handler& handler) = 0;
|
||||
//! Sets the transform for a given mesh handle.
|
||||
virtual void SetTransform(const MeshHandle& meshHandle, const AZ::Transform& transform) = 0;
|
||||
virtual void SetTransform(const MeshHandle& meshHandle, const Transform& transform,
|
||||
const Vector3& nonUniformScale = Vector3::CreateOne()) = 0;
|
||||
//! Gets the transform for a given mesh handle.
|
||||
virtual Transform GetTransform(const MeshHandle& meshHandle) = 0;
|
||||
//! Gets the non-uniform scale for a given mesh handle.
|
||||
virtual Vector3 GetNonUniformScale(const MeshHandle& meshHandle) = 0;
|
||||
//! Sets the sort key for a given mesh handle.
|
||||
virtual void SetSortKey(const MeshHandle& meshHandle, RHI::DrawItemSortKey sortKey) = 0;
|
||||
//! Gets the sort key for a given mesh handle.
|
||||
|
||||
+3
-1
@@ -50,8 +50,10 @@ namespace AZ
|
||||
// TransformServiceFeatureProcessorInterface overrides ...
|
||||
ObjectId ReserveObjectId() override;
|
||||
void ReleaseObjectId(ObjectId& id) override;
|
||||
void SetTransformForId(ObjectId id, const AZ::Transform& transform) override;
|
||||
void SetTransformForId(ObjectId id, const AZ::Transform& transform,
|
||||
const AZ::Vector3& nonUniformScale = AZ::Vector3::CreateOne()) override;
|
||||
AZ::Transform GetTransformForId(ObjectId id) const override;
|
||||
AZ::Vector3 GetNonUniformScaleForId(ObjectId id) const override;
|
||||
|
||||
private:
|
||||
|
||||
|
||||
+6
-3
@@ -13,6 +13,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/Math/Transform.h>
|
||||
#include <AzCore/Math/Vector3.h>
|
||||
#include <Atom/RPI.Public/FeatureProcessor.h>
|
||||
|
||||
namespace AZ
|
||||
@@ -34,11 +35,13 @@ namespace AZ
|
||||
//! Releases an object ID to be used by others. The passed in handle is invalidated.
|
||||
virtual void ReleaseObjectId(ObjectId& id) = 0;
|
||||
|
||||
//! Sets the transform for a given id. Id must be one reserved earlier.
|
||||
virtual void SetTransformForId(ObjectId id, const AZ::Transform& transform) = 0;
|
||||
//! Sets the transform (and optionally non-uniform scale) for a given id. Id must be one reserved earlier.
|
||||
virtual void SetTransformForId(ObjectId id, const AZ::Transform& transform,
|
||||
const AZ::Vector3& nonUniformScale = AZ::Vector3::CreateOne()) = 0;
|
||||
//! Gets the transform for a given id. Id must be one reserved earlier.
|
||||
virtual AZ::Transform GetTransformForId(ObjectId) const = 0;
|
||||
|
||||
//! Gets the non-uniform scale for a given id. Id must be one reserved earlier.
|
||||
virtual AZ::Vector3 GetNonUniformScaleForId(ObjectId id) const = 0;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,11 +31,12 @@ namespace UnitTest
|
||||
MOCK_CONST_METHOD1(GetModel, AZStd::intrusive_ptr<AZ::RPI::Model>(const MeshHandle&));
|
||||
MOCK_CONST_METHOD1(GetMaterialAssignmentMap, const AZ::Render::MaterialAssignmentMap&(const MeshHandle&));
|
||||
MOCK_METHOD2(ConnectModelChangeEventHandler, void(const MeshHandle&, ModelChangedEvent::Handler&));
|
||||
MOCK_METHOD2(SetTransform, void(const MeshHandle&, const AZ::Transform&));
|
||||
MOCK_METHOD3(SetTransform, void(const MeshHandle&, const AZ::Transform&, const AZ::Vector3&));
|
||||
MOCK_METHOD2(SetExcludeFromReflectionCubeMaps, void(const MeshHandle&, bool));
|
||||
MOCK_METHOD2(SetMaterialAssignmentMap, void(const MeshHandle&, const AZ::Data::Instance<AZ::RPI::Material>&));
|
||||
MOCK_METHOD2(SetMaterialAssignmentMap, void(const MeshHandle&, const AZ::Render::MaterialAssignmentMap&));
|
||||
MOCK_METHOD1(GetTransform, AZ::Transform (const MeshHandle&));
|
||||
MOCK_METHOD1(GetTransform, AZ::Transform(const MeshHandle&));
|
||||
MOCK_METHOD1(GetNonUniformScale, AZ::Vector3(const MeshHandle&));
|
||||
MOCK_METHOD2(SetSortKey, void (const MeshHandle&, AZ::RHI::DrawItemSortKey));
|
||||
MOCK_METHOD1(GetSortKey, AZ::RHI::DrawItemSortKey(const MeshHandle&));
|
||||
MOCK_METHOD2(SetLodOverride, void(const MeshHandle&, AZ::RPI::Cullable::LodOverride));
|
||||
|
||||
@@ -504,7 +504,7 @@ namespace AZ
|
||||
box.m_faceCullMode = ConvertRPIFaceCullFlag(faceCull);
|
||||
box.m_color = color;
|
||||
box.m_scale = localMatrix3x4.ExtractScale() * extents;
|
||||
box.m_position = localMatrix3x4.GetTranslation() + center;
|
||||
box.m_position = matrix3x4 * center;
|
||||
box.m_rotationMatrix = Matrix3x3::CreateFromMatrix3x4(localMatrix3x4);
|
||||
box.m_pointSize = m_pointSize;
|
||||
box.m_viewProjOverrideIndex = viewProjOverrideIndex;
|
||||
|
||||
@@ -1238,6 +1238,8 @@ namespace AZ
|
||||
|
||||
void DirectionalLightFeatureProcessor::SetFilterParameterToPass(LightHandle handle, const RPI::View* cameraView)
|
||||
{
|
||||
AZ_ATOM_PROFILE_FUNCTION("DirectionalLightFeatureProcessor", "DirectionalLightFeatureProcessor::SetFilterParameterToPass");
|
||||
|
||||
if (handle != m_shadowingLightHandle)
|
||||
{
|
||||
return;
|
||||
|
||||
@@ -256,7 +256,7 @@ namespace AZ
|
||||
}
|
||||
}
|
||||
|
||||
void MeshFeatureProcessor::SetTransform(const MeshHandle& meshHandle, const AZ::Transform& transform)
|
||||
void MeshFeatureProcessor::SetTransform(const MeshHandle& meshHandle, const AZ::Transform& transform, const AZ::Vector3& nonUniformScale)
|
||||
{
|
||||
if (meshHandle.IsValid())
|
||||
{
|
||||
@@ -264,12 +264,12 @@ namespace AZ
|
||||
meshData.m_cullBoundsNeedsUpdate = true;
|
||||
meshData.m_objectSrgNeedsUpdate = true;
|
||||
|
||||
m_transformService->SetTransformForId(meshHandle->m_objectId, transform);
|
||||
m_transformService->SetTransformForId(meshHandle->m_objectId, transform, nonUniformScale);
|
||||
|
||||
// ray tracing data needs to be updated with the new transform
|
||||
if (m_rayTracingFeatureProcessor)
|
||||
{
|
||||
m_rayTracingFeatureProcessor->SetMeshTransform(meshHandle->m_objectId, transform);
|
||||
m_rayTracingFeatureProcessor->SetMeshTransform(meshHandle->m_objectId, transform, nonUniformScale);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -287,6 +287,19 @@ namespace AZ
|
||||
}
|
||||
}
|
||||
|
||||
Vector3 MeshFeatureProcessor::GetNonUniformScale(const MeshHandle& meshHandle)
|
||||
{
|
||||
if (meshHandle.IsValid())
|
||||
{
|
||||
return m_transformService->GetNonUniformScaleForId(meshHandle->m_objectId);
|
||||
}
|
||||
else
|
||||
{
|
||||
AZ_Assert(false, "Invalid mesh handle");
|
||||
return Vector3::CreateOne();
|
||||
}
|
||||
}
|
||||
|
||||
void MeshFeatureProcessor::SetSortKey(const MeshHandle& meshHandle, RHI::DrawItemSortKey sortKey)
|
||||
{
|
||||
if (meshHandle.IsValid())
|
||||
@@ -845,10 +858,13 @@ namespace AZ
|
||||
AZ_Assert(m_model, "The model has not finished loading yet");
|
||||
|
||||
Transform localToWorld = transformService->GetTransformForId(m_objectId);
|
||||
Vector3 nonUniformScale = transformService->GetNonUniformScaleForId(m_objectId);
|
||||
|
||||
Vector3 center;
|
||||
float radius;
|
||||
Aabb localAabb = m_model->GetAabb();
|
||||
localAabb.MultiplyByScale(nonUniformScale);
|
||||
|
||||
localAabb.GetTransformedAabb(localToWorld).GetAsSphere(center, radius);
|
||||
|
||||
m_cullable.m_cullData.m_boundingSphere = Sphere(center, radius);
|
||||
|
||||
+1
@@ -81,6 +81,7 @@ namespace AZ
|
||||
->HitGroupIndex(blasIndex)
|
||||
->Blas(rayTracingSubMesh.m_blas)
|
||||
->Transform(rayTracingMesh.second.m_transform)
|
||||
->NonUniformScale(rayTracingMesh.second.m_nonUniformScale)
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
@@ -143,7 +143,7 @@ namespace AZ
|
||||
m_meshInfoBufferNeedsUpdate = true;
|
||||
}
|
||||
|
||||
void RayTracingFeatureProcessor::SetMeshTransform(const ObjectId objectId, AZ::Transform transform)
|
||||
void RayTracingFeatureProcessor::SetMeshTransform(const ObjectId objectId, const AZ::Transform transform, const AZ::Vector3 nonUniformScale)
|
||||
{
|
||||
if (!m_rayTracingEnabled)
|
||||
{
|
||||
@@ -154,6 +154,7 @@ namespace AZ
|
||||
if (itMesh != m_meshes.end())
|
||||
{
|
||||
itMesh->second.m_transform = transform;
|
||||
itMesh->second.m_nonUniformScale = nonUniformScale;
|
||||
m_revision++;
|
||||
}
|
||||
|
||||
|
||||
@@ -68,6 +68,9 @@ namespace AZ
|
||||
// mesh transform
|
||||
AZ::Transform m_transform = AZ::Transform::CreateIdentity();
|
||||
|
||||
// mesh non-uniform scale
|
||||
AZ::Vector3 m_nonUniformScale = AZ::Vector3::CreateOne();
|
||||
|
||||
// flag indicating if the Blas objects in the sub-meshes are built
|
||||
bool m_blasBuilt = false;
|
||||
};
|
||||
@@ -85,7 +88,8 @@ namespace AZ
|
||||
|
||||
//! Sets the ray tracing mesh transform
|
||||
//! This will cause an update to the RayTracing acceleration structure on the next frame
|
||||
void SetMeshTransform(const ObjectId objectId, const AZ::Transform transform);
|
||||
void SetMeshTransform(const ObjectId objectId, const AZ::Transform transform,
|
||||
const AZ::Vector3 nonUniformScale = AZ::Vector3::CreateOne());
|
||||
|
||||
//! Retrieves ray tracing data for all meshes in the scene
|
||||
const MeshMap& GetMeshes() const { return m_meshes; }
|
||||
|
||||
+14
-4
@@ -210,14 +210,14 @@ namespace AZ
|
||||
}
|
||||
}
|
||||
|
||||
void TransformServiceFeatureProcessor::SetTransformForId(ObjectId id, const AZ::Transform& transform)
|
||||
void TransformServiceFeatureProcessor::SetTransformForId(ObjectId id, const AZ::Transform& transform, const AZ::Vector3& nonUniformScale)
|
||||
{
|
||||
AZ_Error("TransformServiceFeatureProcessor", m_isWriteable, "Transform data cannot be written to during this phase");
|
||||
AZ_Error("TransformServiceFeatureProcessor", id.IsValid(), "Attempting to set the transform for an invalid handle.");
|
||||
if (id.IsValid())
|
||||
{
|
||||
AZ::Matrix3x4 matrix3x4 = AZ::Matrix3x4::CreateFromTransform(transform);
|
||||
|
||||
matrix3x4.MultiplyByScale(nonUniformScale);
|
||||
matrix3x4.StoreToRowMajorFloat12(m_objectToWorldTransforms.at(id.GetIndex()).m_transform);
|
||||
|
||||
// Inverse transpose to take the non-uniform scale out of the transform for usage with normals.
|
||||
@@ -228,8 +228,18 @@ namespace AZ
|
||||
|
||||
AZ::Transform TransformServiceFeatureProcessor::GetTransformForId(ObjectId id) const
|
||||
{
|
||||
AZ_Error("TransformServiceFeatureProcessor", id.IsValid(), "Attempting to set the transform for an invalid handle.");
|
||||
return AZ::Transform::CreateFromMatrix3x4( Matrix3x4::CreateFromRowMajorFloat12(m_objectToWorldTransforms.at(id.GetIndex()).m_transform) );
|
||||
AZ_Error("TransformServiceFeatureProcessor", id.IsValid(), "Attempting to get the transform for an invalid handle.");
|
||||
AZ::Matrix3x4 matrix3x4 = AZ::Matrix3x4::CreateFromRowMajorFloat12(m_objectToWorldTransforms.at(id.GetIndex()).m_transform);
|
||||
AZ::Transform transform = AZ::Transform::CreateFromMatrix3x4(matrix3x4);
|
||||
transform.ExtractScale();
|
||||
return transform;
|
||||
}
|
||||
|
||||
AZ::Vector3 TransformServiceFeatureProcessor::GetNonUniformScaleForId(ObjectId id) const
|
||||
{
|
||||
AZ_Error("TransformServiceFeatureProcessor", id.IsValid(), "Attempting to get the non-uniform scale for an invalid handle.");
|
||||
AZ::Matrix3x4 matrix3x4 = AZ::Matrix3x4::CreateFromRowMajorFloat12(m_objectToWorldTransforms.at(id.GetIndex()).m_transform);
|
||||
return matrix3x4.RetrieveScale();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,6 +111,7 @@ namespace AZ
|
||||
uint32_t m_instanceID = 0;
|
||||
uint32_t m_hitGroupIndex = 0;
|
||||
AZ::Transform m_transform = AZ::Transform::CreateIdentity();
|
||||
AZ::Vector3 m_nonUniformScale = AZ::Vector3::CreateOne();
|
||||
RHI::Ptr<RHI::RayTracingBlas> m_blas;
|
||||
};
|
||||
using RayTracingTlasInstanceVector = AZStd::vector<RayTracingTlasInstance>;
|
||||
@@ -154,6 +155,7 @@ namespace AZ
|
||||
RayTracingTlasDescriptor* InstanceID(uint32_t instanceID);
|
||||
RayTracingTlasDescriptor* HitGroupIndex(uint32_t hitGroupIndex);
|
||||
RayTracingTlasDescriptor* Transform(const AZ::Transform& transform);
|
||||
RayTracingTlasDescriptor* NonUniformScale(const AZ::Vector3& nonUniformScale);
|
||||
RayTracingTlasDescriptor* Blas(RHI::Ptr<RHI::RayTracingBlas>& blas);
|
||||
RayTracingTlasDescriptor* InstancesBuffer(RHI::Ptr<RHI::Buffer>& tlasInstances);
|
||||
RayTracingTlasDescriptor* NumInstances(uint32_t numInstancesInBuffer);
|
||||
|
||||
@@ -85,6 +85,13 @@ namespace AZ
|
||||
return this;
|
||||
}
|
||||
|
||||
RayTracingTlasDescriptor* RayTracingTlasDescriptor::NonUniformScale(const AZ::Vector3& nonUniformScale)
|
||||
{
|
||||
AZ_Assert(m_buildContext, "NonUniformSCale property can only be added to an Instance entry");
|
||||
m_buildContext->m_nonUniformScale = nonUniformScale;
|
||||
return this;
|
||||
}
|
||||
|
||||
RayTracingTlasDescriptor* RayTracingTlasDescriptor::Blas(RHI::Ptr<RHI::RayTracingBlas>& blas)
|
||||
{
|
||||
AZ_Assert(m_buildContext, "Blas property can only be added to an Instance entry");
|
||||
|
||||
@@ -89,8 +89,9 @@ namespace AZ
|
||||
mappedData[i].InstanceID = instance.m_instanceID;
|
||||
mappedData[i].InstanceContributionToHitGroupIndex = instance.m_hitGroupIndex;
|
||||
// convert transform to row-major 3x4
|
||||
AZ::Matrix3x4 matrix34 = AZ::Matrix3x4::CreateFromTransform(instance.m_transform);
|
||||
matrix34.StoreToRowMajorFloat12(&mappedData[i].Transform[0][0]);
|
||||
AZ::Matrix3x4 matrix3x4 = AZ::Matrix3x4::CreateFromTransform(instance.m_transform);
|
||||
matrix3x4.MultiplyByScale(instance.m_nonUniformScale);
|
||||
matrix3x4.StoreToRowMajorFloat12(&mappedData[i].Transform[0][0]);
|
||||
mappedData[i].AccelerationStructure = static_cast<DX12::Buffer*>(blas->GetBuffers().m_blasBuffer.get())->GetMemoryView().GetGpuAddress();
|
||||
// [GFX TODO][ATOM-5270] Add ray tracing TLAS instance mask support
|
||||
mappedData[i].InstanceMask = 0x1;
|
||||
|
||||
@@ -92,9 +92,9 @@ namespace AZ
|
||||
|
||||
mappedData[i].instanceCustomIndex = instance.m_instanceID;
|
||||
mappedData[i].instanceShaderBindingTableRecordOffset = instance.m_hitGroupIndex;
|
||||
// convert transform to row-major 3x4
|
||||
AZ::Matrix3x4 matrix34 = AZ::Matrix3x4::CreateFromTransform(instance.m_transform);
|
||||
matrix34.StoreToRowMajorFloat12(&mappedData[i].transform.matrix[0][0]);
|
||||
AZ::Matrix3x4 matrix3x4 = AZ::Matrix3x4::CreateFromTransform(instance.m_transform);
|
||||
matrix3x4.MultiplyByScale(instance.m_nonUniformScale);
|
||||
matrix3x4.StoreToRowMajorFloat12(&mappedData[i].transform.matrix[0][0]);
|
||||
|
||||
RayTracingBlas* blas = static_cast<RayTracingBlas*>(instance.m_blas.get());
|
||||
VkAccelerationStructureDeviceAddressInfoKHR addressInfo = {};
|
||||
|
||||
@@ -73,12 +73,14 @@ namespace AZ
|
||||
//! [GFX TODO][ATOM-4343 Bake mesh spatial during AP processing]
|
||||
//!
|
||||
//! @param modelTransform a transform that puts the model into the ray's coordinate space
|
||||
//! @param nonUniformScale Non-uniform scale applied in the model's local frame.
|
||||
//! @param rayStart position where the ray starts
|
||||
//! @param dir direction where the ray ends (does not have to be unit length)
|
||||
//! @param distanceFactor if an intersection is detected, this will be set such that distanceFactor * dir.length == distance to intersection
|
||||
//! @param normal if an intersection is detected, this will be set to the normal at the point of intersection
|
||||
//! @return true if the ray intersects the mesh
|
||||
bool RayIntersection(const AZ::Transform& modelTransform, const AZ::Vector3& rayStart, const AZ::Vector3& dir, float& distanceFactor, AZ::Vector3& normal) const;
|
||||
bool RayIntersection(const AZ::Transform& modelTransform, const AZ::Vector3& nonUniformScale, const AZ::Vector3& rayStart,
|
||||
const AZ::Vector3& dir, float& distanceFactor, AZ::Vector3& normal) const;
|
||||
|
||||
//! Get available UV names from the model and its lods.
|
||||
const AZStd::unordered_set<AZ::Name>& GetUvNames() const;
|
||||
|
||||
@@ -164,18 +164,22 @@ namespace AZ
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Model::RayIntersection(const AZ::Transform& modelTransform, const AZ::Vector3& rayStart, const AZ::Vector3& dir, float& distanceFactor, AZ::Vector3& normal) const
|
||||
bool Model::RayIntersection(const AZ::Transform& modelTransform, const AZ::Vector3& nonUniformScale, const AZ::Vector3& rayStart, const AZ::Vector3& dir, float& distanceFactor, AZ::Vector3& normal) const
|
||||
{
|
||||
AZ_PROFILE_FUNCTION(Debug::ProfileCategory::AzRender);
|
||||
const AZ::Vector3 clampedScale = nonUniformScale.GetMax(AZ::Vector3(AZ::MinTransformScale));
|
||||
|
||||
const AZ::Transform inverseTM = modelTransform.GetInverse();
|
||||
const AZ::Vector3 raySrcLocal = inverseTM.TransformPoint(rayStart);
|
||||
const AZ::Vector3 raySrcLocal = inverseTM.TransformPoint(rayStart) / clampedScale;
|
||||
|
||||
// Instead of just rotating 'dir' we need it to be scaled too, so that 'distanceFactor' will be in the target units rather than object local units.
|
||||
const AZ::Vector3 rayDest = rayStart + dir;
|
||||
const AZ::Vector3 rayDestLocal = inverseTM.TransformPoint(rayDest);
|
||||
const AZ::Vector3 rayDestLocal = inverseTM.TransformPoint(rayDest) / clampedScale;
|
||||
const AZ::Vector3 rayDirLocal = rayDestLocal - raySrcLocal;
|
||||
|
||||
return LocalRayIntersection(raySrcLocal, rayDirLocal, distanceFactor, normal);
|
||||
bool result = LocalRayIntersection(raySrcLocal, rayDirLocal, distanceFactor, normal);
|
||||
normal = (normal * clampedScale).GetNormalized();
|
||||
return result;
|
||||
}
|
||||
|
||||
const AZStd::unordered_set<AZ::Name>& Model::GetUvNames() const
|
||||
|
||||
@@ -4,9 +4,8 @@
|
||||
"parentMaterial": "Materials/Presets/PBR/default_grid.material",
|
||||
"propertyLayoutVersion": 3,
|
||||
"properties": {
|
||||
"ambientOcclusion": {
|
||||
"enable": true,
|
||||
"textureMap": "TestData/Textures/cc0/Rock030_2K_AmbientOcclusion.jpg"
|
||||
"occlusion": {
|
||||
"diffuseTextureMap": "TestData/Textures/cc0/Rock030_2K_AmbientOcclusion.jpg"
|
||||
},
|
||||
"baseColor": {
|
||||
"textureMap": "TestData/Textures/cc0/Rock030_2K_Color.jpg"
|
||||
|
||||
+12
-14
@@ -4,11 +4,6 @@
|
||||
"parentMaterial": "",
|
||||
"propertyLayoutVersion": 3,
|
||||
"properties": {
|
||||
"layer1_ambientOcclusion": {
|
||||
"enable": true,
|
||||
"factor": 1.6399999856948853,
|
||||
"textureMap": "TestData/Textures/cc0/bark1_disp.jpg"
|
||||
},
|
||||
"layer1_baseColor": {
|
||||
"color": [
|
||||
0.3495536744594574,
|
||||
@@ -32,6 +27,10 @@
|
||||
"flipY": true,
|
||||
"textureMap": "TestData/Textures/cc0/bark1_norm.jpg"
|
||||
},
|
||||
"layer1_occlusion": {
|
||||
"diffuseFactor": 1.6399999856948853,
|
||||
"diffuseTextureMap": "TestData/Textures/cc0/bark1_disp.jpg"
|
||||
},
|
||||
"layer1_parallax": {
|
||||
"enable": true,
|
||||
"factor": 0.02500000037252903,
|
||||
@@ -53,10 +52,6 @@
|
||||
"offsetU": 0.5,
|
||||
"offsetV": 0.25
|
||||
},
|
||||
"layer2_ambientOcclusion": {
|
||||
"factor": 1.2200000286102296,
|
||||
"textureMap": "TestData/Textures/cc0/bark1_disp.jpg"
|
||||
},
|
||||
"layer2_baseColor": {
|
||||
"textureMap": "TestData/Textures/cc0/Lava004_1K_Color.jpg"
|
||||
},
|
||||
@@ -76,6 +71,10 @@
|
||||
"flipY": true,
|
||||
"textureMap": "TestData/Textures/cc0/Lava004_1K_Normal.jpg"
|
||||
},
|
||||
"layer2_occlusion": {
|
||||
"specularFactor": 2.0,
|
||||
"specularTextureMap": "TestData/Textures/cc0/Tiles009_1K_Displacement.jpg"
|
||||
},
|
||||
"layer2_parallax": {
|
||||
"enable": true,
|
||||
"factor": 0.01600000075995922,
|
||||
@@ -88,11 +87,6 @@
|
||||
"offsetU": 0.5,
|
||||
"offsetV": 0.25
|
||||
},
|
||||
"layer3_ambientOcclusion": {
|
||||
"enable": true,
|
||||
"factor": 1.0399999618530274,
|
||||
"textureMap": "TestData/Textures/cc0/PaintedMetal003_1K_Displacement.jpg"
|
||||
},
|
||||
"layer3_baseColor": {
|
||||
"color": [
|
||||
0.6315556764602661,
|
||||
@@ -115,6 +109,10 @@
|
||||
"layer3_normal": {
|
||||
"textureMap": "TestData/Textures/cc0/PaintedMetal003_1K_Normal.jpg"
|
||||
},
|
||||
"layer3_occlusion": {
|
||||
"diffuseFactor": 1.0399999618530274,
|
||||
"diffuseTextureMap": "TestData/Textures/cc0/PaintedMetal003_1K_Displacement.jpg"
|
||||
},
|
||||
"layer3_parallax": {
|
||||
"enable": true,
|
||||
"factor": 0.004999999888241291,
|
||||
|
||||
+5
-8
@@ -1,15 +1,12 @@
|
||||
{
|
||||
"description": "",
|
||||
"materialType": "Materials\\Types\\StandardPBR.materialtype",
|
||||
"materialType": "Materials/Types/StandardPBR.materialtype",
|
||||
"parentMaterial": "010_OcclusionBase.material",
|
||||
"propertyLayoutVersion": 3,
|
||||
"properties": {
|
||||
"ambientOcclusion": {
|
||||
"enable": true,
|
||||
"factor": 1.25,
|
||||
"textureMap": "TestData/Textures/TextureHaven/4k_castle_brick_02_red/4k_castle_brick_02_red_ao.png"
|
||||
},
|
||||
"baseColor": {
|
||||
"textureMap": "TestData/Textures/TextureHaven/4k_castle_brick_02_red/4k_castle_brick_02_red_bc.png"
|
||||
"occlusion": {
|
||||
"diffuseFactor": 2.0,
|
||||
"diffuseTextureMap": "TestData/Textures/cc0/Tiles009_1K_AmbientOcclusion.jpg"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"description": "",
|
||||
"materialType": "Materials/Types/StandardPBR.materialtype",
|
||||
"parentMaterial": "010_OcclusionBase.material",
|
||||
"propertyLayoutVersion": 3,
|
||||
"properties": {
|
||||
"occlusion": {
|
||||
"diffuseFactor": 2.0,
|
||||
"diffuseTextureMap": "TestData/Textures/cc0/Tiles009_1K_AmbientOcclusion.jpg",
|
||||
"specularFactor": 2.0,
|
||||
"specularTextureMap": "TestData/Textures/cc0/Tiles009_1K_Displacement.jpg"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"description": "",
|
||||
"materialType": "Materials/Types/StandardPBR.materialtype",
|
||||
"parentMaterial": "",
|
||||
"propertyLayoutVersion": 3,
|
||||
"properties": {
|
||||
"baseColor": {
|
||||
"color": [
|
||||
0.06784161180257797,
|
||||
0.2073090672492981,
|
||||
0.29570457339286806,
|
||||
1.0
|
||||
]
|
||||
},
|
||||
"clearCoat": {
|
||||
"enable": true
|
||||
},
|
||||
"normal": {
|
||||
"textureMap": "TestData/Textures/cc0/Tiles009_1K_Normal.jpg"
|
||||
},
|
||||
"roughness": {
|
||||
"factor": 0.0
|
||||
}
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"description": "",
|
||||
"materialType": "Materials/Types/StandardPBR.materialtype",
|
||||
"parentMaterial": "010_OcclusionBase.material",
|
||||
"propertyLayoutVersion": 3,
|
||||
"properties": {
|
||||
"occlusion": {
|
||||
"specularFactor": 2.0,
|
||||
"specularTextureMap": "TestData/Textures/cc0/Tiles009_1K_Displacement.jpg"
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-3
@@ -4,9 +4,8 @@
|
||||
"parentMaterial": "TestData\\Materials\\StandardPbrTestCases\\UvTilingBase.material",
|
||||
"propertyLayoutVersion": 3,
|
||||
"properties": {
|
||||
"ambientOcclusion": {
|
||||
"enable": true,
|
||||
"textureMap": "TestData/Objects/cube/cube_diff.tif"
|
||||
"occlusion": {
|
||||
"diffuseTextureMap": "TestData/Objects/cube/cube_diff.tif"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -164,7 +164,8 @@ ForwardPassOutput AutoBrick_ForwardPassPS(VSOutput IN)
|
||||
GetSurfaceShape(IN.m_uv, surfaceDepth, surfaceNormal);
|
||||
const float3 normal = TangentSpaceToWorld(surfaceNormal, normalize(IN.m_normal), normalize(IN.m_tangent), normalize(IN.m_bitangent));
|
||||
|
||||
const float occlusion = 1.0f - surfaceDepth * AutoBrickSrg::m_aoFactor;
|
||||
const float diffuseAmbientOcclusion = 1.0f - surfaceDepth * AutoBrickSrg::m_aoFactor;
|
||||
const float specularOcclusion = 1;
|
||||
const float metallic = 0;
|
||||
const float roughness = 1;
|
||||
const float specularF0Factor = 0.5;
|
||||
@@ -179,7 +180,7 @@ ForwardPassOutput AutoBrick_ForwardPassPS(VSOutput IN)
|
||||
|
||||
PbrLightingOutput lightingOutput = PbrLighting(IN, baseColor, metallic, roughness, specularF0Factor,
|
||||
normal, IN.m_tangent, IN.m_bitangent, anisotropy,
|
||||
emissive, occlusion, transmissionTintThickness, transmissionParams, clearCoatFactor, clearCoatRoughness, clearCoatNormal, alpha, OpacityMode::Opaque);
|
||||
emissive, diffuseAmbientOcclusion, specularOcclusion, transmissionTintThickness, transmissionParams, clearCoatFactor, clearCoatRoughness, clearCoatNormal, alpha, OpacityMode::Opaque);
|
||||
|
||||
OUT.m_diffuseColor = lightingOutput.m_diffuseColor;
|
||||
OUT.m_diffuseColor.w = -1; // Subsurface scattering is disabled
|
||||
|
||||
@@ -77,7 +77,7 @@ ForwardPassOutput MinimalPBR_MainPassPS(VSOutput IN)
|
||||
|
||||
PbrLightingOutput lightingOutput = PbrLighting(IN, baseColor, metallic, roughness, specularF0Factor,
|
||||
normal, IN.m_tangent, IN.m_bitangent, anisotropy,
|
||||
emissive, occlusion, transmissionTintThickness, transmissionParams, clearCoatFactor, clearCoatRoughness, clearCoatNormal, alpha, OpacityMode::Opaque);
|
||||
emissive, occlusion, occlusion, transmissionTintThickness, transmissionParams, clearCoatFactor, clearCoatRoughness, clearCoatNormal, alpha, OpacityMode::Opaque);
|
||||
|
||||
OUT.m_diffuseColor = lightingOutput.m_diffuseColor;
|
||||
OUT.m_diffuseColor.w = -1; // Subsurface scattering is disabled
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:de6b49c1c4965896a190ed5f40c7d91f9deb942d859fd96264828df768098a83
|
||||
size 45257
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:0172df6b91bb42bf6c41d18a6fdb7088397663d71f0c2d3ee504a4e91a7e5e98
|
||||
size 426462
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:9de0bb2f58936658e8bd3599e487cbd6af3394c772d3132cd77a73774cfb5994
|
||||
size 230692
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:48a8690b74141da4e7e06cd10b47f0eb787b5333a915cd1e048ab24bec485ad0
|
||||
size 759052
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:ddd79ef9962100cd5a9eec686bdcfb98db19ab410329e50df53d6781f9d8b441
|
||||
size 421004
|
||||
+2
-3
@@ -4,9 +4,8 @@
|
||||
"parentMaterial": "",
|
||||
"propertyLayoutVersion": 3,
|
||||
"properties": {
|
||||
"ambientOcclusion": {
|
||||
"enable": true,
|
||||
"textureMap": "Materials/Bricks038_8K/Bricks038_8K_AmbientOcclusion.png"
|
||||
"occlusion": {
|
||||
"diffuseTextureMap": "Materials/Bricks038_8K/Bricks038_8K_AmbientOcclusion.png"
|
||||
},
|
||||
"baseColor": {
|
||||
"color": [
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user