in scene.cpp, line 77: glutSolidCube(12.0f);
in main.cpp, line 29: VECTOR3D cameraPosition(-2.5f, 15.f,-2.5f);
in main.cpp, line 30: VECTOR3D lightPosition(1.0f, 0.6f,-1.0f);
in main.cpp, line 107: gluPerspective(45.0f, 1.0f, 0.1f, 10.0f);
in main.cpp, line 111: gluLookAt(lightPosition.x, lightPosition.y, lightPosition.z, 0.0f, 0.6f, 0.0f, 0.0f, 1.0f, 0.0f);
the thing is in your first two pictures i can’t see any problem, your light source appears to be higher than any object and pointing down down into the ground and the shadows seems to confirm that
The last image looks like it’s taken from inside the red torus, so naturally it’s not gonna work that well.
That’s normal, the shadowmap also projects in the reverse as it’s not the texture you project it’s the texture coordinates, but it doesn’t matter because in order to look decent and almost artifact free you need to multiply the shadow with the diffuse light, and that will remove the stuff behind the camera.
Thank you very much. if i want everything out of light to be in shadow, how can i do it? one method is to use GL_LIGHT_FALLOFF, but it doesn’t look very well at the edge of light’s view frustum.
there are 4 values you need to multiply together, the shadow, diffuse value, falloff and light texture, the last one uses the same texture coordinates as the depth texture and can be as simple as a white disc on a black background.
If you want you should also clip away everything behind the light.
You can draw the light texture in photoshop or paint if you want, it’s just to get a frame for the light and maybe some fading around the edges, it’s not needed if your using a cubemap, but it does give a bit of an “atmosphere”.
You do not have to use a “light texture”, which implies to me some lightmap or radiance cache anyway. I call it a “light mask”, but you can also compute it in your shader. It’s basically that a shadow mapped light represents the equivalent of a spot light. So if you look at the spot light falloff math in the lighthouse tutorials, or in the red book, you will get the idea. Basically everything that isn’t on the shadow map should not receive light.
The “light texture” or “light mask” has some advantages, because you can control the penumbra effect, etc. If you want to shadow map a point light, you will need 6 shadow maps.