clipping problems

I’m working on casting object shadows, so i had to setup the min. clip distance at 0.1f in order to render cast shadows properly.
However, since i have also a huge terrain, with 0.1f i get a LOT of z-buffer fighting, which disappear if i increase min. clip distance at 10. But at 10 i am not able to see cast shadows so …
there is a way to solve it ?

I don’t understand what shadow technique you are using. Are you using stenciled shadow volumes?


Yes, i studied tutorial #27 at Nehe site and tried to adapt it at my terrain engine. Everything works fine, but in order to draw stencil shadows correctly, as stated in the tut, the minimum clip must be very small. But that gives a lot of artifact when rendering objects (like a terrain engine) very far from the camera.

That´s the reason why real engines cap the shadow volumes at the near and far clipping plane.
Look at nVidias site for stencil shadow volumes, they have a lot of articles on how to do it properly.
And to get rid of the artifacts you might want to check out GL_NV_depth_clamp. That extension was invented to prevent stencil shadows to produce artifacts at the near and far clipping plane. AFAIK, when using it, you don´t have to cap the shadows yourself anymore.


thanks for your help, i found some info about depth clamping, so i tried to enable it like this: glEnable(DEPTH_CLAMP_NV);

That’s what i understood from here:

However, i get an error ‘DEPTH_CLAMP_NV’ : undeclared identifier, so i think the extension is not working. Unfortunately i dont have much experience with using gl extensions …

Solved ! I used the DEPTH_CLAMP_NV extension with
and now setting the minimum clip distance at 10.0f also stenciled shadows are correctly drawn.
I wonder however if Ati has an analogue extension, going to check it out.