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

Unreal – Spawn Particle primarily based on Materials Parameter?


This has been requested previously, and I don’t suppose it’s potential however I’m bringing it up once more simply in case. Eager to spawn a particle on a mesh floor primarily based on a cloth 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 alter 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 how you can use them.

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


This shall be made higher sooner or later sometime, however for now you would in concept do that with slightly hacking.

Arrange your skelmesh you might be 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 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.

When you had, say, a black and white masks, this may provide you with 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 want.

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

ce8ca5996209c94152010268dedeb87dc3a04618



15 Likes

Finest hack i’ve heard up to now!
Good.

I’m largely catching what you’re saying. While 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 instrument 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 in a position to spawn at vertex positions on the mesh? (Versus wherever on a face)

How would possibly one accomplish this in UE/Niagara these days?

Can a separate/hidden masks channel be used one way or the other 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 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 the whole mesh.

How would possibly one accomplish this in UE/Niagara these days?

I’m very interested in an answer to this as nicely. I haven’t been in a position to determine this out alone.

Skeletal mesh location modules write uv’s to a transient parameter, so you should 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.

Apart 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 supplies the MeshUV Module Parameter akin to SampledUV within the [Skeletal Mesh Location] module. In actual fact, for those who bounce 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 good 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 might be achieved with a procedural texture (ie materials). The concept could be the identical in as far as you must pattern the UVs on the mesh, after which feed these UVs to the shader… which could be accomplished 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 may’t kill particles primarily based on shade as this isn’t the particles shade. So I’m questioning if there may be a approach to get that shade onto the particle so you may?

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

Nicely, the gpu particles are technically a shader, so you may simply recreate your materials in niagara. Most likely cheaper if the quantity of particles doesn’t exceed the texel rely of the rt.

Will this setup solely work for GPU particles? In that case, is there any sort 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 would like a piece round, skelMeshSample can pattern the vertex shade, so you may paint it in.



1 Like

Thanks! I’m guessing there’s additionally a approach to feed in a skel mesh’s normals right into a Niagara system too? In order that you would 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 kind output within the search of any vector enter area



1 Like

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

Would you thoughts clarify this slightly extra? how would I’m going about creating a cloth 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’ll be able to 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 on. When 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 would attempt, is utilizing the GBuffer. This can make it view dependent nonetheless.
I’ve accomplished this right here:

And Tharle VFX has a tutorial on it as nicely:



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 an enormous shader.
That is my dissolve map:

I attempted to recreate this within the Scratch Module, however I’m not fairly positive how you can get the feel to indicate up?

To this point 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 indicate the feel.
I do know this isn’t my aim, however is it potential to indicate 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 accurately, to realize what I needed 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 data in display area?

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments