SV_ClipDistance

Started by
0 comments, last by MJP 11 years, 8 months ago
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)?
-----Quat
Advertisement
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.

This topic is closed to new replies.

Advertisement