Skip to content

Commit

Permalink
UnityPlugin: Release 2.20.3
Browse files Browse the repository at this point in the history
  • Loading branch information
PopcornFX Bot committed Oct 24, 2024
1 parent 7324b26 commit 05635a4
Show file tree
Hide file tree
Showing 92 changed files with 159,806 additions and 17,540 deletions.
3 changes: 3 additions & 0 deletions Native/EditorOnly/BrowseEffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
#include <pk_render_helpers/include/draw_requests/rh_billboard.h>

__PK_API_BEGIN
#if !defined(PK_RETAIL)
//----------------------------------------------------------------------------

// Check if the mirrored enum in the C# for the attribute types is up to date:
Expand Down Expand Up @@ -768,4 +769,6 @@ bool CEffectBrowser::BrowseSamplers(const CParticleAttributeList *attribList)
}

//----------------------------------------------------------------------------
#endif // !defined(PK_RETAIL)
__PK_API_END

29 changes: 29 additions & 0 deletions Native/ImplemGraphicsAPI/RenderAPI_Data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ SFlagsToUseSemantic flagsToUseSemantic[__Semantic_Count] =
{ 0U, ShaderVariationFlags::Has_Emissive }, // Semantic_EmissiveColor
{ 0U, ShaderVariationFlags::Has_TransformUVs }, // Semantic_TransformUvsRotate
{ 0U, ShaderVariationFlags::Has_TransformUVs }, // Semantic_TransformUvsScaleAndOffset
{ ShaderVariationFlags::Has_TransformUVs, ShaderVariationFlags::Has_AlphaMasks }, // Semantic_AlphaMasksCursors
{ ShaderVariationFlags::Has_TransformUVs, ShaderVariationFlags::Has_UVDistortions }, // Semantic_UVDistortionCursors
{ ShaderVariationFlags::Has_TransformUVs | ShaderVariationFlags::Has_AlphaRemap, ShaderVariationFlags::Has_Dissolve }, // Semantic_DissolveCursor
};

u32 semanticSize[__Semantic_Count] =
Expand All @@ -158,6 +161,10 @@ u32 semanticSize[__Semantic_Count] =
4 * sizeof(float), // Semantic_EmissiveColor
1 * sizeof(float), // Semantic_TransformUvsRotate
4 * sizeof(float), // Semantic_TransformUvsScaleAndOffset
2 * sizeof(float), // Semantic_AlphaMasksCursors
2 * sizeof(float), // Semantic_UVDistortionsCursors
1 * sizeof(float), // Semantic_DissolveCursor
2 * sizeof(float), // Semantic_RawUv0
};

//----------------------------------------------------------------------------
Expand Down Expand Up @@ -321,6 +328,28 @@ u32 FillOffsetTableAndGetVertexBufferStride(u32 offsetTable[__Semantic_Count], u
offsetTable[Semantic_TransformUVsScaleAndOffset] = vertexOffset;
vertexOffset += semanticSize[Semantic_TransformUVsScaleAndOffset];
}
if ((shaderVariationFlags & ShaderVariationFlags::Has_AlphaMasks) != 0)
{
offsetTable[Semantic_AlphaMasksCursors] = vertexOffset;
vertexOffset += semanticSize[Semantic_AlphaMasksCursors];
}
if ((shaderVariationFlags & ShaderVariationFlags::Has_UVDistortions) != 0)
{
offsetTable[Semantic_UVDistortionsCursors] = vertexOffset;
vertexOffset += semanticSize[Semantic_UVDistortionsCursors];
}
if ((shaderVariationFlags & ShaderVariationFlags::Has_Dissolve) != 0)
{
offsetTable[Semantic_DissolveCursor] = vertexOffset;
vertexOffset += semanticSize[Semantic_DissolveCursor];
}
if ((shaderVariationFlags & ShaderVariationFlags::Has_Atlas) != 0 &&
(shaderVariationFlags & (ShaderVariationFlags::Has_AlphaMasks | ShaderVariationFlags::Has_UVDistortions | ShaderVariationFlags::Has_Dissolve)) != 0)
{
offsetTable[Semantic_RawUv0] = vertexOffset;
vertexOffset += semanticSize[Semantic_RawUv0];
}

return vertexOffset;
}

Expand Down
34 changes: 34 additions & 0 deletions Native/ImplemGraphicsAPI/RenderAPI_Data.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ enum EVertexSemantic
Semantic_TransformUVsRotate,
Semantic_TransformUVsScaleAndOffset,

Semantic_AlphaMasksCursors,
Semantic_UVDistortionsCursors,
Semantic_DissolveCursor,
Semantic_RawUv0,

__Semantic_Count
};

Expand Down Expand Up @@ -218,6 +223,14 @@ PK_INLINE void FillUV1(void * const stream, volatile void * const dstPtr, const

//-------------------------------------------------------------------------------------

PK_INLINE void FillRawUV0(void * const stream, volatile void * const dstPtr, const u32(&offsetTable)[__Semantic_Count])
{
volatile void *dst = Mem::AdvanceRawPointer(dstPtr, offsetTable[Semantic_RawUv0]);
*(CFloat2*)dst = *(const CFloat2*)stream;
}

//-------------------------------------------------------------------------------------

PK_INLINE void FillAtlasId(void * const stream, volatile void * const dstPtr, const u32(&offsetTable)[__Semantic_Count])
{
volatile void *dst = Mem::AdvanceRawPointer(dstPtr, offsetTable[Semantic_AtlasId]);
Expand Down Expand Up @@ -250,5 +263,26 @@ PK_INLINE void FillTransformUVsScaleAndOffset(void * const streamScale, void * c
*(CFloat2*)dst = *(const CFloat2*)streamOffset;
}

PK_INLINE void FillAnimatedMaskedCursors(void * const streamOne, void * const streamTwo, volatile void * const dstPtr, const u32(&offsetTable)[__Semantic_Count])
{
volatile void *dst = Mem::AdvanceRawPointer(dstPtr, offsetTable[Semantic_AlphaMasksCursors]);
*(float*)dst = *(const float*)streamOne;
dst = Mem::AdvanceRawPointer(dst, sizeof(float));
*(float*)dst = *(const float*)streamTwo;
}

PK_INLINE void FillUVDistortionsCursors(void * const streamOne, void * const streamTwo, volatile void * const dstPtr, const u32(&offsetTable)[__Semantic_Count])
{
volatile void *dst = Mem::AdvanceRawPointer(dstPtr, offsetTable[Semantic_UVDistortionsCursors]);
*(float*)dst = *(const float*)streamOne;
dst = Mem::AdvanceRawPointer(dst, sizeof(float));
*(float*)dst = *(const float*)streamTwo;
}

PK_INLINE void FillDissolveCursor(void * const stream, volatile void * const dstPtr, const u32(&offsetTable)[__Semantic_Count])
{
volatile void *dst = Mem::AdvanceRawPointer(dstPtr, offsetTable[Semantic_DissolveCursor]);
*(float*)dst = *(const float*)stream;
}
#undef SIMDFY
//-------------------------------------------------------------------------------------
150 changes: 130 additions & 20 deletions Native/NativeToManaged.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,39 +38,116 @@ extern "C"
}
};


struct SRenderingFeatureAlphaMasksDesc
{
const char *m_AlphaMasks1Map;
const char *m_AlphaMasks2Map;
float m_AlphaMasks1Intensity;
float m_AlphaMasks2Intensity;
float m_AlphaMasks1Weight;
float m_AlphaMasks2Weight;
CFloat2 m_AlphaMasks1Scale;
CFloat2 m_AlphaMasks2Scale;
float m_AlphaMasks1RotationSpeed;
float m_AlphaMasks2RotationSpeed;
CFloat2 m_AlphaMasks1TranslationSpeed;
CFloat2 m_AlphaMasks2TranslationSpeed;

SRenderingFeatureAlphaMasksDesc()
: m_AlphaMasks1Map(null)
, m_AlphaMasks2Map(null)
, m_AlphaMasks1Intensity(0.f)
, m_AlphaMasks2Intensity(0.f)
, m_AlphaMasks1Weight(0.f)
, m_AlphaMasks2Weight(0.f)
, m_AlphaMasks1Scale(CFloat2(0.f, 0.f))
, m_AlphaMasks2Scale(CFloat2(0.f, 0.f))
, m_AlphaMasks1RotationSpeed(0.f)
, m_AlphaMasks2RotationSpeed(0.f)
, m_AlphaMasks1TranslationSpeed(CFloat2(0.f, 0.f))
, m_AlphaMasks2TranslationSpeed(CFloat2(0.f, 0.f))
{
}
};

struct SRenderingFeatureUVDistortionsDesc
{
const char *m_UVDistortions1Map;
const char *m_UVDistortions2Map;
float m_UVDistortions1Intensity;
float m_UVDistortions2Intensity;
CFloat2 m_UVDistortions1Scale;
CFloat2 m_UVDistortions2Scale;
float m_UVDistortions1RotationSpeed;
float m_UVDistortions2RotationSpeed;
CFloat2 m_UVDistortions1TranslationSpeed;
CFloat2 m_UVDistortions2TranslationSpeed;

SRenderingFeatureUVDistortionsDesc()
: m_UVDistortions1Map(null)
, m_UVDistortions2Map(null)
, m_UVDistortions1Intensity(0.f)
, m_UVDistortions2Intensity(0.f)
, m_UVDistortions1Scale(CFloat2(0.f, 0.f))
, m_UVDistortions2Scale(CFloat2(0.f, 0.f))
, m_UVDistortions1RotationSpeed(0.f)
, m_UVDistortions2RotationSpeed(0.f)
, m_UVDistortions1TranslationSpeed(CFloat2(0.f, 0.f))
, m_UVDistortions2TranslationSpeed(CFloat2(0.f, 0.f))
{
}
};

struct SRenderingFeatureDissolveDesc
{
const char *m_DissolveMap;
float m_DissolveSoftness;

SRenderingFeatureDissolveDesc()
: m_DissolveMap(null)
, m_DissolveSoftness(0.f)
{
}
};

// Create Renderers:
// Billboards and ribbons:
struct SPopcornRendererDesc
{
const char *m_CustomName;
const char *m_CustomName;

int m_ShaderVariationFlags;
int m_BlendMode;
ManagedBool m_IsLegacy;
ManagedBool m_RotateUvs;
int m_ShaderVariationFlags;
int m_BlendMode;
ManagedBool m_IsLegacy;
ManagedBool m_RotateUvs;

const char *m_DiffuseMap;
const char *m_EmissiveMap;
const char *m_AlphaRemap;
const char *m_DiffuseRampMap;
const char *m_EmissiveRampMap;
float m_InvSoftnessDistance;
float m_AlphaClipThreshold;
ManagedBool m_TransformUVs_RGBOnly;
const char *m_DiffuseMap;
const char *m_EmissiveMap;
const char *m_AlphaRemap;
const char *m_DiffuseRampMap;
const char *m_EmissiveRampMap;

int m_BillboardMode;
int m_DrawOrder;
float m_InvSoftnessDistance;
float m_AlphaClipThreshold;
ManagedBool m_TransformUVs_RGBOnly;

SRenderingFeatureLitDesc *m_LitRendering;
int m_BillboardMode;
int m_DrawOrder;

int m_CameraID;
unsigned int m_UID;
SRenderingFeatureLitDesc *m_LitRendering;
SRenderingFeatureAlphaMasksDesc *m_AlphaMasks;
SRenderingFeatureUVDistortionsDesc *m_UVDistortions;
SRenderingFeatureDissolveDesc *m_Dissolve;

int m_CameraID;
int m_UID;

SPopcornRendererDesc()
: m_CustomName(null)
, m_ShaderVariationFlags(0)
, m_BlendMode(0)
, m_IsLegacy(ManagedBool_True)
, m_IsLegacy(ManagedBool_False)
, m_RotateUvs(ManagedBool_False)
, m_DiffuseMap(null)
, m_EmissiveMap(null)
Expand All @@ -83,10 +160,28 @@ extern "C"
, m_BillboardMode(0)
, m_DrawOrder(0)
, m_LitRendering(null)
, m_AlphaMasks(null)
, m_UVDistortions(null)
, m_Dissolve(null)
, m_CameraID(0)
, m_UID(0)
{
}

~SPopcornRendererDesc()
{
PK_SAFE_DELETE(m_LitRendering);
m_LitRendering = null;

PK_SAFE_DELETE(m_AlphaMasks);
m_AlphaMasks = null;

PK_SAFE_DELETE(m_UVDistortions);
m_UVDistortions = null;

PK_SAFE_DELETE(m_Dissolve);
m_Dissolve = null;
}
};

struct SRenderingFeatureVATDesc
Expand Down Expand Up @@ -197,6 +292,9 @@ extern "C"
SRenderingFeatureLitDesc *m_LitRendering;
SRenderingFeatureVATDesc *m_VatRendering;
SRenderingFeatureSkeletalAnimDesc *m_AnimDescRendering;
SRenderingFeatureAlphaMasksDesc *m_AlphaMasks;
SRenderingFeatureUVDistortionsDesc *m_UVDistortions;
SRenderingFeatureDissolveDesc *m_Dissolve;

int m_TextureAtlasCount;
CFloat4 *m_TextureAtlas;
Expand All @@ -212,7 +310,7 @@ extern "C"
, m_MeshAsset(null)
, m_ShaderVariationFlags(0)
, m_BlendMode(0)
, m_IsLegacy(ManagedBool_True)
, m_IsLegacy(ManagedBool_False)
, m_HasMeshAtlas(ManagedBool_False)
, m_DiffuseMap(null)
, m_EmissiveMap(null)
Expand All @@ -224,6 +322,9 @@ extern "C"
, m_LitRendering(null)
, m_VatRendering(null)
, m_AnimDescRendering(null)
, m_AlphaMasks(null)
, m_UVDistortions(null)
, m_Dissolve(null)
, m_TextureAtlasCount(0)
, m_TextureAtlas(null)
, m_UID(0)
Expand All @@ -244,6 +345,15 @@ extern "C"
PK_SAFE_DELETE(m_AnimDescRendering);
m_AnimDescRendering = null;

PK_SAFE_DELETE(m_AlphaMasks);
m_AlphaMasks = null;

PK_SAFE_DELETE(m_UVDistortions);
m_UVDistortions = null;

PK_SAFE_DELETE(m_Dissolve);
m_Dissolve = null;

PK_FREE(m_TextureAtlas);
m_TextureAtlas = null;
}
Expand Down
Loading

0 comments on commit 05635a4

Please sign in to comment.