Skip to main content
GameDev.net gamedev.net
🔒 Locked

Vertex Interpolation for Quads

Started by JonW Oct 30, 2010 at 8:34 PM 1 replies 1.2k views
Original Post
JonW
JonW
Hey folks,

In my Direct3D 9.0c application I am drawing a 2D quadrilateral using two triangles in a "triangle strip". I would like to assign a value to each of the four vertices of the quad that will get interpolated across the shape and fed to the pixel shader.

The problem that I'm having is that, since the interpolation of the vertex values occurs across each of the two triangles seperately, the values are not smooth across the entire quad. There is a nasty "seam" in the values along the diagonal where the two triangles come together.

My question is: Is there a good alternative or work-around in order to interpolate correctly across a 2D quadrilateral? The only thing I can think of is to create a giant triangle in place of the quad, and use the pixel shader to "hide" areas of the triangle that I don't want. I would also have to perform a complex calculation to come up with the proper values for the three triangle vertices that would result in an interpolation across the surface that is identical to the quad I want.

I greatly appreciate any additional insight or words of wisdom; thank you!
smasherprog
smasherprog
You probably need more triangles.
Wisdom is knowing when to shut up, so try it.
--Game Development http://nolimitsdesigns.com: Reliable UDP library, Threading library, Math Library, UI Library. Take a look, its all free.
JonW
JonW
Nevermind, I realized that the problem was because I was passing the vertices in screen-space, so affine interpolation was being used. See http://en.wikipedia.org/wiki/Texture_mapping:

Quote:

If these texture coordinates are linearly interpolated across the screen, the result is affine texture mapping. This is a fast calculation, but there can be a noticeable discontinuity between adjacent triangles when these triangles are at an angle to the plane of the screen.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.