DEV Community

Janet Malone
Janet Malone

Posted on

Rendering Minecraft armor trims in the browser without a server

For the last few weekends I've been building a small Minecraft armor trim tester. The part I expected to be simple was rendering the trims. The part that actually took time was making the previews feel immediate without shipping every combination as an image.

The approach I landed on is a small client-side compositing pipeline. Each armor piece is a base texture. Each trim pattern is an alpha mask. Each trim material is just a palette. When you pick diamond chestplate plus gold silence, the browser draws the base piece to an offscreen canvas, draws the mask on top, then uses canvas compositing to replace the mask's opaque pixels with the material's trim color while keeping the mask's edges. The result is cached as an ImageBitmap keyed by piece, pattern, and material. Toggling a different piece is mostly a cache lookup.

Two details mattered. First, I don't use a single hue-rotate filter for trim colors. It looks plausible at a glance, but iron on netherite shifts the base armor too, and gold ends up looking like dirty yellow. The trim material needs its own small set of colors from the game's palette, otherwise the preview lies. Second, pixel art at non-integer scale is a trap. If you render a 16x16 armor texture at 2.5x, the trim mask bleeds into neighboring pixels and the preview looks fuzzy. I render at integer scale, disable image smoothing on the canvas, and let CSS scale the final element with image-rendering: pixelated.

The use case I kept coming back to is planning a set before spending materials. Say you have a netherite chestplate with gold trim and you're considering a diamond helmet with quartz trim. You want to see whether the two pieces read as a set before you commit. A static screenshot doesn't help because the combination space is large. A server render would work, but it adds latency and a cost that a free no-signup tool shouldn't need. Doing the compositing in the browser means changing a dropdown is instant after the first render, and the app still works if the backend is asleep.

There are limits. I'm not trying to be a full 3D skin viewer. The tool is a flat, front-facing preview for comparing armor trims. That constraint is what made the browser-side approach practical. If you want to check a trim combination, you can try it at Armor Trim Tester. It is free and runs in the browser without an account.

Top comments (0)