Skip to main content
← PSoXide SDK guides and examples · SDK 80d1c329e977 · All Cargo features enabled; check feature gates before use.

Module clip_lanes

Module clip_lanes 

Source
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§

LanePlane
A clip plane over Lanes8 vertices; see the module definition.

Functions§

clip_lanes8_plane⚠
clip_lanes8_plane_reference, or the hand-scheduled kernel on the console when the asm-kernels feature is on. Same safety contract; the two produce identical bytes (hello-asmprobe checks it).
clip_lanes8_plane_reference⚠
Clip count vertices at src against plane into dst, returning how many were written. The portable definition.

Type Aliases§

Lanes8
One vertex: [x, y, z, r, g, b, u, v].