PDA

View Full Version : 'True' Quadrilateral Interpolation on AMD?



DarkGKnight
03-25-2011, 04:08 AM
On following the recommendations of this (http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=248305&page=3) thread, I tried to achieve 'true quadrilateral interpolation' via a geometry shader as was suggested in slide 21 (http://developer.nvidia.com/object/nvision08-opengl3.html) of an NVIDIA presentation.

I modified the ogl-330-primitive-smooth-shading sample in Groovounet's OpenGL Sample Pack as follows:
1)Changed the colors to match NVIDIA's presentation
2)Added the directive 'layout (lines_adjacency) in' to the geometry shader.
3) Create a static ELEMENT_ARRAY_BUFFER buffer whose contents held the following indices: { 0,1,3,2 };
4)Bound the named ELEMENT_ARRAY_BUFFER to the Right side rendering, and updated the draw call to the following:

glDrawElementsInstancedBaseVertex(GL_LINES_ADJACEN CY, 4, GL_UNSIGNED_SHORT, NULL, 1, 0);
However, the result of the rendering is the 'backslash' split that is referred to in NVIDIA's presentation. If I don't use geometry shader, the result is the 'slash' split. Is this a limitation of ATI/AMD hardware (no true QUAD support?) or am I doing something incorrectly. The code is running on an ATI Radeon HD 5000 series.

Alfonse Reinheart
03-25-2011, 04:27 AM
I tried to achieve 'true quadrilateral interpolation' via a geometry shader as was suggested in slide 21 of an NVIDIA presentation.

Where in those slides does it say that use of only a geometry shader will result in bilinear interpolation?

The lines_adjacency stuff is just to be able to send four vertices (aka: a quad) to the geometry shader without using GL_QUADS (which is removed in core). The geometry shader still has to write two triangles, which is exactly what you would get with GL_QUADS. Interpolation is still being done by the triangle.

To get proper bilinear interpolation, you need to use a fragment shader.

DarkGKnight
03-25-2011, 09:58 AM
To get proper bilinear interpolation, you need to use a fragment shader.

Is it possible to do bilinear interpolation without some form of texture lookup?

Alfonse Reinheart
03-25-2011, 03:23 PM
Is it possible to do bilinear interpolation without some form of texture lookup?

I didn't say anything about a texture lookup. It's a matter of passing the right data to the fragment shader and having it do the interpolation manually.

Basically, you pass a gl_PointCoord-like value that represents where on the surface the fragment is. This value will interpolate reasonably over a quad's surface.

Unfortunately, you also need to pass all four of the coordinates you want to interpolate to each vertex (with a "flat" interpolation qualifier), so that the fragment shader can use the gl_PointCoord-like value to do the interpolation manually. So you will use up a lot of inputs/outputs.

DarkGKnight
03-25-2011, 03:33 PM
Thanks for the info. Definitely sounds like something that isn't worth the trouble.