F3DEX3
|
Modern microcode for N64 romhacks. Will make you want to finally ditch HLE. Heavily modified version of F3DEX2, partially rewritten from scratch.
F3DEX3 is in alpha. It is not guaranteed to be bug-free, and updates may bring breaking changes.
View the documentation here (or just look through the docs folder).
Compared to F3DEX2 or any other F3D family microcode, F3DEX3 is...
LVP_NOC
configuration (see docs), also faster on the RSPall at the same time!
G_PACKED_NORMALS
enables simultaneous vertex colors and normals/lighting on the same mesh, by encoding the normals in the unused 2 bytes of each vertex using a variant of octahedral encoding. The normals are effectively as precise as with the vanilla method of replacing vertex RGB with normal XYZ.G_AMBOCCLUSION
enables ambient occlusion for opaque materials. Paint the shadow map into the vertex alpha channel; separate factors (set with SPAmbOcclusion
) control how much this affects the ambient light, all directional lights, and all point lights.G_LIGHTTOALPHA
moves light intensity (maximum of R, G, and B of what would normally be the shade color after lighting) to shade alpha. Then, if G_PACKED_NORMALS
is also enabled, the shade RGB is set to the vertex RGB. Together with alpha compare and some special display lists from fast64 which draw triangles two or more times with different CC settings, this enables cel shading. Besides cel shading, G_LIGHTTOALPHA
can also be used for bump mapping or other unusual CC effects (e.g. texture minus vertex color times lighting).G_FRESNEL_COLOR
or G_FRESNEL_ALPHA
enable Fresnel. The dot product between a vertex normal and the vector from the vertex to the camera is computed; this is then scaled and offset with settable factors. The resulting value is then stored to shade color or shade alpha. This is useful for:G_LIGHTING_SPECULAR
changes lighting computation from diffuse to specular. If enabled, the vertex normal for lighting is replaced with the reflection of the vertex-to-camera vector over the vertex normal. Also, a new size value for each light controls how large the light reflection appears to be. This technique is lower fidelity in some ways than the vanilla hilite
system, as it is per-vertex rather than per-pixel, but it allows the material to be textured normally. Plus, it supports all scene lights (including point) with different dynamic colors, whereas the vanilla system supports up to two directional lights and more than one dynamic color is difficult.G_ATTROFFSET_ST_ENABLE
applies a settable offset to vertex ST (SPAttrOffsetST
) after the texture scale. This enables UV scrolling without CPU intervention.SPDontSkipTexLoadsAcross
command.SPTriangleStrip
and SPTriangleFan
commands pack up to 5 tris into one 64-bit GBI command (up from 2 tris in F3DEX2). In any given object, most tris can be drawn with these commands, with only a few at the end drawn with SP2Triangles
or SP1Triangle
. So, this cuts the triangle portion of display lists roughly in half, saving DRAM traffic and ROM space.SPAlphaCompareCull
command enables culling of triangles whose computed shade alpha values are all below or above a settable threshold. This substantially reduces the performance penalty of cel shading–only tris which "straddle" the cel threshold are drawn twice, the others are only drawn once.SPMemset
command fills a specified RDRAM region with a repeated 16-bit value. This can be used for clearing the Z buffer or filling the framebuffer or the letterbox with a solid color faster than the RDP can in fill mode. Practical performance may vary due to scheduling constraints.SPSetLights
), rather than one per light.SPLightToRDP
family of commands (e.g. SPLightToPrimColor
) writes a selectable RDP command (e.g. DPSetPrimColor
) with the RGB color of a selectable light (any including ambient). The alpha channel and any other parameters are encoded in the command. With some limitations, this allows the tint colors of cel shading to match scene lighting with no code intervention. Also useful for other lighting-dependent effects.F3DEX3 introduces a suite of performance profiling capabilities. These take the form of performance counters, which report cycle counts for various operations or the number of items processed of a given type. There are a total of 21 performance counters across multiple microcode versions. See the Profiling section below.
F3DEX3 modifications from F3DEX2 are by Sauraen and are dedicated to the public domain. cpu/
C code is entirely by Sauraen and also dedicated to the public domain.
If you use F3DEX3 in a romhack, please credit "F3DEX3 Microcode - Sauraen" in your project's in-game Staff Roll or wherever other contributors to your project are credited.
Other contributors: