I’m using the IImageWrapper to create a texture from a downloaded PNG at runtime.
It appears fine in my editor tests, but when we run it on the PS4 the texture appears distorted:
Does anyone have any idea what this might be?
I’m just using the standard Image creation example which you’ll find if you search for ‘texture from URL’:
There is a bIsTiling that you can disable from the texture that might help. (call it before UpdateResource)
If this doesnt work I suggest using UTexture2DDynamic and take a look at ENQUEUE_UNIQUE_RENDER_COMMAND_TWOPARAMETER() macro to store data into it. In 4.15 you can take a look at AsyncTaskDownloadImage.cpp (not previous version) to see how it is used.
texture->bNoTiling = true; is not enough to make it work on XBoxOne because the low-level creation of the texture is done via a function called CreateVirtualTexture() which does not handle tiling as intended (at least, that’s my understanding of it).
So, I modified the code of FTexture2DResource::InitRHI() to force the call of SafeCreateTexture2D() instead of CreateVirtualTexture().
In /Engine/Source/Runtime/Engine/Private/Texture2D.cpp, do the following :
if( Owner->bNoTiling )
{
TexCreateFlags |= TexCreate_NoTiling;
//[DN][CDL] 10/Jul/2018
// This is to force SafeCreateTexture2D() instead of CreateVirtualTexture() in \Engine\Source\Runtime\D3D12RHI\Private\XboxOne\XboxOneD3D12Texture.cpp
#if PLATFORM_XBOXONE
TexCreateFlags &= ~(TexCreate_OfflineProcessed);
#endif
//[\DN][CDL] 10/Jul/2018
}