0 like 0 dislike

I have multiple cameras set up with PK Fx Rendering Plugins.

I'm trying to have it so that:

  • Some VFX in front
  • Some UI stuff
  • Some VFX in back

However, I'm running into an issue where all of the VFX get drawn on the front-most camera. This seems like a bug?

Visually, it currently looks like this: https://i.imgur.com/QjckwKT.jpg

However, I want it to look like this instead: https://i.imgur.com/sDPj3UO.jpg

In other words, I want the yellow crescent VFX to be behind the "Granddaddy" card, but the orange fiery stuff to be in front. These are placeholder effects for debugging of course :)

Update 1: I confirmed the issue is with PopcornFX by rendering the same scene, but instead of using Popcorn FX particles, I used cubes:

You can see that the top cube row is correctly behind the card layer, and the bottom cube row is in-front. The issue is that PopcornFX is rendering the FX on the 'behind' layer, on top, when it shouldn't.


Update 2: Just to rule out any possibility that my UI implementation was causing issues, I reproduced the same issue using only GameObjects.

https://i.imgur.com/rYjTLlx.png (Cubes are rendered properly - top row blocked by the blue box, bottom row is on top)

https://i.imgur.com/KHd9Lic.png (PopcornFX renders on top of the blue box, which is wrong)

by Lisk (230 points)

1 Answer

1 like 0 dislike

Hello lisk,

You should be able to render particles on different camera, the only limitation we have right now is that all the particles will be aligned with the main camera in your scene.

To do this, you will need to change the layer of the meshes containing the particle geometry.

This is a little bit tricky:

  • Open the PKFxMaterialFactoryDefault.cs or PKFxMaterialFactoryHDRP.cs if you are using HDRP
  • Here you will find a SetupRenderer method that takes the following parameters:
    • batchDesc which is a description of the renderer being created (if 2 renderers are exactly the same, they are batched together)
    • gameObject which is the GameObject containing the particle mesh
    • meshRenderer which is the actual mesh renderer for the particles

So in this method, you can change the layer of the game object. This is what is already done for the distortion particles.

How to identify which effects to set on which layer?

I think the best way to do this is to change the "Draw Order" on the PopcornFX renderers to make sure it is different between the particles you want on top of the UI and the ones you want in the background.

Then you should be able to do something like that in the SetupRenderer method:

if (batchDesc.m_DrawOrder == -42) // We know that -42 means in the background
gameObject.layer = 5; // Background camera renders layer 5
if (batchDesc.m_DrawOrder == 42) // We know that 42 means on top of UI
gameObject.layer = 6; // Camera on top of UI renders layer 6

This is not an ideal solution and we are working on being able to easily set custom material on particles which might make all of this a little easier in the future.

Hope this helps!


by Paul (8k points)
Hi Paul, thank you for the detailed reply. I really appreciate it.

Unfortunately, I can't find the PKFxMaterialFactoryDefault file.

I should have specified in the original post that I am on this PopcornFX version:
2.9p9 for Unity 5.2 and up

I apologize for not specifying earlier!

My project is still running on Unity 5.4.5f1 since we had issues with upgrading to newer versions of Unity since they caused freezes related to PopcornFX.
Paul will probably elaborate better, and know if there's a solution or not, but apparently this is a pretty old version of the plugin that did not yet support rendering via the Unity pipeline, and where all rendering had to be done internally to the plugin using raw DirectX or OpenGL commands.

Perhaps there's still a way to tell that version of the plugin to render in multiple passes.
Otherwise you'll have to upgrade to a newer version.
Hi Julien, thanks for the reply. Do you know if there is a later version of the plugin that still supports Unity 5.4.5f1? Last time I tried to update, I think the new versions of PopcornFX required Unity 2017+.

Looking forward to Paul's response!
Hi @paulbaron7993 - just wondering if you have any updates on this? It's an important feature for us.
Hello Lisk,

Sorry for the late answer.
I digged a bit in the plugin code and as Julien said, there is sadly no way to achieve that with the version of the plugin that you are using.

The plugin you are using is the last one we released before reforging most of the code and workflow to use Unity's rendering pipeline and not just draw the particles on top of Unity's rendering.

Here are some resources that might help you understand the limitations of the plugin you are currently using:

How the plugin interacts with Unity's rendering pipeline:
How to change in which pass the particles are drawn:

The later versions of the plugin uses features from Unity 2019.

The main issue is that all the PopcornFX assets changed their format and we also changed the interface of the emitter component. We provide an upgrader to patch the PKFxFX component references in Unity's scenes and prefabs but it hasn't been tested for a while and there are some stuffs you will need to patch manually in your project.

If you choose to upgrade, I can send you the latest version of the plugin and guide you though the upgrade process, just drop an email at support@popcornfx.com so that we can send you all the necessary resources.

Hope this helps,
Hi Paul, thanks for the follow-up. I understand the differences now, and it definitely makes sense that you rewrote the plugin to use the Unity rendering pipeline. I'll try to come up with some workarounds in the meantime, then in the future I'll look to upgrading to the latest plugin/Unity.

I very much appreciate the offer to help me upgrade in the future, though it'll still probably be a year away from now.