[ShaderGraph] Help with transforming a World Space Vector3 to a Screen Space Vector2
PROBLEM
https://gfycat.com/oldfashionedvibrantdugong
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.
Graph
// Tracked Object Code
void Update()
{
Shader.SetGlobalVector("_PlayerPosition", Camera.main.WorldToViewportPoint(transform.position));
}
Zoom out of the scene FOV 60 The rest of the graph (Probably not relevant)
Answer by JustJunuh · Jun 20, 2021 at 05:43 AM
Solved! Thanks to Cyan from his Discord server.
The below graph converts a world space vector3 to a screen space vector2
Your answer
Follow this Question
Related Questions
Shader displaying with weird colors 1 Answer
Hair and eye shader? 0 Answers
Shader error when updating shader. 0 Answers
How to modify depth blended shader for second camera/reflection projection? 0 Answers