Sign in to follow this  
Quat

SV_ClipDistance

Recommended Posts

I need to add clip planes for my water reflection pass. SV_ClipDistance seemed nice in that I do not have to modify my pixel shaders.

My question is, does using SV_ClipDistance mess up early-Z optimizations and such? For example, it is recommended to have separate pixel shaders when you need to use clip().

I'm wondering because I was thinking of having all my vertex shaders output SV_ClipDistance, and if I don't need water plane clipping, I would just set the clip plane to the minimum of my world bounding box so that nothing would be clipped.

Or is it best to have separate vertex shaders (one that outputs a SV_ClipDistance value for reflection pass and one that does not)?

Share this post


Link to post
Share on other sites
The clipping that happens due to SV_ClipDistance happens in the rasterizer before the pixel shader is executed, so it shouldn't affect early-z or pixel shaders at all. This is very different from using clip() or discard, which happens in the pixel shader.

It's possible that if you always output SV_ClipDistance then you might cause the rasterizer to do a little extra work, but that would depend on the specifics hardware so I couldn't say for sure. However I would think that it's unlikely to have any major effect on your overall performance.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this