Now as to the “how `smooth`

/`noperspective`

” options work, please check me on this:

`smooth`

vs. `noperspective`

- the jist of it: The intuition seems clear. If you interpolate linearly on the screen (`noperspective`

), you miss the depth foreshortening effect (which you gain with `smooth`

, aka perspective-correct interpolation). For 3D interpolation of a value with a perspective projection, you need bigger steps per pixel closer to the eye. Littler steps per pixel farther from the eye.

So how do they work? From the spec, I gather: `noperspective`

is intuitively:

```
lerp( a.x, b.x )
```

when interpolating across the 2D screen, where `a`

and `b`

are the values at two vertices (call them vertex A and vertex B). Similarly for `.y`

, `.z`

, `.w`

. And `smooth`

(perspective-correct) would be:

```
lerp( a.x/pos_a.w, b.x/pos_b.w )
--------------------------------
lerp( 1/pos_a.w, 1/pos_b.w )
```

and similarly for `.y`

, `.z`

, `.w`

. Note here `pos_a.w`

is `gl_Position.w`

for vertex A, and `pos_b.w`

is `gl_Position.w`

for vertex B. (Is this right?)

So to make the latter (`smooth`

) concrete, then I’m assuming for a `vec4`

varying, the pipeline must:

- take the values of that varying for each triangle vertex (a, b, c),
- compute
`x/posw`

, `y/posw`

, `z/posw`

, `w/posw`

along with `1/posw`

for each,
- linearly interpolate these 5 values across the triangle, and then
- per fragment, divide by the
`1/posw`

again to reveal the perspective correct interpolated `x`

, `y`

, `z`

, `w`

values?

Is this correct?

And this perspective-correct interpolation is totally separate and distinct from projective texturing. That is, doing `texcoord.xyz`

/ `texcoord.w`

in the shader (or doing it implicitly via `tex2Dproj`

or similar). Reason I ask is I remember in the pre-shader days having to make sure you passed `texcoord.w`

= 1 or “bad things” would happen (presumably automatic projective texturing). And I want to make sure that’s not mixed up in perspective-correct texturing.