screen space position in material graph
You can get camera space coordinates from the Input > Texture Coordinates node using the Camera or Window socket, depending on what you are looking for.

The same node provides local position for vertex using the Object socket, you can convert to world coordinates using a Vector Transform node.

Using the Vector Math node you can do the required matrix calculations.

If I interpreted your code right you should need something along the lines of the node tree below.