PKFxSettings V3

From PopcornFX
Jump to navigation Jump to search
Unity-logo-g.png

UnityPopcornFXSettings V3.png

Asset used to choose the settings for the PopcornFX plugin. It's located by default at Assets/PopcornFX/Resources/PKFxSettings but can be in any Resources folder.
You can also access it with the menu item | Edit > Project Settings > PopcornFX

Enable soft particles

Enable/Disable soft particles and allow to use post effects on the PKFxRenderingPlugin_component

Enable File log

Enables/Disables PopcornFX log in a popcorn.htm file at the project's root.

Enable unsafe code

Enables/Disables unsafe code needed for PopcornFX events and raycast collisions.
It will activate the "Allow unsafe code" checkbox and add the define PK_UNSAFE_CODE_ENABLED to the "Scripting Define Symbols" in the Player's Project Settings.

Enable raycast for collisions

Enables/Disables raycast for the collisions instead of the static mesh set with SceneMeshPkmmPath. Those raycasts are emitted by the C# to the Unity engine and are a lot slower than the one for the static meshes.

Impact performance.

Split the draw calls of the particles that require disabling back-face culling

Enable/Disables the split of the draw calls to disable back-face culling.

Run PopcorFX on a single thread to avoid visual studio hangs

Enables/Disables single thread to avoid visual studio hangs while debugging (see Visual Studio hangs: https://docs.microsoft.com/en-us/visualstudio/cross-platform/troubleshooting-and-known-issues-visual-studio-tools-for-unity).

Asset used to create the materials for the particles

See PKFxMaterialFactory.

Automatic mesh resizing to avoid dynamic re-alloc during the next run

Unity has a huge performance issue when retrieving the native handlers on the mesh buffers (see https://docs.unity3d.com/ScriptReference/Mesh.GetNativeVertexBufferPtr.html) As we need to retrieve those handlers every time the meshes are resized, and as we cannot guess how many particles will be spawned in each mesh, we need an estimation of the total number of particles that will be spawned in the Unity project.

To do that, we implemented a counter in the PKFxSettings that will keep track of the most particles spawned per Unity mesh. If you enable this option, during the next play in editor mode, the number of particles will be recorded.

So to avoid lags in your game, make sure to check this option and run through all your scenes. This option does not change anything once the project is build.

Vertex buffer size multiplicator

The size multiplicators are used to avoid resizing the meshes buffers too often.

The formula to compute the vertex buffer size for a mesh is the following:

BufferVertexCount = ParticleCount * VertexPerParticle + VertexBufferSizeMultiplicator * ParticleCount * VertexPerParticle

Lets say that you have a Unity mesh which holds at most 10 regular billboard particles, if your vertex buffer size multiplicator is 0.5, the mesh will be resized to hold 10 + 0.5 * 10 = 15 particles, which means that if more particles spawn later on, the mesh will not have to resize until at least 5 more particles are spawned.

Index buffer size multiplicator

Exactly the same thing as the vertex buffer size multiplicator, but applied to the index count of the meshes. Generally, you should try to set the same value in both multiplicators.