zPSP-Dev / Zig-PSP

A project to bring the Zig Programming Language to the Sony PlayStation Portable!
Other
88 stars 6 forks source link

Bug with projection matrix when rendering the cube #6

Open silbinarywolf opened 9 months ago

silbinarywolf commented 9 months ago

I'm aware this project isn't maintained now but I figured I'd track this bug in the project anyway incase someone else wanted to resolve it.

Details here: https://github.com/hrydgard/ppsspp/issues/17981#issuecomment-1851025066

OK, investigated this in RenderDoc.

The entire cube gets clipped away, I guess we're just very slightly off from what the real PSP is doing.

The reason this is happening is that there's a digit missing in the projection matrix, causing it to squish the cube flat against the Z=0 plane, so this cube will not depth test properly against anything else. The perspective projected texturing still works (if you pass the clipping) since the W coordinate is computed correctly.

289694398-f29450a8-7eb6-4f1a-b7d2-b4a3f32bcb86

Note how the third row (actually column, I believe, but viewed transposed) of the matrix is 0.0f. There should be at least one non-zero number in there.

IridescentRose commented 9 months ago

Interesting bug; I think that's probably part of the depth range -- I will work on this project more when I have more time.

Edit: Very interesting -- I'll have to debug this in more depth.