View Full Version : clipping problems

08-16-2003, 08:12 AM
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 ?

08-16-2003, 11:36 AM
I don't understand what shadow technique you are using. Are you using stenciled shadow volumes?


08-16-2003, 11:53 AM
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.

08-16-2003, 12:55 PM
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.


08-16-2003, 01:23 PM
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: http://www.nvidia.com/dev_content/nvopenglspecs/GL_NV_depth_clamp.txt

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 ...

08-16-2003, 01:54 PM
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.