Skip to content

MewoLab/nijika-wasm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nijika

nijika

Nijika is a custom lightweight WebAssembly module capable of reading specific AssetBundles and DDS textures. It is the backend for AquaNet2's local asset viewer.

Nijika is NOT a general-purpose asset reader yet, it is only made to meet our needs. The limitations for what it is capable of reading are shown below.

Features

It can read...

  • Unity (specifically targetting 2018.4 at the moment, 5.X support may come later) Texture2Ds within AssetBundles with most compression types supported.
  • DDS files compressed with DXT1, DXT3, DXT5 or uncompressed RGB, RGBA, BGR, and BGRA.
  • AWB (with ACB) sound files using vgmstream

It also decodes compression on CPU, not relying on specific GPU extensions that aren't available on some systems. (In the future, it might be a good idea to add GPU support for devices that can decode these formats for added efficiency. For now it's fast enough, though)

Goals

  • Unity 5 support
  • Increase scope for reading AssetBundles?
  • Github Workflow?
  • Better documentation for building & Windows

Building

Requirements

  • Emscripten
  • CMake

Building (Unix-likes)

❗ You can find the latest stable build in the Releases tab.
Please read the release notes for more information.

  1. Pull latest submodules
git submodule update --init --remote --recursive
  1. Build

⚠️ This hasn't been formally tested. I use CLion, sorry

mkdir library
cd library
emcmake .. -DCMAKE_TOOLCHAIN_FILE=$EMSDK/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake
cmake --build .

Usage

Nijika has a TypeScript interface (nijika.ts).
You will have to pass in the module buffer since it cannot find it on it's own.

import { Nijika } from "./nijika.ts";

const nijika = new Nijika(
    await fetch("./nijika.wasm").then(response => response.arrayBuffer())
);
await nijika.loaded;

// For DDS (DXT1, DXT3, DXT5)
nijika.dds(ddsBuffer) // -> outputs blob (not a promise)

// For DDS (BC1/2/3, BC7 & RGB-likes)
nijika.assetBundle(abBuffer) // -> outputs blob (not a promise)

// For AWB/ACB (no custom key support, it MUST be one of the keys included with VGMStream)
// Note: You cannot swap between AWBs willy nilly, you must reinstantiate with .awb() every time you swap.
const awb = nijika.awb(awbBuffer, acbBuffer) // (acb is optional) -> outputs an AWB
awb.trackList() // -> outputs string[]
awb.get(trackIndex) // (index is optional) -> outputs blob

References

Nijika was put together using the following references. Thank you to everyone who helped with the following and Nijika!

  • AssetStudio - Unity CAB file format
  • vgmstream - Audio decoding
  • fpng (Love your work, thank you especially) - PNG creation
  • bcdec - BC1/2/3 & 7 decoding
  • lz4 - Unity AssetBundle compression
  • 7-Zip - LZMA compression

About

A simple WebAssembly module for parsing AssetBundles, DDS, and more.

Resources

License

Stars

Watchers

Forks

Packages

No packages published