UE4: how to emit random meshes

I am trying to emit random meshes form my Mesh Data emiter. So far I have only been able to emit one mesh.
Anyone know how to emit randomly from a set of 5 shapes?

2 Likes

Hey @jettam, traditionally I don’t think you could do this in Unreal. However, with the new morph target stuff, you may be able to have various shapes stored in one mesh and rig up a material to randomly pick between your set morph targets and drive the randomization with the dynamic parameter. I don’t know if this is possible to do off the top of my head, as I haven’t been able to get into that area yet

2 Likes

yeah, not a feature sadly - you could do some crazy material morph target thing, or pack some meshes together and randomise the opacity or vertex offsets to collapse some of them if you can live with the extra overdraw / vert count (i’ve still never really had a good answer from a coder as to the extra cost of including a lot of verts all collapsed to 0…)

honestly though just make multiple emitters with shared properties and spawn different meshes.

2 Likes

Collapsing to zero removes your overdraw. On the vertex side as long as your selection is pretty simple and your collapsing is just an add, there isn’t much cost. The cost is the same as having the same number of vertices as if all of them are around at once. So if you have 3 objects with 100 vertices each, it is the same vertex cost as handling 1 object with 300 vertices.

Best to do the vertex collapse method if you are going to try this thing. Morphtargets will be more costly in most cases. If you can avoid doing texture lookups in the vertex shader you are definitely going to be better off. I’d store an ID as vertex color or a UV channel and then use the particle random to pick one.

1 Like

thanks for the info regarding the vertex scaling - thats pretty much what i thought already but there was some discussion regarding the engine calculating very small triangles at my last job regarding this technique. I’ve only really ever used it on simple quads where it’s likely to be insignificant anyway but i could see the costs adding up on larger meshes.

do you mean the Particle Random material node? or just the random functionality of particles? Last time i checked i thought Particle Random only worked on GPU particles, but i could be wrong/they might have fixed that.

1 Like

So, it is important when you collapse the meshes to also put them off screen. If they are on screen then yah, super small triangles are really bad. Still probably better than large overdraw, but not worth it if the thing is already small. I always collapse to the camera position - cameraforward * 100. That way it is definitely out of frame.

Ah, yeah. I’ve modified ue4 to give me a random value for particles, I’m not sure if there is a good built in way. But you can use the random color as a selector too.

So using the particle color node you can based on one (or many) of the channels. That should work too.

1 Like