Jump to content
  • Advertisement
Sign in to follow this  

OpenGL Alternatives to GL_NV_depth_clamp extension for stencil shadow

This topic is 2769 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello everybody as this is my first topic here!

I am working on a project for OpenGL ES platforms that involves the use of stencil shadow rendering. This comes with the undesired side effect of far plane clipping when using the z-fail variant.
Trying to avoid this clipping, I wish to use something similar to GL_NV_depth_clamp extension ( which works fine when available, not my case though ).
Is there any way to emulate this behavior, maybe in the shader or elsewhere.

I tried to limit my vertices in vertex shader to the far plane ( after doing the transform ) like this:
gl_Position.z = min( gl_Position.z, gl_Position.w );
but this is messing up my geometry so it is not a good solution.

Then i tried in the fragment shader to mimic the depth clamp behavior like this:
gl_FragDepth = clamp( gl_FragCoord.z, gl_DepthRange.near, gl_DepthRange.far );
but this is not working right. ( I see fragments still clipped by the far plane )

PS I prefer not to use other solutions for solving this clipping issue ( as infinite projection matrix ).
Thank you!

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!