🔒 Locked
Generating Normals
Advertisement
Original Post
Could someone give me a link to a tutorial on generating normals, so the lighting on my terrain is smooth. Thanks
is your terrain tesselated patches, or have you got a soup of polygons from a model editor, or what?
********
A Problem Worthy of Attack
Proves It''s Worth by Fighting Back
********
A Problem Worthy of Attack
Proves It''s Worth by Fighting Back
I got my terrain from a height map and a brute force method but i don''t know how to calculate my normals so the lighting will be smooth.
**BUMP**
Could someone please help me.
I have a question too (it is fairly stupid I admit
).
If I have a vertex (-1|-1|0) is its normal then (-1|-1|-1) ?
(I know I could also have it point into the opposite direction, but is this correct?)
Im Anfang war die Tat...
Faust
If I have a vertex (-1|-1|0) is its normal then (-1|-1|-1) ?
(I know I could also have it point into the opposite direction, but is this correct?)
Im Anfang war die Tat...
Faust
quote:
Original post by Hippokrates
I have a question too (it is fairly stupid I admit).
If I have a vertex (-1|-1|0) is its normal then (-1|-1|-1) ?
(I know I could also have it point into the opposite direction, but is this correct?)
Im Anfang war die Tat...
Faust
A normalized vector can't be [-1,-1,-1]. (unless we define a unit as something else)
Try Sqrt( (-1)^2 + (-1)^2 + (-1)^2 ) I'd bet you get a result > 1
____________________________________________
I AM THE GOD OF SHADERS. LET ME ENLIGHT YOU
[edited by - ekas78 on August 3, 2002 5:04:37 PM]
Well, I did not mean a normalized vector but a normal vector to a vertex.
I have got a vertex [-1|-1|0], what is its normal then ?
Im Anfang war die Tat...
Faust
I have got a vertex [-1|-1|0], what is its normal then ?
Im Anfang war die Tat...
Faust
A vertice''s normal cannot be just determined by it''s position. It needs it''s neiboring triangle vertices. From there, you take the cross product of the two vectors of the triangle that share a same point to get a vector perpendicular to the two which is the normal vector. you should normalize it(no relation to it''s normal. it just means to have a magnitude of 1) so calculations are quicker and accurate.
Setting the normals up won''t produce correct lighting. If you arn''t using triangles for rendering but you have all the points, then just get the neiboring vertices and take the cross product of them. If you get backwards lighting, switch the order of the cross product. Backwards order produces backwards normals.
---
My Site
Come join us on IRC in #directxdev @ irc.afternet.org
Setting the normals up won''t produce correct lighting. If you arn''t using triangles for rendering but you have all the points, then just get the neiboring vertices and take the cross product of them. If you get backwards lighting, switch the order of the cross product. Backwards order produces backwards normals.
---
My Site
Come join us on IRC in #directxdev @ irc.afternet.org
Well, I am using these vertices for my quads.
I have those Vertices:
Where there are two stars I have 2 vertices because I am using a triangle list.
Every frame I manually transform vertices and normals (both the same way).
But how do I calculate the normals in this scenario ?
(Just for a single Quad, 6 vertices, 2 primitives)
Im Anfang war die Tat...
Faust
[edited by - Hippokrates on August 4, 2002 1:02:52 PM]
I have those Vertices:
**-----*
| |
| |
*-----**
Where there are two stars I have 2 vertices because I am using a triangle list.
Every frame I manually transform vertices and normals (both the same way).
But how do I calculate the normals in this scenario ?
(Just for a single Quad, 6 vertices, 2 primitives)
Im Anfang war die Tat...
Faust
[edited by - Hippokrates on August 4, 2002 1:02:52 PM]
A--B
|\ |
| \|
D--C
N' = (B-A)x(C-B)
N = N'/|N'|
where 'x' is the cross product and |N| the length of the vector.
N is the normal vector of the quad (given that A,B,C, and D are
on the same plane)
[edit]
Typo.
Maybe you need to flip the direction of N, by either swapping
A and B or C and B in the formula or just multiply N by -1...
If A,B,C and D are not on the same plane, then just calculate
N1 = normal(A,B,C)
N2 = normal(A,C,D)
N = (N1+N2)*0.5
[/edit]
[edited by - darookie on August 4, 2002 1:16:39 PM]
|\ |
| \|
D--C
N' = (B-A)x(C-B)
N = N'/|N'|
where 'x' is the cross product and |N| the length of the vector.
N is the normal vector of the quad (given that A,B,C, and D are
on the same plane)
[edit]
Typo.
Maybe you need to flip the direction of N, by either swapping
A and B or C and B in the formula or just multiply N by -1...
If A,B,C and D are not on the same plane, then just calculate
N1 = normal(A,B,C)
N2 = normal(A,C,D)
N = (N1+N2)*0.5
[/edit]
[edited by - darookie on August 4, 2002 1:16:39 PM]
I have read the various ways to set up normals, but i was looking for a turotial that showed how to do it in actual code.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement