Spawning particles on dissolved edges of a quad texture

Hi everyone! As stated on the title, I’m trying to spawn some particles only on the edges of a dissolved mesh (a quad to be more exactly).

So, let me put you in situation.

I have this nice portal, made using ShaderGraph. It mostly consist of the default-particle sprite to which I apply some noise and uv’s deformation (twirl and so on). After that, I’m able to create the edges (the whitest gloom you can see on the picture). So far, so good.

Now, the issue comes with spawning some particles only on those edges, preferably using VFX Graph (I’m also using URP if that might help).

From what I understood, there are a few ways I could get this done.
Inside VFXGraph, I tried to recreate the nodes from the shadergraph edges (removing the twirl and stuff, leaving only the texture), however, due to the Quad uv’s and/or something faulty on the texture, I’m unable to render the particles on the desired place or not showing at all.
I tried following this discussion to get it done: Spawn particles on dissolving edges - #2 by OrsonFavrel
But I think my issue here is due to the mesh being a quad, and therefore it has only 2 triangles and making everything harder :confused:

With no locuk implementing this approach, I procceeded with the following one: Is there a way to have particles spawn only within the alpha of a referenced texture?

Also, with no luck at all. The issues with this approach are mainly that the texture gets tilled, therefore I see the pattern repeatead all over the quad, and I’m unable to reject the particle (it appears black and white) all over the quad without being masked.

So, I went along and tried a different, more messy, approach.
I created a new camera (let’s call it DepthCamera) which only renders into a layer (DepthOnlyLayer). I made a new shadergraph that outputs only the dissolved edges from the portal, making it so that the camera sees white where the dissolve edges are, and black on the rest of the screen.
With this setup, I went to VFXGraph, grabbed the depthCamera (using the property binder as to ensure the VFXGraph access it properly), but here comes the issue now: when I try to set the position of the particles along the depth, 2 things happens → The particles are all over the screen, or, they don’t take into account the alpha cutout of the quad, making it so that the particles appear in the whole quad instead of only the edges or that they appear far in the horizon.
I also tried using the color buffer instead of the depth buffer, however I can’t seem to find a way to mask by its colors, like where the color is white, spawn particles and where is black, don’t spawn or kill or set unalive.

So currently I’ve been stuck a few days over this with no luck at all. If anyone knows anything, has any feedback or simply want to coment about it, feel free to do it.

Also, let me know if you need any more info, screenshots or anything so I can help you better to help me, thanks everyone and keep on coding!

So noone has any feedback regarding it? It seems to be a real use of VFX to spawn on the edges, however I couldn’t manage to get it work :C

For anyone coming upon this.
As a workaround, I just made it so the VFXGraph uses DepthCollision, and I put the particles behind the quad. So when the particles collide with the quad the bounce and set their life to 0.

Still, would appreciate if nyone has something to offer :C

Hi!

Sorry, we somehow missed this post.

I’m not sure if I followed correctly, but I think it could be that your portal is writing to the depth buffer even for the fully transparent pixels.

This is the default behavior, but you can use alpha clipping in your portal shader to discard every pixel under a certain threshold (a very small threshold would work better for you).

It would help if you posted an image of the issue and the graph.

Cheers!

This effect is so cool, how did you make it?

Hey! Sorry for the delay!
So basically what I did is make a shader on shadergraph (to get the dissolve and spiral effect, bloom, etc) and add it to a quad.
Then using a render texture from another “world” inside the game, like another map placed far from the user (underground per example, where he can’t see it) and just use another camera to capture the render texture and pass it to the shader.
Then is a question of using screen uvs and adapt the matrix projection of the second camera for a better portal effect.

Another way you could do this is by using stencil maks, but that didn’t work for me cause it would give me other headaches (the mesh can’t be transparent for example, so I would lose the dissolve effect) and it was a mess of editing de render pipeline to draw it properly.

So yeah, you can check on youtube, there are plenty of videos regarding portals in Unity, I specially recommend the approach from Sebastian Lague or Brackeys: