I am using Paper2D sprites to render platforms in my game. It works perfectly fine when playing in the editor, but as soon as I use the Launch button or package the game and test it, certain sprites start rendering weirdly.
It seems the texture is being tiled many many times for some reason.
This is how it looks when playing from editor: http://blay09.net/files/ludum/ld32/VisualGlitches/main.png
The sprites are using the default MaskedUnlitSpriteMaterial and it only happens for some of them. This happens for both orthographic and perspective cameras. All rendering settings and sprite/texture properties are left on their defaults.
I’ve added an asset that’s broken for me and one that’s working fine in the packaged version here:
http://blay09.net/files/ludum/ld32/VisualGlitches/ (Amplifier is broken, ConductiveLayer works)
Mobile preview is typically a very good indicator of how a project will render on the device, is that how you’re playing it in the editor? Sometimes rendering issues such as these are a result of unsupported/unrecommended assets being used for mobile development. Have you double-checked the guidelines for Mobile Development documentation to ensure that you’re not including anything that might cause such an issue (the asset you mentioned that is broken, perhaps)?
If you can, include your build’s output logs to this thread as a txt file and I can have a look and see if anything appears to be unsupported.
My target platforms are actually Windows and HTML5. The issue exists on both platforms.
I tried it out in the Mobile Preview of the editor anyways and it’s rendering fine there too.
I’ve attached the two build log files mentioned in the article to this post. If you need the others too, I’ve put them at http://blay09.net/files/ludum/ld32/VisualGlitches/BuildLogs/ as well.
I think I’ve isolated what the issue is and I’m afraid that I don’t have a good workaround without a source modification. It is a race condition between texture and sprite loading during cooking, as the ConditionalPostLoad call doesn’t block for the texture when running the cooker as a separate commandlet like it does when run from the editor. This means that the bug shouldn’t show up when you use Launch On, which defaults to cook-in-editor, but will show up when packaged via Package or UFE.
I’ve filed a ticket UE-14171 and I’ll get that fixed for 4.8. The full fix will be to get size via a different mechanism, but as a quick hack you can try skipping the resizing code by changing UPaperSprite::NeedRescaleSpriteData() to always return false.
This specific issue was fixed in https://github.com/EpicGames/UnrealEngine/commit/e36236bbe51b4c94d19fcf89381eb4a2fd3172ed which will be in 4.8. There are some other benign log warnings for cooked games that I’ll be addressing as well.