Okay … so as an experiment, I swapped the Red and Blue channels in the image and then used that image. It now displays correctly in the HTML build and obviously incorrect in the Editor and Standalone build.
So something during packaging is switching the two channels around of the material.
Is there a way I can swap the channels around inside the Material instead of having to edit the raw image file?
Although it feels ‘wrong’ to need this you can manipulate the channels pretty easily in the Material to do the channel swapping.
After your Texture Sample (Or however you’re reading the material) add a MakeFloat3 node. Although MakeFloat3’s inputs read X, Y, and Z which implies a vector you can use this to create new colours, with X being the Red component, Y the Green, and Z the Blue.
In this case to do the channel swap we just connect the Texture Sample’s Red output to the MakeFloat3’s Z (“Blue”) input, the Green output to MakeFloat3’s Y (“Green”), and the Blue output to MakeFloat’s Z (“Blue”). Now just replace any other connections to the Texture Sample with connections to the MakeFloat3 and it should work nicely.
I am picking up a few anomalies with the HTML builds … but this one has been the weirdest one. I have a flag in my Game Instance now that I set when I am doing an HTML build that when enabled uses an alternative material. Because I am building for HTML, Android, and IOS … this was the best way for me to maintain one code tree. Not the best solution … but we do what we have to.
Unreal engine download assumes the file is in BGRA format, you can check the downloader code and see that raw data is for looped into a texture2d.
You can add a c++ class and create a custom image downloader. You can download the image from the web, directly convert it to texture2d and it will be fine.
I don’t have the exact code, but you can check these two and merge it in your own class…
Web downloader – saves image to disk
Image to texture 2d converter
Currently my web downloader works something like this:
The original issue by qdelpeche should be pasted somewhere as a tutorial for downloading at runtime images based on a URL, inadvertent as it may be… many thanks!