spritefusion-sprite-normals README

The project's README from github.com/Hugo-Dz/spritefusion-sprite-normals. As one markdown file: README.md.

Sprite Fusion Sprite Normals

A tool to generate normal maps for pixel art sprites and animations. Written in Rust, available as a CLI and a WebAssembly library.

Sprite Normals

Why ?

Normal maps let 2D sprites react to dynamic lighting. Ideal for 2.5D games.

Features:

Perfect for

๐Ÿ’ป CLI

Build from source

Requires Rust 1.85 or newer. From this directory:

cargo build --release --locked

The binary is available at target/release/spritefusion-sprite-normals. To install it locally:

cargo install --path . --locked

Usage

spritefusion-sprite-normals <INPUT>... [OPTIONS]
spritefusion-sprite-normals sprite.png -o sprite_n.png
spritefusion-sprite-normals sprites/*.png --output-dir normals
spritefusion-sprite-normals sprite.png -o sprite_n.png --normal-strength 2
spritefusion-sprite-normals sheet.png --frame-size 32x32 -o sheet_n.png
spritefusion-sprite-normals walk.gif -o walk_n.png

Without an output path, maps are saved beside their inputs as <name>_n.png. Run spritefusion-sprite-normals --help for every option.

Animations

GIF and APNG inputs, and PNG sheets with --frame-size, produce three files:

Frames are arranged in row-major order. delays_ms contains [numerator, denominator] pairs in milliseconds. PNG sheets keep their layout and receive a default 100 ms frame delay. Source loop counts are not exported.

Normal PNGs are data textures: disable sRGB sampling in your engine. Use artwork at its native pixel resolution. Generation estimates relief from color and shape; painted highlights can also become surface detail.

๐ŸŒ Web (WASM)

Build with the wasm32-unknown-unknown Rust target and wasm-bindgen CLI 0.2.126:

cargo build --release --target wasm32-unknown-unknown --no-default-features --locked
wasm-bindgen target/wasm32-unknown-unknown/release/spritefusion_sprite_normals.wasm --target web --out-dir pkg

Use the generated package in your project:

import init, { generate_normal_map } from "./pkg/spritefusion_sprite_normals.js";

await init();
const result = generate_normal_map(inputBytes, JSON.stringify({ strength: 1.5 }));
try {
  const normalPng = result.normal_png;
  const colorPng = result.color_png;
  const metadata = JSON.parse(result.metadata);
  // Use these bytes to save files or create image URLs.
} finally {
  result.free();
}

Pass a Uint8Array and "{}" for default settings. Optional keys are strength, detail, smoothing, volume, frame_width, frame_height, and directx. Returned arrays own their bytes and remain valid after free().

The CLI and WASM module use the same generator and animation decoder. Inputs are limited to 64 MiB and 4,194,304 pixels including processing padding; animated inputs additionally allow up to 256 frames and 4,194,304 total decoded pixels.

Development

cargo test --locked
cargo clippy --all-targets --locked -- -D warnings
cargo fmt --check

Acknowledgments

Sprite Normals is a Sprite Fusion project. Sprite Fusion is a tool to generate pixel art sprites and animations for game development.

Other open source pixel art tools

Pixel Snapper

License

MIT License โ€” Hugo Duprez.

spritefusion-sprite-normals (Hugo-Dz/spritefusion-sprite-normals)

pixel-art
Searching Databaseโ€ฆ

What is this?A tool that generates normal maps from pixel art sprites and animated sprite sheets, so 2D sprites can react to dynamic lighting in 2.5D games.
Is this a CLI tool or a library?Both: it's a native Rust CLI binary for local/batch processing, and the same generator compiles to a WebAssembly library for browser-based pipelines.
How do I get the CLI running?Build it from source with Rust 1.85+ using cargo, then find the binary at target/release/spritefusion-sprite-normals, or install it locally from that directory.
Do I need anything besides Rust to build this?For the CLI you just need Rust 1.85+; for the WASM build you additionally need the wasm32-unknown-unknown target and wasm-bindgen CLI 0.2.126.
Are there limits on what sprites it can process?Yes: inputs are capped at 64 MiB and about 4.19 million pixels, with animations additionally limited to 256 frames and the same total decoded pixel budget; original GIF/APNG loop counts aren't preserved in the output.
Who is this aimed at?Game developers making 2D games with dynamic lighting, pixel artists animating sprites that need matching normal-map frames, and anyone building asset pipelines that need native CLI or in-browser processing.
Does this run offline or only in a browser?It runs fully locally: the CLI processes sprites, sheets, and animations on your machine, with the WASM build giving the same offline-capable generator inside a browser or web app.
Does my artwork ever leave my machine?No, processing happens locally in both the CLI and WASM module โ€” no server or upload is involved.
What file formats can I feed into it?PNG sprites or sheets, GIF, and APNG files can all be used as input.
What do I get back for an animated input?Three files: a lossless normal-map atlas, a matching color atlas, and a frames.json file describing atlas/frame dimensions, columns, frame count, and timing.
Can I tune how strong the embossed effect looks?Yes, flags like --normal-strength, --detail-strength, --detail-scale, and --shape-strength let you control overall depth, shading relief, smoothing, and silhouette volume, each with sensible defaults.
Does it support DirectX-style normal maps or just OpenGL?It defaults to OpenGL-style normals but supports --normal-format directx to reverse the green channel for DirectX conventions.
What are similar projects?Pixelorama, raylib, slimdeer, bevy, pyxel, aseprite, pdfcraft, parin
Creator
Hugo-Dz
Size
0.7 MB
Stars
839
Updated
CommitOct 20
Age
1mo
Commits ยท 90 Days