What's new

Texture perspective correction

Hacktarux

Emulator Developer
Moderator
I'm trying to figure out how to implement texture perspective correction in a software renderer. Anyone can explain me how is it supposed to work ?
 
OP
Hacktarux

Hacktarux

Emulator Developer
Moderator
Currently, i'm interpolating u/w, v/w and w and i multiply the interpolated values by w to find the texture coordinates of each points.
It seems to work most of the time but not always. The problem seems to be the clipped triangles especially when w is around 0... I don't know how to change texture coordinates when i clip to w~=0
 

MasterPhW

Master of the Emulation Flame
Why are you not asking the type of the hq2-4x filters.
The objects he is filtering seems that there is a texture perspective correction used.
You know the website? http://www.hiend3d.com/smartflt.html
It's just a try. Hope it helps (or it's the right thing I'm thinking... :p)
 
OP
Hacktarux

Hacktarux

Emulator Developer
Moderator
Perspective correction is different than texture filtering. Without perspective correction, textures look like what you get on a PSX... Nowadays, perspective correction is achived automatically by all 3d hardware. But here's i'm trying to do a software renderer. A software renderer is fun to implement but you have to face a lot of problems that have been eradicated for ages by various api or hardware.

I'm pretty sure now, that i've implemented it correctly except for triangles that are clipped at w=0.
 
OP
Hacktarux

Hacktarux

Emulator Developer
Moderator
Well, i've finally found a solution, it's probably mathematically incorect but at least, it's not visible ;)
 

ector

Emulator Developer
The reason you are having trouble is that you're supposed to clip your triangles in 3D space to the frustum planes, way before worrying about interpolating u/w and stuff :)
If you do that there will be no problems like this whatsoever.
 
OP
Hacktarux

Hacktarux

Emulator Developer
Moderator
yea... would have been easier to do it this way but.... it's in a n64 gfx plugin and i was trying to code it like the original ucode. And this ucode is transforming each vertex with the modelview and projection matrix before defining the triangles and clipping them, so i was supposing there was a way to clip after the projection....
 

Top