rickomax / psxprev

PSXPREV - Playstation (PSX) Files Previewer/Extractor
BSD 2-Clause "Simplified" License
193 stars 10 forks source link

Support tiled texture rendering #79

Closed trigger-segfault closed 12 months ago

trigger-segfault commented 12 months ago

Renderer change

This fully implements renderer support for tiled textures. This works by taking the tuva and tuvm values from the TILE data of a packet, and restoring them to their original values. tuva points to the starting offset where wrapping occurs, and tuvm describes the size of the area that will be wrapped. UV coordinates are treated as base coordinates, where (0,0) is the start of tuva. When UV coordinates exceed the boundaries of tuvm, they will be wrapped.

To handle texture tiling, the fragment shader needed to be updated to receive the tiled area coordinates, and to perform tiled conversion on the UV coordinates. It's assumed that tiling width and tiling height can be independently assigned, meaning if the tiled width is zero, tiled height could still be non-zero and only affect the V coordinate, and so on.

Note: Objects will not be exported with tiled textures, because there's currently no way to preserve that information. Only the renderer can display tiled textures correctly. Exported models will have UVs displayed like they were before this commit, with each vertex UV converted to their tiled counterparts.

Refactor changes