From 1dd4898713fbbcc99557dd0c611d6818151dfd33 Mon Sep 17 00:00:00 2001 From: jiaweig <51759646+jiaweig-amzn@users.noreply.github.com> Date: Tue, 1 Feb 2022 06:47:11 -0800 Subject: [PATCH] LYN-8551 Terrain: Renderer: Create compute pass for clipmaps (#7116) * Allocate a pass that will be used to generate clipmap Signed-off-by: jiaweig <51759646+jiaweig-amzn@users.noreply.github.com> * Fix some small issues Signed-off-by: jiaweig <51759646+jiaweig-amzn@users.noreply.github.com> * Rename the pass to avoid future conflict. Move assets to terrain gem. Signed-off-by: jiaweig <51759646+jiaweig-amzn@users.noreply.github.com> * Turn the pass off Signed-off-by: jiaweig <51759646+jiaweig-amzn@users.noreply.github.com> * Move pass templates to Terrain gem Signed-off-by: jiaweig <51759646+jiaweig-amzn@users.noreply.github.com> * move load template to private Signed-off-by: jiaweig <51759646+jiaweig-amzn@users.noreply.github.com> * Add macro texture compute pass Signed-off-by: jiaweig <51759646+jiaweig-amzn@users.noreply.github.com> * Fix uncleaned code from previous commit Signed-off-by: jiaweig <51759646+jiaweig-amzn@users.noreply.github.com> --- AutomatedTesting/Passes/MainPipeline.pass | 12 +++- .../TerrainDetailTextureComputePass.pass | 52 +++++++++++++++++ .../TerrainMacroTextureComputePass.pass | 52 +++++++++++++++++ .../Passes/TerrainPassTemplates.azasset | 17 ++++++ .../TerrainDetailTextureComputePass.azsl | 18 ++++++ .../TerrainDetailTextureComputePass.shader | 14 +++++ .../TerrainDetailTextureComputePassSrg.azsli | 16 +++++ .../TerrainMacroTextureComputePass.azsl | 18 ++++++ .../TerrainMacroTextureComputePass.shader | 14 +++++ .../TerrainMacroTextureComputePassSrg.azsli | 16 +++++ .../Passes/TerrainDetailTextureComputePass.h | 55 ++++++++++++++++++ .../Passes/TerrainMacroTextureComputePass.h | 55 ++++++++++++++++++ .../Components/TerrainSystemComponent.cpp | 24 ++++++++ .../Components/TerrainSystemComponent.h | 7 +++ .../TerrainDetailTextureComputePass.cpp | 58 +++++++++++++++++++ .../Passes/TerrainMacroTextureComputePass.cpp | 58 +++++++++++++++++++ .../TerrainFeatureProcessor.cpp | 11 ++-- Gems/Terrain/Code/terrain_files.cmake | 4 ++ 18 files changed, 495 insertions(+), 6 deletions(-) create mode 100644 Gems/Terrain/Assets/Passes/TerrainDetailTextureComputePass.pass create mode 100644 Gems/Terrain/Assets/Passes/TerrainMacroTextureComputePass.pass create mode 100644 Gems/Terrain/Assets/Passes/TerrainPassTemplates.azasset create mode 100644 Gems/Terrain/Assets/Shaders/Terrain/TerrainDetailTextureComputePass.azsl create mode 100644 Gems/Terrain/Assets/Shaders/Terrain/TerrainDetailTextureComputePass.shader create mode 100644 Gems/Terrain/Assets/Shaders/Terrain/TerrainDetailTextureComputePassSrg.azsli create mode 100644 Gems/Terrain/Assets/Shaders/Terrain/TerrainMacroTextureComputePass.azsl create mode 100644 Gems/Terrain/Assets/Shaders/Terrain/TerrainMacroTextureComputePass.shader create mode 100644 Gems/Terrain/Assets/Shaders/Terrain/TerrainMacroTextureComputePassSrg.azsli create mode 100644 Gems/Terrain/Code/Include/Terrain/Passes/TerrainDetailTextureComputePass.h create mode 100644 Gems/Terrain/Code/Include/Terrain/Passes/TerrainMacroTextureComputePass.h create mode 100644 Gems/Terrain/Code/Source/TerrainRenderer/Passes/TerrainDetailTextureComputePass.cpp create mode 100644 Gems/Terrain/Code/Source/TerrainRenderer/Passes/TerrainMacroTextureComputePass.cpp diff --git a/AutomatedTesting/Passes/MainPipeline.pass b/AutomatedTesting/Passes/MainPipeline.pass index c34c556983..39b992a11d 100644 --- a/AutomatedTesting/Passes/MainPipeline.pass +++ b/AutomatedTesting/Passes/MainPipeline.pass @@ -42,6 +42,16 @@ "RayTracingAccelerationStructurePass" ] }, + { + "Name": "TerrainDetailTextureComputePass", + "TemplateName": "TerrainDetailTextureComputePassTemplate", + "Enabled": false + }, + { + "Name": "TerrainMacroTextureComputePass", + "TemplateName": "TerrainMacroTextureComputePassTemplate", + "Enabled": false + }, { "Name": "DepthPrePass", "TemplateName": "DepthMSAAParentTemplate", @@ -215,7 +225,7 @@ // Note: The following two lines represent the choice of rendering pipeline for the hair. // You can either choose to use PPLL or ShortCut and accordingly change the flag // 'm_usePPLLRenderTechnique' in the class 'HairFeatureProcessor.cpp' -// "TemplateName": "HairParentPassTemplate", + // "TemplateName": "HairParentPassTemplate", "TemplateName": "HairParentShortCutPassTemplate", "Enabled": true, "Connections": [ diff --git a/Gems/Terrain/Assets/Passes/TerrainDetailTextureComputePass.pass b/Gems/Terrain/Assets/Passes/TerrainDetailTextureComputePass.pass new file mode 100644 index 0000000000..b880979615 --- /dev/null +++ b/Gems/Terrain/Assets/Passes/TerrainDetailTextureComputePass.pass @@ -0,0 +1,52 @@ +{ + "Type": "JsonSerialization", + "Version": 1, + "ClassName": "PassAsset", + "ClassData": { + // Note: all the data here works as placeholders. + "PassTemplate": { + "Name": "TerrainDetailTextureComputePassTemplate", + "PassClass": "TerrainDetailTextureComputePass", + "Slots": [ + { + "Name": "DetailTextureClipmapOutput", + "ShaderInputName": "m_detailTexClipmap", + "SlotType": "Output", + "ScopeAttachmentUsage": "Shader" + } + ], + "ImageAttachments": [ + { + "Name": "DetailTextureClipmap", + "ImageDescriptor": { + "Format": "R32G32B32A32_FLOAT", + "BindFlags": "3", + "SharedQueueMask": "1", + "Size": { + "Width": 1024, + "Height": 1024 + } + } + } + ], + "Connections": [ + { + "LocalSlot": "DetailTextureClipmapOutput", + "AttachmentRef": { + "Pass": "This", + "Attachment": "DetailTextureClipmap" + } + } + ], + "PassData": { + "$type": "Terrain::TerrainDetailTextureComputePassData", + "ShaderAsset": { + "FilePath": "Shaders/Terrain/TerrainDetailTextureComputePass.shader" + }, + "Target Thread Count X": 1024, + "Target Thread Count Y": 1024, + "Target Thread Count Z": 1 + } + } + } +} diff --git a/Gems/Terrain/Assets/Passes/TerrainMacroTextureComputePass.pass b/Gems/Terrain/Assets/Passes/TerrainMacroTextureComputePass.pass new file mode 100644 index 0000000000..ecb31acf69 --- /dev/null +++ b/Gems/Terrain/Assets/Passes/TerrainMacroTextureComputePass.pass @@ -0,0 +1,52 @@ +{ + "Type": "JsonSerialization", + "Version": 1, + "ClassName": "PassAsset", + "ClassData": { + // Note: all the data here works as placeholders. + "PassTemplate": { + "Name": "TerrainMacroTextureComputePassTemplate", + "PassClass": "TerrainMacroTextureComputePass", + "Slots": [ + { + "Name": "MacroTextureClipmapOutput", + "ShaderInputName": "m_macroTexClipmap", + "SlotType": "Output", + "ScopeAttachmentUsage": "Shader" + } + ], + "ImageAttachments": [ + { + "Name": "MacroTextureClipmap", + "ImageDescriptor": { + "Format": "R32G32B32A32_FLOAT", + "BindFlags": "3", + "SharedQueueMask": "1", + "Size": { + "Width": 1024, + "Height": 1024 + } + } + } + ], + "Connections": [ + { + "LocalSlot": "MacroTextureClipmapOutput", + "AttachmentRef": { + "Pass": "This", + "Attachment": "MacroTextureClipmap" + } + } + ], + "PassData": { + "$type": "Terrain::TerrainMacroTextureComputePassData", + "ShaderAsset": { + "FilePath": "Shaders/Terrain/TerrainMacroTextureComputePass.shader" + }, + "Target Thread Count X": 1024, + "Target Thread Count Y": 1024, + "Target Thread Count Z": 1 + } + } + } +} diff --git a/Gems/Terrain/Assets/Passes/TerrainPassTemplates.azasset b/Gems/Terrain/Assets/Passes/TerrainPassTemplates.azasset new file mode 100644 index 0000000000..8b20edb6b9 --- /dev/null +++ b/Gems/Terrain/Assets/Passes/TerrainPassTemplates.azasset @@ -0,0 +1,17 @@ +{ + "Type": "JsonSerialization", + "Version": 1, + "ClassName": "AssetAliasesSourceData", + "ClassData": { + "AssetPaths": [ + { + "Name": "TerrainDetailTextureComputePassTemplate", + "Path": "Passes/TerrainDetailTextureComputePass.pass" + }, + { + "Name": "TerrainMacroTextureComputePassTemplate", + "Path": "Passes/TerrainMacroTextureComputePass.pass" + } + ] + } +} diff --git a/Gems/Terrain/Assets/Shaders/Terrain/TerrainDetailTextureComputePass.azsl b/Gems/Terrain/Assets/Shaders/Terrain/TerrainDetailTextureComputePass.azsl new file mode 100644 index 0000000000..a982e1aa49 --- /dev/null +++ b/Gems/Terrain/Assets/Shaders/Terrain/TerrainDetailTextureComputePass.azsl @@ -0,0 +1,18 @@ +/* + * Copyright (c) Contributors to the Open 3D Engine Project. + * For complete copyright and license terms please see the LICENSE at the root of this distribution. + * + * SPDX-License-Identifier: Apache-2.0 OR MIT + * + */ +#include "TerrainDetailTextureComputePassSrg.azsli" + +[numthreads(32,32,1)] +void MainCS( + uint3 dispatchThreadID : SV_DispatchThreadID, + uint3 groupID : SV_GroupID, + uint groupIndex : SV_GroupIndex) +{ + // Simple code to paint the whole image yellow for debug purpose before we actually write clipmap generation code + PassSrg::m_detailTexClipmap[dispatchThreadID.xy].rgba = float4(1.0, 1.0, 0.0, 1.0); +} diff --git a/Gems/Terrain/Assets/Shaders/Terrain/TerrainDetailTextureComputePass.shader b/Gems/Terrain/Assets/Shaders/Terrain/TerrainDetailTextureComputePass.shader new file mode 100644 index 0000000000..6b0488aaaa --- /dev/null +++ b/Gems/Terrain/Assets/Shaders/Terrain/TerrainDetailTextureComputePass.shader @@ -0,0 +1,14 @@ +{ + "Source": "TerrainDetailTextureComputePass.azsl", + + "ProgramSettings": + { + "EntryPoints": + [ + { + "name": "MainCS", + "type": "Compute" + } + ] + } +} diff --git a/Gems/Terrain/Assets/Shaders/Terrain/TerrainDetailTextureComputePassSrg.azsli b/Gems/Terrain/Assets/Shaders/Terrain/TerrainDetailTextureComputePassSrg.azsli new file mode 100644 index 0000000000..aaa67b52da --- /dev/null +++ b/Gems/Terrain/Assets/Shaders/Terrain/TerrainDetailTextureComputePassSrg.azsli @@ -0,0 +1,16 @@ +/* + * Copyright (c) Contributors to the Open 3D Engine Project. + * For complete copyright and license terms please see the LICENSE at the root of this distribution. + * + * SPDX-License-Identifier: Apache-2.0 OR MIT + * + */ + +#pragma once + +#include + +ShaderResourceGroup PassSrg : SRG_PerPass +{ + RWTexture2D m_detailTexClipmap; +} diff --git a/Gems/Terrain/Assets/Shaders/Terrain/TerrainMacroTextureComputePass.azsl b/Gems/Terrain/Assets/Shaders/Terrain/TerrainMacroTextureComputePass.azsl new file mode 100644 index 0000000000..287002cf09 --- /dev/null +++ b/Gems/Terrain/Assets/Shaders/Terrain/TerrainMacroTextureComputePass.azsl @@ -0,0 +1,18 @@ +/* + * Copyright (c) Contributors to the Open 3D Engine Project. + * For complete copyright and license terms please see the LICENSE at the root of this distribution. + * + * SPDX-License-Identifier: Apache-2.0 OR MIT + * + */ +#include "TerrainMacroTextureComputePassSrg.azsli" + +[numthreads(32,32,1)] +void MainCS( + uint3 dispatchThreadID : SV_DispatchThreadID, + uint3 groupID : SV_GroupID, + uint groupIndex : SV_GroupIndex) +{ + // Simple code to paint the whole image magenta for debug purpose before we actually write clipmap generation code + PassSrg::m_macroTexClipmap[dispatchThreadID.xy].rgba = float4(1.0, 0.0, 1.0, 1.0); +} diff --git a/Gems/Terrain/Assets/Shaders/Terrain/TerrainMacroTextureComputePass.shader b/Gems/Terrain/Assets/Shaders/Terrain/TerrainMacroTextureComputePass.shader new file mode 100644 index 0000000000..5e043dea12 --- /dev/null +++ b/Gems/Terrain/Assets/Shaders/Terrain/TerrainMacroTextureComputePass.shader @@ -0,0 +1,14 @@ +{ + "Source": "TerrainMacroTextureComputePass.azsl", + + "ProgramSettings": + { + "EntryPoints": + [ + { + "name": "MainCS", + "type": "Compute" + } + ] + } +} diff --git a/Gems/Terrain/Assets/Shaders/Terrain/TerrainMacroTextureComputePassSrg.azsli b/Gems/Terrain/Assets/Shaders/Terrain/TerrainMacroTextureComputePassSrg.azsli new file mode 100644 index 0000000000..462e5cee34 --- /dev/null +++ b/Gems/Terrain/Assets/Shaders/Terrain/TerrainMacroTextureComputePassSrg.azsli @@ -0,0 +1,16 @@ +/* + * Copyright (c) Contributors to the Open 3D Engine Project. + * For complete copyright and license terms please see the LICENSE at the root of this distribution. + * + * SPDX-License-Identifier: Apache-2.0 OR MIT + * + */ + +#pragma once + +#include + +ShaderResourceGroup PassSrg : SRG_PerPass +{ + RWTexture2D m_macroTexClipmap; +} diff --git a/Gems/Terrain/Code/Include/Terrain/Passes/TerrainDetailTextureComputePass.h b/Gems/Terrain/Code/Include/Terrain/Passes/TerrainDetailTextureComputePass.h new file mode 100644 index 0000000000..b7d5138d7f --- /dev/null +++ b/Gems/Terrain/Code/Include/Terrain/Passes/TerrainDetailTextureComputePass.h @@ -0,0 +1,55 @@ +/* + * Copyright (c) Contributors to the Open 3D Engine Project. + * For complete copyright and license terms please see the LICENSE at the root of this distribution. + * + * SPDX-License-Identifier: Apache-2.0 OR MIT + * + */ +#pragma once + +#include + +#include +#include +#include +#include + +namespace Terrain +{ + class TerrainFeatureProcessor; + + struct TerrainDetailTextureComputePassData + : public AZ::RPI::ComputePassData + { + AZ_RTTI(Terrain::TerrainDetailTextureComputePassData, "{387F7457-16E5-4AA6-8D96-56ED4532CA8D}", AZ::RPI::ComputePassData); + AZ_CLASS_ALLOCATOR(Terrain::TerrainDetailTextureComputePassData, AZ::SystemAllocator, 0); + + TerrainDetailTextureComputePassData() = default; + virtual ~TerrainDetailTextureComputePassData() = default; + + static void Reflect(AZ::ReflectContext* context); + }; + + class TerrainDetailTextureComputePass + : public AZ::RPI::ComputePass + { + AZ_RPI_PASS(TerrainDetailTextureComputePass); + + public: + AZ_RTTI(Terrain::TerrainDetailTextureComputePass, "{69A8207B-3311-4BB1-BD4E-A08B5E0424B5}", AZ::RPI::ComputePass); + AZ_CLASS_ALLOCATOR(Terrain::TerrainDetailTextureComputePass, AZ::SystemAllocator, 0); + virtual ~TerrainDetailTextureComputePass() = default; + + static AZ::RPI::Ptr Create(const AZ::RPI::PassDescriptor& descriptor); + + void SetFeatureProcessor(); + + void CompileResources(const AZ::RHI::FrameGraphCompileContext& context) override; + private: + TerrainDetailTextureComputePass(const AZ::RPI::PassDescriptor& descriptor); + + void BuildCommandListInternal(const AZ::RHI::FrameGraphExecuteContext& context) override; + + TerrainFeatureProcessor* m_terrainFeatureProcessor; + }; +} // namespace AZ::Render diff --git a/Gems/Terrain/Code/Include/Terrain/Passes/TerrainMacroTextureComputePass.h b/Gems/Terrain/Code/Include/Terrain/Passes/TerrainMacroTextureComputePass.h new file mode 100644 index 0000000000..5cadea0706 --- /dev/null +++ b/Gems/Terrain/Code/Include/Terrain/Passes/TerrainMacroTextureComputePass.h @@ -0,0 +1,55 @@ +/* + * Copyright (c) Contributors to the Open 3D Engine Project. + * For complete copyright and license terms please see the LICENSE at the root of this distribution. + * + * SPDX-License-Identifier: Apache-2.0 OR MIT + * + */ +#pragma once + +#include + +#include +#include +#include +#include + +namespace Terrain +{ + class TerrainFeatureProcessor; + + struct TerrainMacroTextureComputePassData + : public AZ::RPI::ComputePassData + { + AZ_RTTI(Terrain::TerrainMacroTextureComputePassData, "{BB11DACF-AF47-402D-92C6-33C644F6F530}", AZ::RPI::ComputePassData); + AZ_CLASS_ALLOCATOR(Terrain::TerrainMacroTextureComputePassData, AZ::SystemAllocator, 0); + + TerrainMacroTextureComputePassData() = default; + virtual ~TerrainMacroTextureComputePassData() = default; + + static void Reflect(AZ::ReflectContext* context); + }; + + class TerrainMacroTextureComputePass + : public AZ::RPI::ComputePass + { + AZ_RPI_PASS(TerrainMacroTextureComputePass); + + public: + AZ_RTTI(Terrain::TerrainMacroTextureComputePass, "{E493C3D2-D657-49ED-A5B1-A29B2995F6A8}", AZ::RPI::ComputePass); + AZ_CLASS_ALLOCATOR(Terrain::TerrainMacroTextureComputePass, AZ::SystemAllocator, 0); + virtual ~TerrainMacroTextureComputePass() = default; + + static AZ::RPI::Ptr Create(const AZ::RPI::PassDescriptor& descriptor); + + void SetFeatureProcessor(); + + void CompileResources(const AZ::RHI::FrameGraphCompileContext& context) override; + private: + TerrainMacroTextureComputePass(const AZ::RPI::PassDescriptor& descriptor); + + void BuildCommandListInternal(const AZ::RHI::FrameGraphExecuteContext& context) override; + + TerrainFeatureProcessor* m_terrainFeatureProcessor; + }; +} // namespace AZ::Render diff --git a/Gems/Terrain/Code/Source/Components/TerrainSystemComponent.cpp b/Gems/Terrain/Code/Source/Components/TerrainSystemComponent.cpp index 5357ccce32..ae321b37ff 100644 --- a/Gems/Terrain/Code/Source/Components/TerrainSystemComponent.cpp +++ b/Gems/Terrain/Code/Source/Components/TerrainSystemComponent.cpp @@ -14,6 +14,8 @@ #include #include +#include +#include namespace Terrain { @@ -63,11 +65,33 @@ namespace Terrain // every time an entity is added or removed to a level. If this ever changes, the Terrain System ownership could move into // the level component. m_terrainSystem = new TerrainSystem(); + + auto* passSystem = AZ::RPI::PassSystemInterface::Get(); + AZ_Assert(passSystem, "Cannot get the pass system."); + + // Setup handler for load pass templates mappings + m_loadTemplatesHandler = AZ::RPI::PassSystemInterface::OnReadyLoadTemplatesEvent::Handler([this]() { this->LoadPassTemplateMappings(); }); + passSystem->ConnectEvent(m_loadTemplatesHandler); + + // Register terrain system related passes + passSystem->AddPassCreator(AZ::Name("TerrainDetailTextureComputePass"), &TerrainDetailTextureComputePass::Create); + passSystem->AddPassCreator(AZ::Name("TerrainMacroTextureComputePass"), &TerrainDetailTextureComputePass::Create); } void TerrainSystemComponent::Deactivate() { + m_loadTemplatesHandler.Disconnect(); + delete m_terrainSystem; m_terrainSystem = nullptr; } + + void TerrainSystemComponent::LoadPassTemplateMappings() + { + auto* passSystem = AZ::RPI::PassSystemInterface::Get(); + AZ_Assert(passSystem, "Cannot get the pass system."); + + const char* passTemplatesFile = "Passes/TerrainPassTemplates.azasset"; + passSystem->LoadPassTemplateMappings(passTemplatesFile); + } } diff --git a/Gems/Terrain/Code/Source/Components/TerrainSystemComponent.h b/Gems/Terrain/Code/Source/Components/TerrainSystemComponent.h index b294c0473a..586c9c6be3 100644 --- a/Gems/Terrain/Code/Source/Components/TerrainSystemComponent.h +++ b/Gems/Terrain/Code/Source/Components/TerrainSystemComponent.h @@ -9,6 +9,7 @@ #pragma once #include +#include namespace Terrain { @@ -36,5 +37,11 @@ namespace Terrain //////////////////////////////////////////////////////////////////////// TerrainSystem* m_terrainSystem{ nullptr }; + + private: + //! Used for loading the pass templates of the terrain gem. + AZ::RPI::PassSystemInterface::OnReadyLoadTemplatesEvent::Handler m_loadTemplatesHandler; + + void LoadPassTemplateMappings(); }; } diff --git a/Gems/Terrain/Code/Source/TerrainRenderer/Passes/TerrainDetailTextureComputePass.cpp b/Gems/Terrain/Code/Source/TerrainRenderer/Passes/TerrainDetailTextureComputePass.cpp new file mode 100644 index 0000000000..0bfbfa134d --- /dev/null +++ b/Gems/Terrain/Code/Source/TerrainRenderer/Passes/TerrainDetailTextureComputePass.cpp @@ -0,0 +1,58 @@ +/* + * Copyright (c) Contributors to the Open 3D Engine Project. + * For complete copyright and license terms please see the LICENSE at the root of this distribution. + * + * SPDX-License-Identifier: Apache-2.0 OR MIT + * + */ + +#include +#include +#include +#include +#include + +namespace Terrain +{ + void TerrainDetailTextureComputePassData::Reflect(AZ::ReflectContext* context) + { + if (auto* serializeContext = azrtti_cast(context)) + { + serializeContext->Class() + ->Version(1); + } + } + + AZ::RPI::Ptr TerrainDetailTextureComputePass::Create(const AZ::RPI::PassDescriptor& descriptor) + { + AZ::RPI::Ptr pass = aznew TerrainDetailTextureComputePass(descriptor); + return pass; + } + + TerrainDetailTextureComputePass::TerrainDetailTextureComputePass(const AZ::RPI::PassDescriptor& descriptor) + : AZ::RPI::ComputePass(descriptor) + { + const TerrainDetailTextureComputePass* passData = AZ::RPI::PassUtils::GetPassData(descriptor); + if (passData) + { + // Copy data to pass + + } + } + + void TerrainDetailTextureComputePass::BuildCommandListInternal(const AZ::RHI::FrameGraphExecuteContext& context) + { + ComputePass::BuildCommandListInternal(context); + } + + void TerrainDetailTextureComputePass::SetFeatureProcessor() + { + m_terrainFeatureProcessor = GetRenderPipeline()->GetScene()->GetFeatureProcessor(); + } + + void TerrainDetailTextureComputePass::CompileResources(const AZ::RHI::FrameGraphCompileContext& context) + { + ComputePass::CompileResources(context); + } + +} // namespace Terrain diff --git a/Gems/Terrain/Code/Source/TerrainRenderer/Passes/TerrainMacroTextureComputePass.cpp b/Gems/Terrain/Code/Source/TerrainRenderer/Passes/TerrainMacroTextureComputePass.cpp new file mode 100644 index 0000000000..32eb849db3 --- /dev/null +++ b/Gems/Terrain/Code/Source/TerrainRenderer/Passes/TerrainMacroTextureComputePass.cpp @@ -0,0 +1,58 @@ +/* + * Copyright (c) Contributors to the Open 3D Engine Project. + * For complete copyright and license terms please see the LICENSE at the root of this distribution. + * + * SPDX-License-Identifier: Apache-2.0 OR MIT + * + */ + +#include +#include +#include +#include +#include + +namespace Terrain +{ + void TerrainMacroTextureComputePassData::Reflect(AZ::ReflectContext* context) + { + if (auto* serializeContext = azrtti_cast(context)) + { + serializeContext->Class() + ->Version(1); + } + } + + AZ::RPI::Ptr TerrainMacroTextureComputePass::Create(const AZ::RPI::PassDescriptor& descriptor) + { + AZ::RPI::Ptr pass = aznew TerrainMacroTextureComputePass(descriptor); + return pass; + } + + TerrainMacroTextureComputePass::TerrainMacroTextureComputePass(const AZ::RPI::PassDescriptor& descriptor) + : AZ::RPI::ComputePass(descriptor) + { + const TerrainMacroTextureComputePass* passData = AZ::RPI::PassUtils::GetPassData(descriptor); + if (passData) + { + // Copy data to pass + + } + } + + void TerrainMacroTextureComputePass::BuildCommandListInternal(const AZ::RHI::FrameGraphExecuteContext& context) + { + ComputePass::BuildCommandListInternal(context); + } + + void TerrainMacroTextureComputePass::SetFeatureProcessor() + { + m_terrainFeatureProcessor = GetRenderPipeline()->GetScene()->GetFeatureProcessor(); + } + + void TerrainMacroTextureComputePass::CompileResources(const AZ::RHI::FrameGraphCompileContext& context) + { + ComputePass::CompileResources(context); + } + +} // namespace Terrain diff --git a/Gems/Terrain/Code/Source/TerrainRenderer/TerrainFeatureProcessor.cpp b/Gems/Terrain/Code/Source/TerrainRenderer/TerrainFeatureProcessor.cpp index 17cded8c97..e33f951bb1 100644 --- a/Gems/Terrain/Code/Source/TerrainRenderer/TerrainFeatureProcessor.cpp +++ b/Gems/Terrain/Code/Source/TerrainRenderer/TerrainFeatureProcessor.cpp @@ -6,12 +6,13 @@ * */ +#include +#include #include #include - #include - +#include #include #include #include @@ -21,9 +22,6 @@ #include #include #include - -#include - #include #include @@ -55,6 +53,9 @@ namespace Terrain ->Version(0) ; } + + TerrainDetailTextureComputePassData::Reflect(context); + TerrainMacroTextureComputePassData::Reflect(context); } void TerrainFeatureProcessor::Activate() diff --git a/Gems/Terrain/Code/terrain_files.cmake b/Gems/Terrain/Code/terrain_files.cmake index 53a7c6ac6d..cfc7d40cd5 100644 --- a/Gems/Terrain/Code/terrain_files.cmake +++ b/Gems/Terrain/Code/terrain_files.cmake @@ -9,6 +9,8 @@ set(FILES Include/Terrain/Ebuses/TerrainAreaSurfaceRequestBus.h Include/Terrain/TerrainDataConstants.h + Include/Terrain/Passes/TerrainDetailTextureComputePass.h + Include/Terrain/Passes/TerrainMacroTextureComputePass.h Source/Components/TerrainHeightGradientListComponent.cpp Source/Components/TerrainHeightGradientListComponent.h Source/Components/TerrainLayerSpawnerComponent.cpp @@ -39,6 +41,8 @@ set(FILES Source/TerrainRenderer/BindlessImageArrayHandler.h Source/TerrainRenderer/ClipmapBounds.cpp Source/TerrainRenderer/ClipmapBounds.h + Source/TerrainRenderer/Passes/TerrainDetailTextureComputePass.cpp + Source/TerrainRenderer/Passes/TerrainMacroTextureComputePass.cpp Source/TerrainRenderer/TerrainFeatureProcessor.cpp Source/TerrainRenderer/TerrainFeatureProcessor.h Source/TerrainRenderer/TerrainDetailMaterialManager.cpp