Jump to content
  • Advertisement
Sign in to follow this  
Phong

Interpolation on GPU

This topic is 3631 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


Link to 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


Link to 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


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!