Linear / nonlinear texture displaying a distorted quadrant

In a previous question, it was found that when texturing a square, the face is divided into triangles and texture coordinates interpolated in an affine way.

Unfortunately, I do not know how to fix this. the link provided was useful, but it did not give the desired effect. The author concludes: "Note that the image looks as if a long rectangular square extends over a distance ... It can become quite confusing ... because of the" false perception of depth "that it produces."

What I would like to do is make the texture retain the original texture scaling. For example, in the trapezoidal case, I want the vertical intervals of the texels to be the same (an example created with a paint program):

Note that since the vertical distance is identical, there is still a clear distortion of parity, the straight lines in the texture space are no longer straight lines in the world space. Thus, I believe that the required mapping should be non-linear.

The question is, is this possible in the pipeline of a fixed function? I'm not even sure what the “right answer” is for more general quads; I believe that interpolation functions can get very complicated very quickly, and I understand that “keep the original scaling” is not quite an algorithm. The triangles of world space are no longer linear in texture space.

As an aside, I really don't understand the texture coordinates of 3 rd and 4 th ; if someone can point me to a resource, that would be great.

+7
source share
2 answers

The best approach to a solution that works with modern gpu-api can be found on the Nathan Reed blog.

http://www.reedbeta.com/blog/2012/05/26/quadrilateral-interpolation-part-1/

But in the end, you had a problem similar to the original problem with the prospect :( I'm trying to solve it and publish the solution as soon as I can.

+2
source

Wow, this is a pretty complicated problem. Basically you do not bring perspective into the equation. Your final x, y coordinate is divided by the z value you get when you rotate. This means that you will get a smaller change in the texture space (s, t) that you get from the camera.

However, by doing this, you effectively interpolate linearly as z increases. I wrote an ANCIENT demo that did this back in 1997. This is called "affine" texture mapping.

The thing is that you divide x and y by z, you really need to interpolate your values ​​with "1 / z". This correctly takes into account the perspective that applies (when you divide x and y) by z. Therefore, you get a “perspective correct” texture mapping .

I wish I could talk about this in detail, but over the past 15-plus years of alcohol abuse my memory is a bit vague.) I would like to visit the software rendering the other day, because I am convinced that with the release of OpenCL it will soon become the best a way to create a rendering engine!

In any case, I hope that some help and apologies I can no longer help.

(Aside from when I figured out all this visualization 15 years ago, I liked that now I had all the resources available, the Internet made my work and life easier. It was incredibly painful. I remember how I initially tried to perform 1 / z interpolation but it decreased as it approached, and I abandoned it when I had to turn things around ... to this day, as my knowledge increased exponentially, I STILL really wish I wrote a "slow", but completely promising correct rendering ... one day I will turn to him ;))

Good luck

0
source

Source: https://habr.com/ru/post/917126/


All Articles