Sharon Clay (src++at++rose.asd.sgi.com)
Thu, 1 Aug 1996 01:06:31 -0700
As Simon says (no pun intended :-) iR only supports up to 24 bits of Z.
However, the iR is using a special compressed Z format that should
give better precision for large databases than the traditional
fixed screen Z mapping. Specifically, much better precision is
achieved at far ranges with some small loss of precision at near ranges.
Increasing bits of Z produces better precision at all ranges but
with rapidly diminishing returns after around 20+ bits.
I've attached a utility program written by Kurt Akeley that mimicks
the iR compression scheme so that you can see what the minimum representable
separation distance is at different ranges for different sizes of Z.
For example, in a 23 bit compressed Z with near plane at 1 and far
plane at 10000 we have:
% zinfo 1 10000 23
range 1 to 10000
23-bit zbuffer: 4 exponent bits, 19 mantissa bits
range min separation Effective Z bits
-------------------------------- -------------- ------
1.000000 to 1.999796 0.00000381 20
1.999800 to 3.998793 0.00000762 21
3.998800 to 7.994389 0.00001524 22
7.994404 to 15.976006 0.00003042 23
15.976036 to 31.901046 0.00006065 24
31.901107 to 63.599205 0.00012053 25
63.599325 to 126.394552 0.00023803 26
126.394790 to 249.633875 0.00046425 27
249.634339 to 487.107915 0.00088382 28
487.108798 to 928.965299 0.00160726 29
928.966907 to 1700.006282 0.00269127 30
1700.008973 to 2905.993067 0.00393202 31
2905.996999 to 4503.325820 0.00472132 32
4503.330541 to 6210.059507 0.00000000 33
6210.068486 to 10000.000000 0.00000000 33
====================================================================
/*
** Kurt Akeley
** 13 April 1996
**
** For each exponent value of a floating-point depth format, three
** things are computed and printed:
**
** 1. The range of eye-coordinate values that are encoded with that
** exponent,
**
** 2. The minimum eye-coordinate distance between adjacent depth
** values within that range. (This is the eye-coordinate distance
** between the farthest and next-to-farthest representations in
** the range.), and
**
** 3. The effective number of zbuffer bits in the range.
**
** The program accepts up to three parameters:
**
** 1. The near and far clipping planes, in whatever units are convenient
** for the analysis, and
**
** 2. The number of bits stored in float-point depth values.
*/
#include <stdio.h>
typedef unsigned long ulong;
#define RightBits(i) ((i == 32) ? (ulong)0xffffffff : (ulong)(1<<(i))-1)
#define MAX(a, b) ((a > b) ? a : b)
#define EXP_BITS 4
#define MAX_EXP 14 /* assumes the last exponent is special */
#define Z_BITS 32 /* bits in an unsigned long */
double near = 1.0;
double far = 100000;
int mant_bits = 12;
unsigned long Expand(int exp, int mant);
double CompDist(unsigned long z_screen, unsigned long vpfar);
main (int argc, char** argv) {
int exp;
unsigned long vpfar;
int max_mant;
double near_dist;
double far_dist;
double next_to_far_dist;
int bits;
if (argc > 1) {
sscanf(argv[1],"%lf", &near);
}
if (argc > 2) {
sscanf(argv[2],"%lf", &far);
}
if (argc > 3) {
mant_bits = atoi(argv[3]) - EXP_BITS;
}
fprintf(stdout, "\n");
fprintf(stdout, "range %lg to %lg\n", near, far);
fprintf(stdout, "%d-bit zbuffer: %d exponent bits, %d mantissa bits\n",
EXP_BITS + mant_bits, EXP_BITS, mant_bits);
fprintf(stdout, "\n");
fprintf(stdout, " range ");
fprintf(stdout, " min separation");
fprintf(stdout, " Z bits ");
fprintf(stdout, "\n");
fprintf(stdout, "--------------------------------");
fprintf(stdout, " --------------");
fprintf(stdout, " ------ ");
fprintf(stdout, "\n");
max_mant = RightBits(mant_bits);
vpfar = Expand(MAX_EXP, max_mant);
for (exp=0; exp <= MAX_EXP; exp++) {
bits = mant_bits + exp + (exp==MAX_EXP?0:1);
near_dist = CompDist(Expand(exp,0), vpfar);
far_dist = CompDist(Expand(exp,max_mant), vpfar);
next_to_far_dist = CompDist(Expand(exp,max_mant-1), vpfar);
fprintf(stdout,"%14.6lf to %14.6lf", near_dist, far_dist);
fprintf(stdout," %14.8lf", far_dist - next_to_far_dist);
fprintf(stdout," %2d", bits);
fprintf(stdout,"\n");
}
}
/*
** Convert the provided exponent and mantissa values to the corresponding
** uncompressed depth value.
*/
unsigned long Expand(int exp, int mant) {
unsigned long z;
int mant_shift;
int exp_shift;
exp_shift = MAX(18, (Z_BITS - exp));
z = (RightBits(exp) << exp_shift) & 0xfffc0000;
mant_shift = Z_BITS - (exp + mant_bits + (exp==MAX_EXP ? 0 : 1));
if (mant_shift < 0)
z |= mant >> (-mant_shift);
else
z |= mant << mant_shift;
return z;
}
/*
** Return the distance in eye coordinates from the origin to the plane
** defined by z_screen
*/
double CompDist(unsigned long z_screen, unsigned long vpfar) {
double z_eye, distance;
double v_sz, v_cz;
v_sz = vpfar / 2.0;
v_cz = vpfar / 2.0;
z_eye = ((2.0*v_sz*far*near)/(far-near)) /
((double)z_screen - (v_sz*((far+near)/(far-near))) - v_cz);
distance = -z_eye;
return distance;
}
--
-----{-----{---++at++ -----{----{---++at++ -----{----{---++at++ -----{----{---++at++
Sharon Rose Clay (Fischler) - Silicon Graphics, Advanced Systems Dev.
src++at++sgi.com (415) 933 - 1002 FAX: (415) 965 - 2658 MS 8U-590
http://www.sgi.com/Technology/Performer/
-----{-----{---++at++ -----{----{---++at++ -----{----{---++at++ -----{----{---++at++
=======================================================================
List Archives, FAQ, FTP: http://www.sgi.com/Technology/Performer/
Submissions: info-performer++at++sgi.com
Admin. requests: info-performer-request++at++sgi.com
This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:53:17 PDT