libretro / beetle-psx-libretro

Standalone port/fork of Mednafen PSX to the Libretro API.
GNU General Public License v2.0
303 stars 129 forks source link

Leftmost column and bottommost row of texels do not get texture mapped onto 3D models. #712

Open ManDude opened 3 years ago

ManDude commented 3 years ago

There is an error in how the hardware renders do texture mapping on 3D objects, where the leftmost and bottommost texels (based on how they're stored in VRAM) are incorrectly ignored. This is due to an epic quirk in how the PS1 handles the UVs versus how modern hardware rendering pipelines handle them. I have observed this bug in every single PS1 hardware renderer I've ever encountered.

This off-by-one error can be observed very easily in Crash Bandicoot, with any of the crates that have their faces split in half:

Incorrect behavior: image

Correct behavior (using special tools): image

Software implementations of the PS1 renderer (in this case, Beetle PSX): image

This looks especially ugly when any sort of linear interpolation or upscaling is done on the textures.

This is caused because the "UV" for the texture here is [0-31,0-15], instead of the usual [0-32,0-16], which are the dimensions of the texture: WillT_8_1

This "off-by-one" behavior is actually correct for sprites!

Version/Commit

This bug is exclusive to all hardware implementations of the ps1 renderer as far as I'm aware.

Core options

NONE of the options affect this behavior.

Environment information

xzn commented 3 years ago

Duckstation renders this correct at 1x resolution scale. That's one HW renderer that gets it right xd