PDA

View Full Version : Lit triangle strip banding problem



SuperFreq
02-06-2004, 01:10 PM
So I am having a problem with triangle strips not displaying correctly when lighting is enabled. I am building a tree-like cylindrical object by "skinning" a center-point list.
Everything looks great until I enable lighting where, depending on how I rotate the object, I get an almost Moire pattern of poorly lit polys. It seems to effect the specular aspect of the object the most.
The first thing I thought was that it was a problem with the normals, but I am calculating the normals based on the centerpoint to the edge of the model which is the vector I use to create the point, so this can't be incorrect. In some views there are whole sections of the model which look correct, but as soon as you rotate it looks bad.
I just can't seem to figure out what the problem is.
I was wondering if my normals were getting messed with somehow. I tried enabling GL_NORMALIZE but that did nothing.
Is it that I am reusing my normal arrays? I loop though with two arrays and reuse them after I call GL_TRIANGLE_STRIP. Could this cause problems.
for(howeverManyPoints)
{
//calculate first normal array and points
//calculate second normal array and points
glBegin(GL_TRIANGLE_STRIPS);
for(numPointsAroundCylinder)
{
glNormal3d(firstnormalarray[i]);
glVertex3d(firstpointarray[i]);

glNormal3d(secondNormalArray[i]);
glVertex3d(secondpointarray[i]);
}
glEnd();
}

material is setup as follows:
ambient = (0.5, 0.2, 0.2, 0.5)
diffuse = (1.0, 0.2, 0.2, 0.5)
specular= (0.0, 0.0, 1.0, 1.0)
shinyness= 10;

lighting is setup as follows:
ambient = (1.0, 1.0, 1.0, 1.0);
everything else is default and position is set to a reasonable position.

My only other guess is that it is a driver/hardware issue.

I know it could be alot of things that could be causing the problem, but does anyone have an idea of what the problem could be?

Nychold
02-06-2004, 04:25 PM
Originally posted by SuperFreq:
<...snip...>
for(howeverManyPoints)
{
//calculate first normal array and points
//calculate second normal array and points
glBegin(GL_TRIANGLE_STRIPS);
for(numPointsAroundCylinder)
{
glNormal3d(firstnormalarray[i]);
glVertex3d(firstpointarray[i]);

glNormal3d(secondNormalArray[i]);
glVertex3d(secondpointarray[i]);
}
glEnd();
}

material is setup as follows:
ambient = (0.5, 0.2, 0.2, 0.5)
diffuse = (1.0, 0.2, 0.2, 0.5)
specular= (0.0, 0.0, 1.0, 1.0)
shinyness= 10;

lighting is setup as follows:
ambient = (1.0, 1.0, 1.0, 1.0);

<...snip...>


This is a curiousity...glNormal3d requires three (3) doubles to be passed, not one:

glNormal3d(normalX,normalY,normalZ)

did you mean glNormal3dv(&normalVector)?

Otherwise, this could be causing major problems in the calculation of the normal vectors, not to mention the vertices (which have the same problem...glVertex3d requires three doubles). I'd go back and either correct this post, or correct the code using this information.

SuperFreq
02-09-2004, 07:49 AM
Sorry for the confusion. In my haste I seem to have written some poor pseudo-code. What I meant in my for loop was as follows:




for(numPointsAroundCylinder)
{
glNormal3d(firstnormalarray[i].x,
firstnormalarray[i].y,
firstnormalarray[i].z);
glVertex3d(firstpointarray[i].x,
firstpointarray[i].y,
firstpointarray[i].z);

glNormal3d(secondNormalArray[i].x,
secondNormalArray[i].y,
secondNormalArray[i].z);
glVertex3d(secondpointarray[i].x,
secondpointarray[i].y,
secondpointarray[i].z);
}


Sorry for the confusion. Thanks for the help. The more I look at this problem the more I believe that it is a driver issue. I will try to post a picture, maybe that would help.

[This message has been edited by SuperFreq (edited 02-09-2004).]

SuperFreq
02-09-2004, 10:47 AM
Here is a link to a screenshot of the issue. (I hope this works)
http://www.imagestation.com/album/?id=4287742463

[This message has been edited by SuperFreq (edited 02-09-2004).]

chowe6685
02-09-2004, 12:16 PM
the image is pretty small, but it almost looks like a problem with your depth testing, have you tried bumping the near plane out a bit?

SuperFreq
02-10-2004, 10:46 AM
Sorry about the image size, the image is actually pretty large it's just that the imagestation site only shows the low res version if you are not a member. (I need to find a better image site for these forums).

Anyhow, I have tried playing with the near and far planes. It is currently set at 10 for near and 5000 for far. I cut it all the way down to 900 and 1000 where I could only see a sliver of the model and the issue still existed.

I am currently using VC7 to compile with. Are there any issues with VC7's opengl libraries? The problem existed with VC6 as well. My graphics card is a quadro2 which isn't the best but the issue still exists on a GeForce4600 (still compiled with the same library). All I have done for drivers is download the latest nForce Unified driver from nVidia. Is there anything else I need?

SuperFreq
02-13-2004, 03:07 PM
Ok, so just in case someone else gets this problem, I must post the solution to this. This problem was caused because depth test was not enabled. It was actually disabled later in the code and not re-enabled. Since I was drawing circular strips of triangles, depending on what order they were drawn at they would often overwrite the front facing polys.

It figures it would be something so easy.

Thank you to all that helped.