Question

Im toying with shadow volume on my iPhone and everything work at the exception if the shadow volume cap is clip by the far plane.

Since gl_ClipVertex is not available in GLSL ES, how can I clip the gl_Position.z to be at the far plane? I already try to use gl_Position.z = gl_Position.w, but the result is wrong and the shadow volume seems to follow the camera direction. Is there any other way to do it?

No correct solution

OTHER TIPS

in order for shadow volumes to work, you probably need to avoid the cap being clipped by the far plane. To do that, either increase depth range (move far plane farther away), or decrease the amount of extrusion.

There are many shadow volume techniques, some of them designed specifically with avoiding depth capping in mind. Mine favorite is Carmack's reverse, that works well as long as you know the bounding box of your geometry (Carmack uses BSP trees so it's easy for him), because then you know exactly how far it is necessary to extrude the shadow volume. Also, some clipping may need to be done if the light is very close to a shadow casting object (otherwise not the far cap, but the corners of the volume will end up clipped). While this is easy to explain, it is rather hard to implement. There are also some other algorithms, better suited for simple implementation on GPU (see here http://www.nvidia.com.br/object/robust_shadow_volumes.html).

I hope this will help you, feel free to comment if you require further assistance.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top