Optional perspective-correct texture interpolation

Open
#237 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
38/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
c, web-dev

Research direction

Read repro.c for the prototype API and inspect PsyZ’s projection and textured GPU packet submission paths to find where per-vertex reciprocal depth could be retained and passed through. Then check the renderer’s interpolation behavior across primitives and platforms; done means opt-in perspective-correct UVs with affine rendering as the default, independent of fractional vertex positions, and the listed color, masking, transparency, sorting, and culling behavior preserved.

Written by the indexing model from the issue text.

Description

This is an opt-in enhancement request, not a PS1 accuracy defect. Affine texture interpolation reproduces the original hardware, but can make textures visibly slide or bend across a surface as its orientation changes.

Synthetic demonstration

One textured quad and a generated checkerboard compare affine mapping with reciprocal-depth interpolation. The screen-space vertices are identical in both renders; only texture interpolation changes.

Affine mapping on the left; perspective-correct mapping on the right

repro.c contains the complete synthetic example and the declaration of its experimental port API. That API is not available in unmodified PsyZ; this is a prototype usage example, not a baseline buildable reproducer. The captures use our patched backend. The generated checkerboard contains no game assets.

Game demonstration

Two separate videos show one complete 360° turn of Orbital. Fractional vertex positions are enabled in both videos; only affine versus perspective-correct texture mapping changes.

Before — Affine texture mapping

https://github.com/user-attachments/assets/9726bd8e-a5bc-4005-a321-263057192122

After — Perspective-correct texture mapping

https://github.com/user-attachments/assets/1e9ae824-b7fa-4525-9fd4-e6b721591c06

Each clip is approximately 24 seconds at 30 fps. A diagnostic build sets the same model angle for each corresponding frame, covering a full turn and returning to the starting angle. Both clips use the same crop and scale. Menu background animations run independently; compare the car preview. These are separate continuous turns, not concatenated mode switches.

Captured from TM4 Rewired 38e6d4e with a local prototype based on PsyZ 35c673ecf1c4ba799a812d701918c2c52935475b. Only rendered footage is supplied: no game source, executable, model or texture files.

Requested capability

Allow optional per-vertex reciprocal depth alongside a textured GPU packet and use it for perspective-correct UV interpolation. Keep affine mapping when the additional information is absent or invalid, and make this independently switchable from fractional vertex positions.

Packet data alone does not preserve the depth needed for reliable correction; our prototype retains it during projection and associates it with submitted vertices. Keep depth sorting, culling and simulation unchanged. Texture perspective must not unintentionally change Gouraud color interpolation, mask/STP behavior or transparency.

These demonstrations establish feasibility, not a finalized API or complete compatibility coverage for every primitive/platform. Classic affine rendering should remain the default.

Captured in Chromium 157 / WebGL2 on macOS arm64, with render scale 3× for the game footage. The synthetic checkerboard uses a 320×240 VRAM readback.

Dominant language
C
Stars
107
Forks
26
Avg merge
2d 21h
Merged PRs (30d)
5

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Xeeynamo/psyz

All issues in Xeeynamo/psyz

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.