   Dark spot at poles on my sphere
  I am sure the normals are wrong at the tops of the poles on my sphere but not sure what I need to do to fix them....for(float b = 0.0f; b <= 90 - delta; b +=delta){for(float a = 0.0f; a <= 360 - delta; a +=delta){vertices[n].vx = r * sin((a) / 180 * NX::MATH::PI) * sin((b) / 180 * NX::MATH::PI) - h;vertices[n].vy = r * cos((a) / 180 * NX::MATH::PI) * sin((b) / 180 * NX::MATH::PI) + k;vertices[n].vz = r * cos((b) / 180 * NX::MATH::PI) - z;vertices[n].t = (2 * b) / 360;vertices[n].s = (a) / 360;v1.Set(vertices[n].vx, vertices[n].vy, vertices[n].vz);tc.Set(vertices[n].s, vertices[n].t);triangle[0] = v1;tcTriangle[0] = tc;n++;vertices[n].vx = r * sin((a) / 180 * NX::MATH::PI) * sin((b + delta) / 180 * NX::MATH::PI) - h;vertices[n].vy = r * cos((a) / 180 * NX::MATH::PI) * sin((b + delta) / 180 * NX::MATH::PI) + k;vertices[n].vz = r * cos((b + delta) / 180 * NX::MATH::PI) - z;vertices[n].t = (2 * (b + delta)) / 360;vertices[n].s = (a) / 360;v2.Set(vertices[n].vx, vertices[n].vy, vertices[n].vz);tc.Set(vertices[n].s, vertices[n].t);triangle[1] = v2;tcTriangle[1] = tc;n++;vertices[n].vx = r * sin((a + delta) / 180 * NX::MATH::PI) * sin((b) / 180 * NX::MATH::PI) - h;vertices[n].vy = r * cos((a + delta) / 180 * NX::MATH::PI) * sin((b) / 180 * NX::MATH::PI) + k;vertices[n].vz = r * cos((b) / 180 * NX::MATH::PI) - z;vertices[n].t = (2 * b) / 360;vertices[n].s = (a + delta) / 360;v3.Set(vertices[n].vx, vertices[n].vy, vertices[n].vz);tc.Set(vertices[n].s, vertices[n].t);triangle[2] = v3;tcTriangle[2] = tc;n++;vertices[n].vx = r * sin((a + delta) / 180 * NX::MATH::PI) * sin((b + delta) / 180 * NX::MATH::PI) - h;vertices[n].vy = r * cos((a + delta) / 180 * NX::MATH::PI) * sin((b + delta) / 180 * NX::MATH::PI) + k;vertices[n].vz = r * cos((b + delta) / 180 * NX::MATH::PI) - z;vertices[n].t = (2 * (b + delta)) / 360;vertices[n].s = (a + delta) / 360;tc.Set(vertices[n].s, vertices[n].t);n++;NX::MATH::CalculateNormal(normalVec, v2, v1, v3);normalVec.Normalize();bitangentVec = NX::MATH::CalculateTangents(triangle, tcTriangle, normalVec, tangentVec);normal.push_back(normalVec);normal.push_back(normalVec);normal.push_back(normalVec);normal.push_back(normalVec);tangent.push_back(tangentVec);tangent.push_back(tangentVec);tangent.push_back(tangentVec);tangent.push_back(tangentVec);bitangent.push_back(bitangentVec);bitangent.push_back(bitangentVec);bitangent.push_back(bitangentVec);bitangent.push_back(bitangentVec);}}I am using strips BTW...Any help or ideas welcomed.Thanks   
  Don't calculate the normals by cross productBy definition, v = r * n + c, where v is a vertex on the sphere, n is the normal vector at that point, and c is the center of the sphere.  So you have already found the normal when you calculated v.;  Huh?I have seen others use Cross() to find it on their spheres? I not following what you are saying....Thanks for the reply though.   ;  gpu_fem's way is indeed a better way to calculate normals, but a cross product should work as well.But did you actually check using a debugger if your normals that are wrong, or it's just a guess?Of course I don't know how your CalculateTangents function works, but something I could imagine that would be the problem is that it takes a cross product with the up vector to get a vector perpendicular to your normal, but if your normal would also point up, then this would yield a 0 vector, which would go to INF after normalization.   ;//Returns the Bitangent vector//vTriangle[3] send in as vertex points on meshtemplate<typename T> inline vec3<T> CalculateTangents(const vec3<T> vTriangle[3],   const vec2<T> vTexCoords[3],   const vec3<T>& N, vec3<T>& vTangent){    vec3<T> dv2v1, dv3v1;    T dc2c1t = 0, dc2c1b = 0, dc3c1t = 0, dc3c1b = 0;    T M = 0;dv2v1  = vTriangle[1] - vTriangle[0];dv3v1  = vTriangle[2] - vTriangle[0];   dc2c1t = vTexCoords[1].x - vTexCoords[0].x;dc2c1b = vTexCoords[1].y - vTexCoords[0].y;    dc3c1t = vTexCoords[2].x - vTexCoords[0].x;    dc3c1b = vTexCoords[2].y - vTexCoords[0].y;    M = (dc2c1t * dc3c1b) - (dc3c1t * dc2c1b);    M = 1 / M;    dv2v1 *=dc3c1b;dv3v1 *=dc2c1b;    vTangent = dv2v1 - dv3v1;    vTangent *=M; vTangent.Normalize();   vec3<T> B = vec3<T>::Cross(N, vTangent);vTangent  = vec3<T>::Cross(B, N);vTangent.Normalize();B.Normalize();return B;};Quote:Original post by MARS_999Huh?I not following what you are saying....What gpu_fem was saying is that if you have calculated the vertex you already have the normal and do not need to calculate it. If the center of your sphere is (0, 0, 0) then the coordinates of the vertices are equal to a vector from the center of the sphere to the vertex. So you just need to take the vertex position as vector and normalize it. This is your normal.If your sphere's center is not at the origin you need to subtract the center coordinates (interpreted as vector) from your vertex coordinates and normalize the resulting vector. That's your normal then. No need to waste CPU cycles to calculate the normal [smile];  Exactly.  Sorry I didn't make this clear.  So your normal for v1 is (e.g.) [  sin((a) / 180 * NX::MATH::PI) * sin((b) / 180 * NX::MATH::PI),   cos((a) / 180 * NX::MATH::PI) * sin((b) / 180 * NX::MATH::PI),   cos((b) / 180 * NX::MATH::PI) ]This is already normalized (by definition) and always points in the correct direction.  It also results in smooth shading automatically.The only case this doesn't work is if you want solid shading, where you want a constant normal on the triangle (to get a faceted look).   ;Quote:Original post by quasar3dgpu_fem's way is indeed a better way to calculate normals, but a cross product should work as well.But did you actually check using a debugger if your normals that are wrong, or it's just a guess?Of course I don't know how your CalculateTangents function works, but something I could imagine that would be the problem is that it takes a cross product with the up vector to get a vector perpendicular to your normal, but if your normal would also point up, then this would yield a 0 vector, which would go to INF after normalization.What can I do to stop that from happening? I think this is happening on the last rows in the strips... I am using gpu_fem's idea and still seeing the dark spot on the top and bottom pole. From the data I am seeing printed out I am getting a NAN value so...Thanks   ;  At the top of your pole lets say your top vert is 0,0,5 (assuming Z is up!)you'd normalize that vert coordinate and get 0,0,1just do that for every vert and you have your vert normals.the fact that your sphere is rendering right (despite the dark spot at the poles) means that this should totally work (:   ;  If I change the delta amount on the loop the spot grows and shrinks...I still think its a problem with the tangent bitangent values...Thanks[Edited by - MARS_999 on May 27, 2009 7:12:29 PM]