F3DEX3
|
Modern graphics microcode for N64 romhacks. Will make you want to finally ditch HLE. Heavily modified version of F3DEX2, with all vertex and lighting code rewritten from scratch.
F3DEX3 is in beta. The GBI should be relatively stable but may change if there is a good reason.
View the documentation here (or just look through the docs folder).
Compared to F3DEX2 or any other F3D family microcode, F3DEX3 is...
NOC
configuration) and/or when using point lights, 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 the 5-6-5 bit encoding by HailToDodongo from Tiny3D. Model-space precision of the normals is reduced, but this is rarely noticeable, and the performance is nearly identical to vanilla normals (without simultaneous vertex colors).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.SPTriSnake
command provides a flexible, generalized triangle strip primitive, which can better leverage the vertex cache than a traditional triangle strip. This packs up to 8 tris per display list command, for up to 4x less memory bandwidth for loading tris; typical meshes should see a 2-3x memory bandwidth reduction in the triangle portion of display lists.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. This can also be used to cull tris which are fully in fog, replacing far clipping which is removed in F3DEX3.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.SPFlush
command can ensure that the RDP starts clearing the framebuffer as soon as possible during the frame, instead of waiting a short time for further RSP processing.NOC
configuration) are slightly faster than in F3DEX2.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 Performance Counters page in the docs.
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: