Re: [Plib-devel] Ancient history....depth buffer queries
Brought to you by:
sjbaker
From: Steve B. <sjb...@ai...> - 2000-05-16 21:13:54
|
Scott McMillan wrote: > I was going through some very old info-performer archives... *VERY* old! > ...on depth/range calculations and I came across your formula again... Actually the formula came from SGI - but it seems to be right for other systems. > I have a question. Here's what you wrote (I think...as formatting > has garbled the equation): > > > This comes up about every 6 months....here is the stock reply... > > > > The 'official' SGI solution to this is... > > > > z = value in z buffer after rendering (input) > > range = distance to pixel in database units (output) > > > > np = distance to near clipping plane > > fp = distance far clipping plane > > > > nz = near-clip z value > > fz = far-clip z value > > (as read from glGetIntegerv ( GL_DEPTH_RANGE,...) for OpenGL) > > > > For each Z-buffer value: > > > > fp*np(fz-nz) > > ------------ > > fp-np > > - range = -------------------------- > > (fp+np)(fz-nz) fz+nz > > z - -------------- - ----- > > 2(fp-np) 2 > > > > My questions are: > 1) has this formatting been restored correctly? Hmmm - not sure. I'd have to be at work to answer that one. I'll have to let you know sometime tomorrow. > 2) Could you explain the nz/fz equations more clearly... Sorry - it's not my equation - I just regurgitated it from a previous email from Micheal Jones - who no longer works at SGI. I'll try to dig out some actual code where I used the equation and email it to you tomorrow. Are you actually using Performer or is this really an OpenGL problem? If it's OpenGL, then I wrote a FAQ about Z buffer values here: http://web2.airmail.net/sjbaker1/omniv.html ...that has the inverse equation (for OpenGL - not Performer). -- Steve Baker http://web2.airmail.net/sjbaker1 sjb...@ai... (home) http://www.woodsoup.org/~sbaker sj...@ht... (work) |