Skip to content

Commit

Permalink
UnityPlugin: Release 2.18.6
Browse files Browse the repository at this point in the history
  • Loading branch information
PopcornFX Bot committed Mar 29, 2024
1 parent a0a3b02 commit a9a2560
Show file tree
Hide file tree
Showing 101 changed files with 76,326 additions and 35,612 deletions.
20 changes: 19 additions & 1 deletion Native/FxEffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ int CPKFXEffect::LoadFX(const CString &fx)
// GetAllAttributes doesn't check if m_EffectID is valid now
// and return the parent effect default container instead of null for newly instantiated emitters.
// So force create the attribute container here
m_Emitter->SetAllAttributes(null);
if (m_Emitter == null)
return -1;
m_Emitter->SetAllAttributes(null);

if (CRuntimeManager::Instance().GetIsUnitTesting())
{
Expand Down Expand Up @@ -145,6 +147,8 @@ int CPKFXEffect::LoadFX(const CString &fx)

void CPKFXEffect::RunFX(float delay, float prewarm)
{
if (m_Emitter == null) //If effect is being stopped
return;
// Setup the effect instance basic parameters
PopcornFX::SEffectStartCtl effectStartCtl;
effectStartCtl.m_TimeFromStartOfFrame = delay;
Expand Down Expand Up @@ -273,6 +277,8 @@ void CPKFXEffect::Update(float dt)

SAttributesContainer::SAttrib *CPKFXEffect::GetAttributesBuffer()
{
if (m_Emitter == null) //If effect is being stopped
return null;
if (m_Emitter->GetAllAttributes() == null)
{
m_Emitter->SetAllAttributes(null);
Expand All @@ -282,6 +288,8 @@ SAttributesContainer::SAttrib *CPKFXEffect::GetAttributesBuffer()

void CPKFXEffect::UpdateAttributesBuffer()
{
if (m_Emitter == null) //If effect is being stopped
return;
m_Emitter->SetAllAttributes(m_Emitter->GetAllAttributes());
}

Expand Down Expand Up @@ -471,6 +479,8 @@ bool CPKFXEffect::EffectEndUpdateSamplerSkinning(u32 smpID)

bool CPKFXEffect::SetSamplerShapeBasics(u32 smpID, EShapeType type, const CFloat3 &size)
{
if (m_Emitter == null) //If effect is being stopped
return false;
SSamplerData &samplerData = m_SamplersData[smpID];
// Wait for the sampler change thread:
_WaitForSwitchSamplers(&samplerData);
Expand Down Expand Up @@ -729,6 +739,8 @@ bool CPKFXEffect::SetSamplerShapeTransform(u32 smpID, const CFloat4x4 &transform

bool CPKFXEffect::SetSamplerCurve(u32 smpID, const SCurveSamplerToFill *curveData)
{
if (m_Emitter == null) //If effect is being stopped
return false;
SSamplerData &samplerData = m_SamplersData[smpID];
const float CURVE_MINIMUM_DELTA = 0.0001f;

Expand Down Expand Up @@ -981,6 +993,8 @@ bool CPKFXEffect::SetSamplerCurve(u32 smpID, const SCurveSamplerToFill *curveDat

bool CPKFXEffect::SetSamplerTexture(u32 smpID, const STextureSamplerToFill *texture)
{
if (m_Emitter == null) //If effect is being stopped
return false;
const u32 width = texture->m_Width;
const u32 height = texture->m_Height;
const u32 sizeInBytes = texture->m_SizeInBytes;
Expand Down Expand Up @@ -1080,6 +1094,8 @@ bool CPKFXEffect::SetSamplerTexture(u32 smpID, const STextureSamplerToFill *text

bool CPKFXEffect::SetSamplerText(u32 smpID, const char *text)
{
if (m_Emitter == null) //If effect is being stopped
return false;
CString textStr(text);
SSamplerData &samplerData = m_SamplersData[smpID];

Expand Down Expand Up @@ -1280,6 +1296,8 @@ PShapeDescriptor_Mesh CPKFXEffect::_LoadSamplerShapeMeshFromPkmm( CConstMemorySt

bool CPKFXEffect::_SetSamplerShapeMesh(u32 smpID, SSamplerData &samplerData, const PShapeDescriptor_Mesh &shapeDescriptor, const PResourceMeshBatch &meshBatch, const PPkFxSkinnedMesh &skinnedMesh)
{
if (m_Emitter == null) //If effect is being stopped
return false;
if (!PK_VERIFY(samplerData.m_SamplerType == SamplerShape))
{
CLog::Log(PK_ERROR, "Set sampler mesh on another type of sampler");
Expand Down
4 changes: 2 additions & 2 deletions Native/ImplemGraphicsAPI/RenderAPI_VulkanData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ void *CVulkanData::BeginModifyNativeBuffer(SBufferHandles &bufferHandle, bool is
{
(void)isIdxBuff; (void)fullSize; (void)mapSize;

PK_ASSERT(CRuntimeManager::Instance().IsRenderThread());
PK_ASSERT(CRuntimeManager::Instance().GetScene().IsRenderThread());
IUnityGraphicsVulkan *graphicVulkan = CRuntimeManager::Instance().GetUnityGraphicsVulkan();
if (!PK_VERIFY(graphicVulkan != null))
return null;
Expand Down Expand Up @@ -112,7 +112,7 @@ void *CVulkanData::BeginModifyNativeBuffer(SBufferHandles &bufferHandle, bool is
void CVulkanData::EndModifyNativeBuffer(SBufferHandles &bufferHandle, bool isIdxBuff)
{
(void)isIdxBuff;
PK_ASSERT(CRuntimeManager::Instance().IsRenderThread());
PK_ASSERT(CRuntimeManager::Instance().GetScene().IsRenderThread());
IUnityGraphicsVulkan *graphicVulkan = CRuntimeManager::Instance().GetUnityGraphicsVulkan();
if (!PK_VERIFY(graphicVulkan != null))
return;
Expand Down
4 changes: 2 additions & 2 deletions Native/NativeToManaged.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ extern "C"
const char *m_EmissiveRampMap;
float m_InvSoftnessDistance;
float m_AlphaClipThreshold;
bool m_DoubleSided;

SRenderingFeatureLitDesc *m_LitRendering;
SRenderingFeatureVATDesc *m_VatRendering;
Expand All @@ -168,6 +167,7 @@ extern "C"
int m_DrawOrder;

ManagedBool m_TransformUVs_RGBOnly;
ManagedBool m_UseVertexColor;

SMeshRendererDesc()
: m_MeshAsset(null)
Expand All @@ -181,7 +181,6 @@ extern "C"
, m_EmissiveRampMap(null)
, m_InvSoftnessDistance(0)
, m_AlphaClipThreshold(0)
, m_DoubleSided(false)
, m_LitRendering(null)
, m_VatRendering(null)
, m_AnimDescRendering(null)
Expand All @@ -190,6 +189,7 @@ extern "C"
, m_UID(-1)
, m_DrawOrder(0)
, m_TransformUVs_RGBOnly(ManagedBool_False)
, m_UseVertexColor(ManagedBool_False)
{
}

Expand Down
2 changes: 2 additions & 0 deletions Native/RenderingIntegration/UnityBillboardingBatchPolicy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ CUnityBillboardingBatchPolicy::CUnityBillboardingBatchPolicy()
, m_MappedIdxBuffer(null)
, m_MappedInfoBillboardBuffer(null)
, m_MappedAtlasesBuffer(null)
, m_HasAtlas(false)
, m_HasTransformUV(false)
{
}

Expand Down
25 changes: 15 additions & 10 deletions Native/RenderingIntegration/UnityRendererCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,8 @@ bool CParticleMaterialDescBillboard::operator == (const CParticleMaterialDescBil
m_EmissiveRampMap == oth.m_EmissiveRampMap &&
m_AtlasDefinition == oth.m_AtlasDefinition &&
m_AtlasSubdivX == oth.m_AtlasSubdivX &&
m_AtlasSubdivY == oth.m_AtlasSubdivY;
m_AtlasSubdivY == oth.m_AtlasSubdivY &&
m_AlphaThreshold == oth.m_AlphaThreshold;
}

//----------------------------------------------------------------------------
Expand Down Expand Up @@ -455,6 +456,7 @@ CParticleMaterialDescMesh::CParticleMaterialDescMesh()
, m_InvSoftnessDistance(0.0f)
, m_AlphaThreshold(0.5f)
, m_TransformUVs_RGBOnly(false)
, m_UseVertexColor(false)
, m_AtlasPath(CStringId::Null)
, m_AtlasSubdivs(0, 0)
{
Expand Down Expand Up @@ -491,6 +493,7 @@ bool CParticleMaterialDescMesh::InitFromRenderer(const CRendererDataMesh &render
const SRendererFeaturePropertyValue *atlasBlending = renderer.m_Declaration.FindProperty(BasicRendererProperties::SID_Atlas_Blending());
const SRendererFeaturePropertyValue *transformUVs = renderer.m_Declaration.FindProperty(BasicRendererProperties::SID_TransformUVs());
const SRendererFeaturePropertyValue *transformUVsRGBOnly = renderer.m_Declaration.FindProperty(BasicRendererProperties::SID_TransformUVs_RGBOnly());
const SRendererFeaturePropertyValue *doubleSided = renderer.m_Declaration.FindProperty(BasicRendererProperties::SID_Culling_DoubleSided());

m_Flags.m_ShaderVariationFlags = 0;

Expand Down Expand Up @@ -520,6 +523,8 @@ bool CParticleMaterialDescMesh::InitFromRenderer(const CRendererDataMesh &render
if (transformUVsRGBOnly != null && transformUVsRGBOnly->ValueB())
m_TransformUVs_RGBOnly = transformUVsRGBOnly->ValueB();
}
if (doubleSided != null && doubleSided->ValueB())
m_Flags.m_ShaderVariationFlags |= ShaderVariationFlags::Has_DoubleSided;

if (diffuseColorInput.Valid())
m_Flags.m_ShaderVariationFlags |= ShaderVariationFlags::Has_Color;
Expand Down Expand Up @@ -597,24 +602,20 @@ bool CParticleMaterialDescMesh::InitFromRenderer(const CRendererDataMesh &render
}
}

//-----------------------------
// Choose the culling mode:
//-----------------------------
m_DoubleSided = true; // Keep culling off by default
if (renderer.m_Declaration.IsFeatureEnabled(BasicRendererProperties::SID_Culling()))
m_DoubleSided = renderer.m_Declaration.GetPropertyValue_B(BasicRendererProperties::SID_Culling_DoubleSided(), true);

//-----------------------------
// Retrieve the shader uniforms (mesh resource, property values...):
//-----------------------------
const SRendererFeaturePropertyValue *mesh = renderer.m_Declaration.FindProperty(BasicRendererProperties::SID_Mesh());
const SRendererFeaturePropertyValue *meshAtlas = renderer.m_Declaration.FindProperty(BasicRendererProperties::SID_MeshAtlas());
const SRendererFeaturePropertyValue* meshUseVertexColor = renderer.m_Declaration.FindProperty(BasicRendererProperties::SID_UseVertexColor());

if (PK_VERIFY(mesh != null && !mesh->ValuePath().Empty()))
m_MeshPath = CStringId(CFilePath::Purified(mesh->ValuePath()));
else
return false;

if (meshUseVertexColor != null && meshUseVertexColor->ValueB())
m_UseVertexColor = true;
// Skeletal anim:
if (skeletalAnim != null && skeletalAnim->ValueB() && skeletalAnimTexResol != null && skeletalAnimTex != null &&
skeletalAnimBonesTranslateBoundsMin != null && skeletalAnimBonesTranslateBoundsMax != null && skeletalAnimCount != null)
Expand All @@ -624,6 +625,7 @@ bool CParticleMaterialDescMesh::InitFromRenderer(const CRendererDataMesh &render
m_SkeletalAnimTranslationBoundsMin = skeletalAnimBonesTranslateBoundsMin->ValueF().xyz();
m_SkeletalAnimTranslationBoundsMax = skeletalAnimBonesTranslateBoundsMax->ValueF().xyz();
m_SkeletalAnimCount = (u32)skeletalAnimCount->ValueI().x();
m_UseVertexColor = true;
if (skeletalAnimUseBonesScale != null && skeletalAnimUseBonesScale->ValueB() &&
skeletalAnimBonesScaleBoundsMin != null && skeletalAnimBonesScaleBoundsMax != null)
{
Expand Down Expand Up @@ -667,6 +669,7 @@ bool CParticleMaterialDescMesh::InitFromRenderer(const CRendererDataMesh &render

if ((m_Flags.m_ShaderVariationFlags & ShaderVariationFlags::Has_FluidVAT) != 0)
{
m_UseVertexColor = true;
const SRendererFeaturePropertyValue *fluid_PositionMap = renderer.m_Declaration.FindProperty(VertexAnimationRendererProperties::SID_VertexAnimation_Fluid_PositionMap());
if (fluid_PositionMap != null && !fluid_PositionMap->ValuePath().Empty())
m_Vat_PositionMap = CStringId(CFilePath::Purified(fluid_PositionMap->ValuePath()));
Expand All @@ -689,6 +692,7 @@ bool CParticleMaterialDescMesh::InitFromRenderer(const CRendererDataMesh &render
}
else if ((m_Flags.m_ShaderVariationFlags & ShaderVariationFlags::Has_SoftVAT) != 0)
{
m_UseVertexColor = true;
const SRendererFeaturePropertyValue *soft_PositionMap = renderer.m_Declaration.FindProperty(VertexAnimationRendererProperties::SID_VertexAnimation_Soft_PositionMap());
if (soft_PositionMap != null && !soft_PositionMap->ValuePath().Empty())
m_Vat_PositionMap = CStringId(CFilePath::Purified(soft_PositionMap->ValuePath()));
Expand All @@ -711,6 +715,7 @@ bool CParticleMaterialDescMesh::InitFromRenderer(const CRendererDataMesh &render
}
else if ((m_Flags.m_ShaderVariationFlags & ShaderVariationFlags::Has_RigidVAT) != 0)
{
m_UseVertexColor = true;
const SRendererFeaturePropertyValue *rigid_PositionMap = renderer.m_Declaration.FindProperty(VertexAnimationRendererProperties::SID_VertexAnimation_Rigid_PositionMap());
if (rigid_PositionMap != null && !rigid_PositionMap->ValuePath().Empty())
m_Vat_PositionMap = CStringId(CFilePath::Purified(rigid_PositionMap->ValuePath()));
Expand Down Expand Up @@ -961,9 +966,9 @@ bool CUnityRendererCache::GetRendererInfo(SMeshRendererDesc &desc)
desc.m_DiffuseMap = m_MaterialDescMesh.m_DiffuseMap.ToStringData();
desc.m_InvSoftnessDistance = m_MaterialDescMesh.m_InvSoftnessDistance;
desc.m_AlphaClipThreshold = m_MaterialDescMesh.m_AlphaThreshold;
desc.m_DoubleSided = m_MaterialDescMesh.m_DoubleSided;
desc.m_DrawOrder = m_MaterialDescMesh.m_Flags.m_DrawOrder;
desc.m_TransformUVs_RGBOnly = m_MaterialDescBillboard.m_TransformUVs_RGBOnly ? ManagedBool_True : ManagedBool_False;
desc.m_TransformUVs_RGBOnly = m_MaterialDescMesh.m_TransformUVs_RGBOnly ? ManagedBool_True : ManagedBool_False;
desc.m_UseVertexColor = m_MaterialDescMesh.m_UseVertexColor ? ManagedBool_True : ManagedBool_False;

bool fluidVAT = (m_MaterialDescMesh.m_Flags.m_ShaderVariationFlags & ShaderVariationFlags::Has_FluidVAT) != 0;
bool softVAT = (m_MaterialDescMesh.m_Flags.m_ShaderVariationFlags & ShaderVariationFlags::Has_SoftVAT) != 0;
Expand Down
4 changes: 2 additions & 2 deletions Native/RenderingIntegration/UnityRendererCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,6 @@ class CParticleMaterialDescMesh
float m_Roughness;
float m_Metalness;

bool m_DoubleSided;

// VAT
CStringId m_Vat_PositionMap;
CStringId m_Vat_NormalMap;
Expand Down Expand Up @@ -232,6 +230,8 @@ class CParticleMaterialDescMesh
float m_AlphaThreshold;

bool m_TransformUVs_RGBOnly;
bool m_UseVertexColor;


// Should break batching (no batching for meshes right now so this is useless):
CStringId m_AtlasPath;
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Unity PopcornFX Plugin

Integrates the **PopcornFX Runtime SDK** into **Unity** as a Plugin.
* **Version:** `v2.18.5`
* **Version:** `v2.18.6`
* **Unity:** `2019.4` to `2022.x`
* **Platforms:** `Windows`, `Linux`, `MacOS`, `iOS`, `Android`, `PS4`, `XboxOne`, `Switch`.
[Contact-us](https://www.popcornfx.com/contact-popcornfx/) to request access to the plugin for consoles.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Unity PopcornFX Plugin
Integrates the **PopcornFX Runtime SDK** into **Unity** as a Plugin.
* **Version:** `v2.18.5`
* **Version:** `v2.18.6`
* **Unity:** `2019.4` to `2021.x`
* **Platforms:** `Windows`, `Linux`, `MacOS`, `iOS`, `Android`, `PS4`, `XboxOne`, `Switch`. [Contact-us](http://www.popcornfx.com/contact-us/) for more information.

Expand Down
2 changes: 1 addition & 1 deletion com.persistant-studios.popcornfx.hdrp/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Unity PopcornFX Plugin

Integrates the **PopcornFX Runtime SDK** into **Unity** as a Plugin.
* **Version:** `v2.18.5`
* **Version:** `v2.18.6`
* **Unity:** `2019.4` to `2022.x`
* **Platforms:** `Windows`, `Linux`, `MacOS`, `iOS`, `Android`, `PS4`, `XboxOne`, `Switch`.
[Contact-us](https://www.popcornfx.com/contact-popcornfx/) to request access to the plugin for consoles.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ MonoBehaviour:
m_MeshDiffuseColorPropertyName: _BaseColor
m_MeshEmissiveColorPropertyName: _EmissiveColor
m_MeshAlphaCursorPropertyName: _AlphaCursor
m_MeshCullingModePropertyName: _Cull
m_MeshVATCursorPropertyName: _VATCursor
m_VATPositionMapPropertyName: _VATPositionMap
m_VATNormalMapPropertyName: _VATNormalMap
Expand All @@ -43,11 +44,34 @@ MonoBehaviour:
m_VATBoundsPositionPropertyName: _VATBounds
m_VATPadToPowerOf2PropertyName: _VATPadToPowerOf2
m_VATPaddedRatioPropertyName: _VATPaddedRatio
m_SkeletalAnimTexturePropertyName: _SkeletalAnimTexture
m_SkeletalAnimTextureResolPropertyName: _SkeletalAnimTextureResol
m_SkeletalAnimCountPropertyName: _SkeletalAnimCount
m_SkeletalAnimUseBoneScalePropertyName: _SkeletalAnimUseBoneScale
m_SkeletalAnimCursor0PropertyName: _SkeletalAnimCursor0
m_SkeletalAnimIdx0PropertyName: _SkeletalAnimIdx0
m_SkeletalAnimCursor1PropertyName: _SkeletalAnimCursor1
m_SkeletalAnimIdx1PropertyName: _SkeletalAnimIdx1
m_SkeletalAnimTransitionPropertyName: _SkeletalAnimTransition
m_SkeletalAnimTranslationBoundsMinPropertyName: _SkeletalAnimTranslationBoundsMin
m_SkeletalAnimTranslationBoundsMaxPropertyName: _SkeletalAnimTranslationBoundsMax
m_SkeletalAnimScaleBoundsMinPropertyName: _SkeletalAnimScaleBoundsMin
m_SkeletalAnimScaleBoundsMaxPropertyName: _SkeletalAnimScaleBoundsMax
m_MeshTransformRow0PropertyName: _SkeletalMeshTransform0
m_MeshTransformRow1PropertyName: _SkeletalMeshTransform1
m_MeshTransformRow2PropertyName: _SkeletalMeshTransform2
m_MeshTransformRow3PropertyName: _SkeletalMeshTransform3
m_TextureAtlasPropertyName: _AtlasRects
m_AtlasCountPropertyName: _AtlasCount
m_AtlasIdPropertyName: _AtlasId
m_TransformUVsRGBOnlyPropertyName: _TransformUVs_RGBOnly
m_UseVertexColorPropertyName: _UseVertexColor
m_UseShader: 1
m_Shader: {fileID: -6465566751694194690, guid: 097cbbe54a212154e84c35ef4b48666f,
type: 3}
m_Material: {fileID: 2100000, guid: b2d3e622faad20245b5fc4781894e0f4, type: 2}
m_RenderTypes: 00000100
m_RenderTypes: 00000100000000
m_BlendMode: 000000000101
m_ShaderMask: 524207
m_SupportedShaderMask: 523695
m_MandatoryShaderMask: 0
m_BillboardingLocation: 0
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,14 @@ MonoBehaviour:
m_TextureAtlasPropertyName: _AtlasRects
m_AtlasCountPropertyName: _AtlasCount
m_AtlasIdPropertyName: _AtlasId
m_TransformUVsRGBOnlyPropertyName: _TransformUVs_RGBOnly
m_UseVertexColorPropertyName: _UseVertexColor
m_UseShader: 1
m_Shader: {fileID: -6465566751694194690, guid: ca078762f84b2d4498a7e9e6d37499d4,
type: 3}
m_Material: {fileID: 2100000, guid: b2d3e622faad20245b5fc4781894e0f4, type: 2}
m_RenderTypes: 00000100
m_RenderTypes: 00000100000000
m_BlendMode: 000000000101
m_DoubleSided: 1
m_SupportedShaderMask: 524207
m_MandatoryShaderMask: 0
m_MandatoryShaderMask: 512
m_BillboardingLocation: 0
Loading

0 comments on commit a9a2560

Please sign in to comment.