PerInstanceRandom and Instanced Static Mesh bug.

In 4.17, unlike 4.16.3, “PerInstanceRandom” node in material doesn’t change value with instances of Instanced static mesh component, if they are NOT added in construction script or directly to component.
Reproduction steps:

  1. New project or any other.
  2. Create new material with PerInstanceRandom connected to “Emissive Color”. Will have to set it to use with Instances as automatic doesn’t seem to work.
  3. Create new actor and connect “Add Instance Static Mesh Component” to “Event BeginPlay”.
  4. Set mesh to anything and material to the one created in “2.”.
  5. After component, connect multiple “Add Instance” nodes with random locations or use for loop.
  6. Observe as all instances have the same color.

If you do this in Construction script or directly click + to add instances to mesh component, PerInstanceRandom works. If you than use Update Instance Transform on the same instances PerInstanceRandom doesn’t work.

Hello Naifu,

Thank you for reporting this issue. I’ve reproduce the issue and entered a bug report for the issue. You can use the following link to track the issue’s progress: UE-48340.

Have a nice day!

hey we’re blocked on this. any guidance when 4.17.2 will be released?

4.17.2 should be release really soon.

After 4.17.2 and 4.18 fixes I have noticed another strange behavior with PerInstanceRandom.

HISMC - Hierarchical Instanced Static Mesh Component

ISMC - Instanced Static Mesh Component

If you rotate HISMC, it will reset/change PerInstanceRandom value to all Instances, unless you disable collisions for HISMC. ISMC doesn’t have this behavior.
If you update instance transform of an instance its PerInstanceRandom value is reset/changed for HISMC and ISMC.

I have tested this with 4.17.2 and 4.18 release versions.

Hello Naifu,

Thank you for following up and reporting this issue. I’ve entered a new bug for this particular issue which can be found and tracked here: UE-52049

Have a good one!

I have tested the fixes in 4.19 preview 1 and rotating HISMC seems to be fixed. However, with HISMC there is still a problem if you have more instances spawned (at least 6) and you try to get certain instances transforms, add random values to them and update it. What happens is that sometimes two or more instances swap their per instance randomized colors. It is really random and higher sample size or the longer I am modifying transforms makes it worse.

Also adding or removing an instance resets PerInstanceRandom of all instances in HISMC.

Hi
You were right for the Add causing issue with the RandomStream, unfortunately i couldn’t repro for the Remove and the code would not allow this either.

As for your other issue, keep in mind that adding/removing instance will alter the orders of the instances in your array, so it might feel like it’s not doing what you expect.

You are right, removing a random instance changes orders in both ISMC and HISMC. (Instances change color.) Additionally, if I am removing only the last instance in ISMC, order doesn’t change contrary to HISMC where it does.

However, adding an instance changes color/order only in HISMC.
Also, I have noticed that sometimes when updating Transform in HISMC, instances also swap colors/orders.
*Now in 4.19 Preview 2

I’m running against the same issue, maby removing a instance should just leave the array empty on that location and fill it up when something is added again to not mess with ordering? or somehow copy and past the per instance values to the new seed location.

This issue is marked as fixed in 4.19 but it is still affecting 4.23.

Can this issue be updated?