Sign in to follow this  
SimeonReilly

Calculating vertex normals

Recommended Posts

Hiyas, slightly off-center question here, no code involved!

I have an exam coming up for which I am woefully unprepared. And I just can't figure out how to get this done. Could anyone fill me in? As concisely as possible? Many thanks for any help

[img]https://lh6.googleusercontent.com/_vgiWUMw8eWs/Tc8Jo91zG1I/AAAAAAAAAKA/b8Sk3weptFg/s800/vnormal.PNG[/img]

Share this post


Link to post
Share on other sites
interesting, if those large quads/triangles are part of that sphere then you should use the fact that its a sphere to your advantage. Are those numbers vertex positions? Can't quite work out if its possible to do with the information you've been given.

I guess your safer calculating the face vertices and smootinhg. Will these be weighted though?

Share this post


Link to post
Share on other sites
[quote name='GregMichael' timestamp='1305416697' post='4810886']
If it's a sphere....then just normalise the vertex position - job done.
[/quote]

If its centered at the origin yeah, but is it?

Share this post


Link to post
Share on other sites
[quote name='thefries' timestamp='1305416000' post='4810881']
You have to calculate the normals of the 4 triangles that use that vertex (so you can ignore vertex <-10,15,10> and <1,18,16>), then average those 4 normals.
[/quote]

okay so the equation I have for finding the triangle normals is

(we have three vertices v1, v2, v3)
u1 = (v2 - v1) / || (v2 -v1) || - where || A || is the magnitude of A
u2 = (v3 - v1) / || (v3 - v1) ||

normal = u2 x u1 / || u2 x u1|| - where x denotes cross product

so we get 4 triangle normals n1, n2, n3, n4

Our vertex normal vn is:

vn = ( 1/4 * (n1 + n2 + n3 + n4) ) / || ( 1/4 * (n1 + n2 + n3 + n4) ) ||

Is this correct? Seems like something of a pain in the ass.

Share this post


Link to post
Share on other sites
[quote][quote]If it's a sphere....then just normalise the vertex position - job done.[/quote]

If its centered at the origin yeah, but is it?[/quote]

That does not make a big difference. Let's say you know the origin. Then you get the right normal by normalizing (Vertexposition-Origin).

Share this post


Link to post
Share on other sites
[quote name='Fabbo' timestamp='1305470712' post='4811090']
[quote][quote]If it's a sphere....then just normalise the vertex position - job done.[/quote]

If its centered at the origin yeah, but is it?[/quote]

That does not make a big difference. Let's say you know the origin. Then you get the right normal by normalizing (Vertexposition-Origin).
[/quote]
There is nothing in the assignment that directly indicates where the origin is.

Share this post


Link to post
Share on other sites
[quote name='Mentalpants' timestamp='1305467686' post='4811076']
[quote name='thefries' timestamp='1305416000' post='4810881']
You have to calculate the normals of the 4 triangles that use that vertex (so you can ignore vertex <-10,15,10> and <1,18,16>), then average those 4 normals.
[/quote]

okay so the equation I have for finding the triangle normals is

(we have three vertices v1, v2, v3)
u1 = (v2 - v1) / || (v2 -v1) || - where || A || is the magnitude of A
u2 = (v3 - v1) / || (v3 - v1) ||

normal = u2 x u1 / || u2 x u1|| - where x denotes cross product

so we get 4 triangle normals n1, n2, n3, n4

Our vertex normal vn is:

vn = ( 1/4 * (n1 + n2 + n3 + n4) ) / || ( 1/4 * (n1 + n2 + n3 + n4) ) ||

Is this correct? Seems like something of a pain in the ass.
[/quote]


Can anyone verify the correctness of this?

Share this post


Link to post
Share on other sites
[quote name='Brother Bob' timestamp='1305471330' post='4811092']
[quote name='Fabbo' timestamp='1305470712' post='4811090']
[quote][quote]If it's a sphere....then just normalise the vertex position - job done.[/quote]

If its centered at the origin yeah, but is it?[/quote]

That does not make a big difference. Let's say you know the origin. Then you get the right normal by normalizing (Vertexposition-Origin).
[/quote]
There is nothing in the assignment that directly indicates where the origin is.
[/quote]
You are right that the origin is not given explicitly.

But if it is a sphere like shown above then the origin is known.
just fnd the two vertices with the highest face connections (top of sphere and bottom of sphere) and interpolate to the middle of them. There is the origin.
Finding the origin is something you have to do once for all vertices of the sphere. I'd say interpolating between the connected faces takes more time.

Share this post


Link to post
Share on other sites
[quote name='Fabbo' timestamp='1305497227' post='4811226']
[quote name='Brother Bob' timestamp='1305471330' post='4811092']
[quote name='Fabbo' timestamp='1305470712' post='4811090']
[quote][quote]If it's a sphere....then just normalise the vertex position - job done.[/quote]

If its centered at the origin yeah, but is it?[/quote]

That does not make a big difference. Let's say you know the origin. Then you get the right normal by normalizing (Vertexposition-Origin).
[/quote]
There is nothing in the assignment that directly indicates where the origin is.
[/quote]
You are right that the origin is not given explicitly.

But if it is a sphere like shown above then the origin is known.
just fnd the two vertices with the highest face connections (top of sphere and bottom of sphere) and interpolate to the middle of them. There is the origin.
Finding the origin is something you have to do once for all vertices of the sphere. I'd say interpolating between the connected faces takes more time.
[/quote]
But only one such point is given, the other one is not.

If you want to determine the center of the sphere, you would have to find a sphere that gives you the listed coordinates. It is possible, and assuming that the coordinates are not subject to rounding or otherwise are not fully accurate (for example, they are rounded to integers for the purpose of easy hand calculation, and I find it likely they are because sphere coordinates are rarely that nice looking), there is in fact a single unique solution for the center. However, I seriously doubt finding that center so you can normalize the center-to-point vector is easier than just calculating the face normals and averaging to find the vertex normal

Mentalpants:
I have sort of forgot to focus on your questions about your solution, sorry. Your approach is valid (not saying others aren't, there are many ways and interpretations of what a vertex normal actually is in the general sense and how to calculate it). Your vectors u1 and u2 spans the edges of a triangle, and its normal is the cross product between them. The vertex normal is then the average of the four face normals connecting to the vertex in question. So your approach is indeed valid.

Share this post


Link to post
Share on other sites
Thanks for your help, gentlemen. It really makes a difference.


Unfortunately I am not done yet! Me and my fellow students seek your patience for one more question.
(Hope it doesn't look like I am pushing my luck here - just some of this stuff really wasn't explained very well at all to us, our notes are rubbish)

[url="http://www.gamedev.net/topic/602133-ray-tracing-construction-and-finding-a-pixel/"]http://www.gamedev.net/topic/602133-ray-tracing-construction-and-finding-a-pixel/[/url]

Share this post


Link to post
Share on other sites
[quote]But only one such point is given, the other one is not.

If you want to determine the center of the sphere, you would have to find a sphere that gives you the listed coordinates. It is possible, and assuming that the coordinates are not subject to rounding or otherwise are not fully accurate (for example, they are rounded to integers for the purpose of easy hand calculation, and I find it likely they are because sphere coordinates are rarely that nice looking), there is in fact a single unique solution for the center. However, I seriously doubt finding that center so you can normalize the center-to-point vector is easier than just calculating the face normals and averaging to find the vertex normal[/quote]

Okay, now i get it. =D I thought of a realistic case in which you have all vertices in a buffer. My fault.

But in case that there is a sphere in a vertex buffer, it should be a fast solution for a sphere. It is optimizable if you can assume that the model is not rotated.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this