Best practice with having thousands of static mesh instances with different materials assigned to them?

The impact is minimal, but that doesn’t mean you shouldn’t set up benckmarks to get ypur baselines.

Everything you do - in any engine - should be based on performance testing first.

If more people followed that simple rule, you’d see a lot better videogames out there…

Overriding instance materials doesn’t really cost all that much. Its just the same as it being a completely different material/object.

Shader tricks like perInstanceRandom cost less.
So you could hook that into a syatem to decide how the rock looks but
Once you include both textures in the shader file your memory footprint is larger, which may or may not be a worse hinderance.

You could simply extract a single channel out of the moss, probably green as thats predominant on the moss, and feed that in as follows:

Subtract from green (so green - 1-green). Leaves you with colorless in place of green.
Place in lerp B
revirwing this as it was incorreect

Use per instance random to power an alpha value that goes 0 or 1 (in an IF so its clean).
Perinstancerandom - look what it outputs.
Plug into the source of if.
Set values on if.
Use as alpha of lerp.

And now you have a cheaper rock that can sometimes be white where the green is, sometimes white.

If your shader uses world position for defining the moss area you are in a performance trouble situation anyway, so I gave the example assuming moss is just texture.

You can do the same using WPO, the cost is just higher for it…

1 Like