Monday, December 4, 2023
HomeVisual EffectsUnreal - Spawn Particle primarily based on Materials Parameter?

Unreal – Spawn Particle primarily based on Materials Parameter?


This has been requested prior to now, 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 primarily based 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 easy methods to use them.

I do know this may be completed in PopcornFX, as I’ve completed 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 likely be made higher sooner or later sometime, however for now you may in principle do that with a bit 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 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 components are, and black particles for the black components.

Then, do some logic within the vertex shader to break down any particles which are totally 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 type of factor worlds higher in Niagara, however for now with Cascade this could be the one technique to accomplish it.

ce8ca5996209c94152010268dedeb87dc3a04618



15 Likes

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

I’m largely catching what you’re saying. Once 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 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 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 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 all the mesh.

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

I’m very interested by an answer to this as effectively. 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 colour.x > .1 to take away particles.

Apart 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. Actually, if you happen to bounce 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 it’s essential 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 may very well be achieved with a procedural texture (ie materials). The thought could be the identical in as far as it’s a must to pattern the UVs on the mesh, after which feed these UVs to the shader… which could be completed by plugging these sampled UVs right into a DynamicMaterialParameter.

Nevertheless, I imagine that is designed to drive the fabric assigned to the SpriteRenderer so you may’t kill particles primarily based on colour as this isn’t the particles colour. So I’m questioning if there is perhaps a technique to get that colour onto the particle so you may?

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

Effectively, 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 form 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 colour, so you may paint it in.



1 Like

Thanks! I’m guessing there’s additionally a technique to feed in a skel mesh’s normals right into a Niagara system too? In order that you may 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 discipline



1 Like

Thanks once more, I respect all the data and recommendation :slight_smile: I’ll undoubtedly bookmark these for later, in case I neglect :+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 making an attempt 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 pattern textures and many others. In the event you want particular assist about it, publish your dissolve shader logic right here and we will rebuild it in Niagara collectively :slight_smile:

One other technique you may strive, 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 effectively:



2 Likes

Thanks for the reply and the provide to assist!
I put this collectively actual fast for the reason that 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 certain easy methods to get the feel to point out up?

To date this simply change the colour base on the Dynamic parameter.
I attempted wanting in initialized particle module, however I didn’t see any helpful clue to point out the feel.
I do know this isn’t my aim, 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 screen area?

I’ve discovered time to have completed it. It was simpler than I assumed. :smiley:
SkullDissolveWithEdgeParticles

It finally ends up being a mix of three emitters.

1 for the principle 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 so as to dissolve the the primary two on the similar charge, they should have the identical loop length 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!

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments