shading and tesselation. how?

hello,
I have a set of coordinate in a linear array which give a cylinder shape.(array of 341 points).
I would like to apply shading on it. But I think I have to build my object with polygon to have normals. Is it Right? How to do that? could you give me the principles in order to do that? Is it “the tesslation”?

thank you!!!

Hello,

Tessellation refers to the way that you can break an area of polygons down into a finer area of polygons. For example, instead of displaying a surface as two triangles, you could display the same surface with many more triangles. The advantages of this are smooth shading. Smooth shading on curved surfaces is essential! Imaging the surface of a body of water when it is moderately calm, as in a pool. The surface is smooth, as that is how you generally want surfaces to appear, unless the object is meant to have a boxy appearence, like a cube.

There are two types of normals essential to that of simple lighting effects in computer graphics. Surface normals and vertex normals. A surface normal is just a normalized vector perpendicular to a surface. On curved and wavy surfaces, this results in flat shading, you would not want this on a curved surface like a cylinder, it would give a boxy look. Vertex normals are normals that are specified per vertex, allowing smooth interpolation between surfaces. Here and here are two good resources for what you want to know.

Ok, so you have an array of unique vertices that make up your cylinder. You are off to a good start. First I recommend that you build an index array that references the vertex values. You then use this index array to draw your geometry. You build the array on what type of primitive you want to use, triangles, quads, etc… Second, you will have to build an array of vertex normals. For every vertex, there will be a vertex normal. Your index array will also reference your vertex normals. The references above offer information on how to calculate vertex normals. Also, if you are not familiar with vertex arrays, do a search on the forums here, there is tons of good stuff. Hope this helps.

Old GLman

[This message has been edited by Old GLman (edited 05-01-2002).]

Originally posted by Old GLman:
[b]Hello,

Tessellation refers to the way that you can break an area of polygons down into a finer area of polygons. For example, instead of displaying a surface as two triangles, you could display the same surface with many more triangles. The advantages of this are smooth shading. Smooth shading on curved surfaces is essential! Imaging the surface of a body of water when it is moderately calm, as in a pool. The surface is smooth, as that is how you generally want surfaces to appear, unless the object is meant to have a boxy appearence, like a cube.

There are two types of normals essential to that of simple lighting effects in computer graphics. Surface normals and vertex normals. A surface normal is just a normalized vector perpendicular to a surface. On curved and wavy surfaces, this results in flat shading, you would not want this on a curved surface like a cylinder, it would give a boxy look. Vertex normals are normals that are specified per vertex, allowing smooth interpolation between surfaces. Here and here are two good resources for what you want to know.

Ok, so you have an array of unique vertices that make up your cylinder. You are off to a good start. First I recommend that you build an index array that references the vertex values. You then use this index array to draw your geometry. You build the array on what type of primitive you want to use, triangles, quads, etc… Second, you will have to build an array of vertex normals. For every vertex, there will be a vertex normal. Your index array will also reference your vertex normals. The references above offer information on how to calculate vertex normals. Also, if you are not familiar with vertex arrays, do a search on the forums here, there is tons of good stuff. Hope this helps.

Old GLman

[This message has been edited by Old GLman (edited 05-01-2002).][/b]

Hi,

thank you for your answer. I have some difficulties to understand “the index array” in the third part of your answer. Could you be more accurate?

thank you

hello,

thank you everybody for your answers.
I still have some problems with the normals and the shading. I would like to have a smooth shading. So I need to compute the normals of each vertex.
My cylinder is made up of triangles like this.

c
|
|
|__
a b

I calculate the normal of each vertex(a,b and c)
the problem is at this point.
Hae I to create a function to average the three normals of each vertex or not ?
is it
averageNormal=(normal in a + normal in b + normal in c)/3

What is the goal of the function glNormal3fv?

As you can see I’m a little bit confused. Is someone can clarify all that please?

Hello,

I think you have it the wrong way around. You want to average the surface normals of all the triangles that share that vertex. There is a good example on how to do this on Nate Millar’s website. If you follow the link above it you will find a link to vertex normals that show the general algorithm for calculation vertex normals. Also on his website is a program that shows you how to do it. You can download it from a link in the intro. glVertex3fv lets you pass the vertex as an array rather than three seperate points, like this ->

float v[3];
// fill the array with x, y, z coordinates, respectively
glVertex3fv( v );

Hope this helps.

Old GLman

What website? the second link doesn’t work. I can’t find a good tutorial about flat and smooth shading.

Nate’s site still works for me. Try it again.