The far half of the straight stripe takes up less space in the image than the near one. We recognize this as perspective while we’re looking at the whole image, but we easily forget about it when we tell the GPU to calculate the texture coordinate inside the triangle. The vertices are already on the screen. You can draw a straight line between them and find its middle. The temptation remains to assign this middle the average value of two attributes. For an attribute that must be linear on the original surface, this answer is generally incorrect. The projection maintains the straightness of the edge, but changes the distribution of points along it.
This difference shows up even without complex lighting, filtering or large textures. An inclined plane with a grid drawn on it is sufficient. If you interpolate its coordinates linearly in screen space, the grid will behave like a drawing that is stretched after projection. The geometric contour can remain completely correct. The error lives in how the attribute is distributed between the correct vertices. Therefore, increasing the image detail does not in itself restore the desired rule. It is necessary to change the mathematical relationship between the values and the position of the fragment.
GLSL 4.60.8, published August 14, 2023, calls perspective-correct interpolation smooth and linear in screen space noperspective. These long-standing definitions were reviewed on November 2, 2026. The word smooth here does not mean a promise of soft edges or antialiasing. It specifies how the fragment shader’s input value is received. Behind the visually simple difference in names are different functions depending on the position on the screen. It is more convenient to understand them through one attribute and one calculated point.
Weight appears before division
The position of the vertex after transformations is specified by clip coordinates, including the w component. To get to normalized coordinates, a perspective division is performed: the corresponding components are divided by w. In a simple perspective construction, w is related to depth, but you cannot substitute any convenient screen z in its place. The interpolation formula uses exactly the value determined by the vertex transformation. The depth buffer coordinate arises from further projection and range conventions; its numerical value is not a universal replacement for the original w.
Let the screen barycentric weights λ0, λ1, λ2 be known inside the already projected triangle. Their sum is equal to one. Linear screen interpolation of attribute a would calculate the sum λi·ai. But for a perspective-correct result, you must first interpolate ai/wi and 1/wi separately, and then divide the resulting sums. In other words, the value is equal to a = Σ(λi·ai/wi) / Σ(λi/wi). For the points under consideration, we assume an acceptable geometry after clipping and a non-zero denominator. This is an analytical formula, not a GPU measurement result.
Its meaning can be restored without memorizing the finished fractional expression. The projection changes the visible fraction of the segment that each vertex receives. To restore the weights’ relationship to the original surface, the screen weight is multiplied by the inverse w. After such a change, the new weights no longer have to add up to one. Dividing by the total sum normalizes them again. The numerator mixes the attribute with adjusted weights, the denominator provides the correct scale. Therefore, the additional division is part of the geometry, and not an arbitrary decoration of the calculation.
Consider a point on the edge where the third barycentric weight is zero and the other two are equal to 0.5. For the near vertex we set w0 = 1 and a0 = 0. For the far vertex we set w1 = 4 and a1 = 1. A simple screen average will give 0.5. The perspective-correct formula gives a numerator of 0.125 and a denominator of 0.625; their ratio is 0.2. In the middle of the projected edge, the attribute corresponds to only a fifth of the original linear change. This is how perspective compresses the far section without bending the edge itself.
Checking the direction of the correction is more useful than simply agreeing with the fractions. At the far vertex, the inverse w is smaller, which means its contribution at equal screen weights is weakened. A point with an attribute of 0.5 on the original segment should be closer to the far vertex on the screen than its screen middle. Thus, both sides of the same argument are consistent: the perspective image and the reconstructed coordinate describe one surface. If the resulting formula increases the contribution of the far vertex in this example, it is likely that w and the inverse w are reversed.
This also implies a practical limitation of manual corrections. If the author divides all components of gl_Position by w in advance, and then passes a new w equal to one, he changes not only the convenience of storing coordinates. Subsequent interpolation rules no longer receive the same perspective scale information; In addition, the intervention affects steps that expect correct clip coordinates. Therefore, correcting the attribute distribution must be done in a consistent shader model and API. You can’t mechanically declare the vertices already projected, lose the original w, and expect the rasterizer to reconstruct the missing number from the shape of a triangle. Identical screen vertices themselves allow different initial depths and hence different attribute distributions.
If w of all vertices is the same, the factor 1/w cancels. The perspective formula then coincides with the screen linear one. This is a useful limiting case: the difference arises from unequal perspective scale, not from a necessary property of any triangular figure. The orthographic projection and some specially prepared attributes are capable of producing a match. However, a match on one frontal rectangle does not prove that the choice of qualifier makes no difference for a tilted surface. The case to check is precisely the one where depth and scale no longer match.

The same formula extends from the edge to the interior of the triangle: all three weights are involved. For a vector attribute, the components are calculated according to the general rule, with the same denominator. This allows a pair of texture coordinates to be kept consistent. But interpolation does not automatically understand the value of the vector. A post-mix normal, for example, usually needs to be normalized before use where unit length is expected. Perspective correctness of an attribute’s distribution and fulfillment of its physical constraint are different requirements. Having corrected one, we must not forget the second.
The Vulkan specification defines interpolation in the context of rasterization and corresponding shader interface decorations. In HLSL, Microsoft describes interpolation modifiers, including linear and noperspective. The terminology differs between languages, so you need to transfer the code according to the meaning of the mode, and not according to the literal coincidence of the word linear. Linearity can refer to the surface before projection or to the image after it. Until the space is named, the word does not yet define an unambiguous mathematical operation.
When screen linearity is needed by itself
There are tasks that just require uniform changes across the screen. For example, an attribute can specify the distance in screen units to a certain line or a specially prepared drawing on top of an image. Then the correction for perspective can distort the desired screen dependence. Noperspective is not an outdated, low-quality version of smooth. It corresponds to a different formulation of the problem. The shader author must know what space the attribute is associated with: the surface material, the image geometry, or a custom construction.
Even in such a task, the qualifier does not create the correct initial value. If vertices are given distances in world units, noperspective alone does not convert them to pixels. The screen effect will require consistent calculations of vertex values and consideration of viewport scale. This is especially important when the effect needs to maintain thickness as the resolution changes. The desired behavior consists of attribute definition, geometry transformation, and interpolation. An error in any of them may superficially resemble an “incorrect perspective”, although the rasterizer formula itself is executed correctly.
The flat mode solves another problem. It passes the value of a specific provoking vertex to the primitive instead of smooth blending. This is suitable, for example, for some integer identifiers that cannot be averaged meaningfully across vertices. But flat does not mean calculating the average color of the face and does not restore the surface normal from its geometry. If a program needs such a result, it needs to be prepared. Selecting one source and calculating a new value from multiple sources remain different actions, even if the finished image in a particular case looks the same.
The location where interpolation is evaluated is selected separately. Centroid and sample are related to the location of the sample relative to the coverage of the primitive and to multisampling. They do not replace perspective mode. It is possible to discuss both linearity space and sampling point in the same interface, but these are independent issues. At the edge of the triangle, moving the evaluation point can change the value even with the same weighting rule. Therefore, explaining any boundary artifact with the word smooth is not enough: you need to establish where the value is calculated and what geometry covers this point.
Small triangles sometimes hide mode differences. In a small area, the change in perspective scale may be weak, and the screen approximation will seem acceptable. This does not imply universal accuracy when stretching the same material over a large polygon. Tessellation can reduce the appearance of approximation error, but it changes the geometric work and is not the same as restoring the original mathematical convention. If an attribute must follow a surface, the exact rule should be chosen directly rather than hoping that an additional mesh will always hide the unsuitable space.
After receiving the coordinates, the texture is left with filtering and selecting the level of detail. A perspective-correct coordinate helps to specify the correct local dependency, but does not by itself prevent aliasing. A pattern that is too small may require mipmaps and suitable filtering, even if every calculated coordinate is geometrically correct. The opposite situation is also possible: high-quality filtering will make the incorrect distribution smooth, preserving its geometric error. This is a good example of why the visual word “quality” combines independent properties that have to be tested by separate reasoning.
Interpolation also does not promise the same results for every arithmetic operation on all devices. Actual accuracy and margin of error are determined by the API and implementation within specified limits. The fraction in the tutorial example is calculated exactly for the selected rational numbers; it shows the required direction and magnitude of the correction in the mathematical model. It is not a message about the number of clock cycles, the internal format of the hardware interpolator, or an editorial comparison of video cards. Such statements would require other sources and measurements, which this geometric analysis does not perform.
The practical question for a shader therefore begins with the origin of the attribute. If the coordinates are to maintain a pattern on an inclined surface, their behavior is associated with that surface. If a value should vary uniformly across the image, it is specified in screen space. If the value is the name of a primitive, it is usually not interpolated as a continuous quantity at all. These decisions arise from the meaning of the data, not from ranking the words smooth, noperspective and flat from beautiful to ugly. Different modes provide correct answers to different questions.
The attribute at our screen-space midpoint is still 0.2 when the attribute follows the original segment with the chosen w values. The value 0.5 also has the exact meaning – the average in the image. There is no dispute between two GPU about correct arithmetic. There is a choice of which space the author wanted to make linear. When this choice is named, perspective stops looking like a secret adjustment to the image and becomes an explicit part of defining the data the shader receives for each fragment.



