Sign in to follow this  

Problem with normals of triangle-strips

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

Hey guys,

I have some trouble to set the vertex-normals for a triangle-strip, which is stored within one big array.
At the end of each row, I draw 2 "dummy"-triangles to be able to jump to the beginning of the next row.
Which means, if I want to draw:
1--4--7
| / | / |
2--5--8
| / | / |
3--6--9
My ordering is 1,2,4,5,7,8,8,2,3,5,6,8,9.

When I don't use light and shading, everything looks fine. But when I turn on lightning, the normals come into play and I have a lot of stripes within the rendered surface. Has anybody an idea how I can avoid these stripes? Have I forgot to initialize something?

I have no idea - its the first time that I want to shade a rendered surface.

Thanks a lot for your help [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]


[code]
void initGL(){
...
glEnable(GL_TEXTURE_2D);
glEnable(GL_DEPTH_TEST);
GLfloat LightAmbient[]= { 0.5f, 0.5f, 0.5f, 1.0f };
GLfloat LightDiffuse[]= { 1.0f, 1.0f, 1.0f, 1.0f };
GLfloat LightPosition[]= { 0.0f, 800.0f, 2.0f, 1.0f };
glLightfv(GL_LIGHT0, GL_AMBIENT, LightAmbient);
glLightfv(GL_LIGHT0, GL_DIFFUSE, LightDiffuse);
glLightfv(GL_LIGHT0, GL_POSITION,LightPosition);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
glEnable(GL_COLOR_MATERIAL);
glShadeModel(GL_SMOOTH);
...
}
[/code]


Here you can see the result...
[attachment=7969:terrain.png]

Share this post


Link to post
Share on other sites
Perhaps your normals are wrong. They, obviously, should not contradict what other adjacent triangles have at the same vertex (different strip).

Btw. Unrelated, but i mention anyway. Might want to use just indexed triangles - by my count, the days where strips were worth a damn are long gone (immho).

Share this post


Link to post
Share on other sites
ok, thanks a lot...I will check my normals....

@triangle-strips: I know...and it was not my idea...but its part of a university-project and we have to use triangle strips :(

Share this post


Link to post
Share on other sites

This topic is 2080 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this