Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Quick Direct3D Question

DanTheRockerDanTheRocker Member Posts: 95
struct CUSTOMVERTEX
{
D3DXVECTOR3 position; // vertex position
D3DXVECTOR3 normal; // vertex normal
};

What is the vertex normal?

Comments

  • SephirothSephiroth Fayetteville, NC, USAMember Posts: 1,035
    : struct CUSTOMVERTEX
    : {
    : D3DXVECTOR3 position; // vertex position
    : D3DXVECTOR3 normal; // vertex normal
    : };
    :
    : What is the vertex normal?
    :
    Most likely used for movement/translations, such as on a rotating door in a 3D game like Unreal or Half-Life. Normal is the original object center, while position is where it currently is.

    -[italic][b][red]S[/red][purple]e[/purple][blue]p[/blue][green]h[/green][red]i[/red][purple]r[/purple][blue]o[/blue][green]t[/green][red]h[/red][/b][/italic]

  • WudanWudan Member Posts: 66
    A normal is a direction. A vertex normal is the direction that the vertex is pointing.

    You can use vertex normals for shading a face during realtime lighting. If a face has 3 vertex, and each vertex has normals, you can calculate the brightness of each vertex by comparing the direction of the vertex normal to the direction of the light. So if the light is directly facing the normal, the vertex is very bright. If the normal is 90 degrees to the light, it is very dark.

    So for your CUSTOMVERTEX structure, each vertex has a position in space, and a direction to face.

    : struct CUSTOMVERTEX
    : {
    : D3DXVECTOR3 position; // vertex position
    : D3DXVECTOR3 normal; // vertex normal
    : };
    :
    : What is the vertex normal?
    :

  • MutilateMutilate Member Posts: 22
    : A normal is a direction. A vertex normal is the direction that the vertex is pointing.
    :
    : You can use vertex normals for shading a face during realtime lighting. If a face has 3 vertex, and each vertex has normals, you can calculate the brightness of each vertex by comparing the direction of the vertex normal to the direction of the light. So if the light is directly facing the normal, the vertex is very bright. If the normal is 90 degrees to the light, it is very dark.
    :
    : So for your CUSTOMVERTEX structure, each vertex has a position in space, and a direction to face.
    :

    I'm here at school and have nothing to do so I just do the maths lammer.

    Your answer is correct Wudan, but hasn't really a mathematical sense.
    I read a lot on this topic and found it a very smart solution so I spear it with u (or just lame but whatever).
    I said that has no sense 'cause a vertex is basicaly a point which has only position in the space and not orientation (direction, angle, ...).
    A normal is not given by a vertex but by a surface, so lats take a triangle:
    A normal of the triangle is a vector which is perpendicolar to the surface (90 deg between). We often choose as normal a normalized vector (lenght=1) and which is pointing the face that has the vertex in clockwise order (vertex_0,vertex_1,vertex_2) for backface removal.

    Ok then if the normal depends only on the triangle all the vertex should have the same normal, so why give a different normal to each vertex?
    To understand that we need to think about the fact that all vertex should have the same normal, that's because a triangle (or whatever poligon) is flat. So a vector perpendicolar to one tessel (that should be the word to define a very small portion of a surface...not sure) of the triangle is perpendicolar to any other tessel.
    Then what means that vertexs have different normals? It means that the surface is not flat!
    Not our case that wouldn't be a poligon anymore, but who cares we just use it for lighting that's it.
    So here is the good thinking, we render it as a poligons but we process lighting as it were a Hermite surface (like Bezier, but has normal vectors instead of control points), so we give the impression that the surface isn't flat.
    It's called grourad shading or something (lucky that I dont have to pronunce it).

    We compute the brightness of a vertex by doing a dot product (that's the way u call it, isn't it ?), between the vertex_normal_vector (vnv) and the light_direction_vector (ldv)
    vnv.lvn = vnv_x*lvn_x + vnv_y*lvn_y + vnv_z*lvn_z = cos(angle(lvn,vvn))*leght_vnv*lenght_lvn
    if we chose lenght_vnv=1 and lenght_lvn=1 you get we allready get cos(angle(lvn,vvn)).
    That we would use as brightness factor (range cos(90)=1 | cos(0)=cos(180)=0) if it is negative the vertex wont get light.

    Mutilate
  • WudanWudan Member Posts: 66
    Your answer is correct Mutilate, but lacks an 'easily understood' sense. Because of the relative mathematical knowledge required to understand what's going on, its sometimes better to explain in such a way that you can picture it in your head, as not everyone can understand by looking at formula's & equations. If someone asks me, 'what's a vertex normal' then I think I can gauge roughly, their maths knowledge. In this case I tried to explain in a way that lacks the more confusing mathematical sense. Then again, throwing around needless miss spelt multi-syllable tessel's, perpendicolar's, and poligons may also lead someone else to think you know your stuff, which I suspect is the genuine reason for your post.




  • MutilateMutilate Member Posts: 22
    You didn't understand my reason...maybe 'cause I didn't explain they, so:
    First of all sorry for my english, grammatics, spelling and stuff but I'm still learning english and being a letteracture's guru is not the topic of my life, I just hope u understand what I write.
    Second I really dont have much maths knowledge to show off because I'm still dealing with the high school, so that will be only arrogant and stupid from my side.
    But I belive that as programmer when u use a maths knowledge that u didn't get from yourself, you should have at least the intellectual honesty to understand what's behind it and not just call the whocareshowitdoesthis(a,b,c); function by knowing what a,b,c mean.
    Second, like I said, I found rather genial the grouar...ourad..whatever shading methode so I just wanted to share this. We all feel as programmers the elegance of a fast-simple solution to a difficult problem, isn't it ?

    Then...it seems u get it into personal way...didn't mean that, I said your answer didn't really have a mathematical's sense, not that u didn't know it or whatever.

    To finish this post that isn't really topic-coerent I just say that I thing u shouldn't use something u dont understand (Eistein would have said that) and that u shouldn't lead people to find sense were is none (The church will never say that...ehehe).

    Mutilate
  • WudanWudan Member Posts: 66

    Ok mutilate, Maybe I did take it personal but you did start by calling me a lamer ! But it looks like that was down to the language barrier. Top tip, If your english isn't that good, forget words like 'lamer' :) And as we're throwing around quotes...

    Make things as simple, simple as can be. But no simpler.
    - Albert einstein




  • MutilateMutilate Member Posts: 22
    :
    : Ok mutilate, Maybe I did take it personal but you did start by calling me a lamer ! But it looks like that was down to the language barrier. Top tip, If your english isn't that good, forget words like 'lamer' :) And as we're throwing around quotes...
    :
    : Make things as simple, simple as can be. But no simpler.
    : - Albert einstein

    [Last Post we are...a bit out of topic]

    >>I'm here at school and have nothing to do so I just do the maths lammer.
    By that I meant that I was the lammer ('cause you allready explained it didn't you ?) not you.

    P.S.: Very nice sentence you get there from the E=1/2*(m*c^2)/SQR(1-v^2/c^2) but think about what he meant by "But not simpler".

    Mutilate
Sign In or Register to comment.