When creating a particle it’s possible to specify a source material that uses a texture that includes multiple sub-images and have it pick linearly or randomly from them.
Is there a way to accomplish a similar effect with decals?
Say I wanted to put a bunch of bullet hole variations into a single texture and material, and then choose from them randomly when placing the decal.
Or should I just stick to importing multiple individual textures and creating a material for each?
You have three valid options in my opinion in this case:
Create material with 2 texture parameters and lerp scalar parameters. In your blueprint, choose the correct texture (for example, at time frame 2.7, choose image 2 and 3) and correct lerp alpha value (0.7 in this case). In each tick function, change those material parameters and you will get the animation. This is the most flexible method but requires blueprint that control a decal, which should not really be an issue. Additionally, you can create non-linear animations (drive timeline that translates to correct frame), add additional particl effects etc.
Create all logic inside a material. there are possible nodes that accomplish subuv splitting but it is not to difficult to calculate offsets by yourself. Basically, translate texture coordinates in region [0,1]x[0,1] to the correct box. For example, if zou have 4x4 grid inside your texture, use:
TextureCoording -> divide by 4 both U an V coordinate -> add the image offset
The image offset is (1/4 * row, 1/4* column index). From time, row is calculated as floor(time * arbitrary scale number / 4) and row as floor(time * arbitrary scale (modulus %) 4).
Use material logic but use custom material node to accomplish the splitting (I know it exists but I do not know the exact name). This is the same as 2)
I hope this helps a bit. Sorry I can’t give you an example, I do not have UE4 installed on this computer.
to expand on what .osolin said - there is a SubUV_Function node in the material editor that does all the work for you. you just have to feed it your texture, the number of rows and columns and the specific frame you want to display.
as for the actual frame number and getting a random value you could use the world position of the decal and get something from that or just feed a parameter from blueprint into it.