spark.jsspark emoji

Real-Time GPU Texture Codecs for the Web

spark.js is a standalone JavaScript package that exposes a subset of the Spark codecs through a simple and lightweight API:

texture = await spark.encodeTexture("image.avif", { mips: true, srgb: true })

spark.js enables faster transmission and better visual quality with extremely fast GPU optimized transcoding. It allows you to use the same image formats and compression workflows across both 2D and 3D content without the need for specialized file formats or separate content pipelines for 3D assets.

Modern image formats like WebP, AVIF and JXL provide excellent quality across a wide range of compression ratios, making them ideal for storage and transmission. In contrast, native GPU formats offer compact in-memory representations but compress poorly. While rate-distortion optimization (RDO) can help, the quality of RDO-based encoders degrades significantly at lower bitrates.

Rate / Distortion chart
The chart above compares the SSIMULACRA2 score of multiple encoders at various bit rates.
Higher values indicate better visual quality. Bit rate (and thus file size) decreases toward the left.

With spark.js you can use modern image formats for storage and delivery, then transcode them at runtime to the most efficient GPU-native format supported by the device. This is literally free bandwidth!

Transcoding to native GPU formats is critical for performance. These formats use 75% less memory than decompressed image formats, which reduces memory usage, increases efficiency, and lowers power consumption.

You can find the source code on the spark.js GitHub repository and install the package via npm: npm install @ludicon/spark.js

Examples

The following examples are all encoded targeting a SSIMULACRA2 score of 80, which is generally considered very high quality (distortion not noticeable by an average observer under normal viewing conditions). The image on the left is the decoded output and the right is the SSIMULACRA2 distortion map which shows the perceptual error distribution.

AVIF + Spark (BC7): 241K
rocks blaze rocks blaze ssimulacra2
Basis + zstd (UASTC): 490K (or 657K with mips)
rocks basis rocks basis ssimulacra2
OodleTex + Kraken (BC7): 366K (or 499K with mips)
rocks otex rocks otex ssimulacra2
AVIF + Spark (BC7): 31K
kodim blaze kodim blaze ssimulacra2
Basis + zstd (UASTC): 249K
kodim basis kodim basis ssimulacra2
OodleTex + Kraken (BC7): 141K
kodim otex kodim otex ssimulacra2

Note how the images encoded with AVIF have a much smaller size at the same quality level.

The examples above are using:

spark.js is not limited to raster image formats. It can also be used for vector graphics, which provide a compact representation independent of scale.

SVG + Spark (BC7): 70K
Tiger SVG Tiger BC7

Browser Compatibility

spark.js requires a browser with WebGPU support and a compatible GPU driver. WebGPU is supported in most modern Chromium-based browsers and is gradually being adopted elsewhere.

The spark.js codecs work reliably across all WebGPU-enabled browsers and devices we've tested. However, some browsers have issues with other functionality in the spark.js API. The table below summarizes current support:

Chrome Edge Opera Firefox Safari
Windows ✅ no known issues ⚠️ some known issues N/A
macOS ✅ no known issues ⚠️ some known issues ⚠️ some known issues
Android ✅ no known issues ❌ not supported N/A
iOS N/A N/A ⚠️ some known issues
Linux ❓ not tested ❌ not supported N/A

Demo

To test compatibility in your browser, visit the spark.js⚡️ viewer. If the page fails to load or shows a WebGPU error, your browser may not yet support the required features.

spark.js viewer

Licensing

Whether you’re building a hobby project or a commercial product, spark.js offers simple and affordable licensing. It’s free for non-commercial use, and commercial licenses come with low one-time fees and lifetime distribution rights.

The table below summarizes the available license tiers:

License Level Non-commercial Indie Pro
Development Budget --- Under $1M Over $1M
Fee Free $1,000 $10,000
Distribution rights Lifetime Lifetime Lifetime
Support No No 1 year
Optional
Attribution Waiver No No $5,000
Yearly Support $2,000 $2,000 $5,000

Licenses are granted per project and include lifetime rights to distribute the spark.js runtime and codecs, with no royalties or ongoing fees.

Use under the free tier is governed by our non-commercial End User License Agreement.

Commercial use is governed by our Commercial License Agreement.

If you’re unsure which license applies to your project or if you’d like to discuss custom terms, get in touch.

Commercial use involves any form of monetization through direct sale, donation or promotion of a product using spark.js, and also 'internal use' where spark.js is used in a commercial setting by a business or organization.

The development budget refers to the total estimated cost of creating your web-based product at the time it is released or made publicly available. This includes expenses such as salaries, contractor fees, operational costs, licensing fees, and hardware or software purchases.

We ask that your Product visibly includes the following message:

Powered by spark.js⚡️

This attribution must include a hyperlink to https://ludicon.com/sparkjs and be visible to end users of your Product.

Pro users with a commercial license may waive this attribution requirement by purchasing an attribution waiver for an additional fee of $5,000.

Community Support:
Free for all users via the GitHub forums.

Commercial Support:
Available for purchase by Free, Indie, and Pro users.
Includes email support at support@ludicon.com with a guaranteed response within 3 business days.
Also includes early access to beta builds and targeted fixes for your use case.

Developers who require personalized support or additional features are encouraged to obtain a full Spark license. This includes:

  • Priority email support.
  • Private Slack channel access.
  • Custom performance analysis of your application.
  • One phone or video call per quarter.
  • Availability for in-person meetings at industry events.
  • Influence over the roadmap and priority consideration for feature requests.

Yes, all licenses include perpetual access to version updates.

Update frequency and content are not guaranteed and are determined solely by Ludicon.




To stay in touch with us and receive Spark development updates, consider subscribing to our newsletter:


spark.js is a product by Ludicon LLC