I’m having a dickens of a time trying to convert some pixel data. I was wondering if you guys might have some ideas.
My original data is **RGBA 32bpp **HDR. I’m attempting to import it into UE via C++.
On the UE side of things I’m initializing the texture with ETextureSourceFormat::TSF_RGBA16F. Then I cache it to EPixelFormat::PF_FloatRGBA. These just seemed to be the closest valid formats, the formats available to Source.Init() seem really limited.
Because of all the various channel re-ordering I potentially had to do where an acceptable format might only be BGRA or something like that, I’m just looping over every pixel and adding it to a TArray before using Memcpy to get my modified data into the source texture.
So a straight TArrray <float> is giving me some weird results:
Oh yeah, so the left texture is a side case where it actually comes in as two-channel 32bpp, so in that case I add the first channel to the pixel array three times then add the alpha, since I’m still targeting RGBA. There is no way that should come out green like that unless I’m doing Memcpy wrong. Also, you can see how the textures cut off halfway. So there’s some clues.
All of this is based off the assumption that if I feed 32 bit floats to UE it’ll figure out how to turn it into the right kind of data for that SourceFormat above.
This is how I copy all the data once it’s done:
TArray <float> Pixels;
// byte copying stuff here
FMemory::Memcpy(MipData, Pixels.GetData(), Pixels.Num());
So originally I was multiplying Pixels.Num() by Pixels.GetTypeSize(), but that was getting access violations. Does Memcpy want the number of typed elements it’s copying or the number of bytes?