Interpolating 1/z in screen-space

Started by
0 comments, last by maxest 13 years, 5 months ago
I want to do perspective-correct interpolation. I took the formula (12) from here http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.3.211&rep=rep1&type=pdf and it seems something is a bit wrongly "inversed". The code:
mtx mat = world * cameraTranslate * cameraRotate * persp * ortho;float s = 0.0f;for (int i = 0; i <= 10; i++){	vec4 q(-5,0,0), Q(5,0,0);	q *= mat;	Q *= mat;	float wt = 1.0f/q.w + s*(1.0f/Q.w - 1.0f/q.w);	wt = 1.0f/wt;	...	s += 0.1f;

(during wt computation, q.w and Q/w contain view-space Z-values [both are < 0 since I have right-handed coordinate system])

And the perspective and ortho matrices:
mtx persp(-near,  0.0f,  0.0f,     0.0f,	   0.0f, -near,  0.0f,     0.0f,	   0.0f,  0.0f, -near-far, 1.0f,	   0.0f,  0.0f, -near*far, 0.0f);mtx ortho(2.0f/(right-left),          0.0f,                       0.0f,                  0.0f,		  0.0f,                       2.0f/(top-bottom),          0.0f,                  0.0f,		  0.0f,                       0.0f,                      -2.0f/(far-near),       0.0f,		 -(right+left)/(right-left), -(top+bottom)/(top-bottom), -(near+far)/(far-near), 1.0f);


Thoeretically, for such a positioning of points in screen-space:
q...  .   .        .Q

I should get values like:
-10  -9.5  -9  -7  -3  -1

But I get:
-10  -6  -4  -2  -1.5  -1

So it looks a bit "inversed" and I can't figure out why

[Edited by - maxest on November 14, 2010 7:46:22 AM]
Advertisement
Hmm... I'm starting to think that I misinterpreted the results and in fact the ones I get are valid. Can somebody confirm that?

This topic is closed to new replies.

Advertisement