From f8e4e6c8d37c76e830d2637f96af70a1aebdaf07 Mon Sep 17 00:00:00 2001 From: PopcornFX Bot Date: Thu, 22 Aug 2024 17:34:14 +0200 Subject: [PATCH] PopcornFX Gem 2.19.7 --- Assets/shaders/Common/RibbonSrg.azsli | 33 ++++++++++++++++--- Code/CMakeLists.txt | 2 +- Code/Platform/Linux/PAL_linux.cmake | 8 ++--- Code/Platform/Mac/PAL_mac.cmake | 4 +-- Code/Platform/Windows/PAL_windows.cmake | 4 +-- .../Integration/Managers/RenderManager.cpp | 3 +- .../AtomIntegration/AtomPipelineCache.cpp | 2 ++ .../AtomIntegration/AtomPipelineCache.h | 2 ++ .../AtomIntegration/RibbonBatchDrawer.cpp | 18 ++++++++++ .../AtomIntegration/RibbonBatchDrawer.h | 2 ++ README.md | 2 +- gem.json | 8 ++--- 12 files changed, 69 insertions(+), 19 deletions(-) diff --git a/Assets/shaders/Common/RibbonSrg.azsli b/Assets/shaders/Common/RibbonSrg.azsli index 48b25b2..6ac68aa 100644 --- a/Assets/shaders/Common/RibbonSrg.azsli +++ b/Assets/shaders/Common/RibbonSrg.azsli @@ -11,7 +11,9 @@ ShaderResourceGroup RendererSrg : SRG_PerDraw { // Draw call flags: uint m_rendererFlags; - uint m_particleCount; + uint m_tubesPlanesOffset; + uint m_vpp; + uint m_particleCount; // Material: StructuredBuffer m_diffuseColors; StructuredBuffer m_emissiveColors; @@ -21,9 +23,32 @@ ShaderResourceGroup RendererSrg : SRG_PerDraw uint GetParticleIdx(uint vertexIdx) { - uint particleIdx = vertexIdx / 4; - if (vertexIdx % 4 > 1) - particleIdx = min(particleIdx + 1, RendererSrg::m_particleCount - 1); + const int vpp = RendererSrg::m_vpp; // Note: if tube/multiplane with differing vertex count end up being batched, this won't work. + const int vppHalf = vpp / 2 - 1; + + + uint particleIdx = 0; + if (vertexIdx < RendererSrg::m_tubesPlanesOffset * 4) // No tube/multiplane batching yet with quad bb modes, but this might come. + { + // First two vertices within a quad: grab the current particle, last two: grab the next one + // Clamps to the total particle count to avoid overflowing the GPU sim buffers + //particleIdx = min(vertexIdx / 4 + saturate(vertexIdx % 4 - 1), RendererSrg::m_particleCount - 1); + particleIdx = vertexIdx / 4; + if (vertexIdx % 4 > 1) + particleIdx = min(particleIdx + 1, RendererSrg::m_particleCount - 1); + } + else + { + // First n (n being segmentCount/planeCount + 1) vertices: grab the current particle, last n: grab the next one + // Clamps to the total particle count to avoid overflowing the GPU sim buffers + //particleIdx = min(RendererSrg::m_tubesPlanesOffset + (vertexIdx - (RendererSrg::m_tubesPlanesOffset * 4)) / vpp + + // saturate(vertexIdx % vpp - vppHalf), + // RendererSrg::m_particleCount - 1); + particleIdx = RendererSrg::m_tubesPlanesOffset + (vertexIdx - (RendererSrg::m_tubesPlanesOffset * 4)) / vpp; + if (vertexIdx % vpp > vppHalf) + particleIdx = min(particleIdx + 1, RendererSrg::m_particleCount - 1); + } + return particleIdx; } diff --git a/Code/CMakeLists.txt b/Code/CMakeLists.txt index 8785573..3918f37 100644 --- a/Code/CMakeLists.txt +++ b/Code/CMakeLists.txt @@ -3,7 +3,7 @@ # https://www.popcornfx.com/terms-and-conditions/ #---------------------------------------------------------------------------- -set(POPCORNFX_VERSION 2.19.6) +set(POPCORNFX_VERSION 2.19.7) set(POPCORNFX_LICENSE O3DE) o3de_pal_dir(pal_dir ${CMAKE_CURRENT_LIST_DIR}/Platform/${PAL_PLATFORM_NAME} "${gem_restricted_path}" "${gem_path}" "${gem_name}") diff --git a/Code/Platform/Linux/PAL_linux.cmake b/Code/Platform/Linux/PAL_linux.cmake index 9450c92..9ee827a 100644 --- a/Code/Platform/Linux/PAL_linux.cmake +++ b/Code/Platform/Linux/PAL_linux.cmake @@ -6,12 +6,12 @@ set(LY_PACKAGE_SERVER_URLS ${LY_PACKAGE_SERVER_URLS} "https://downloads.popcornfx.com/o3de-packages") if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64") set(package_name PopcornFX-${POPCORNFX_VERSION}-${POPCORNFX_LICENSE}-linux) - set(pk_package_hash 2112123d081402998b91b22b8c652126d7012fbaa3720dce85220ab9a410a837) - set(pk_package_id i8MZ5vNtezYGK7CE) + set(pk_package_hash f443ddb42b335f2fe90783a68ac36d6a43464ee2a7fef627a07d25009d0e3059) + set(pk_package_id JSDb9nAxnaGksduz) elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "aarch64") set(package_name PopcornFX-${POPCORNFX_VERSION}-${POPCORNFX_LICENSE}-linux-aarch64) - set(pk_package_hash 2112123d081402998b91b22b8c652126d7012fbaa3720dce85220ab9a410a837_ARM64) - set(pk_package_id i8MZ5vNtezYGK7CE_ARM64) + set(pk_package_hash f443ddb42b335f2fe90783a68ac36d6a43464ee2a7fef627a07d25009d0e3059_ARM64) + set(pk_package_id JSDb9nAxnaGksduz_ARM64) else() message(FATAL_ERROR "Unsupported linux architecture ${CMAKE_SYSTEM_PROCESSOR}") endif() diff --git a/Code/Platform/Mac/PAL_mac.cmake b/Code/Platform/Mac/PAL_mac.cmake index 60f6ec6..c3a8156 100644 --- a/Code/Platform/Mac/PAL_mac.cmake +++ b/Code/Platform/Mac/PAL_mac.cmake @@ -5,8 +5,8 @@ set(LY_PACKAGE_SERVER_URLS ${LY_PACKAGE_SERVER_URLS} "https://downloads.popcornfx.com/o3de-packages") set(package_name PopcornFX-${POPCORNFX_VERSION}-${POPCORNFX_LICENSE}-mac) -set(pk_package_hash 11024c36ee4f18c9f166acddbc2ceb17c78d700a1eae9a3fb08a3b51d91fa0fa) -set(pk_package_id aAclANkhYKZ0RnQR) +set(pk_package_hash 1e720bcb429c7e3b6a42ff7b74ba5dfcbe377d92bced9d3b62a16ce2ea017979) +set(pk_package_id GTqdTuQ1VmyZIm3f) ly_associate_package(PACKAGE_NAME ${package_name} TARGETS PopcornFX PACKAGE_HASH ${pk_package_hash}) pk_download_package_ifn(${package_name} ${pk_package_id}) diff --git a/Code/Platform/Windows/PAL_windows.cmake b/Code/Platform/Windows/PAL_windows.cmake index 69ea293..241c94b 100644 --- a/Code/Platform/Windows/PAL_windows.cmake +++ b/Code/Platform/Windows/PAL_windows.cmake @@ -5,8 +5,8 @@ set(LY_PACKAGE_SERVER_URLS ${LY_PACKAGE_SERVER_URLS} "https://downloads.popcornfx.com/o3de-packages") set(package_name PopcornFX-${POPCORNFX_VERSION}-${POPCORNFX_LICENSE}-windows) -set(pk_package_hash e5cad8a35b8310d08b0064fc3f02326aa1062cf513a649729ef74dd686b11dab) -set(pk_package_id qpAwLC9YjMCnh3XJ) +set(pk_package_hash 9b1d3358d7a9da07e6c3ff230e79acff853de78351105773f379b7855959dc82) +set(pk_package_id CjtFjAonhAZRd3gZ) ly_associate_package(PACKAGE_NAME ${package_name} TARGETS PopcornFX PACKAGE_HASH ${pk_package_hash}) pk_download_package_ifn(${package_name} ${pk_package_id}) diff --git a/Code/Source/Integration/Managers/RenderManager.cpp b/Code/Source/Integration/Managers/RenderManager.cpp index 7d0de4e..d4232e0 100644 --- a/Code/Source/Integration/Managers/RenderManager.cpp +++ b/Code/Source/Integration/Managers/RenderManager.cpp @@ -54,8 +54,9 @@ void CRenderManager::Activate(CParticleMediumCollection *mediumCollection, const dynamicPoolDescriptor.m_largestPooledAllocationSizeInBytes = 0x100000; #if O3DE_VERSION_MAJOR >= 4 && O3DE_VERSION_MINOR >= 2 + dynamicPoolDescriptor.m_deviceMask = AZ::RHI::MultiDevice::DefaultDevice; m_BufferPool = aznew AZ::RHI::BufferPool; - AZ::RHI::ResultCode resultCode = m_BufferPool->Init(AZ::RHI::MultiDevice::DefaultDevice, dynamicPoolDescriptor); + AZ::RHI::ResultCode resultCode = m_BufferPool->Init(dynamicPoolDescriptor); #else m_BufferPool = AZ::RHI::Factory::Get().CreateBufferPool(); AZ::RHI::ResultCode resultCode = m_BufferPool->Init(*AZ::RHI::RHISystemInterface::Get()->GetDevice(), dynamicPoolDescriptor); diff --git a/Code/Source/Integration/Render/AtomIntegration/AtomPipelineCache.cpp b/Code/Source/Integration/Render/AtomIntegration/AtomPipelineCache.cpp index b8051e5..ec0925d 100644 --- a/Code/Source/Integration/Render/AtomIntegration/AtomPipelineCache.cpp +++ b/Code/Source/Integration/Render/AtomIntegration/AtomPipelineCache.cpp @@ -441,6 +441,8 @@ void CAtomPipelineCache::_FillRibbonSrgBindIndices(const CAtomRendererCache *ren AZ::Name constantNames[RibbonSrg::__Max_ConstantsSemantic] = { AZ::Name("m_rendererFlags"), + AZ::Name("m_tubesPlanesOffset"), + AZ::Name("m_vpp"), AZ::Name("m_particleCount"), }; diff --git a/Code/Source/Integration/Render/AtomIntegration/AtomPipelineCache.h b/Code/Source/Integration/Render/AtomIntegration/AtomPipelineCache.h index 079d1e5..d51d4bd 100644 --- a/Code/Source/Integration/Render/AtomIntegration/AtomPipelineCache.h +++ b/Code/Source/Integration/Render/AtomIntegration/AtomPipelineCache.h @@ -50,6 +50,8 @@ namespace RibbonSrg enum EConstantsSemantic { RendererFlags_ShaderRead, + TubesPlanesOffset_ShaderRead, + VPP_ShaderRead, ParticleCount_ShaderRead, __Max_ConstantsSemantic, diff --git a/Code/Source/Integration/Render/AtomIntegration/RibbonBatchDrawer.cpp b/Code/Source/Integration/Render/AtomIntegration/RibbonBatchDrawer.cpp index 8f44a8f..014257c 100644 --- a/Code/Source/Integration/Render/AtomIntegration/RibbonBatchDrawer.cpp +++ b/Code/Source/Integration/Render/AtomIntegration/RibbonBatchDrawer.cpp @@ -27,6 +27,22 @@ CRibbonBatchDrawer::~CRibbonBatchDrawer() //---------------------------------------------------------------------------- +bool CRibbonBatchDrawer::Setup(const CRendererDataBase *renderer, const CParticleRenderMedium *owner, const CFrameCollector *fc, const CStringId &storageClass) +{ + if (!Super::Setup(renderer, owner, fc, storageClass)) + return false; + + const ERibbonMode mode = renderer->m_Declaration.GetPropertyValue_Enum(BasicRendererProperties::SID_BillboardingMode(), RibbonMode_ViewposAligned); + if (mode == RibbonMode_SideAxisAlignedTube) + m_VPP = (u8)(renderer->m_Declaration.GetPropertyValue_I1(BasicRendererProperties::SID_GeometryRibbon_SegmentCount(), 8) + 1) * 2; + else if (mode == RibbonMode_SideAxisAlignedMultiPlane) + m_VPP = (u8)renderer->m_Declaration.GetPropertyValue_I1(BasicRendererProperties::SID_GeometryRibbon_PlaneCount(), 2) * 4; + + return true; +} + +//---------------------------------------------------------------------------- + bool CRibbonBatchDrawer::AreRenderersCompatible(const CRendererDataBase *rendererA, const CRendererDataBase *rendererB) const { if (!Super::AreRenderersCompatible(rendererA, rendererB)) @@ -334,6 +350,8 @@ bool CRibbonBatchDrawer::EmitDrawCall(SRenderContext &ctx, const SRendererBatchD } m_PipelineCaches[0].SetRibbonSrgConstantValue(RibbonSrg::RendererFlags_ShaderRead, rendererCache->m_BasicDescription.m_RendererFlags); + m_PipelineCaches[0].SetRibbonSrgConstantValue(RibbonSrg::TubesPlanesOffset_ShaderRead, m_VPP > 0 ? 0 : particleCount); // For now, no batching of tube/multiplane ribbons with quad bb modes + m_PipelineCaches[0].SetRibbonSrgConstantValue(RibbonSrg::VPP_ShaderRead, m_VPP); m_PipelineCaches[0].SetRibbonSrgConstantValue(RibbonSrg::ParticleCount_ShaderRead, particleCount); // Additional field buffers: diff --git a/Code/Source/Integration/Render/AtomIntegration/RibbonBatchDrawer.h b/Code/Source/Integration/Render/AtomIntegration/RibbonBatchDrawer.h index 6488291..075931d 100644 --- a/Code/Source/Integration/Render/AtomIntegration/RibbonBatchDrawer.h +++ b/Code/Source/Integration/Render/AtomIntegration/RibbonBatchDrawer.h @@ -23,6 +23,7 @@ class CRibbonBatchDrawer : public CRendererBatchJobs_Ribbon_CPUBB, CRibbonBatchDrawer(); virtual ~CRibbonBatchDrawer(); + virtual bool Setup(const CRendererDataBase *renderer, const CParticleRenderMedium *owner, const CFrameCollector *fc, const CStringId &storageClass) override; virtual bool AreRenderersCompatible(const CRendererDataBase *rendererA, const CRendererDataBase *rendererB) const override; virtual bool AllocBuffers(SRenderContext &ctx, const SRendererBatchDrawPass &drawPass) override; virtual bool MapBuffers(SRenderContext &ctx, const SRendererBatchDrawPass &drawPass) override; @@ -36,6 +37,7 @@ class CRibbonBatchDrawer : public CRendererBatchJobs_Ribbon_CPUBB, // Atlas definition buffer: AZ::RHI::Ptr m_AtlasDefinition = null; u32 m_AtlasSubRectsCount = 0; + u8 m_VPP = 0; }; //---------------------------------------------------------------------------- diff --git a/README.md b/README.md index 8aac19b..183cbe8 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # O3DE PopcornFX Plugin Integrates the **PopcornFX Runtime SDK** into **O3DE** as a Gem. -* **Version:** `v2.19.6` +* **Version:** `v2.19.7` * **O3DE:** `23.05`, `23.10` * **Supported platforms:** `Windows`, `MacOS`, `Linux`, `iOS`, `Android` diff --git a/gem.json b/gem.json index 9e2434e..2043718 100644 --- a/gem.json +++ b/gem.json @@ -1,13 +1,13 @@ { "gem_name": "PopcornFX", - "display_name": "PopcornFX 2.19.6", + "display_name": "PopcornFX 2.19.7", "license": "Community", "license_url": "https://www.popcornfx.com/popcornfx-community-license", "origin": "Persistant Studios - popcornfx.com", "repo_uri": "https://downloads.popcornfx.com/o3de-repo", - "origin_uri": "https://downloads.popcornfx.com/o3de-repo/PopcornFX-2.19/O3DE_PopcornFXGem_v2.19.6_Win64_Linux64_LinuxARM64_Mac64.zip", - "version": "2.19.6", - "last_updated": "2024-07-25", + "origin_uri": "https://downloads.popcornfx.com/o3de-repo/PopcornFX-2.19/O3DE_PopcornFXGem_v2.19.7_Win64_Linux64_LinuxARM64_Mac64.zip", + "version": "2.19.7", + "last_updated": "2024-08-22", "type": "Code", "summary": "The PopcornFX Gem provides real-time FX solution for particle effects.", "canonical_tags": [