Expand description
One-plane convex clip of eight-lane i32 vertices.
GoldSrc’s renderers (Half-Life, Counter-Strike) clip textured polygons
against the view frustum in view space, one plane at a time, carrying
position, colour and UV as eight i32 lanes: [x, y, z, r, g, b, u, v].
Every plane they use is linear in two of those lanes, and every crossing is
interpolated the same way, so the whole pass is one function of the plane’s
four numbers. clip_lanes8_plane_reference states it with the generic
attributed_clip kernel; with the asm-kernels
feature on the console, clip_lanes8_plane runs a hand-scheduled kernel
that produces the same bytes.
§Definition
A vertex v is inside when
v[primary_offset / 4] * primary + v[2] * depth + bias >= 0 (wrapping
i32 arithmetic). The polygon is traversed previous-to-current; each edge
whose endpoints disagree emits a crossing before the current vertex, and an
inside vertex is copied. A crossing orders its endpoints by (x, y, z)
(signed, lexicographic) so a shared edge interpolates identically from both
sides, takes t = ratio_q12_i32(d_a, d_a - d_b) with the distances in that
order, and sets every lane to lerp_q12_i32_wide of the two endpoints;
lane 2 is then replaced by forced_depth when force_depth is non-zero (a
near plane lands exactly on its distance). When count vertices would
overflow capacity the pass stops and returns capacity.
Structs§
Functions§
- clip_
lanes8_ ⚠plane clip_lanes8_plane_reference, or the hand-scheduled kernel on the console when theasm-kernelsfeature is on. Same safety contract; the two produce identical bytes (hello-asmprobechecks it).- clip_
lanes8_ ⚠plane_ reference - Clip
countvertices atsrcagainstplaneintodst, returning how many were written. The portable definition.
Type Aliases§
- Lanes8
- One vertex:
[x, y, z, r, g, b, u, v].