   Shadowmaps: Stencil surface and problems with distance
  My problem is, that if there is no geometry to render from the light camera, then the z-value will read as very close.That means, that when I compare that area with the scene from the world camera's view, that that area will be totally in shadow.For instance, if I render to the shadowmap only a character for instance, (if I don't want the terrain to self-shadow), then I would expect all the empty space to be at a very far distance, so it won't shadow anything.How do I accomplish this, when the z-value for an empty area reads as very close?Edit: I use DirectX and I use the flag D3DFMT_D24X8 (I tested with D3DFMT_D16 with similar result) for the stencil buffer.   
I use opengl and there is a function I call (because it said to). glClearDepth(1.0) and I beleive I use a value of 1.0. I'm very new to depth mapping but I beleive this is why I dont have your problem. When I clear the depth buffer I set the value's to 1.0 and I assume this is the other end of 0.0 ( the screen ).I retreived this from HERE.The Clear can be used for clearing stencil bits within a depth buffer. Simply set the Flags parameter to determine how Clear works with the render target and any associated depth or stencil buffers. The D3DCLEAR_TARGET flag will clear the viewport using an arbitrary RGBA color that you provide in the Color argument (this is not the material color). The D3DCLEAR_ZBUFFER flag will clear the depth buffer to an arbitrary depth you specify in Z: 0.0 is the closest distance, and 1.0 is the farthest. The D3DCLEAR_STENCIL flag will reset the stencil bits to the value you provide in the Stencil argument. You can use integers that range from 0 to 2n-1, where n is the stencil buffer bit depth.Good luck.   ;  Yeah that what you do, just clear to the farthest distance...you clear anyway each frame so this is free.   ;  Thanx alot guys. I couldn't see the first answer? Dunno what went wrong. I had to look up honayboyz and look through the "recent replies". Luckily the answer was there in the first three lines, hehe.I had been clearing like I normally do, with a black color. I changed that to white instead :)*Wanders off feeling like a newb after this silly problem*   