PDA

View Full Version : Gouraud-Interpolation



guju
06-20-2002, 10:39 PM
Does this problem also occur with textures on quad elements? I have strange texture results on quads. I have a square with four quads. The boundary nodes have the same value. Only the one inner node has a different value. I do not get a constant distribution? How can i correct it?
Thanks

dorbie
06-21-2002, 02:21 AM
I assume you're talking about a 1D texture here, mesh radially from the center to get better results, you need to think about the triangulation of the quads:




_____
|\ | /|
| \|/ |
|--X--|
| /|\ |
|/_|_\|

guju
06-22-2002, 05:25 AM
until now i have about 400000 quads and if i split them it will decrease frame rates extreme!

jwatte
06-22-2002, 07:27 AM
Yep, a quad is typically turned into two tris internally, and these may interpolate differently along the diagonal. You can correct this by using the Q texture coordinate as mentioned elsewhere on this forum.

dorbie
06-23-2002, 03:11 AM
Some things cannot be fixed using q.

This will not reduce framerates significantly if you send your tris using the correct primitives. It may even be faster if you send your quads naively now.

guju
06-24-2002, 12:08 AM
That means for my texture i display all elements as Tri-elements. For the overlaying mesh i display the quads. Right?

dorbie
06-24-2002, 01:17 AM
If you mean you want to draw a wireframe representation of the quads then yes drawing as quads would do that, then draw triangles for the fill.

For fill I would suggest using a trifan primitive to render the triangle version. That seems to be the most vertex efficient way to go.

For example:




v2 __v3_ v4
|\ | /|
| \|/ |
v9|--v1-|v5
| /|\ |
|/_|_\|
v8 v7 v6

glBegin(GL_TRIANGLE_FAN);
glVertex3fv(v1);
glVertex3fv(v2);
glVertex3fv(v3);
glVertex3fv(v4);
glVertex3fv(v5);
glVertex3fv(v6);
glVertex3fv(v7);
glVertex3fv(v8);
glVertex3fv(v9);
glVertex3fv(v2);
glEnd();

That should do (just add tcoords) until you get into vertex array rendering or whatever your preference is on your platform of choice.

guju
06-24-2002, 05:56 AM
How do you split the quad into four trias? If i use the gravity point, in some cases it can bee outside of the quad!

davepermen
06-24-2002, 06:01 AM
if your quad is not a quad, stop using it. bether use triangles directly.. then you know where your edges are, and you know what to do..

guju
06-24-2002, 06:04 AM
I am reading in files, where fem-elements are defined. In some cases a quad can have very bad geometry. So that is the reason why i have to take these cases also into account!!

dorbie
06-24-2002, 06:53 AM
The quad is a quad, the problem is the interpolation of parameters, OpenGL triangulates it first. It's a fairly common problem. Read the post.

guju, I was asumming based on your description that you have 4 quads. I have split four quads into 8 tris. I don't know what you mean by your gravity point.....hmm do you mean that the point at the common junction of the quads is teh gravity point? Yikes. You'd have to clip the edges to the bounds I suppose (depending on desired behaviour, or perhaps use stencil, but that's just getting ugly.

[This message has been edited by dorbie (edited 06-24-2002).]

tcobbs
06-24-2002, 01:17 PM
Originally posted by guju:
How do you split the quad into four trias? If i use the gravity point, in some cases it can bee outside of the quad!

The gravity point will always fall inside a convex quad. If you have quads whose gravity point is outside, then they must be concave. OpenGL doesn't support concave quads (results are undefined), so you have to split them into two triangles manually.

guju
06-24-2002, 11:14 PM
I divide my quads now into four tria-elements. The color interpolation works very good, but performance goes done! I use GL_TRIANGLE_FAN's for each quad. Can i use GL_TRIANGLE_FAN with vertex arrays?