Jump to content

  • Log In with Google      Sign In   
  • Create Account

#Actualfrench_hustler

Posted 21 August 2012 - 01:55 PM

Ah sorry, I didn't understand the question very well, haha. Posted Image

Generally you'd pass the normal per vertex in your input layout. If you only have access to the face normals, then you'd want the average normal of all faces that the vertex is apart of.


This. The Wavefront .obj normals are usually not suited for direct transfer. You'll have to do some pre-work and create a buffer of per-vertex normals. As a matter of fact, I always export my models to a .obj format WITHOUT normals. I pre-compute the normals myself at load time (though that's a bit inefficient for high poly count models).

Anyways, here is an example of how to do this:
http://www.lighthouse3d.com/opengl/terrain/index.php3?normals

Basically you want to get the 3 vertices that make up a face.
Get the 2 perpendicular vectors and cross them to get a normal.
Accumulate that normal for the faces' vertices.
Do that for all faces and in the end you will average by dividing the amount of times you've accumulated for that specific vertex. That number should be equal to the amount of faces that use that vertex.

There are other fancier ways to calculate normals (such as adding weights). But a simple averaging should get you started properly.

#2french_hustler

Posted 21 August 2012 - 01:53 PM

Ah sorry, I didn't understand the question very well, haha. Posted Image

Generally you'd pass the normal per vertex in your input layout. If you only have access to the face normals, then you'd want the average normal of all faces that the vertex is apart of.


This. The Wavefront .obj normals are usually not suited for direct transfer. You'll have to do some pre-work and create a buffer of per-vertex normals. As a matter of fact, I always export my models to a .obj format WITHOUT normals. I pre-compute the normals myself at load time (though that's a bit inefficient for high poly count models).

Anyways, here is an example of how to do this:
http://devmaster.net...mals-of-a-mesh/

Basically you want to get the 3 vertices that make up a face.
Get the 2 perpendicular vectors and cross them to get a normal.
Accumulate that normal for the faces' vertices.
Do that for all faces and in the end you will average by dividing the amount of times you've accumulated for that specific vertex. That number should be equal to the amount of faces that use that vertex.

There are other fancier ways to calculate normals (such as adding weights). But a simple averaging should get you started properly.

#1french_hustler

Posted 21 August 2012 - 01:52 PM

Ah sorry, I didn't understand the question very well, haha. Posted Image

Generally you'd pass the normal per vertex in your input layout. If you only have access to the face normals, then you'd want the average normal of all faces that the vertex is apart of.


This. The Wavefront .obj normals are usually not suited for direct transfer. You'll have to do some per-work and create a buffer of per-vertex normals. As a matter of fact, I always export my models to a .obj format WITHOUT normals. I pre-compute the normals myself at load time (though that's a bit inefficient for high poly count models).

Anyways, here is an example of how to do this:
http://devmaster.net/forums/topic/1065-calculating-normals-of-a-mesh/

Basically you want to get the 3 vertices that make up a face.
Get the 2 perpendicular vectors and cross them to get a normal.
Accumulate that normal for the faces' vertices.
Do that for all faces and in the end you will average by dividing the amount of times you've accumulated for that specific vertex. That number should be equal to the amount of faces that use that vertex.

There are other fancier ways to calculate normals (such as adding weights). But a simple averaging should get you started properly.

PARTNERS