Module border

Module border 

Source
Expand description

Outer + inner border pass.

MD2 paints two rectangular rings around the frame between the wave / shape overlays and the blur pyramid. Outer ring thickness comes from ob_size, inner from ib_size; both are MD2-space fractions of the shorter screen dimension, so a horizontal strip on a 16:9 display is screen-symmetric (the thickness in x is divided by the aspect ratio).

Implementation: one alpha-blended TriangleList pipeline, no vertex buffer. The vertex shader derives the 24-vertex frame from @builtin(vertex_index) and a per-draw uniform carrying the outer extent (e.g. (1, 1) for the outer ring), the inner extent (e.g. (1 - t_x, 1 - t_y)), and the ring colour. Two draws per frame at most; both are no-ops when the alpha is zero.

Dispatch slot: after CustomShapeRenderer, before the blur pyramid — so the rings feed back next frame (a high-decay preset trails them inward, mirroring MD2’s behaviour) and contribute to GetBlur*.

Structs§

BorderRenderer
GPU pass for the two MD2 border rings.
BorderUniform
One ring’s per-draw uniform: outer + inner clip-space extents and the ring’s RGBA colour. The vertex shader treats the extents as (±outer_x, ±outer_y) for the outer quad corners and (±inner_x, ±inner_y) for the inner quad corners; the four frame strips (top/bottom/left/right) are built from those eight corners.

Constants§

BORDER_VERTICES_PER_RING
Number of vertices the WGSL shader expands per ring. 4 strips × 2 triangles × 3 vertices = 24. Exposed for tests.

Functions§

ring_uniform 🔒
Build a BorderUniform for one ring given its outer extent (out_x, out_y) in clip space, the MD2 size (a fraction of the shorter screen axis), the RGBA colour, and the framebuffer aspect ratio width / height.