EPOK RUNTIME
Polygon
polygon.hpp · PSX polygon preparation, clipping and submission
Module
PSX polygon preparation, clipping and submission.
Include this module
C++ include
#include "polygon.hpp"Types
CameraQ12Q12 camera coordinates (4096 = one unit), as used by scripts and colliders.Type aliasCameraQ8Q8 camera coordinates (256 = one unit) produced by the GTE projection path.Type aliasCameraUnitsCamera-space scale used by the renderer.Class templateClipVertexStruct declared by the polygon module for PSX polygon preparation, clipping and submission.StructProjectedVertexStruct declared by the polygon module for PSX polygon preparation, clipping and submission.StructQuadPacketPer-quad attributes prepared once, then copied per emitted triangle.StructFunctions and methods
blend_fogPerforms `blend fog` as part of PSX polygon preparation, clipping and submission.FunctionbucketOrdering table bucket from three depths: (za+zb+zc) / (3 << DepthShift), exact for the frustum range without an integer division.Methodclip_polygonSutherland-Hodgman against the frustum planes named by `planes` (bit i = plane i of frustum_outcode).Function templatefloor_divFloor division for a positive divisor, matching the GTE's arithmetic shift.Functionfog_amountLinear fog: 0 before start, 4096 at or beyond end.Functionmodulate_channel(c * 128 + 127) / 255 for c in 0..255, exact without a division.Functionmodulate_colorPerforms `modulate color` as part of PSX polygon preparation, clipping and submission.Functionpack_colorPerforms `pack color` as part of PSX polygon preparation, clipping and submission.Functionproject_cpuCPU perspective for clipped or fallback vertices, rounding like the GTE so mixed triangles share edges.Function templatescale_channela * b / 255 for 0..255 inputs, exact.Functionscreen_areaScreen area sign in the GPU's coordinate system; zero for degenerate triangles.FunctionFields, variables and values
cameracamera space, CameraUnits scaleFieldclut16already shifted into the high halfwordFieldcolorExposes `color` on `epok::ClipVertex` for PSX polygon preparation, clipping and submission.FieldcommandGPU command byte with transparency bitFielddepth_biasExposes `depth_bias` on `epok::QuadPacket` for PSX polygon preparation, clipping and submission.FieldfarExposes `far` on `epok::CameraUnits` for PSX polygon preparation, clipping and submission.Variablefinal_colorpacked 0x00BBGGRR; modulated (128 = 1.0) when texturedFieldfogQ12 fog amount, 0 when nearer than the fog startFieldnearExposes `near` on `epok::CameraUnits` for PSX polygon preparation, clipping and submission.VariableoutcodeExposes `outcode` on `epok::ProjectedVertex` for PSX polygon preparation, clipping and submission.FieldpExposes `p` on `epok::ClipVertex` for PSX polygon preparation, clipping and submission.Fieldscreenvalid when visibleFieldshadedpacked fogged 0..255 colors kept for the clipperFieldtexturedExposes `textured` on `epok::QuadPacket` for PSX polygon preparation, clipping and submission.Fieldtpage16already shifted into the high halfwordFielduv16.16 texture pixelsFielduvu | v << 8FieldvisibleExposes `visible` on `epok::ProjectedVertex` for PSX polygon preparation, clipping and submission.Field