My scene is quite simple that I have two spheres placed close to each other. I have one point light in the scene and set the position of it to be inside of one of the two spheres. However the other sphere can still get the light from that point light. What I want is the light is occluded by the sphere.
My context is the followings:
glShadeModel(GL_SMOOTH);
glEnable(GL_DEPTH_TEST);
glDepthFunc( GL_LEQUAL );
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
glEnable(GL_MULTISAMPLE);
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
glHint(GL_POINT_SMOOTH_HINT, GL_NICEST);
glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glEnable(GL_COLOR_MATERIAL);
glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);
glEnable(GL_LIGHTING);
// Light's color
GLfloat ambientColor[] = { 0.3f, 0.3f, 0.3f, 1.0f };
GLfloat diffuseColor[] = { 1.0f, 0.0f, 1.0, 1.0f };
GLfloat lightPosition[] = {0, 0, 0, 1.0f };
glLightfv(GL_LIGHT0, GL_AMBIENT, ambientColor);
glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuseColor);
glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);
glEnable(GL_LIGHT0);
Do I miss something?