@@ -788,7 +788,13 @@ UTexture2DArray* UglTFRuntimeAsset::LoadImageArrayFromBlob(const FglTFRuntimeIma
788
788
789
789
if (Width > 0 && Height > 0 )
790
790
{
791
+ #if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 1
791
792
int64 ImageSize = GPixelFormats[PixelFormat].Get2DImageSizeInBytes (Width, Height);
793
+ #else
794
+ const int64 BlockWidth = (Width + GPixelFormats[PixelFormat].BlockSizeX - 1 ) / GPixelFormats[PixelFormat].BlockSizeX ;
795
+ const int64 BlockHeight = (Width + GPixelFormats[PixelFormat].BlockSizeY - 1 ) / GPixelFormats[PixelFormat].BlockSizeY ;
796
+ int64 ImageSize = BlockWidth * BlockHeight * GPixelFormats[PixelFormat].BlockBytes ;
797
+ #endif
792
798
int32 NumberOfSlices = UncompressedBytes.Num () / ImageSize;
793
799
TArray<FglTFRuntimeMipMap> Mips;
794
800
@@ -852,7 +858,11 @@ UTextureCube* UglTFRuntimeAsset::LoadCubeMapFromBlob(const bool bSpherical, cons
852
858
if (bSpherical)
853
859
{
854
860
const int32 Resolution = Height;
861
+ #if ENGINE_MAJOR_VERSION >= 5
855
862
auto GetCubemapFace = [Resolution, Width, Height, PixelFormat](const TArray64<uint8>& Pixels, const FVector3f Start, const FVector3f Right, const FVector3f Up, TArray64<uint8>& OutPixels)
863
+ #else
864
+ auto GetCubemapFace = [Resolution, Width, Height, PixelFormat](const TArray64<uint8>& Pixels, const FVector Start, const FVector Right, const FVector Up, TArray64<uint8>& OutPixels)
865
+ #endif
856
866
{
857
867
const int64 Pitch = Resolution * GPixelFormats[PixelFormat].BlockBytes ;
858
868
OutPixels.AddUninitialized (Pitch * Resolution);
@@ -913,6 +923,7 @@ UTextureCube* UglTFRuntimeAsset::LoadCubeMapFromBlob(const bool bSpherical, cons
913
923
FX = FMath::Abs (FX);
914
924
FY = FMath::Abs (FY);
915
925
926
+ #if ENGINE_MAJOR_VERSION >= 5
916
927
if (PixelFormat == EPixelFormat::PF_FloatRGB)
917
928
{
918
929
const FFloat16* Colors = reinterpret_cast <const FFloat16*>(Pixels.GetData ());
@@ -952,6 +963,48 @@ UTextureCube* UglTFRuntimeAsset::LoadCubeMapFromBlob(const bool bSpherical, cons
952
963
953
964
FMemory::Memcpy (OutPixels.GetData () + Offset, &Color16, sizeof (FFloat16) * 4 );
954
965
}
966
+
967
+ #else
968
+ if (PixelFormat == EPixelFormat::PF_FloatRGB)
969
+ {
970
+ const FFloat16* Colors = reinterpret_cast <const FFloat16*>(Pixels.GetData ());
971
+ const int64 Offset00 = Y2 * (Width * 3 ) + (X2 * 3 );
972
+ const FVector Color00 = FVector (Colors[Offset00], Colors[Offset00 + 1 ], Colors[Offset00 + 2 ]);
973
+ const int64 Offset10 = Y2 * (Width * 3 ) + (X3 * 3 );
974
+ const FVector Color10 = FVector (Colors[Offset10], Colors[Offset10 + 1 ], Colors[Offset10 + 2 ]);
975
+
976
+ const int64 Offset01 = Y3 * (Width * 3 ) + (X2 * 3 );
977
+ const FVector Color01 = FVector (Colors[Offset01], Colors[Offset01 + 1 ], Colors[Offset01 + 2 ]);
978
+ const int64 Offset11 = Y3 * (Width * 3 ) + (X3 * 3 );
979
+ const FVector Color11 = FVector (Colors[Offset11], Colors[Offset11 + 1 ], Colors[Offset11 + 2 ]);
980
+
981
+ FVector Color = FMath::BiLerp (Color00, Color10, Color01, Color11, FX, FY);
982
+
983
+ FFloat16Color Color16 = FLinearColor (Color);
984
+
985
+
986
+ FMemory::Memcpy (OutPixels.GetData () + Offset, &Color16, sizeof (FFloat16) * 3 );
987
+ }
988
+ else if (PixelFormat == EPixelFormat::PF_FloatRGBA)
989
+ {
990
+ const FFloat16* Colors = reinterpret_cast <const FFloat16*>(Pixels.GetData ());
991
+ const int64 Offset00 = Y2 * (Width * 4 ) + (X2 * 4 );
992
+ const FVector4 Color00 = FVector4 (Colors[Offset00], Colors[Offset00 + 1 ], Colors[Offset00 + 2 ], Colors[Offset00 + 3 ]);
993
+ const int64 Offset10 = Y2 * (Width * 4 ) + (X3 * 4 );
994
+ const FVector4 Color10 = FVector4 (Colors[Offset10], Colors[Offset10 + 1 ], Colors[Offset10 + 2 ], Colors[Offset10 + 3 ]);
995
+
996
+ const int64 Offset01 = Y3 * (Width * 4 ) + (X2 * 4 );
997
+ const FVector4 Color01 = FVector4 (Colors[Offset01], Colors[Offset01 + 1 ], Colors[Offset01 + 2 ], Colors[Offset01 + 3 ]);
998
+ const int64 Offset11 = Y3 * (Width * 4 ) + (X3 * 4 );
999
+ const FVector4 Color11 = FVector4 (Colors[Offset11], Colors[Offset11 + 1 ], Colors[Offset11 + 2 ], Colors[Offset11 + 3 ]);
1000
+
1001
+ FVector4 Color = FMath::BiLerp (Color00, Color10, Color01, Color11, FX, FY);
1002
+
1003
+ FFloat16Color Color16 = FLinearColor (Color);
1004
+
1005
+ FMemory::Memcpy (OutPixels.GetData () + Offset, &Color16, sizeof (FFloat16) * 4 );
1006
+ }
1007
+ #endif
955
1008
else
956
1009
{
957
1010
@@ -986,7 +1039,13 @@ UTextureCube* UglTFRuntimeAsset::LoadCubeMapFromBlob(const bool bSpherical, cons
986
1039
}
987
1040
else
988
1041
{
1042
+ #if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 1
989
1043
int64 ImageSize = GPixelFormats[PixelFormat].Get2DImageSizeInBytes (Width, Height);
1044
+ #else
1045
+ const int64 BlockWidth = (Width + GPixelFormats[PixelFormat].BlockSizeX - 1 ) / GPixelFormats[PixelFormat].BlockSizeX ;
1046
+ const int64 BlockHeight = (Width + GPixelFormats[PixelFormat].BlockSizeY - 1 ) / GPixelFormats[PixelFormat].BlockSizeY ;
1047
+ int64 ImageSize = BlockWidth * BlockHeight * GPixelFormats[PixelFormat].BlockBytes ;
1048
+ #endif
990
1049
int32 NumberOfSlices = UncompressedBytes.Num () / ImageSize;
991
1050
if (NumberOfSlices != 6 )
992
1051
{
0 commit comments