Every browser <canvas>.toDataURL('image/png') silently quantizes your heightmap down to 8 bits per channel (256 discrete shades). For web thumbnails nobody notices. For a 60W MOPA fiber laser or xTool F1 Ultra running 200 slices into a 40 mm C360 brass challenge coin, 8-bit quantization creates ugly 7.8 µm topographic contour terraces across every domed medallion and beveled rim.

To solve that cleanly without a server render farm, we built a zero-dependency true 16-bit big-endian grayscale PNG encoder and parametric signed-distance-field (SDF) heightmap generator in pure TypeScript — powering our free browser utility at CutPath CAD /depth-map-test.

1. Why HTML5 Canvas Fails 3D Fiber Slicing (and How to Emit Raw bitDepth = 16 PNGs)

The PNG specification (ISO/IEC 15948) natively supports bitDepth = 16, colorType = 0 (grayscale) — storing 65,535 Z-levels per pixel (0.031 µm step resolution on a 2.0 mm relief!). Browser Canvas APIs only expose Uint8ClampedArray RGBA buffers, so we assemble the PNG chunks directly from our Float32Array heightfield using fflate.zlibSync and an IEEE 802.3 CRC32 table:

  • IHDR: 13-byte header with bitDepth = 16, colorType = 0, compression = 0, filter = 0, interlace = 0.
  • pHYs (Critical for LightBurn & XCS 1:1 Scale): 9-byte chunk encoding exact pixels-per-meter (Math.round((cols / widthMm) * 1000) with unit byte 1 = meters). Without pHYs, LightBurn and xTool Creative Space guess 72 or 96 DPI and import your 40 mm brass coin at the wrong physical size.
  • IDAT: Scanlines prefixed with filter byte 0x00 followed by big-endian uint16 height values ((u16 >>> 8) & 0xff, u16 & 0xff), compressed with deflate level 6.

2. Parametric SDF Geometry & Helical Rope Borders

Instead of hand-painting noisy Photoshop gradients, every blank in CutPath's Challenge Coin & Calibration Generator is evaluated analytically in millimeter space:

  • Calibration Grid Card (50×50 mm): 16/25/32 caliper pads, a full-width continuous 16-bit ramp, a mathematically circular hemispherical boss (instantly reveals 8-bit contour rings), and progressive micro-wall survival ridges.
  • Helical Rope & Milled Reeded Coin Rims: Evaluated in polar coordinates (r, θ) with sin(θ * ropeCount + tRim * 2.6π) modulated by a smooth crown envelope and bidirectional smoothstep outer chamfer.
  • Tapered Brass Wax Seal & Zippo Rounded-Box SDF: Uses exact sdRoundedBox(px, py, hx, hy, r) with selectable 10°–45° wall draft angles and 1-click Black = High polarity inversion for recessed molds.

3. Real-Time Blinn-Phong Brass Normal Shading + 100-Pass Caliper Calibration

Before burning a single pass, operators inspect the heightfield with real-time finite-difference surface normals (dz/dx, dz/dy), cavity ambient occlusion, and Blinn-Phong specular highlights in Antiqued Brass, Brushed Steel, Carved Walnut, Thermal Z, or Raw 16-Bit Map views — plus a live centerline Z cross-section and 100-pass caliper pass-depth calculator.

Try It Free (Zero Signup)