PDA

View Full Version : NV_depth_clamp and Stencil Shadow Volumes



Dark Photon
09-08-2005, 09:06 AM
I've been getting my head around stencil shadow volumes with all the tweaks and optimizations, and I've got a really dumb question.

Depth Pass suffers from near-plane clipping.

Depth Fail inverts the problem and suffers far-plane clipping.

We can deal with Depth Fail's problem by: 1) pushing the far clip to infinity, or 2) using NV_depth_clamp to smash geometry outside the near/far planes onto the clip planes.

(You probably see this coming, but...)

Why not just use NV_depth_clamp to fix Depth Pass? :confused:

Admittedly we need caps on our stencil volumes now, but Depth Pass might reduce stencil write bandwidth in scenes where most shadow volume fragments are hidden by receiving geometry. Though that might be offset by the extra fill when in a shadow.

I'm probably missing something obvious here, so please, flame away.

Dez
09-09-2005, 12:30 AM
Depth pass is in some (even most) cases used in subsequent rendering passes not only involving stencil shadow volumes rendering but also color rendering. If you clamp your depth values, you will probably get "strange" (everything outside camera's view frustum z-fighting on near and far clipping planes) results from color rendering pass. This is only one case when using such approach is not as good idea as it seems.

stefan
09-12-2005, 12:06 AM
I hoped someone who really knows would answer this question, but this hasn't happened yet. So I'll say something (that might be corrected by that person ;-)

First I don't think that subsequent rendering passes are really the problem that prevents this idea. The z-clamp would have be to be enabled only for the shadow volumes, but you don't write z-values when drawing the shadow volumes.

I asked myself this question some time ago, but I couldn't answer the following question:
Would the rasterization be correct for object behind the camera if you use z-clamp? (E.g. even a very small triangle directly in front of the light but behind the viewer would have to cover the whole screen.)

Dez
09-12-2005, 03:28 AM
I must admit that I completely missed the point made by Dark Photon ;) . I thought that he meant to used depth clamping during initial depth buffer rendering - my bad and I am terribly sorry for the confusion that I caused.



I asked myself this question some time ago, but I couldn't answer the following question:
Would the rasterization be correct for object behind the camera if you use z-clamp? (E.g. even a very small triangle directly in front of the light but behind the viewer would have to cover the whole screen.)
And in my opinion is will not be correct. One of the reasons is as follows: If I remember the NV_depth_clamp specs correctly it only disables near and far plane clipping and clamps fragment depth values to currently set depth range. This works fine as long as the geometry is located between view point and near clipping plane, but when it falls behind view point, it will get clipped by the remaining clipping planes. Please correct if I am wrong in thinking that the geometry is clipped according to "infinite" side planes equations.

Dark Photon
09-13-2005, 06:18 AM
Dez:
If I remember the NV_depth_clamp specs correctly it only disables near and far plane clipping and clamps fragment depth values to currently set depth range. This works fine as long as the geometry is located between view point and near clipping plane, but when it falls behind view point, it will get clipped by the remaining clipping planes.Ah - thanks. The more I consider it, I think you're right. With half-space homogenous clipping, that'd sure be what happens. Even with volume caps, eyepoint in shadow wouldn't always work.

Thanks for the replies.