Newbie vertex question
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.
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]
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]
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.
Second question. I''m not sure (8?), but if you need a large number of lights, you might want to consider vertex shaders.
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?
(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?
After, I reread crazedgenius''s comment I now understand. Please disregard the above question.
Thanks for the help.
Thanks for the help.
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?
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)
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)
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.
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.
Most 3-D modeling programs export the normals for you.
Jim Adams
home.att.net/~rpgbook
Author, Programming Role-Playing Games with DirectX
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.
Jim Adams
home.att.net/~rpgbook
Author, Programming Role-Playing Games with DirectX
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement