Help with converting a World Space Vector3 to a Screen Space Vector2

PROBLEM

As you can see in the video, I’ve gotten fairly close. When the tracked object is a certain distance away from the camera, the screen space circle mask effect is perfect. However, when the tracked object moves too close to the camera or too far away, the circle mask no longer works. The problem is that I can’t figure out how to transform the tracked object’s world position to screen space coordinates. All help is appreciated! Thanks in advance.

Video FOV 120

oldfashionedvibrantdugong

Here’s the UV part of the graph

Scene FOV 60

Additional materials

Tracked Object Code

void Update()
{
        Shader.SetGlobalVector("_PlayerPosition", Camera.main.WorldToViewportPoint(transform.position));
}

Rest of the graph (Probably not relevant, wanted to share regardless)

Solved! Thanks to Cyan from his Discord server.
https://twitter.com/Cyanilux

The below graph converts a world space vector3 to a screen space vector2

1 Like