When creating a transient UTexture2D, I notice that specifying a PF_R8G8B8A8 will cause the color data in the Mip array to be packed in as [BGRA] per pixel while PF_B8G8R8A8 will pack pixels color data as [RGBA].
So under PF_R8G8B8A8, FColor(255,0,0,255) is blue.
But with PF_B8G8R8A8, FColor(255,0,0,255) is red.
Here’s some code:
MyTexture= UTexture2D::CreateTransient(64, 64, PF_R8G8B8A8);
MyTexture->UpdateResourceW();
FColor *MipData = static_cast<FColor*>(
MyTexture->PlatformData->Mips[0].BulkData.Lock(LOCK_READ_WRITE)
);
for (int32 pixelNum = 0; pixelNum < 64*64; ++pixelNum)
{
MipData[pixelNum] = FColor(255,0,0,255);
}
MyTexture->PlatformData->Mips[0].BulkData.Unlock();
MyTexture->UpdateResourceW();
I hook this texture up to a material instance dynamic an feed it into emissive and apply the material to a static mesh plane. I get this result:
https://dl.dropboxusercontent.com/u/33133319/PF_R8G8B8A8.jpg
However, if I change the code in line 1 to:
MyTexture= UTexture2D::CreateTransient(SizeX, SizeY, PF_B8G8R8A8);
I get the result I had expected before:
https://dl.dropboxusercontent.com/u/33133319/PF_B8G8R8A8.jpg
Why do these seem flipped?