Why calculate Refraction distortion (in mode Index of Refraction)Clip?

I noticed there are a clip when distortion vector very small ,Its said“//this will result in a less expensive apply pass since the clipped pixels won’t set stencil to pass”. Dose it necessary?When enable Refraction, if a triangle normal close to camera vector and we set some refraction here,around this area always have a small circle have no refraction.here is the source code in DistortionCommon.ush:

float2 BufferUVDistortion = ViewportUVDistortion * ResolvedView.ViewSizeAndInvSize.xy * ResolvedView.BufferSizeAndInvSize.zw;

//clip if the distortion distance (squared) is too small to be noticed
//this will result in a less expensive apply pass since the clipped pixels won't set stencil to pass
if (TryToClip) //Tips:This Flag set to True in default pipeline(in strate pipeline is about roughness)
{
	clip(dot(BufferUVDistortion, BufferUVDistortion) - .00001);
}

Dose it necessary clip such a small area to improve the performance?

1 Like