retrieving INVERSE_PROJECTION_MATRIX via script

Godot Version

4.3

Question

Hello everyone,
i need to do some reprojecting for which i need to feed the Inverse Projection matrix of a camera, which is not the main camera into a shader. I’m trying to retrieve the projection matrix via a c# script and set a matching uniform mat4 in my shader. At the moment this looks something like this:
_mat.SetShaderParameter("cam_inv_projection_matrix", cam.GetCameraProjection().Inverse());
The problem is that i can’t seem to retrieve the correct matrix from the camera. For testing I’m using the matrix and the depth texture of the main camera to display the world position as a color (based on the godot advanced post processing documentation)

When using the INVERSE_PROJECTION_MATRIX provided by the shader this looks like this:


which is about what i would expect

When using the manually set inverse projection matrix of my main cam though this instead looks like this:

The matrices are not matching, which i need them too for the rest of the shader to work. Does anyone know if i need to do some extra adjustments to the camera projection for this to work?