does anyone understand this bit of shader code?

Hi, I’m trying to reproduce this fake sphere effect, but I don’t understand the code at all.

I think it’s supposed to go into a custom hlsl node and then into world offset, maybe?

centerToEyeDist is probably the vector length of world position - camera position

I don’t know what ‘r’ is. it probably stands for radius, but i’m not sure how to find that input.

The code is supposed to move a disc mesh in such way, that it separate visible and hidden parts of the sphere from given point of view. CenterToEyeDist is length of virtual sphere location in camera space. OffsetDist is the distance mesh would be offset from virtual sphere center towards view origin. offsetScale is distance mesh vertices would be pushed away from mesh center on a XY plane of camera space. r is radius of virtual sphere.

Basic implementation in material graph would look something like this: