Reading through the source code of the XeGTAO project I found this function while looking for the denoise filter:
lpfloat4 XeGTAO_CalculateEdges( const lpfloat centerZ, const lpfloat leftZ, const lpfloat rightZ, const lpfloat topZ, const lpfloat bottomZ )
{
lpfloat4 edgesLRTB = lpfloat4( leftZ, rightZ, topZ, bottomZ ) - (lpfloat)centerZ;
lpfloat slopeLR = (edgesLRTB.y - edgesLRTB.x) * 0.5;
lpfloat slopeTB = (edgesLRTB.w - edgesLRTB.z) * 0.5;
lpfloat4 edgesLRTBSlopeAdjusted = edgesLRTB + lpfloat4( slopeLR, -slopeLR, slopeTB, -slopeTB );
edgesLRTB = min( abs( edgesLRTB ), abs( edgesLRTBSlopeAdjusted ) );
return lpfloat4(saturate( ( 1.25 - edgesLRTB / (centerZ * 0.011) ) ));
}
(From XeGTAO.hlsli)
Where centerZ
, left/right/...Z
are view space z values.
As the name suggests the function is used to find edges for the denoising filter.
While I understand the general idea I find it difficult to make sense of the last line, this thing in particular: 1.25 - edgesLRTB / (centerZ * 0.011)
.
Could you guess where do those constants come from? Could you suggest any resource about edge/silhouette extraction from depth (to be used as input for a filter/displayed for non-photorealistic rendering)?