ata4 / angrylion-rdp-plus

A low-level N64 video emulation plugin, based on the pixel-perfect angrylion RDP plugin with some improvements.
158 stars 25 forks source link

primitive lod frac VS lod frac #121

Closed Dragorn421 closed 3 years ago

Dragorn421 commented 3 years ago

Angrylion sets the primitive lod frac from the gDPSetPrimColor command:

https://github.com/ata4/angrylion-rdp-plus/blob/master/src/core/n64video/rdp/combiner.c#L507

void rdp_set_prim_color(struct rdp_state* wstate, const uint32_t* args)
{
    wstate->min_level = (args[0] >> 8) & 0x1f;
    wstate->primitive_lod_frac = args[0] & 0xff;

However, what I read suggests that the setprimcolor command sets the "lod frac" and not the "primitive lod frac": Ocarina Of Time 64 wiki: https://wiki.cloudmodding.com/oot/F3DZEX2#Parameter_Description :

G_CCMUX_LOD_FRACTION — Uses the LOD fraction value specified in the primitive color register for all color components. G_CCMUX_PRIM_LOD_FRAC — Unclear, used in only one (undocumented) Color Combiner configuration. Possibly the calculated LOD value for the current pixel of the primitive. I'm not sure what their source is on this unfortunately.

N64 manual uses "lod fraction" and not "primitive lod fraction" around gDPSetPrimColor: http://n64devkit.square7.ch/keywords/index/data/graphics.htm#primitive%20color%20register :

primitive color register A general-use register in the color combiner that is set with the gDPSetPrimColor function. This register is used for primitive color settings, and for setting the color of the first highlight and the LOD fraction.

http://n64devkit.square7.ch/pro-man/pro12/12-06.htm#02 :

Table 12-21 gsDPSetPrimColor(minlevel,frac,r,g,b,a), gsDPSetEnvColor(r,g,b,a)

Parameter Values
minlevel minimum LOD level
frac LOD fraction for blending two texture tiles
r,g,b,a color


My current guess is "lod frac" is just another value for use in the combiner, and "prim lod frac" is some kind of computed value (but according to what rules?). But Angrylion does the opposite.

So here I am, asking if whoever maintains this has more sources on what "lod frac" and "prim lod frac" do. Thanks in advance!

Dragorn421 commented 3 years ago

I had some hardware testing done for drawing triangles that used (combiner constants names in gbi.h) PRIM_LOD_FRAC (red, green tris) and LOD_FRACTION (blue tri) in the combiner, and used setPrimColor to change the lodFrac each frame

As expected angrylion shows the red and green tris fading in On hardware (no idea why stuff is black and white and messed up on this rom I made): https://streamable.com/ooauxg at 35s the same tris are fading in

So setPrimColor does set the value used by PRIM_LOD_FRAC and LOD_FRACTION is for something else

TLDR: angrylion is right, as always