Monday, December 4, 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 suppose it’s attainable however I’m bringing it up once more simply in case. Desirous 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 comply with 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 how one can use them.

I do know this may be completed in PopcornFX, as I’ve completed it earlier than (unsure concerning 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 needed so it’s now thought-about damaged without end” conditions).


This shall be made higher sooner or later sometime, however for now you might in idea do that with somewhat hacking.

Arrange your skelmesh you’re emitting from with a masks that maps to your UVs the best way you need.
Make a system that reads from it utilizing skel vert/surf areas.
Allow “inherit UV”.
In your particle, drop in a dynamic enter. Set the 0 and 1 entries to “spawn time solely” and “auto set”. Identify 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 provide you with white particles the place the white components are, and black particles for the black components.

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

Going ahead we’ll make this sort 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 date!
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 capable of 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 all the things else about it’s nonetheless damaged.

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

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

Can a separate/hidden masks channel be used in some way in order to not intervene 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 give you, 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 your entire mesh.

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

I’m very interested by an answer to this as nicely. I haven’t been capable of determine this out alone.

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 similar 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 offers the MeshUV Module Parameter akin to SampledUV within the [Skeletal Mesh Location] module. In reality, in the event you soar into the corresponding Niagara Module Scripts you will note 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 you’ll want 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 sort of sourcing could possibly be achieved with a procedural texture (ie materials). The concept could 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 might be completed 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 could be a strategy to get that shade onto the particle so you’ll be able to?

I suppose alternatively, one may 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 depend of the rt.

Will this setup solely work for GPU particles? In that case, is there any type of workaround for mesh particles? Like rocks or crystals spawning off a personality’s mesh within the route 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’d like 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 might level non-square sprites or geo in the identical route because the mesh face or vert regular?

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



1 Like

Thanks once more, I recognize all the data and recommendation :slight_smile: I’ll positively bookmark these for later, in case I neglect :+1:

Would you thoughts clarify this somewhat extra? how would I am going about creating a fabric inside Niagara? as a scratch module? I’m making an attempt to spawn customized particles from the perimeters of a dissolving mesh and I’m having a tough time masking out all the things 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 can even pattern textures and so forth. In the event you want particular assist about it, submit your dissolve shader logic right here and we are able to rebuild it in Niagara collectively :slight_smile:

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

And Tharle VFX has a tutorial on it as nicely:



1 Like

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments