How to collect textures?

Hello people! Need help.
I have instance meshes that mimic cubes, like in minecraft. They need one texture and material, something like satin.

However, I don’t want to manually stack the textures into one image each time, doing a lot of manual work.
I want the engine to do this for me before starting the “game”. In addition, one texture does not allow you to create mods for my “game”
When there are a lot of images, or I want to get rid of the next new block, holes will remain in the atlas, human errors may occur.

What we have:
A large number of images that are stored in an array, or any other way convenient for you, that are in the project and are waiting to be used. But, they should not be in the material.

What I want to do:
I want the engine to take all the textures from the array and generate an atlas, 2d image. Render or something.
I don’t know how to force the engine to create a new image from an updated list of images.

Believe me, doing it with your hands every time is long, boring, there may be errors when deleting blocks, or refusing an image. You will have holes because you don’t want to move the rest of the textures already set up for other blocks for example.

I’m also ready to hear any options on how to conveniently implement a texture system for instance meshes. I already have a database in the game that stores the parameters and properties of blocks, their strength, transparency. It would be cool if the texture data that the engine took was stored there.

@anonymous_user_9a6172541 Assigning texture and parameters to instances can be done through the “SetCustomDataValue” node

You need to pass in your HISM or ISM component, it’s element index and the needed data.

You can read the data in the material with “PerInstanceCustomData” node

To pick at the fine details of the instances (retrieve the data) is a little more tricky.
I wrote a custom library that can do this. Normally these parameters are not exposed by the engine to blueprints.

.h file

#pragma once

#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "InstancedLibrary.generated.h"

/**
 * 
 */
UCLASS()
class YOUR_API UInstancedLibrary : public UBlueprintFunctionLibrary
{
	GENERATED_BODY()
	
public:
	UFUNCTION(BlueprintCallable)
	static TArray<float> GetData(UInstancedStaticMeshComponent* passedComponent);

	UFUNCTION(BlueprintCallable)
		float GetDataAtIndex(UInstancedStaticMeshComponent* passedComponent, int32 InstanceIndex, int32 CustomDataIndex);
};

.cpp file

#include "InstancedLibrary.h"
#include "Components/HierarchicalInstancedStaticMeshComponent.h"
#include "Components/InstancedStaticMeshComponent.h"

TArray<float> UInstancedLibrary::GetData(UInstancedStaticMeshComponent* passedComponent)
{
	return passedComponent->PerInstanceSMCustomData;
}

float UInstancedLibrary::GetDataAtIndex(UInstancedStaticMeshComponent* passedComponent, int32 InstanceIndex, int32 CustomDataIndex)
{		
	return passedComponent->PerInstanceSMCustomData[InstanceIndex * passedComponent->NumCustomDataFloats + CustomDataIndex];
}