Jump to content
• Advertisement

# Interpolation on GPU

This topic is 3717 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

## Recommended Posts

This question has no practical reason, but I am very curious about it. How modern GPU interpolates values across polygon, using baricentric coordinates or just scanline bilinear interpolation. And how it performs perspective-correction.

#### Share this post

##### Share on other sites
Advertisement
In general, modern GPUs have fixed function hardware to provide interpolated values at points on the polygon. There are a fixed number of these 'interpolators' in a GPU. This number determines the maximum number of interpolated attributes you can use before becoming 'interpolator limited'. It's normally hard to reach this limit before hitting a bottleneck somewhere else, though.
Different GPUs will implement these units in different ways, barycentric coordinates is one way to implement them.
No modern GPUs use scanline based interpolation. Everything is done with small blocks of pixels in parallel (say 2x2 - a quad). Linear interpolation would not produce perspective correct interpolants anyway.
To get perspective correct interpolation, you need to perform 'perspective division' at each point. To make a linear interpolator produce perspective correct values, interpolate the coordinate divided by W (say, U/W), and the reciprocal of the W component (1/W) of your homogeneous coordinate across the polygon. Then at each point, divide all your coordinates through by this reciprocal (W/U / 1/W = U). This is normally accomplished by reciprocating 1/W and multiplying by that because multiplication is cheaper than division. Read up on 'rational linear interpolation' or 'hyperbolic interpolation' for more information.

#### Share this post

##### Share on other sites
Thanks a lot for this valuable piece of information. Also wanted to ask, what if perspective is not along z axis? I mean 4x4 projection matrix allows to do perspective along y or x axis or a combination.

#### Share this post

##### Share on other sites

• Advertisement
• Advertisement

• ### Popular Contributors

1. 1
2. 2
3. 3
4. 4
Rutin
15
5. 5
• Advertisement

• 13
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633724
• Total Posts
3013556
×

## Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!