HTML5 exports are missing textures

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Magister Werner

I’ve been trying to export my 2d-game running GLES2 to HTML5 and getting it to run properly. Whenever I do this, some of my textures appear to be missing in the exported version. This includes all my animated textures and textures that are applied to objects in code only and that are not visible in the editor.

Is there a workaround to this? I’ve looked around for answers on the web, but I’m not getting anywhere.

Are your textures using non-power-of-two sizes? This can cause various problems if they are set to repeat or are using mipmaps. The best way to fix this is to resize your textures to the nearest greater power of 2.

The WebGL 1.0 specification (which is similar to GLES2) does not mandate support for non-power-of-two textures.

Also, can you reproduce this when exporting the project to a native PC platform (Windows/macOS/Linux)?

Calinou | 2022-04-20 18:17

Thank you for your reply.

The first four png-files that aren’t exporting properly are all spritesheets containing 16 rows and columns. The total sprite dimensions are 2560x2560 which sounds like a power of 2 to me.

The other 15 png-files that aren’t exporting have all sorts of odd dimensions such as 58x53, 64x53, 45x51, 16x12 and 13x10 for example.

My sprites are not set to repeat nor using mipmaps.

Exporting to PC or macOS works just fine. I have had no issues whatsoever.

Magister Werner | 2022-04-20 20:29

Edit: added an answer instead.

EdJolly | 2022-11-16 15:20

:bust_in_silhouette: Reply From: EdJolly

Bump - I’m having the same issue. OP, did you ever find a solution?
Thanks!

Unfortunately I never found a solution. It made me so frustrated I completely stopped working on my game instead. I might get back to it once Godot 4 is out.

Magister Werner | 2022-11-16 15:01

:bust_in_silhouette: Reply From: EdJolly

Ok: a simple solution that worked for me:

  1. When dynamically importing textures into sprites, instead of load(), use ResourceLoader.load(). The ResourceLoader is capable of finding the referenced files even after export.
  2. If dynamically importing scripts, make sure you set the script form to plain text when exporting.

I did those two things and solved my problems. I hope they get you your game project back!