#### Archived

This topic is now archived and is closed to further replies.

# Newbie vertex question

This topic is 5897 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Two questions to ask of the wise people here. What is a a vertex normal? I can only think of a normal as a cross-product of two vectors. A single point can''t have a normal!? I''m sure it''s simple, but my brain can''t wrap around it yet. Second question, just off-hand does anyone know how many active lights a Geforce3 Ti-200 can have. I looked at the CAPS with the DXUtil tool and it said -1. Thanks in advance.

##### Share on other sites
Ok, here's my stab at an explanation.

The normal of a vertex is used to affect lighting calculations when rendering the poly it is associated with. In a flat shaded environment, vertex normals are used to calculate a face normal which is used to calculate the lighting properties of that face. In Goroud (sp) and Phong shading, the vertex normals are directly used with the particular algorithms, Goroud or Phong, to calcualate the lighting properties of that one pixel.

In a sense, the normal is the direction light is reflected from that vertex. Consider it to be the "front" of the vertex.

Most GeForce cards can handle 8 lights in hardware. I'm not sure about every model though.

[edited by - smanches on August 27, 2002 7:56:13 PM]

##### Share on other sites
A triangle has a normal (based on the cross product). That triangle is defined by three vertices, which in turn are probably used in more than one triangle. The vertex normal is the average of all the face normals of faces that use that vertex. For a single triangle, the vertex normal is the triangle''s normal. If you imagine the center vertex in a triangle fan, the vertex normal is the average of all the faces in the fan.

Second question. I''m not sure (8?), but if you need a large number of lights, you might want to consider vertex shaders.

##### Share on other sites
I think I understand the bigger picture now, but I''m still confused at the implementation level. So let me show give an example question, and hopefully you can point me in the direction of an answer.

(simple)
Lets say I have a custom vertex that consists of a position and normal vector.

Now I want to make a single triangle and shine a directional light on it.

Lets say the position of my three vertices is to be
1. ( 0,1,0)
2. (-1,-1,-1)
3. ( 1,-1,1)

Now I have give DX8 the normals for these vertices what would the normals be for each, and how do I calculate each of them?
1. ?
2. ?
3. ?
P.S. I could easily determine the normal for this triangle:
Let 1 and 2 represent vector A
Let 1 and 3 represent vector B
Then AxB is the normal for the triangle.
But this is a surface normal not a vertice normal? Correct?

##### Share on other sites
After, I reread crazedgenius''s comment I now understand. Please disregard the above question.

Thanks for the help.

##### Share on other sites
I thought the face normal was a combination of the three vertex normals associated with it, since you don''t supply face normals to a rendering system?

##### Share on other sites
I didn''t understand, then I thought I did. Well, I don''t understand again. I''m learning from the book DX8 Special effects, and I''m doing a lighting project. The sample they give in the book is of a cylinder being lighted. The cylinder is algorithmically generated, both the vertex position and normals for each vertex. These normals are easy for me to understand, because there are no “edges” on a cylinder. (this same example can be found in the SDK tutorial on intro to lighting)

So I decided to add a directional light to one of my previous little projects. I have a pyramid with only three faces rotating. So I figured I would add lights to that project. I figured all I would have to do is add normals to the vertices and then setup my lights and materials. (simple) Well, I can’t figure out what the normal should be for my vertices.

(wishing I could draw on this)
Figure there are three triangles forming this pyramid. (duh)
Lets label each triangle face A,B,C which each have three vertices. (again duh)
Now face A and face B and face C share one vertice. (this is the “top” or “tip” of the pyramid)

What is the normal for this vertice? Is it the cross product of all three faces? This also applies to the “bottom corner” vertice that is shared by only two sides. (Say face A and face B) Is this vertice normal the cross product of both face A and face B?

Second question. I’m assuming that when you load a 3-D model from file. that the file contains the normal for each vertex? (As determined by the 3-D graphics design program)

##### Share on other sites
No, you don''t have to have three vertices to have normals. Think of a normal as a direction the vertex is pointing/facing. When light hits the vertex, it reflects the light back at an angle based on the normal. When you begin joining vertices (creating polygons), the renderer will usually interpolate the normal across the surface of the polygon. Depending on how those normals for each vertex point, that means hard edges or soft edges, plus smooth shading across the surface. For that reason, you do not have to average the normal direction for each face unless you want that effect.

quote:

What is the normal for this vertice? Is it the cross product of all three faces? This also applies to the “bottom corner” vertice that is shared by only two sides. (Say face A and face B) Is this vertice normal the cross product of both face A and face B?

If you are limiting yourself to only 4 faces and 5 vertices, than yes, the top vertex would distribute the face normals. This would mean you''ll have smooth shading applied to the pyramid.

If you want hard edge and no smooth shading, you''ll need to use 4 face and 12 vertices. Each group of 3 vertices represent a face, and each of those have a normal pointing away from the face. Even though some of those vertices will share the same 3-D coordinates in space, the normals will differ.

quote:

Second question. I’m assuming that when you load a 3-D model from file. that the file contains the normal for each vertex? (As determined by the 3-D graphics design program)

Most 3-D modeling programs export the normals for you.

home.att.net/~rpgbook
Author, Programming Role-Playing Games with DirectX

##### Share on other sites
Wow, I think I actually understand.

I really mean it this time!

Thank you Jim

1. 1
Rutin
31
2. 2
3. 3
4. 4
5. 5

• 13
• 53
• 11
• 10
• 14
• ### Forum Statistics

• Total Topics
632967
• Total Posts
3009553
• ### Who's Online (See full list)

There are no registered users currently online

×

## Important Information

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!