I have an algorithm which creates a cubemap using simplex noise. It creates 6 bitmaps in memory (not the file format just the raw data). How do I get unreal engine to load up the data into a cubemap at run time? Essentially im looking for an unreal engine equivalent to glTexImage2D() in opengl. I want to use the algorithm for procedurally generating things like planets.
Here is a way I have done it for a normal texture. I wrote all the FColor data to a TArray. Not the most efficent I am sure but maybe it will kick start you to the right path?
void TextureFromImage_Internal(const int32 SrcWidth, const int32 SrcHeight, const TArray<FColor> &SrcData, const bool UseAlpha, UTexture* &retVal)
{
// Create the texture
retVal = UTexture2D::CreateTransient(
SrcWidth,
SrcHeight,
PF_B8G8R8A8
);
// Lock the texture so it can be modified
uint8* MipData = static_cast<uint8*>(((UTexture2D *)retVal)->PlatformData->Mips[0].BulkData.Lock(LOCK_READ_WRITE));
// Create base mip.
uint8* DestPtr = NULL;
const FColor* SrcPtr = NULL;
for (int32 y = 0; y<SrcHeight; y++)
{
DestPtr = &MipData[(SrcHeight - 1 - y) * SrcWidth * sizeof(FColor)];
SrcPtr = const_cast<FColor*>(&SrcData[(SrcHeight - 1 - y) * SrcWidth]);
for (int32 x = 0; x<SrcWidth; x++)
{
*DestPtr++ = SrcPtr->B;
*DestPtr++ = SrcPtr->G;
*DestPtr++ = SrcPtr->R;
if (UseAlpha)
{
*DestPtr++ = SrcPtr->A;
}
else
{
*DestPtr++ = 0xFF;
}
SrcPtr++;
}
}
// Unlock the texture
((UTexture2D*)retVal)->PlatformData->Mips[0].BulkData.Unlock();
retVal->UpdateResource();
}