I have another problem with my point light. It looked like it was working with a single plane, but with a cube its not working. The back and front faces aren’t being lit. See picture.

[ATTACH=CONFIG]818[/ATTACH]

Lightning Calculations

```
vec3 calcDirectLight(float intensity, vec3 color, vec3 direction, vec3 normal)
{
float diffuseFactor = max(dot(normal, -direction), 0);
return color * intensity * diffuseFactor;
}
vec3 calcPointLight(float intensity, vec3 color, vec3 position, float constant, float linear, float exponent, vec3 normal)
{;
vec3 lightDir = vertex_position - position;
float lightDist = length(lightDir);
lightDir = lightDir / lightDist;
float attenuation = 1.0f / (0.1f + constant + linear * lightDist + exponent * lightDist * lightDist);
vec3 diffuse = calcDirectLight(intensity, color, lightDir, normal);
return diffuse * attenuation;
}
```

Cube Implementation

```
float halfWidth = 50.0f;
float halfLength = 50.0f;
float height = 100.0f;
float x_lo = -halfWidth;
float x_hi = halfWidth;
float z_lo = -halfLength;
float z_hi = halfLength;
float y_lo = 0;
float y_hi = height;
Vector3f pColor = Vector3f(1, 1, 1);
//Bottom Plane
Plane plane1 = Plane(
Vertex(Vector3f(x_lo, y_lo, z_lo), pColor, Vector3f(0, 1, 0), Vector2f(0, 0)),
Vertex(Vector3f(x_lo, y_lo, z_hi), pColor, Vector3f(0, 1, 0), Vector2f(1, 0)),
Vertex(Vector3f(x_hi, y_lo, z_hi), pColor, Vector3f(0, 1, 0), Vector2f(1, 1)),
Vertex(Vector3f(x_hi, y_lo, z_lo), pColor, Vector3f(0, 1, 0), Vector2f(0, 1)),
false,
false
);
//Top Plane
Plane plane2 = Plane(
Vertex(Vector3f(x_lo, y_hi, z_lo), pColor, Vector3f(0, -1, 0), Vector2f(0, 0)),
Vertex(Vector3f(x_lo, y_hi, z_hi), pColor, Vector3f(0, -1, 0), Vector2f(1, 0)),
Vertex(Vector3f(x_hi, y_hi, z_hi), pColor, Vector3f(0, -1, 0), Vector2f(1, 1)),
Vertex(Vector3f(x_hi, y_hi, z_lo), pColor, Vector3f(0, -1, 0), Vector2f(0, 1)),
false,
true
);
//Left Plane
Plane plane3 = Plane(
Vertex(Vector3f(x_lo, y_hi, z_hi), pColor, Vector3f(1, 0, 0), Vector2f(0, 0)),
Vertex(Vector3f(x_lo, y_lo, z_hi), pColor, Vector3f(1, 0, 0), Vector2f(1, 0)),
Vertex(Vector3f(x_lo, y_lo, z_lo), pColor, Vector3f(1, 0, 0), Vector2f(1, 1)),
Vertex(Vector3f(x_lo, y_hi, z_lo), pColor, Vector3f(1, 0, 0), Vector2f(0, 1)),
false,
false
);
//Right Plane
Plane plane4 = Plane(
Vertex(Vector3f(x_hi, y_hi, z_hi), pColor, Vector3f(-1, 0, 0), Vector2f(0, 0)),
Vertex(Vector3f(x_hi, y_lo, z_hi), pColor, Vector3f(-1, 0, 0), Vector2f(1, 0)),
Vertex(Vector3f(x_hi, y_lo, z_lo), pColor, Vector3f(-1, 0, 0), Vector2f(1, 1)),
Vertex(Vector3f(x_hi, y_hi, z_lo), pColor, Vector3f(-1, 0, 0), Vector2f(0, 1)),
false,
true
);
//Back Plane
Plane plane5 = Plane(
Vertex(Vector3f(x_hi, y_hi, z_lo), pColor, Vector3f(0, 0, 1), Vector2f(0, 0)),
Vertex(Vector3f(x_lo, y_hi, z_lo), pColor, Vector3f(0, 0, 1), Vector2f(1, 0)),
Vertex(Vector3f(x_lo, y_lo, z_lo), pColor, Vector3f(0, 0, 1), Vector2f(1, 1)),
Vertex(Vector3f(x_hi, y_lo, z_lo), pColor, Vector3f(0, 0, 1), Vector2f(0, 1)),
false,
false
);
//Front Plane
Plane plane6 = Plane(
Vertex(Vector3f(x_hi, y_hi, z_hi), pColor, Vector3f(0, 0, -1), Vector2f(0, 0)),
Vertex(Vector3f(x_lo, y_hi, z_hi), pColor, Vector3f(0, 0, -1), Vector2f(1, 0)),
Vertex(Vector3f(x_lo, y_lo, z_hi), pColor, Vector3f(0, 0, -1), Vector2f(1, 1)),
Vertex(Vector3f(x_hi, y_lo, z_hi), pColor, Vector3f(0, 0, -1), Vector2f(0, 1)),
false,
true
);
plane1.Draw();
plane2.Draw();
plane3.Draw();
plane4.Draw();
plane5.Draw();
plane6.Draw();
```

If I change the normal vector of the front/back faces, to some like (1,0,0) or (0,1,0) it lights the plane. So the lightning is working. Just something going on with normals along Z…??