If the Custom Value is 1, output a stone texture, if the Value is 2, output a grass Texture, if the Value is 3, output a medal texture
It’s a float, not an int. You’d have to program the material to switch textures depending on float values, which you could do with lerps, but it’s a bit of a pain in bum, unless you specifically have a reason for doing this.
What are you trying to do?
I am trying to make a instanced static mesh change textures based on the using custom data per each instance
Thank you, but this would work very well with 2 textures/colors where you could use the custom data as an alpha, but in my case i want to use over 50 textures, is there a better way than lerping all of the textures, like an texture array where you can get one of the textures using the custom data?
This might be the solution.
Doesn’t look great
Maybe Using a Texture Atlas because it is a highly used practice, but how would i go about doing that?
For X textures, you will need X-1 tests. As well, the per-instance is a float.
You can convert it to an int in the range of X buy multiplying PerInstance by X and then taking the floor/ciel to get the nearest integer. Or you can can use a series of lerps/if-statements to subdivide the range of 0.0 → 1.0.
Past that, you will need X texture samplers to flip from, you cannot just switch the texture itself, it needs to be sampled, so there is that to consider.
Consider packing textures if you can get away with it. If you can use a grey-scale-map as a source, you can put 4 of them into a single sampler and then switch based of channel vs sampler.
How many instances are you aiming for?
the player creates the instances, so there should be no limit
They have to do it manually? They’re probably never going to make more than a few hundred at most, presumably.
If that’s so, you could just use normal material instances.
how would i have each instance use their preferred material instance
For example, you have the grass tool selected, and you make a linetrace that hits the instance, how would i apply a different material instance for that specifed instance?
Ah, so you’re sort of giving them ‘editor’ tools?
Then, yes, you need to find a ‘funky’ method.
Thing is, grass already runs like a dog with a wooden leg in Unreal, and you’re going to make one that runs faster, on top of the engine? Hmmm… I think you’ve got your work cut out… :-/
imagine left click creates an ISM that mesh is a cube. the blueprint gets the current texture that the player wants to put onto the cube. i had already done this. i just am very confused how i am gonna use the custom data to change the material on the instance i want to.
So am I
All the examples I’ve seen using custom data, only use it for material variations, like color, lerping etc.
If you want to totally switch texture ( and normal ), it is possible, but the material would be a massive mess and would probably be the thing that ended up slowing down your system.
Like @Frenetic says, you’ll need X-1 lerps or ‘if nodes’ for X textures.
Just to check, and be very clear: this node is usually used for providing per instance variation. If you just want to have different materials on each instance, why not just set the material?
I would, but i want different textures for each instance.
I take it back anyway, I just typed a load of rubbish
Yes, you can only manipulate floats on the material on each instance.
That means, you can change color, or fade between one texture and another, but you can’t change materials.
That is true. There is texture atlases, and texture arrays (Texture2DArray) but very little documentation on them, and i am not sure on how compatible they would be with the custom data per instance node in the material editor.