[Niagara 5.0] Mesh Array Mini Tutorial

Niagara Mesh Array Mini Tutorial

ArrayExample
Example Use

MeshArray

Mesh array is a super useful tool in Niagara for displaying different meshes on different particles within the same emitter.

It can be used together with mesh flipbooks to create mesh animations or to optimize emitter count (with some caveats)

It looks somewhat complicated, but It’s actually really straightforward so hopefully this can serve as a resource to get you started.


SETUP

In the Render section, click + and add a new Mesh Renderer
image

Then in the Mesh Renderer, scroll down to the Meshes Array, and add a few using the + button.

You can change the per mesh size, rotation and offset in here as well

You can also select a StaticMesh Object User Parameter from here if you want to dynamically change the mesh from BP. (Unfortunately it’s not quite possible to pass in an array of meshes)


USE

Once you have it setup like this, you can now select which mesh to show by using the MeshIndex[int32] parameter.

You can set it directly from InitializeParticle in the MeshAttributes section

Or you can set it manually using a set node


MESH FLIPBOOK

This function in the mesh renderer can be used to easily import a set of meshes.
Although the naming required to get it to work is specific.
You’ll want to name your meshes with a suffix, like [_001] [_002] [_003] etc…

Then in the mesh renderer go to MeshFlipbook and enable it (careful it will remove the existing ones).

Next set the following inputs to respectively the first mesh in your sequence, the format (image is setup for _xxx), and the amount of meshes you have in total

The meshes array will automatically be filled with the meshes from your sequence

If you want to animate the sequence you can, for example, use SubUVAnimation Node + setter node to convert from float to int32. (Or write your own module)


EXTRA

Be careful not too use too many different meshes, keep in mind that each mesh will need to be loaded and rendered separately. Use STAT Niagara [Get Dynamic Mesh Elements] etc. to profile.

On the other hand, Niagara can instantiate quite a few meshes before running into issues, so you can use that to your advantage.


Please let me know if you have any issues or corrections.

21 Likes

Thanks for the info! Was curious, is it possible to put, say, 3 meshes in the array, and then spawn only 3 particles so that each particle is one of the 3 meshes with no repeats? So that I spawn a sphere, box, and torus and not two spheres and a box.

1 Like

Yeah, possible.

If you spawn all of them at the same time, set the mesh index to execution index.
If you spawn them on different frames, try setting mesh index to UniqueID.

1 Like

Unpopular question :raised_hand:: in term of perf which one is cheaper? — Having multiple renderers (using the same material) and set visibility vs. having multiple mesh indices with one material?

Hmm, haven’t really noticed a difference between those. So, not sure, probably not that different.

1 Like

Omg. I think this is what I’ve been needing for the past 2 weeks for my orbiting elemental blades mesh effect. Think I just dug up a treasure chest. Thank you!

1 Like

a small tweak to original post question. I have set Mesh Renderer to have 1 Mesh and an array of 8 Materials. How can I get material 0-7 for each mesh to show?


I thought this would work, or maybe I need to still have 8 mesh indexes even if they are using the same mesh?

The materials aren’t part of the array system, they are intended to override material slots in the mesh (in case the mesh has multiple of them).

What you probably want to do is put a copy of the mesh with the right material in the mesh list, and then not use a material override

editing with some caveats.
I wrote the above with the intend to inform about how you could use the mesh array features to achieve the goal that was being set out. As Tobias called out, this is not necessarily the best way of achieving that specific goal, just a way that uses mesh arrays.

1 Like

I didn’t even know that was an option. I thought u had to set material in Niagara for it to work in a particle system. So u literally mean to make 7 duplicate of my blade static mesh and then use one with each material instance on it?

Probably easiest is to just have 8 Mesh Renderer components. Each with just your mesh and the respective material assigned as override material. Then you can select the renderer instead of the mesh array.
It’s already heavy on memory (depending on your material), to load all 8 materials into memory at all times. If you were to dupe the mesh as well, you also load 8 different meshes into memory in addition, so I would not advise this.

Best solution, of course, would be to also eliminate the need of having 8 materials. E.g. by doing the different looks inside the shader. This of course is only possible, if the individual materials don’t differ drastically in terms of looks. If it’s mostly color and a slightly different noise, you can easily do this in the material and use a swtich node to have different params for each of your ‘elements’. Then set the switch selector via Dynamic Parameter.

1 Like

It’s 4am here. should probably get to bed, but ill look into this suggestion tomorrow. Thank you. For the record, the materials are instances, not all masters. But yes they have different noise textures(2 each), panning speeds and colors, glow, contrast, something called alpha blend, etc.
Last post for the night. Take care

I just saw a video on how to use visibility tags. I think i need to use those, so im gonna try using only 1 mesh with 8 different visibility tags in a single emitter. Maybe it’ll eork. Ill update here with the result.

Hey man. This is my emitter setup. PS: I have figured out every possible way to choose from an array, but not able to have all 8 spawn at once without being right on top of each other. Im using a Normalized Index Position which is supposed to make them spaced out evenly around an orbit.


I just don’t know why they wont do that

Edit: I figured out how to do the evenly spaced array index thing using a color array. Will elaborate more in the near future to explain. Thank you everyone for your help and support. I won’t be able to post my solution unless someone replies to this bec there is apparently a limit on consecutive replies from a single person.