Can instanced static meshes have different texture properties?

Hello,

Is it possible to modify the texturing of instanced static meshes per object ?

More precisely, i have tried to modify the texture tiling of differents instanced static meshes, but i end up with always the same tiling for all of them.

I can modify their geometry though (scale, location, rotation).

Is there a way to get (instanced) meshes with different texture coordinate properties, or is this an unavoidable consequence of using instanced meshes ?

Thanks

Cedric

1 Like

As far as I am aware, No. However you could see about just using multiple Instanced Static Mesh components and changing the textures on them. Not as good as 1 ISM but still better than 100s of normal static meshes.

The point of an ISM is that they are all using the same rendering data to expedite the process by not needing to clear the information on the GPU between each mesh rendered. It basically say “ok, I have my mesh and texture data, and then I just need to clear my transform data as I do this 100 times.”

What your asking to do would require it to recalculate the texture to be applying between rendering, which is the highest memory cost (usually).

Sorry I dont have a better answer for you, but hope you also understand ISM a little better.

2 Likes

I thought it was something like that but wasn’t sure, thank you very much for the detailed explanations.

Cedric

1 Like

May an infinitesimal change to the object’s scale and use that to select between different properties. Basically drive properties by encoding a small selector into the the scale values.

I have a similar problem and this sounds like a perfect solution for me. However I can’t get a hold of the per instance scale. There is an object scale node in the material editor but it returns the scale of the instanced mesh component not the scale of the actual instances. Do you know how I get the scale of the instances in the material editor?

@Bonepower, call the GetInstanceTransform function on the (hierarchical) instanced static mesh component

@muchcharles, can you explain how you’d make the material take the object’s scale to alter its parameters?

Hi, I ended up needing this and looked into it further.

I think scale is only easily available for instanced foliage. In the perinstancedata there is a transform matrix that you could get scale from with the custom material node and some math, but I found an easier way: modify the code so that the value of “PerInstanceRandom” can be manually set instead of generated from a random seed.

Then you can just pass your data directly in. PerInstanceRandom is one component of a halt4, so it is a half-precision float. You should be able to have around 2048 unique integers to encode things with without much work.

The initialization from a random seed is done in: FStaticMeshInstanceBuffer::Init

(edit: searching around, this guy did the same thing and posted an implementation, he also has some caveats on using the float: Customise UVs per instance with Instanced Static Meshes - Rendering - Unreal Engine Forums )

“TransformLocalVectorToWorld should return you per instance transformed position, but only if used in vertex frequency shader” Material Local Space and Instanced Static Meshes - Asset Creation - Unreal Engine Forums

This is an old post, but as I couldn’t find solution anywhere on forums I will post my solution in case someone else is looking for that.
There is material node PerInstanceCustomData. To pass different data per instance we can use “Set Custom Data Value” node in blueprint:


To connect PerInstanceCustomData to other material nodes that require float “VertexInterpolator” is needed.

Yep, as Sitiana said, the SetCustomDataValue works, but there’s a few little extra things to know.
Here’s a quick video on how to set it up:

1 Like