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>monroegm-disable-blank-issue-2
parent
c6a0d76843
commit
1dd4898713
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
{
|
||||
"Type": "JsonSerialization",
|
||||
"Version": 1,
|
||||
"ClassName": "AssetAliasesSourceData",
|
||||
"ClassData": {
|
||||
"AssetPaths": [
|
||||
{
|
||||
"Name": "TerrainDetailTextureComputePassTemplate",
|
||||
"Path": "Passes/TerrainDetailTextureComputePass.pass"
|
||||
},
|
||||
{
|
||||
"Name": "TerrainMacroTextureComputePassTemplate",
|
||||
"Path": "Passes/TerrainMacroTextureComputePass.pass"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@ -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);
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
{
|
||||
"Source": "TerrainDetailTextureComputePass.azsl",
|
||||
|
||||
"ProgramSettings":
|
||||
{
|
||||
"EntryPoints":
|
||||
[
|
||||
{
|
||||
"name": "MainCS",
|
||||
"type": "Compute"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@ -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 <Atom/Features/SrgSemantics.azsli>
|
||||
|
||||
ShaderResourceGroup PassSrg : SRG_PerPass
|
||||
{
|
||||
RWTexture2D<float4> m_detailTexClipmap;
|
||||
}
|
||||
@ -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);
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
{
|
||||
"Source": "TerrainMacroTextureComputePass.azsl",
|
||||
|
||||
"ProgramSettings":
|
||||
{
|
||||
"EntryPoints":
|
||||
[
|
||||
{
|
||||
"name": "MainCS",
|
||||
"type": "Compute"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@ -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 <Atom/Features/SrgSemantics.azsli>
|
||||
|
||||
ShaderResourceGroup PassSrg : SRG_PerPass
|
||||
{
|
||||
RWTexture2D<float4> m_macroTexClipmap;
|
||||
}
|
||||
@ -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 <AzCore/Memory/SystemAllocator.h>
|
||||
|
||||
#include <Atom/RPI.Public/Pass/Pass.h>
|
||||
#include <Atom/RPI.Public/Pass/ComputePass.h>
|
||||
#include <Atom/RPI.Reflect/Pass/ComputePassData.h>
|
||||
#include <Atom/RPI.Reflect/Pass/PassDescriptor.h>
|
||||
|
||||
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<TerrainDetailTextureComputePass> 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
|
||||
@ -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 <AzCore/Memory/SystemAllocator.h>
|
||||
|
||||
#include <Atom/RPI.Public/Pass/Pass.h>
|
||||
#include <Atom/RPI.Public/Pass/ComputePass.h>
|
||||
#include <Atom/RPI.Reflect/Pass/ComputePassData.h>
|
||||
#include <Atom/RPI.Reflect/Pass/PassDescriptor.h>
|
||||
|
||||
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<TerrainMacroTextureComputePass> 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
|
||||
@ -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 <Terrain/Passes/TerrainDetailTextureComputePass.h>
|
||||
#include <TerrainRenderer/TerrainFeatureProcessor.h>
|
||||
#include <Atom/RPI.Public/Pass/PassUtils.h>
|
||||
#include <Atom/RPI.Public/RenderPipeline.h>
|
||||
#include <Atom/RPI.Public/Scene.h>
|
||||
|
||||
namespace Terrain
|
||||
{
|
||||
void TerrainDetailTextureComputePassData::Reflect(AZ::ReflectContext* context)
|
||||
{
|
||||
if (auto* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
|
||||
{
|
||||
serializeContext->Class<Terrain::TerrainDetailTextureComputePassData, AZ::RPI::ComputePassData>()
|
||||
->Version(1);
|
||||
}
|
||||
}
|
||||
|
||||
AZ::RPI::Ptr<TerrainDetailTextureComputePass> TerrainDetailTextureComputePass::Create(const AZ::RPI::PassDescriptor& descriptor)
|
||||
{
|
||||
AZ::RPI::Ptr<TerrainDetailTextureComputePass> pass = aznew TerrainDetailTextureComputePass(descriptor);
|
||||
return pass;
|
||||
}
|
||||
|
||||
TerrainDetailTextureComputePass::TerrainDetailTextureComputePass(const AZ::RPI::PassDescriptor& descriptor)
|
||||
: AZ::RPI::ComputePass(descriptor)
|
||||
{
|
||||
const TerrainDetailTextureComputePass* passData = AZ::RPI::PassUtils::GetPassData<TerrainDetailTextureComputePass>(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<TerrainFeatureProcessor>();
|
||||
}
|
||||
|
||||
void TerrainDetailTextureComputePass::CompileResources(const AZ::RHI::FrameGraphCompileContext& context)
|
||||
{
|
||||
ComputePass::CompileResources(context);
|
||||
}
|
||||
|
||||
} // namespace Terrain
|
||||
@ -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 <Terrain/Passes/TerrainMacroTextureComputePass.h>
|
||||
#include <TerrainRenderer/TerrainFeatureProcessor.h>
|
||||
#include <Atom/RPI.Public/Pass/PassUtils.h>
|
||||
#include <Atom/RPI.Public/RenderPipeline.h>
|
||||
#include <Atom/RPI.Public/Scene.h>
|
||||
|
||||
namespace Terrain
|
||||
{
|
||||
void TerrainMacroTextureComputePassData::Reflect(AZ::ReflectContext* context)
|
||||
{
|
||||
if (auto* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
|
||||
{
|
||||
serializeContext->Class<Terrain::TerrainMacroTextureComputePassData, AZ::RPI::ComputePassData>()
|
||||
->Version(1);
|
||||
}
|
||||
}
|
||||
|
||||
AZ::RPI::Ptr<TerrainMacroTextureComputePass> TerrainMacroTextureComputePass::Create(const AZ::RPI::PassDescriptor& descriptor)
|
||||
{
|
||||
AZ::RPI::Ptr<TerrainMacroTextureComputePass> pass = aznew TerrainMacroTextureComputePass(descriptor);
|
||||
return pass;
|
||||
}
|
||||
|
||||
TerrainMacroTextureComputePass::TerrainMacroTextureComputePass(const AZ::RPI::PassDescriptor& descriptor)
|
||||
: AZ::RPI::ComputePass(descriptor)
|
||||
{
|
||||
const TerrainMacroTextureComputePass* passData = AZ::RPI::PassUtils::GetPassData<TerrainMacroTextureComputePass>(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<TerrainFeatureProcessor>();
|
||||
}
|
||||
|
||||
void TerrainMacroTextureComputePass::CompileResources(const AZ::RHI::FrameGraphCompileContext& context)
|
||||
{
|
||||
ComputePass::CompileResources(context);
|
||||
}
|
||||
|
||||
} // namespace Terrain
|
||||
Loading…
Reference in New Issue