   hyperbolic interpolation
  If I do a linear interpolation between a and b like this...a + (b - a) * scalecan I do a hyperbolic interpolation like this...1 / ( 1/a + (1/b - 1/a) * scale )My goal is perspective-correct clipping of texture coordinates.  Tests reveal numbers that look reasonable, but my textures look bad.  Thanks for any help.   
  That formula is almost certainly wrong. Think about the mapping between coordinate space (R^2) and the scene (R^3), write down the equations carefully, see what point in space you are interested in and use the equations to retrieve the coordinates. It shouldn't be all that difficult.;Quote:Original post by alvaroThat formula is almost certainly wrong...Thanks for the reply, but how do you justify your conclusion?  Varying "scale" from 0 to 1 results in the following set of values...It looks somewhat hyperbolic to me.  So I thought it might work for clipping values that go off into the distance.  Just wanted to see if others had run across this problem and solved it.  I appreciate your comments though.;  Well, the idea is most likely completely incorrect. You can't do that by just interpolating coordinates specially, because the perspective correct clipping should depend to z. If the triangle is orthogonal to view direction, interpolation of course must be linear. Just draw it on the paper, camera as point, to the right screen plane, and the parallel plane with triangle.Of course interpolation should be different for differently oriented triangles, even if vertices project onto same points on screen.Are you doing frustum clipping and need to compute clipped coordinates? The "right" way of doing it is to clip your triangle in 3D space, and linearly interpolate texture coordinates between vertices. It is good if you tell what you want to do, so we can tell how to do it (now i can only say that idea is almost certanly wrong, "almost" comes from not knowing what exactly you want)   ;  Clipping in clip space is simpler, since the frustum has been transformed at this point into a cube (or rectangular solid, whatever they are called, if you want to be generic about it). However, as the OP has noted depth (z) is not linear here, it is proportional to 1/z. The way (or one them) to get perspective correct texture mapping is to interpolate 1/z (linearly) across the spans of your triangle, as well as u/z and v/z. These can be used to get the actual (u,v) when you need to look up from the texture, and can be calculated using the linear interpolation equation in the OP's first post when computing clipped coordinates.Google for "perspective correct texture mapping" or checking out your favorite book on the graphics pipeline should give you a wealth more information. Dmytry is right, however, you cannot just "hyperbolically" interpolate your coordinates. I think that entire second formula is useless for just about anything.   ;Quote:Original post by DmytryWell, the idea is most likely completely incorrect. You can't do that by just interpolating coordinates specially, because the perspective correct clipping should depend to z...Yep, you're right about that.  So, I pluged z values into the original formula, and the textures are looking much better.  The perspective is corrected by this formula, but only in ideal cases with reasonable viewing angles and distances.  I'm going to abandon the formula idea and next try clipping my Z's and tex coords against the frustum, in 3D space.  Thanks, your posts have helped me.