Is possible generating texture atlas for 3d mesh at runtime?

Hello everyone!
I would like to ask if the idea of generating a texture atlas of a 3D mesh at runtime is possible!
Because once I decide what clothes and accessories my avatar will wear in the game lobby, I want to be able to put the textures of the clothes and accessories into one texture atlas.
I’m searching for information with keywords like ‘texture atlas for mesh’ and ‘runtime texture atlas’, but found very little. lol

Is this for optimization?

You can use multiple atlases for each material slot on the character, but if this is for putting everything into a single texture for optimization you should have a few options. Also, you are correct people have not really talked about this even though it’s a very important topic.

You can probably use render targets to combine textures: Creating Textures Using Blueprints and Render Targets | Unreal Engine 4.27 Documentation

I do however think there is a better solution that you can execute with C++. Looking at the default Texture Class and Texture 2D Object, you really can’t do what you wish:

You can overwrite texture data like this, but for smaller portions in texture would be more difficult, especially to calculate the specific areas of overwriting:

// Create an array to store the combined texture data
TArray<FColor> CombinedData;
CombinedData.SetNumZeroed(SourceDataR.Num());

// Combine the textures by assigning the R and G channel values
for (int32 i = 0; i < SourceDataR.Num(); i++)
{
    CombinedData[i].R = SourceDataR[i].R;
    CombinedData[i].G = SourceDataG[i].R;
}
1 Like

Thank you so much!!! I’m thrilled to hear such a detailed and kind response.
Yes, my attempts are for optimization.
I’ll have to look into the render targets you mentioned, but as you said, it’s going to be a very difficult journey…

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.