melonJS icon indicating copy to clipboard operation
melonJS copied to clipboard

compressed textures in WebGL

Open obiot opened this issue 2 years ago • 3 comments
trafficstars

one key feature still missing in melonJS, if anyone is up to it, is the ability to load compressed texture for WebGL, with the benefits of shorting loading time and using less VRAM.

At minima (if I'm correct), supporting ASTC (the new format for WebGL), DXT (for destop), PVR (for IOS) and ETC[1/2] (for Android).

Extra bonus, this tool could be integrated in the boilerplate build chain to automatically compress textures : https://www.npmjs.com/package/texture-compressor/v/0.3.1

and last but not least an interesting article here about compressed textures: https://www.shukantpal.com/blog/pixijs/do-not-use-uncompressed-textures/

obiot avatar Apr 10 '23 00:04 obiot

You can also use TexturePacker for this - we support all these formats and in addition to that BasisU which is mentioned in the pixijs post.

BasisU uses a single texture file that is transcoded into the native formats. The only disadvantage is, that the transcoder WASM.

CodeAndWeb avatar Oct 17 '23 09:10 CodeAndWeb

definitely, that's what I'm actually doing for now :)

on the article, I actually did not realise it was from pixi :P

obiot avatar Oct 17 '23 09:10 obiot

following some recent code restructuring, the loader is now basically ready for compressed texture, see below:

https://github.com/melonjs/melonJS/blob/fd4411f17627189a691461042598441ccda593b6/src/loader/parsers/image.js#L48 https://github.com/melonjs/melonJS/tree/master/src/loader/parsers/compressed_textures

all remaining is to actually parse/transcode the texture themselves and upload them in the the GPU Ram.

obiot avatar Mar 21 '24 01:03 obiot