Individually colored static mesh instances

Hi, I have a simple blueprint that creates instanced static meshes to form a spherical shell consisting of small pieces of a spherical shell and assigns a separate color for each of them. It works fine and here is the blueprint:

The only issue is that as the sphere consists of uniformly shaped pieces, they start to overlap near the poles (this is just background information and not directly related to the question). To solve this I have made an array of segments that are the correct size to not overlap and creating a “perfect sphere”. Now I try to do the same coloring for all the instances in the array but for some reason it suddenly does not work. Does anyone have an idea of what is going on here?

Here is the creation of the array of static mesh instances from the list of static meshes:

And here is the building up of instances and consequent coloring:

The sphere appears as intended and I have tested that the indexes are as intended and the color values are successfully fetched from the data table. What can be the reason that the custom colors are not applied to the instances?

Thanks in advance!

You’re adding as many instances as you have parts

The whole point of instancing, is you have one ISM, and then add instances.

1 Like

I have 180 parts and I am creating 360 instances of each (The sphere consists of 64800 pieces in total). At least that is what I intend to do. Do you think this is the reason that the coloring does not appear?

1 Like

Ah sorry, very cursory glance…

That’s ok of course, I assumed you’d fallen into the classic ISM trap.

I will look further…

1 Like

Thank you!

1 Like

It looks logical. The only tweak maybe is to directly use the ISM reference from the loop, as you already have it

The row name in the first example seems to be 0,1,2. In the second, it’s all over the place? Maybe that’s by design.

1 Like

I tried directly using the ISM but it didn’t solve the issue. Also the row names are actually the same 0,1,2,… all the way to 64799 in both cases. It is just that in the first case I have one ISM that is instanced 64800 times but in the other case I have 180 of them that are all instanced 360 times each. The math is there just to transform the indexes going from 0-179 and 0-359 into one that goes from 0-64799. I made sure that this is the case by printing out the names in both cases and they do indeed match.

So the issue still persists and the coloring does not show up. Thank you anyway for looking into this!

1 Like

Sorry I couldn’t see it :slight_smile:

1 Like

Anyone have any ideas?


If Im right ,this “Get” will return you a copied element in the array but not a reference,thats why you cant change anything on it.

Hi, Thanks for the answer! However, I have changed it to look like this:

And it still does not work. At least if I understand this correctly, I am now getting the reference to the actual ISM and not a copy.

This is irrelevant, it’s always by-ref.

  • to me it seems the Dirty state remains unflagged - so the instances never update.

  • are you using Vertex Interpolator in the material, can we see the mat setup?

Sure, here is the material:

But note that the first script I have does the changes with no problem:
image

And nothing is marked dirty here.

That’s the point, it should. The setup seems fine at a glance. Keep removing complexity until stuff shows up.

  • how about that dither mask?
  • can you elaborate on this:

What are the chances you’re looking at the wrong thing since all the instances are who knows where? :man_shrugging: Do tell, I might be missing the point since we can only see fragments of the setup.

Yes, that seems like a good way to go about it.

The dither mask makes a semi-translucent material by basically poking holes in the material instead of actually bein translucent. This simply achieves the type of translucency that I want.

The location thing is on purpose. The meshes that I use are small cut out slices of a spherical shell and so their center is one radius away from the actual mesh as you can see here:
image

The ISM that I want to create is then that one segment simply rotated a certain amount of degrees many times. The result is sort of a sphere made up of these puzzle pieces all centered in the same place as you can see here:
image

The conclusion being, that they are indeed positioned in a way that does make sense.
Did this answer your question?

1 Like

I just tested it under UE5 (since things are somewhat buggy) and it seems to behave fine:


Things to double check:

  • values that you are feeding into the Set Custom Data Value node; print some to eyeball it, see if things add up
  • this material flag:

  • the ISM custom data count:

Any luck?

2 Likes

Thank you!! It was the Num Custom Data Floats variable in the Add Instanced Static Mesh Component node :smiley:
image

1 Like

Woah! That looks kewl :sunglasses: Especially considering it’s made by rotating a bunch of instances around a pivot. :+1:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.