pub fn project_triangle_fogged(
verts: [Vec3I16; 3],
normals: [Vec3I16; 3],
material: (u8, u8, u8),
) -> FoggedTriExpand description
Run the full PS1-commercial triangle pipeline with per-vertex
fog. Three interleaved RTPS + NCDS pairs give each vertex its
own IR0 (its own depth-cue weight), then NCLIP + AVSZ3
finish the bookkeeping.
§Why per-vertex, not batched
RTPT + NCDT is faster (4 GTE ops vs 8) but produces uniform
fog across each triangle – RTPT only writes IR0 for the last
vertex, and NCDT then reuses that single IR0 for each
vertex’s stage-3 blend. The visible result is stepped shading:
every triangle has one flat fog tint, and seams between
triangles are obvious.
3× RTPS + 3× NCDS sets IR0 per vertex, so NCDS blends
each vertex’s material toward FC by that vertex’s own depth
weight. GP0 0x34 Gouraud-interpolates the three vertex tints
across the triangle, giving a smooth per-pixel gradient with
no inter-triangle seam.
Cost is about 2× the GTE work per triangle vs the batched path. Still well under budget for PSX-scale scenes (~100 tris/frame).
§Pipeline
For each vertex i = 0, 1, 2:
- Load
verts[i]into V0. RTPS– projects V0, pushes SXY + SZ FIFOs, setsIR0from DQA/DQB × the perspective divisor.- Load
normals[i]into V0 (overwriting the position –RTPSalready consumed it). NCDS– computes lit + fogged colour using the currentIR0, pushes RGB FIFO.
After the loop:
5. NCLIP – reads SXY0/1/2 from the FIFO, flags back-face.
6. AVSZ3 – reads SZ1/2/3, computes the OT-slot key.
NCDS doesn’t touch the SXY or SZ FIFOs, so they still hold
the three per-vertex projection results when NCLIP and AVSZ3
run at the end.
§Prerequisites
All scene state must be loaded by the caller:
- Rotation matrix (
scene::load_rotation) - Translation (
scene::load_translation) - Projection plane + screen offset
(
scene::set_projection_plane,scene::set_screen_offset) - Light rig (
LightRig::load,for_objectapplied) - Far colour (
scene::load_far_color) - Depth-cue coefficients (
scene::set_depth_cue) - AVSZ weights (
scene::set_average_z_weights)