Dave2001
July 1st, 2002, 15:07
We're trying to translate SetPrimDepth z into a z value that we can use like any other vertex's z.
According to docs, SetPrimDepth uses the following equation, with screenZ the value input to SetPrimDepth:
screenZ=(z/w)*0x3fe0 + 0x3fe0
This is kind of a hard question to ask, but we need to know sooo much more about how this equation works.
I believe the place to start is what exactly does w represent for SetPrimDepth? Or does z even represent the z we're trying to find?
[edited to make question much shorter & less history ;)]
Gonetz
July 2nd, 2002, 19:57
ok, i think i found solution.
we have screenZ, from above formula we get
z/w = (screenZ-0x3fe0)/0x3fe0, so we know z/w
z = vertex_z*projection[2][2] + projection[3][2]
w = vertex_z*projection[2][3] + projection[3][3]
projection[2][3] usually -1 and projection[3][3] is 0. we use such projection matrix for calculation near and far clipping planes.
so,
w = -vertex_z =>
vertex_z = - (projection[3][2])/(projection[2][2]+z/w)
desired z = w = -vertex_z
DukeNukem64 works correct with this z, hurrah!
Rice
July 2nd, 2002, 21:56
Gonetz, the solution is cool, thanks.
Dave2001
July 3rd, 2002, 01:45
Hmm, that solution seems to work fine with Duke Nukem 64, but Extreme-G 2, with the sky triangle covering the whole screen, gets a z value of 0 with z update enabled...
Good job though :)
vBulletin v3.6.2, Copyright ©2000-2009, Jelsoft Enterprises Ltd.