Wednesday, November 29, 2023
HomeVisual EffectsUnreal - Spawn Particle based mostly on Materials Parameter?

Unreal – Spawn Particle based mostly on Materials Parameter?


This has been requested previously, and I don’t assume it’s attainable however I’m bringing it up once more simply in case. Eager to spawn a particle on a mesh floor based mostly on a fabric parameter. For instance if I’ve quad mesh with masks texture on the fabric, then I spawn particles from the floor of the quad the place it’s white and never the place it’s black. Wanting this to be dynamic, in order I modify the masks within the materials then the spawn factors observe appropriately.

The “Skel Vert/Surf Location” module with the “Inherit UV” parameter and utilizing “Dynamic Parameter” node within the materials appear promising however I don’t know methods to use them.

I do know this may be performed in PopcornFX, as I’ve performed it earlier than (undecided in regards to the dynamic materials half although), however my office is anti PopcornFX plugin (a type of, “It didn’t work this one time for what we wished so it’s now thought-about damaged eternally” conditions).


This will probably be made higher sooner or later sometime, however for now you possibly can in idea do that with a bit hacking.

Arrange your skelmesh you’re emitting from with a masks that maps to your UVs the way in which you need.
Make a system that reads from it utilizing skel vert/surf places.
Allow “inherit UV”.
In your particle, drop in a dynamic enter. Set the 0 and 1 entries to “spawn time solely” and “auto set”. Title them X and Y.
in your particle materials, put in your dynamic parameter and append the 0 and 1 (X and Y) collectively to make a UV.
Use that UV to pattern the identical masks texture your mesh is.

In the event you had, say, a black and white masks, this could offer you white particles the place the white elements are, and black particles for the black elements.

Then, do some logic within the vertex shader to break down any particles which might be totally black to 0,0,0 or one thing and let the GPU cull the degenerates. It’s a hack, however might work OK relying on counts and wish.

Going ahead we’ll make this type of factor worlds higher in Niagara, however for now with Cascade this could be the one strategy to accomplish it.

ce8ca5996209c94152010268dedeb87dc3a04618



15 Likes

Greatest hack i’ve heard to this point!
Good.

I’m largely catching what you’re saying. Whenever you say use the UV to pattern the identical masks texture because the mesh, do you imply, within the particle materials, simply plug within the appended XY dynamic parameter values within the UV’s of a Texture Pattern with the identical texture because the mesh masks?

Additionally, I’m not in a position to rename Param names of the Dynamic module within the particle system. It’s grayed out and the device tip says “Learn Solely” on the finish of the outline.

I’ve the particles spawning from the mesh, however every part else about it’s nonetheless damaged.

PS With the Skel Vert/Surf Location module (together with this hack) are particles solely in a position to spawn at vertex positions on the mesh? (Versus wherever on a face)

How may one accomplish this in UE/Niagara these days?

Can a separate/hidden masks channel be used by some means in order to not intrude with a meshes ‘hero’ supplies & UVs?

I haven’t discovered a lot reference, and have been poking round in a scratch module to see what I can provide you with, however the analog I’ve in my head is Houdini’s scatter by attribute, which bursts particles solely in a color-masked space, and never over all the mesh.

How may one accomplish this in UE/Niagara these days?

I’m very interested in an answer to this as properly. I haven’t been in a position to determine this out by myself.

Skeletal mesh location modules write uv’s to a transient parameter, so you need to use it to to pattern a textures (module additionally already exists) after which use a kill particles module with one thing like shade.x > .1 to take away particles.

Aside from that it’s the identical as what has been described earlier than.



2 Likes

Candy, thanks for the reply. Simply discovered this tut which explains exactly.

I solely want to do that on a StaticMesh, and the [Sample Static Mesh] Module gives the MeshUV Module Parameter akin to SampledUV within the [Skeletal Mesh Location] module. The truth is, in the event you leap into the corresponding Niagara Module Scripts you will notice they each use [Get Tri UV]. The [Sample Static Mesh] module outputs it as MeshUV whereas the [Skeletal Mesh Location] outputs it as SampledUV as a result of it has to trace the motion of of every Tri because the mesh animates/deforms (good ole bary centric coordinate maths)

Heh, so the catch right here is it’s worthwhile to pattern a picture map, and because you manually assign a texture to a mesh it presumes you’ll do the identical in Niagara. So I questioned if this type of sourcing could possibly be achieved with a procedural texture (ie materials). The concept can be the identical in as far as you need to pattern the UVs on the mesh, after which feed these UVs to the shader… which may be performed by plugging these sampled UVs right into a DynamicMaterialParameter.

Nonetheless, I consider that is designed to drive the fabric assigned to the SpriteRenderer so you’ll be able to’t kill particles based mostly on shade as this isn’t the particles shade. So I’m questioning if there is perhaps a strategy to get that shade onto the particle so you’ll be able to?

I suppose alternatively, one might periodically write out the fabric to a render goal and pattern that.

Properly, the gpu particles are technically a shader, so you’ll be able to simply recreate your materials in niagara. In all probability cheaper if the quantity of particles doesn’t exceed the texel rely of the rt.

Will this setup solely work for GPU particles? If that’s the case, is there any type of workaround for mesh particles? Like rocks or crystals spawning off a personality’s mesh within the course of the mesh’s normals, whereas utilizing a texture for his or her spawn location?

Niagara mesh particles can use gpu compute sims if I’m not mistaken.
If you need a piece round, skelMeshSample can pattern the vertex shade, so you’ll be able to paint it in.



1 Like

Thanks! I’m guessing there’s additionally a strategy to feed in a skel mesh’s normals right into a Niagara system too? In order that you possibly can level non-square sprites or geo in the identical course because the mesh face or vert regular?

Yeah, the skelmesh sampler modules has it as an output, simply sort output within the search of any vector enter area



1 Like

Thanks once more, I recognize all the information and recommendation :slight_smile: I’ll undoubtedly bookmark these for later, in case I overlook :+1:

Would you thoughts clarify this a bit extra? how would I am going about creating a fabric inside Niagara? as a scratch module? I’m attempting to spawn customized particles from the perimeters of a dissolving mesh and I’m having a tough time masking out every part however the edge. Any ideas?

Sure, in scratchpad. You possibly can mainly simply re-create the very same logic that you’re doing within the shader to dissolve the mesh, however in Niagara. Niagara may also pattern textures and so on. In the event you want particular assist about it, submit your dissolve shader logic right here and we will rebuild it in Niagara collectively :slight_smile:

One other methodology you possibly can attempt, is utilizing the GBuffer. This can make it view dependent nonetheless.
I’ve performed this right here:

And Tharle VFX has a tutorial on it as properly:



2 Likes

Thanks for the reply and the supply to assist!
I put this collectively actual fast because the dissolve I used to be utilizing was in a giant shader.
That is my dissolve map:

I attempted to recreate this within the Scratch Module, however I’m not fairly positive methods to get the feel to point out up?

Up to now this simply change the colour base on the Dynamic parameter.
I attempted trying in initialized particle module, however I didn’t see any helpful clue to point out the feel.
I do know this isn’t my purpose, however is it attainable to point out a texture on a sprite with the scratch module?

Within the tutorial you linked, he sampled a mesh after which map the feel to it to spawn the particle from, is that this a should?
If I perceive it appropriately, to realize what I wished within the first place I ought to mix the pattern mesh+texture after which add within the dissolve perform and the kill particles factor, proper?
Btw, is GBuffer one thing that’s built-in for Unreal/Unity? It’s like a spot the place I can learn shading associated information in display house?

I’ve discovered time to have performed it. It was easier than I believed. :smiley:
SkullDissolveWithEdgeParticles

It finally ends up being a mix of three emitters.

1 for the primary texture that dissolves, 1 to spawn particles on the sting of the dissolve, and 1 to spawn particles from these particles as a result of to be able to dissolve the the primary two on the identical price, they should have the identical loop period or all of the particles dies on the finish of the loop.
So I did find yourself having to pattern a mesh to make use of it as a spawn location, after which I simply use a customized scratch module that’s basically the mixture of kill particles and pattern texture (use UV of mesh to take action) with the dissolve impact I wished.

Please lmk if there’s something I ought to do to enhance/optimize this!



1 Like

Appears to be like nice! I’m glad you discovered a means to do that. That’s just about the answer I had in thoughts :slight_smile:

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments