light.setParams(GL_POSITION, new Vector4f(lightPos.x, lightPos.y + 0.5f, lightPos.z, 1f)); glLightf(GL_LIGHT0, GL_SPOT_CUTOFF, 180); glLightf(GL_LIGHT0, GL_SPOT_EXPONENT, 2f); glLightf(GL_LIGHT0, GL_CONSTANT_ATTENUATION, 1.5f); glLightf(GL_LIGHT0, GL_LINEAR_ATTENUATION, 0.5f); glLightf(GL_LIGHT0, GL_QUADRATIC_ATTENUATION, 0.2f);
but I can in fact block the lighting with my glLight parameters? Meaning a solid object will actually stop some light from coming through?
As far as I know, no. Remember that polygons are drawn one after another, with no state kept except what state you explicitly set. So after you have drawn the outer walls, the state is lost, and the interior is drawn with no knowledge about the walls' existence. You might also draw the interior first, so just keeping state wouldn't solve the problem.Shadows are in itself a very complex topic in 3d rendering. You might want to take the shortcut and do what Minecraft does (you're still writing that Minecraft clone, right?): For each rendered face, draw the face in a light color if the cube it faces (note: not the filled cube that "presents" the face) is "lit", and use a dark color if not. Drawing a texture in dark or light colors can be done with glColorxx and an appropriate (color/texture) blending mode -- the latter should automatically be the case unless you turned it off.A cube is lit if there is only air above it. You'd probably want some optimized data structure again to keep this information ready when rendering. This is the shortcut you're taking with this approach: The nature of your light source is fixed.