x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Texture created with IImageWrapper appears distorted on PS4

Hi there!

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:

distorted texture on PS4

correct texture in Editor

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':

 UTexture2D* texture = nullptr;
     
     IImageWrapperModule& imageWrapperModule = FModuleManager::LoadModuleChecked<IImageWrapperModule>(FName("ImageWrapper"));
     IImageWrapperPtr imageWrapper = imageWrapperModule.CreateImageWrapper(EImageFormat::PNG);
 
     if (imageWrapper.IsValid() && imageWrapper->SetCompressed(imageArray.GetData(), imageArray.Num()))
     {
         const TArray<uint8>* uncompressedBGRA = nullptr;
         if (imageWrapper->GetRaw(ERGBFormat::BGRA, 8, uncompressedBGRA))
         {
             int32 height = imageWrapper->GetHeight();
             int32 width = imageWrapper->GetWidth();
 
             texture = UTexture2D::CreateTransient(width, height, PF_B8G8R8A8);
 
             void* TextureData = texture->PlatformData->Mips[0].BulkData.Lock(LOCK_READ_WRITE);
             FMemory::Memcpy(TextureData, uncompressedBGRA->GetData(), uncompressedBGRA->Num());
             texture->PlatformData->Mips[0].BulkData.Unlock();
             texture->UpdateResource();
         }
     }

Any help would be much appreciated!

Product Version: UE 4.13
Tags:
more ▼

asked Mar 30 '17 at 09:47 AM in C++ Programming

avatar image

actionthom
56 3 4 7

avatar image IGorilla Mar 30 '17 at 01:39 PM

Not sure if it is related, but PS4 only takes square textures.

avatar image actionthom Mar 30 '17 at 01:52 PM

Thanks! Ours are square already unfortunately :(

avatar image IGorilla Mar 30 '17 at 02:33 PM

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.

avatar image IGorilla Mar 30 '17 at 03:04 PM

Correcting myself as it is bNoTiling that you should look for instead of bIsTiling . Might still not work though.

avatar image actionthom Apr 04 '17 at 03:54 PM

Thank you!

I'll try this first thing tomorrow :)

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

3 answers: sort voted first

This was solved by making the following changes to my code. Thanks for all the help!

 texture->bNoTiling;
 
 uint8* TextureData = static_cast<uint8*>(texture->PlatformData->Mips[0].BulkData.Lock(LOCK_READ_WRITE));
more ▼

answered Apr 07 '17 at 03:05 PM

avatar image

actionthom
56 3 4 7

avatar image IGorilla Apr 07 '17 at 03:24 PM

It should be: texture->bNoTiling = true; ... right? Otherwise that part should not do anything.

avatar image actionthom Apr 07 '17 at 03:27 PM

yes indeed

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

Solved it on PS4, but not on XBoxOne unfortunately. Any Idea ?

more ▼

answered Jul 10 '18 at 01:12 PM

avatar image

elliotek
61 2 4 10

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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
     }
   

It's kind of a hack but it works fine for me.

more ▼

answered Jul 11 '18 at 07:57 AM

avatar image

elliotek
61 2 4 10

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question