New to 4.25 was the ability to specify per instance custom float data.
It appears to work great for Instanced mesh, but for Hierarchical Instanced Static Mesh the indices are not stable. As the camera moves around the custom data moves to different instances.
I have submitted a bug report but I have not heard anything.
I found this link showing someone reporting the same problem but no answers yet.
I have spent some hours looking into the problem and I suspect that the problem is that the Custom Data values are indexed in the shader (MaterialTemplate.ush) directly, not via the InstanceReorderTable (which is not GPU visible anyway). I’m not sure of the best way to fix this as I don’t really understand how the HISM system works with the Tree rebuilding and instance reordering.
I submitted a bug report a few weeks ago but it has not been accepted yet. It’s easy to recreate the problem with a simple BP creation script. Sample project can be downloaded here.
===============================
UPDATE: I received an email from Epic stating this has been fixed and should be released in 4.26.
One of the advantages of HISMs is per instance culling. As soon as they leave frustum, they’re culled - you’re experiencing the same as my almost working blue sphere animation.
Not sure whether this is a bug or HISM limitation
It seems to affected by the way the instances are originally ordered:
As can be seen above - one of the sides is barely affected as those indexes are neatly ordered ascending.
If all the spheres are on screen it works fine. As some move off screen the sphere colours start changing. It might be LOD related but I’ve not set anything up regarding LOD.
I don’t think it’s a limitation of the HISM per se. For example the transforms work just fine. When instances are re-ordered due to culling etc, they are updated in the InstanceReorderTable in the HISM object (I think). If the custom data could be indexed via this table on GPU I think it would fix it.
Unfortunately the InstanceReorderTable is not accessible on GPU.
Another way would be to update the entire Custom data GPU copy every time the instances were reordered, and keep the GPU data in the final instance order including the reordering.
Until this works, the per instance custom data is pretty much useless for HISM.
Until this works, the per instance
custom data is pretty much useless for
HISM.
I have little to add here, unfortunately. I was under the impression this worked OK (since I needed no culling) until I started adding custom LODs last week and… yeah, you know the rest.
Adding an answer to say I received an email from Epic in response to a bug report I submitted, stating this has been fixed and should be released in 4.26.
Thought I’d reply to this to say that in 4.27.2 I don’t have the issue.
Setting up a test in a new project appears to work fine.
This .gif (sorry about the quality here) shows a HISM with 1 million cube instances, each with their PerInstanceCustomData value set to the instance’s index. So the first instance has a custom value of 0.0, the next has 1.0, etc., up to 1 million.
Culling distances are 0 and 3000.
I created the HISM in C++ however, not in a blueprint.
I didn’t need to use BuildTreeIfOutdated() at all, as I’ve seen some other searches mention.
I do find an issue with the precision of my PerInstanceCustomData values getting worse as they get larger. I found this occurs in 2 places:
in the VertexInterpolator node output
and in the inner workings of the DebugFloat3Values node
I used Floor(myValue + 0.3f) on the VertexInterpolator output to deal with most of the imprecision, but did nothing to whatever Debug3FloatValues is doing with its input. So as you can see, imprecision is still a thing in the example (as those decimal values climb higher), but I believe this isn’t connected to the HISM custom data/thread topic.