Index: normal.c
===================================================================
--- normal.c	(revision 478)
+++ normal.c	(revision 479)
@@ -45,7 +45,7 @@
 norm[1]=vect[0][2]*vect[1][0] - vect[0][0]*vect[1][2];
 norm[2]=vect[0][0]*vect[1][1] - vect[0][1]*vect[1][0];
 
-// ... wich we normalize.
+// ... which we normalize.
 
 len=sqrt(norm[0]*norm[0] + norm[1]*norm[1] + norm[2]*norm[2]);
 
@@ -71,6 +71,63 @@
 }
 
 
+void raydium_normal_generate_lastest_tangent(void)
+{
+GLuint index=raydium_vertex_index;
+GLfloat v01x,v01y,v01z;
+GLfloat v02x,v02y,v02z;
+GLfloat du01,dv01;
+GLfloat du02,dv02;
+GLfloat tx,ty,tz;
+float s;
+int i;
+
+// index | -1 -2 -3
+// vert  |  2  1  0
+
+// vector from vert0 to vert1 (3D)
+v01x=raydium_vertex_x[index-2] - raydium_vertex_x[index-3];
+v01y=raydium_vertex_y[index-2] - raydium_vertex_y[index-3];
+v01z=raydium_vertex_z[index-2] - raydium_vertex_z[index-3];
+
+// vector from vert0 to vert2 (3D)
+v02x=raydium_vertex_x[index-1] - raydium_vertex_x[index-3];
+v02y=raydium_vertex_y[index-1] - raydium_vertex_y[index-3];
+v02z=raydium_vertex_z[index-1] - raydium_vertex_z[index-3];
+
+// vector from uv0 to uv1 (2D)
+du01=raydium_vertex_texture_u[index-2] - raydium_vertex_texture_u[index-3];
+dv01=raydium_vertex_texture_v[index-2] - raydium_vertex_texture_v[index-3];
+
+// vector from uv0 to uv2 (2D)
+du02=raydium_vertex_texture_u[index-1] - raydium_vertex_texture_u[index-3];
+dv02=raydium_vertex_texture_v[index-1] - raydium_vertex_texture_v[index-3];
+
+// 1/(u*v' - u'*v)
+s=1/(du01*dv02 - du02*dv01);
+
+// tangent ...
+tx=s*(dv02*v01x + (-dv01)*v02x);
+ty=s*(dv02*v01y + (-dv01)*v02y);
+tz=s*(dv02*v01z + (-dv01)*v02z);
+
+// ... and normalize:
+s=sqrt(tx*tx + ty*ty + tz*tz);
+tx/=s;
+ty/=s;
+tz/=s;
+
+// printf("tangent = [%f %f %f]\n",tx,ty,tz);
+
+for(i=1;i<=3;i++)
+    {
+    raydium_vertex_tangent_x[index-i]=tx;
+    raydium_vertex_tangent_y[index-i]=ty;
+    raydium_vertex_tangent_z[index-i]=tz;
+    }
+}
+
+
 void raydium_normal_restore_all(void)
 {
 GLuint i;