Any tutorials for understanding vertex normal and vertex tangent?

Software: Away3D 4.x

scutterry, Newbie
Posted: 14 September 2011 03:21 AM   Total Posts: 17

Recently, I learn Away3d 4.0. When I dig into the source of Cube. In the buildGeometry function, the following code.

vertexNormals[vidx] 0;
vertexTangents[vidx] 1;
vertices[vidx++outer_pos;
vertexNormals[vidx] 0;
vertexTangents[vidx] 0;
vertices[vidx++= -hh j*dh;
vertexNormals[vidx] = -1;
vertexTangents[vidx] 0;
vertices[vidx++= -hd

I want to know what vertexNormals and vertexTangents are, and how to calculate THEM. Are there any tutorials on them?
Thanks in advance.

   

riffraff, Newbie
Posted: 08 February 2012 08:54 AM   Total Posts: 9   [ # 1 ]

Hi!

Normals are simple, normal is a unit vector pointing from vertex, and it is used for lighting calculation. Because strength of lighting depends on angle on which light falls on surface. Engine multiplies this normal with direction to light which is also normalised and gets a cosinus of angle between them. Then this cosinus is used to multiply strength of light, because when angle closes to 0 degrees(sun at noon) the cosinus closes to 1.0, and when angle closes to 90 degrees(sun set/sun rise) then cosinus closes to 0.0 .

But what are tangents for? I don’t know really. Maybe for some bump mapping calculation?

Greetings

   

Avatar
theMightyAtom, Sr. Member
Posted: 08 February 2012 10:02 AM   Total Posts: 669   [ # 2 ]

Excellent question!
While I understand the vertex normal, I’ve been blissfully ignoring vertexTangents and your question made me find out what they are.
Again they are used for lighting calculation in shaders, but where a vertexNormal can be thought of as a line protruding from the vertex in the direction it is facing (important as you need to know which is the front and back) the vertex Tangent is just that, i.e. a tangent to the surface of the object at that point in space.

The good news is that you don’t necessarily have to calculate them yourself, hence my ability to create geometry without understanding them :O)

Away3D 4.0 includes the functions, autoDeriveVertexNormals() and autoDeriveVertexTangents() on subgeometries, and that should take care of it for you if you want the logical, intuitive ones.

myMesh.geometry.subGeometries[0].autoDeriveVertexNormals();
myMesh.geometry.subGeometries[0].autoDeriveVertexTangents(); 

should get you there :O)

Good Luck!

   

riffraff, Newbie
Posted: 08 February 2012 10:11 AM   Total Posts: 9   [ # 3 ]

Thanks a lot o’MightyAtom grin
Documentation is vestigial on this subject. I couldn’t find a tiny crumb of information what are tangents for.
Greetings

   

inSertCodE, Sr. Member
Posted: 08 February 2012 11:27 PM   Total Posts: 105   [ # 4 ]

autoDerive… calculates the average which in most cases from my experience you get natural lightning. As said, those are pretty mighty functions.
I’ve build my own 3d binary format for static mesh in away3d. In it you have option to save only the basic geometry (vertex, indices and UV) in which case normals and tangent are autoDerived.
With this I get:
1. less than 1/3 file size for the model compared to *.3ds (which is the lightest -in terms of file size- format that away3d parses). For a web-based application this is huge advantage.
2. It is parsed many times faster than *.3ds

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X