I’ve been looking at the Order Independent Transparency paper by Cass Everitt, from the Nvidia site. The idea is to peel away layers by using a shadow map to drop fragments that are too close, while using the regular ZBuffer to make sure that only the closest fragment passing the shadow test affects RGB.
What I can’t figure out is how depth_replace fits into the picture. The straightforward way to do the peeling seems to be, move xyzw into strq and set texture matrix == projection * modelview. At what point would one want to change the rendered fragment’s Z ??
Do you mean that with NV2x, the final s,t is not accurate enough to access eg a 1024x1024 map with some certainty that you’re grabbing the right pixel ?
I can see how depth_replace helps with this, but I’m still not sure how you’d route the resulting Z to the shadowmap side of the comparison, and not the fragment side…?
You use the shadow mapping functionality to compare a depth component (from a texture) to a texture coordinate (generated such that R=Z). However, texture coordinates are interpolated differently from depth. Depth is interpolated linearly, whereas texture coordinates are interpolated with perspective correction. See section 3.4.1 of the spec.
This means that your shadow map depths and your texture coordinate depths are not necessarily the same after interpolation, so your depth comparison is hosed. To get around this, depth replace can be used to override the linearly interpolated depth values with perspective-corrected values. Only then can you perform a meaningful depth comparison to do your depth peeling.