Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect texture wrapping in Super Mario 64 #13

Open
hulkholden opened this issue Sep 24, 2023 · 1 comment
Open

Incorrect texture wrapping in Super Mario 64 #13

hulkholden opened this issue Sep 24, 2023 · 1 comment

Comments

@hulkholden
Copy link
Owner

example of wrapping problem
exmaple of wrapping problem

The textures themselves are being decoded ok

star texture

The tiles are configured with G_TX_WRAP at 16 pixels:

tile # format size line tmem palette cmS maskS shiftS cmT maskT shiftT left top right bottom width height unmasked w unmasked h
G_TX_RENDERTILE G_IM_FMT_RGBA G_IM_SIZ_16b 4 0 0 G_TX_WRAP 4 0 G_TX_WRAP 4 0 0 0 15 15 16 16 16 16
G_TX_LOADTILE G_IM_FMT_RGBA G_IM_SIZ_16b 0 0 0 G_TX_WRAP 4 0 G_TX_WRAP 4 0 0 0 0 0 1 1 1 1

RDP is set up with bilinear filtering:

setting value
textureConvert G_TC_FILT
textureFilter G_TF_BILERP

In the case of the star it's being rendered with texrect:

02636 e4404078003c803c gsSPTextureRectangle(242,15,258,31,G_TX_RENDERTILE,0,0,1,1);
cmd2 = 0x00000000, cmd3 = 0x10000400
st0 = (0, 0) st1 = (16, 16)

Some possibilities:

  • texture lookup in the fragment shader using float UVs is too imprecise
  • texrect coords are slightly off (it's generating st1 of (16,16) but maybe this should be (15,15)?
@hulkholden
Copy link
Owner Author

Also worth mentioning this is G_CYC_COPY. In this mode we're adding 1 to the width and height:

    // In Fill/Copy mode the coordinates are inclusive (i.e. add 1.0f to the w/h)
    if (cycleType === gbi.CycleType.G_CYC_COPY ||
      cycleType === gbi.CycleType.G_CYC_FILL) {
      xh += 1.0;
      yh += 1.0;
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant