Guide5 min read3 sections

Cutout materials and the ivy planter

docs/ALPHA_MATERIALS.mdSource updated 2026-10-24
Markdown
On this page 3 sections

The glb-masked.1 profile adds glTF MASK materials to the owned renderer, including color, depth and both directional and point-light shadow passes. The Engine Observatory's furnished Hearth study now includes an original terracotta ivy planter with shared and reflected leaf geometry. This is development content, not a change to the playable Darkwind world or its deployed beta.

Run the development build's /diagnostics.html and choose Run the checks. The final retained image shows the furnished study and ivy after the worker has released its GPU resources.

#Import and runtime contract

Masked models use format 4. Existing format 1–3 identities remain unchanged. This stage introduced isolated compiler jobs asset-job.4 / glb-compiler.4 (advanced to version 5 by animation clips); previous cached jobs cannot satisfy the expanded contract. The independently validated runtime artifact requires a mask material, paired alphaMode: MASK and alphaCutoff, and tangent frames on masked primitives. Mask-only geometry uses deterministic fallback frames; normal-mapped geometry retains the surface profile's MikkTSpace path.

Coverage is baseColorTexture.a * baseColorFactor.a >= alphaCutoff. Equality passes; a value below the cutoff discards the fragment before color or depth writes. The cutoff defaults to 0.5. This bounded profile accepts finite values from zero through 1,000,000: zero retains even zero-alpha samples, and values above one hide the material. An explicit cutoff requires an explicit alpha mode. OPAQUE ignores a validated cutoff and base-color alpha; BLEND remains unsupported. These conventions follow the Khronos glTF specification.

A masked base-color image uses color texture processing: sRGB RGB, linear alpha, alpha-weighted linear-light RGB mips, and averaged alpha. GPU uploads use rgba8unorm-srgb, whose alpha stays linear. Emissive maps still use color-opaque; normal and parameter maps retain their existing interpretation. Factor-only masks need no image or UVs and sample a shared white fallback. Mips do not rescale alpha to preserve threshold coverage, so distant foliage can thin; coverage-preserving mip generation remains future work.

Alpha rejection affects rendering only. Static collision still follows authored geometry; transparent texels do not cut holes in physics triangles. Decorative foliage must use an appropriate collision choice in authored content.

#Rendering and ownership

The complete forward-shaders.5 bundle contains thirteen pipelines: the prior nine plus single/double-sided masked color and shadow variants. Shader replacement compiles and accepts the complete bundle atomically. Masked color draws support the same normal, occlusion, emissive and metallic/roughness maps as surface materials; texture samples precede divergent fragment rejection. Shadow draws sample the same alpha/factor/cutoff. Their empty group-1 layout avoids binding the shadow texture while writing it. The instance ABI remains 112 bytes.

Each distinct masked material group owns a separate 16-byte cutoff/factor uniform in addition to its 16-byte surface uniform. Reflected/shared geometry deduplicates material groups and image storage. Admission includes tangents, uniforms, images and the white fallback within the existing logical resource budgets. Images referenced by unused source materials remain conservatively owned and counted. Partial allocation failures destroy the candidate; rejected replacements preserve the last accepted frame. Device reconstruction reinstalls validated CPU artifacts.

The analytic panel with a backing plane owns 424 logical bytes, seven buffers and two textures. Factor-only masks allocate the fallback even when there are no source images. Counts are logical ownership, not physical VRAM measurements.

#Fixtures and acceptance

Regenerate the original sources and pinned model artifacts with:

Terminal
node --import tsx tools/cli/alpha-model-fixture.ts
node --import tsx tools/cli/ivy-planter.ts

The analytic source encodes alpha 0, 127, 128 and 255 in a 2×2 image. An independent half-panel geometry reference verifies visible coverage and depth against a later-drawn backing plane. Separate horizontal fixtures verify directional and point-light shadows. Eight controls exercise zero, exact threshold equality, cutoff above one and factor multiplication; further controls cover factor-only masks, reflected geometry, back-face culling, normal/occlusion composition, replacement and device loss.

Color/depth reference images must agree within one eight-bit channel value over the entire image. Shadow references use the same interior bound. Differences above one are permitted only within a 5×5 reference neighborhood with contrast at least 16, capped at 144 pixels (0.1% of the 480×300 image). This accounts for subpixel rasterization differences between a geometry edge and a fragment-discard edge, including the 3×3 shadow filter. The first strict whole-image comparison failed: 14 sun-case edge pixels differed, up to 71 channel values. The acceptance record retains that result and the revised criterion rather than claiming whole-image equivalence. Independent controls replace masked shadows with solid rectangles and require more than 64 changed pixels, preventing an absent-shadow implementation from passing the reference check.

The ivy source has 38 nodes, 584 instanced triangles, four source primitives and one original 128×128 RGBA leaf image. Shared leaf geometry includes reflected instances. Alongside the original Hearth asset, the final study contains 45 objects, 5,889 triangles and twelve prepared meshes. Native rendered evidence shows the leaves and trailing stems against the window and bench.

Headless checks cover isolated/packaged import, profile and rehashed-payload rejection, alpha-preserving mips, resource budgets and allocation failures, deterministic ivy generation, authored-world ECS draws and full checkpoint replay. Browser evidence exercises actual WebGPU color/depth/shadow output and exact replacement/reconstruction. The production Docker smoke imports both the analytic mask fixture and the ivy source without development dependencies.

Alpha blending, coverage-preserving mips, skeletal animation, streamed residency, live asset activation, playable-world art integration and physical-device acceptance remain open. No full milestone is closed. See the acceptance record for the exact tested source, results and limitations.

Local acceptance passes all 244 headless tests and all 26 browser scenarios, plus type/package checks, content validation and server compilation. The native study, desktop and narrow captures were inspected. Remote CI/Docker acceptance remains pending for this source; the previous surface-stage screenshot stall is retained in its CI record.

End of Cutout materials