   AABB Normals
  Hi. im curr working on a ray tracing and im stuck... i just dont seem to get my normals right. im not sure on how much code i need to paste but i will give it a try.here i have my normal calc. as u can c a intersection point is given repr the position on the box to calculate the normal. Vec3 Box::GetNormalAt(Vec3& intersection_point_v) {Vec3 normal = Vec3(); // 0,0,0float min = std::numeric_limits<float>::max();intersection_point_v = intersection_point_v - this->GetMid();float distance = Math::Abs((this->GetMax().x - this->GetMin().x) - Math::Abs(intersection_point_v.x));if(distance < min) {min = distance;normal = Vec3(1.0f, 0.0f, 0.0f) * Math::Sign(intersection_point_v.x);}distance = Math::Abs((this->GetMax().y - this->GetMin().y) - Math::Abs(intersection_point_v.y));if(distance < min) {min = distance;normal = Vec3(0.0f, 1.0f, 0.0f) * Math::Sign(intersection_point_v.y);}distance = Math::Abs((this->GetMax().z - this->GetMin().z) - Math::Abs(intersection_point_v.z));if(distance < min) {min = distance;normal = Vec3(0.0f, 0.0f, 1.0f) * Math::Sign(intersection_point_v.z);}return normal.Normalize();}this works like a charm on the front of the aabb but all of the sides are black. im tired and sad :(   
  I guess this is too obvious, but if your light is in front of your box, then the front will be light, while the sides will be ambiently lit.This is just off the top of my head:to get the normal of a point that is definitely on a side of the aabb:struct aabb{vec3 center;vec3 dimensions; // from the center, so dims<2,2,2> means the box is 4x4x4vec3 get_normal_from_surface_pt(vec3 surfpt){surfpt = surfpt - center; // localise the pt to the boxsurfpt = surfpt / dimensions; // "normalise" the pt so that one of the components will be 1 or -1, as it lies on the surface of the aabbvec3 normal;normal.x = (abs(surfpt.x) == 1)? surfpt.x : 0;normal.y = (abs(surfpt.y) == 1)? surfpt.y : 0;normal.z = (abs(surfpt.z) == 1)? surfpt.z : 0;return normal.normalized();}};Pretty sure that will do what you want, obviously the edges and corners are indeterminate as far as normals go, this algorithm will return a "smoothed" normal for those cases.