I followed the red book 9th edition code, which has the complete code for the vertex shader and the fragment shader, so I typed them and they seem to be OK except for a uniform mat3 that has the NormalMatrix which is not used by either shader and is not needed since both thye MV and the MVP matrices are passed and the MV is used to compute the normals of the sphere.

I just wrote the main app with the same initial values supplied by the red book, but didn’t get the correct result, I got a ball with ligthing but the star, stripe and base colors are messed up. So I looked closer at the initial values and suspected that there is something wrong with the plane equations defining the star. The planes defining the star were written simply as the x and y coordinates of the 5 points lying in the x-y plane of the regular pentagon drawn inside a unit circle and the z is zero and the w (constant) is same for all planes 0.2. So I changed the initial values of the planes by computing the cross product of the z-axis (assuming all planes are parallel to the z-axis) and 2 non-consecutive points of the pentagon to get the normal of the plane, and then wrote the a,b,c,d of the plane equation from the plane and one of the 2-points. Well the image changed but still messed up. Cannot think of anything else, appreciate help from anyone who got it working…

Here is the code used in computing the new initial value of Halfspace:

```
vec3 v[5] = {{1.0, 0.0, 0.0}, {0.309016994, 0.951056516, 0.0},
{-0.809016994, 0.587785252, 0.0} , {-0.809016994, -0.587785252, 0.0},
{0.309016994, -0.951056516, 0.0}};
vec4 HalfSpace[5];
int pj2;
for (int i=0; i<5; i++) {
int j1 = (i%2==0)?i/2:(i-1)/2;
int j2 = (i%2==0)?(j1+2):(pj2+1);
pj2 = j2;
HalfSpace[i] = vec4(v[j1][1]-v[j2][1], v[j1][0]-v[j2][0], 0.0, (v[j1][1]-v[j2][1])*v[j1][0] + (v[j1][0]-v[j2][0])*v[j1][1]);
}
```