Research
SPRITETOMESH: Automatic Mesh Generation for 2D Skeletal Animation Using Learned Segmentation and Contour-Aware Vertex Placement
Overview Research area: Computer vision applied to 2D graphics production — specifically, automatic triangle mesh generation from game sprite images for skeletal animation frameworks. Technical level:

- arXiv
- 2602.21153
- Published
- 2026-02-24
- Authors
- Bastien Gimbert
AI summary
Overview
Research area: Computer vision applied to 2D graphics production — specifically, automatic triangle mesh generation from game sprite images for skeletal animation frameworks.
Technical level: Intermediate. The paper assumes familiarity with convolutional segmentation networks (U-Net, EfficientNet) and classical computer vision primitives (Canny, bilateral filtering, Douglas-Peucker, Delaunay triangulation), but it explains each component clearly.
Scope in one sentence: The paper presents SpriteToMesh, a four-stage pipeline that converts a single 2D sprite image into an animation-ready triangle mesh by combining a learned segmentation network with algorithmic, contour-aware vertex placement.
What This Paper Is About
In 2D skeletal animation (used by frameworks such as Spine2D, DragonBones, Live2D, and Creature Animation), an artist must draw a triangle mesh over a sprite so that different parts of the artwork can be deformed by bones. Today that mesh is placed entirely by hand, which the paper reports takes 15–60 minutes per sprite. The goal of this work is to automate the whole process: given a sprite image, produce a mesh whose vertices sit both on the outer silhouette and along internal visual boundaries such as limb edges and clothing seams, so distinct regions can be deformed independently.
Key Contributions
- A fully automatic four-stage pipeline (mask acquisition, exterior contour extraction, interior boundary detection, Delaunay triangulation) that produces a Spine2D-compatible JSON mesh from an arbitrary sprite, running in under 3 seconds per sprite.
- A trained segmentation model — an EfficientNet-B0 encoder with a U-Net decoder, approximately 9.3 million parameters — trained on over 100,000 sprite-mask pairs from 172 games, achieving an IoU of 0.87 (0.8697 on the validation set).
- A documented negative result: a controlled experiment showing that direct vertex position prediction by heatmap regression does not work for this task. The heatmap decoder's loss plateaued at 0.061 while the segmentation decoder trained normally under identical conditions, which the author attributes to the inherently artistic, non-unique nature of vertex placement.
- A novel dataset and tooling: a dataset of 100,363 samples (74,366 "region" samples with masks only, and 25,997 "mesh" samples with masks and vertex annotations) built by decoding 882 binary Spine
.skelfiles with a released converter, SkelToJson, which achieved a 100% conversion success rate.
Main Findings
- Segmentation performance: On the validation set at the best epoch (epoch 14), the model reached an IoU of 0.8697, a Dice score of 0.9304, pixel accuracy of 0.9741, a BCE loss of 0.0523, and a Dice loss of 0.0696. Failures concentrated on sprites with very thin structures (hair strands, weapon tips) and sprites whose foreground color closely matched the composited background.
- Heatmap regression fails: The segmentation head converged to an IoU of 0.87, while the heatmap head hit a loss plateau of 0.061 with approximately zero peak recall, learning only a near-uniform low activation over the sprite region rather than localized vertex peaks. Table 2 lists final losses of 0.122 (segmentation) versus 0.061 (heatmap plateau).
- Mesh statistics: Across test sprites, the generated meshes averaged 64 ± 12 exterior vertices, 420 ± 180 interior vertices, 484 ± 185 total vertices, and 890 ± 350 triangles, with a processing time of 1.8 ± 0.6 seconds and mask coverage above 99.5%.
- Ablation results: The full pipeline reached 78.3% boundary adherence with 484 vertices and an angle ratio of 0.42. Removing the bilateral filter dropped adherence to 71.2% and raised vertex count to 623; single-channel Canny dropped it to 64.8%; removing Douglas-Peucker simplification raised the vertex count to 1,847 with only 76.5% adherence; removing arc subdivision gave 73.1% with 389 vertices; grid-only interior placement gave 42.6%; and removing interior vertices entirely gave 0% adherence with 64 vertices.
- Component importance, quantified: Bilateral filtering reduced spurious vertices by 22% while improving boundary adherence by 7.1 percentage points. Multi-channel Canny captured 13.5 more percentage points of boundaries than grayscale-only detection. Without Douglas-Peucker simplification, 3.8× more vertices were generated for only marginally better adherence and worse triangle quality.
- Baseline comparison: Alpha-only hull achieved 0% boundary adherence with 64 vertices and 1 articulable region; uniform grid achieved 42.6% with 520 vertices (partial articulation); Shi-Tomasi corners achieved 55.3% with 667 vertices (partial); SpriteToMesh achieved 78.3% with 484 vertices and full articulation.
- Runtime: A 6000 × 6000 pixel sprite is processed in under 3 seconds on an NVIDIA RTX 4070 Laptop with 8 GB VRAM — under 0.1 s for the alpha mask path, about 0.3 s for the model path, about 0.2 s for exterior contour extraction, about 1.2 s for interior boundary detection, and about 0.1 s for triangulation. This is reported as a 300× to 1200× speedup over manual creation.
- Limited generalization: The model was trained exclusively on Spine2D sprites from online casino and slot games (172 games spanning anime, cartoon, and pixel art styles) and does not generalize to arbitrary images such as logos, photographs, vector icons, or non-game artwork.
Methodology in Plain English
The pipeline avoids trying to make one model do everything, and instead splits the problem by whether the ground truth is unambiguous.
- Get a mask. If the sprite has an alpha channel that is not uniformly opaque, the mask is produced by simple thresholding at 128. Otherwise, a U-Net with an EfficientNet-B0 encoder (pre-trained on ImageNet) predicts the foreground mask from a 256 × 256 RGB image. Training uses a combined binary cross-entropy plus Dice loss with AdamW, a learning rate of 10⁻³ for the decoder and 10⁻⁴ for the encoder, weight decay of 10⁻⁴, and cosine annealing over 30 epochs with a batch size of 32. To force the network to learn from visual features rather than alpha transparency, every training sprite is composited onto a random background — solid color, gradient, or Perlin-like noise.
- Trace the outside. The mask contour is lightly smoothed, extracted at full resolution, then simplified with Douglas-Peucker at a tolerance of 0.003 × perimeter to find structural keypoints (corners, concavities, inflection points). Between keypoints, extra vertices are added by walking along the actual contour path at regular arc-length intervals, targeting 50 exterior vertices.
- Find the inside edges. The RGB image is bilateral-filtered (d = 9, σ_color = 75, σ_space = 75) to remove texture noise. Canny edge detection at thresholds 40 and 120 is run separately on the grayscale, R, G, and B channels and the results are OR'd together, so edges visible in only one channel are not missed. Edges near the silhouette are removed by masking with an eroded mask, small gaps are closed morphologically, and vertices are placed along the surviving contours — simplified with Douglas-Peucker at 0.012 × arc length, subdivided every 40 pixels, kept only if at least 6 pixels from the mask boundary, and globally deduplicated at an 18-pixel radius.
- Triangulate and filter. All vertices are fed to Delaunay triangulation; any triangle whose centroid falls outside the mask is discarded, ensuring the mesh covers only the sprite foreground.
The paper also describes a deliberate experiment in doing this the "end-to-end" way: adding a second decoder head that predicts vertex heatmaps (Gaussian kernels with σ = 3 pixels, weighted MSE with positive pixel weight 100, combined with the segmentation loss at λ = 50). That head never converged, which the author argues is expected, because the same sprite can be validly meshed many different ways — there is no single correct answer for a network to learn.
Why This Matters
The paper's impact comes from two places. First, it removes a genuine production bottleneck: the 15–60 minutes per sprite of manual vertex placement, multiplied across asset libraries that may contain hundreds or thousands of sprites. Second, its negative result is a useful research signal — it argues that vertex placement in animation meshes belongs in the same category as artistic decisions rather than anatomical keypoints, and that hybrid learned/algorithmic designs are the right response when ground truth is ambiguous.
Real-world applications:
- Game studios and indie developers producing 2D skeletal animation assets, who can pre-generate meshes instead of drawing them by hand in Spine2D.
- Live-service and mobile games with large, frequently updated sprite libraries, where automated meshing reduces turnaround time on new content.
- Asset pipeline and tooling developers who need a programmatic way to convert raw sprite art into riggable meshes at scale.
- 2D animation and motion design tools that could incorporate automatic meshing as a first-pass step before artists refine the result.
Industry relevance: the released model targets the Spine2D ecosystem specifically, and the paper notes that existing auto-mesh tools in that ecosystem only look at the alpha channel, producing regular grids or convex hulls that ignore internal visual structure entirely. A tool that follows internal boundaries is a direct improvement over what is currently shipped in these products.
Future Directions
- Automatic parameter tuning. The interior detection stage depends on several thresholds (Canny thresholds, minimum contour length, deduplication radius); the paper suggests conditioning these on image statistics or sprite category rather than relying on fixed defaults.
- Semantic awareness. The current method uses only low-level features such as edges and color transitions, and cannot distinguish arms from legs or identify clothing layers. Integrating semantic segmentation or part-based decomposition could place vertices in functionally meaningful locations.
- Automatic skeleton generation. The paper identifies auto-rigging — producing both the mesh and the bone hierarchy from one sprite — as the natural extension of this work.
- Style adaptation and generalization. Because training data came exclusively from Spine2D casino and slot games, extending to logos, photographs, vector icons, and non-game artwork would require domain adaptation or fine-tuning on a broader dataset.
Target Audience
This paper is most useful to game developers and technical artists working with 2D skeletal animation, to graphics and computer vision researchers interested in mesh generation from images or in hybrid learned/algorithmic pipelines, and to tooling engineers building asset production pipelines. Readers looking for a concrete case study of when a neural network should and should not be used — and what a well-documented negative result looks like — will also find it valuable.
Authors’ abstract
We present SPRITETOMESH, a fully automatic pipeline for converting 2D game sprite images into triangle meshes compatible with skeletal animation frameworks such as Spine2D. Creating animation-ready meshes is traditionally a tedious manual process requiring artists to carefully place vertices along visual boundaries, a task that typically takes 15-60 minutes per sprite. Our method addresses this through a hybrid learned-algorithmic approach. A segmentation network (EfficientNet-B0 encoder with U-Net decoder) trained on over 100,000 sprite-mask pairs from 172 games achieves an IoU of 0.87, providing accurate binary masks from arbitrary input images. From these masks, we extract exterior contour vertices using Douglas-Peucker simplification with adaptive arc subdivision, and interior vertices along visual boundaries detected via bilateral-filtered multi-channel Canny edge detection with contour-following placement. Delaunay triangulation with mask-based centroid filtering produces the final mesh. Through controlled experiments, we demonstrate that direct vertex position prediction via neural network heatmap regression is fundamentally not viable for this task: the heatmap decoder consistently fails to converge (loss plateau at 0.061) while the segmentation decoder trains normally under identical conditions. We attribute this to the inherently artistic nature of vertex placement - the same sprite can be meshed validly in many different ways. This negative result validates our hybrid design: learned segmentation where ground truth is unambiguous, algorithmic placement where domain heuristics are appropriate. The complete pipeline processes a sprite in under 3 seconds, representing a speedup of 300x-1200x over manual creation. We release our trained model to the game development community.