7dtd-map icon indicating copy to clipboard operation
7dtd-map copied to clipboard

Efficient splat3/4 rendering

Open kui opened this issue 6 years ago • 8 comments

At A18 (or later A17?), splat3.png is completely transparent image. So we require to drop the alpha values of splat3.png on web browsers.

But the processing takes match time because the image is parsed with pure javascript.

We need to know about browser API (around File API? ImageBitmap? or Canvas?).

kui avatar Oct 09 '19 15:10 kui

  • createImageBitmap(file); then drowImage(bitmap, 0, 0) for a canvas drows all pixels which are rgba=(0, 0, 0, 0), So it drops rgb values.
  • Using getContext("2d", { alpha: false }) is the same result.

Web browsers might drop rgb values of pixels which the alpha value is 0.

kui avatar Oct 10 '19 07:10 kui

Or WebAssembly SIMD in Beta Chrome 84?

kui avatar Jul 14 '20 10:07 kui

Splat convert is now fast enough by 026258dab05f61291b4a8cc5dc4c07edf5c4fd70. It takes vast time that slice creates new array instance.

kui avatar Jun 18 '21 17:06 kui

This issue should treat about pngjs.pack() into Blob. It takes about 14 secs in my env yet.

kui avatar Jun 18 '21 17:06 kui

Avoid to use pngjs.pack() in bcfcf17c103046944f667a914febcd11772d80b9.

  • Before: about 14s
  • After: about 5s

kui avatar Jun 19 '21 17:06 kui

I will try wasm for PNG parsing.

kui avatar Jun 19 '21 17:06 kui

Rust png with wasm parses faster than pngjs.

Benchmark: https://github.com/kui/png-parse-benchmark

Result:

image

Note: It is slower than pngjs when devtool is opened.

But I'll not use this rust wasm. Code maintenance with wasm is harder than the current code. I think this benchmark result is not worth it.

kui avatar Jun 20 '21 10:06 kui

Same PC but the latest Chrome (126) image

kui avatar Jul 21 '24 11:07 kui