Getting Scene Depth on Quest

Hi,
I’m trying to get the scene depth to work properly on Meta Quest.
I’m using the built-in function SampleSceneDepth(uv);
I calculate the UV using the also build-in function ComputeScreenPos(TransformObjectToHClip(v.vertex.xyz));

While it works fine on PC VR, it looks alright ok on the quest as well, but as soon as an object gets in front of the plane where the scene depth is used, that object gets doubled in one of the eyes.

See bug on the bottom planes here:

The top planes are working fine, but are made using shadergraph instead of HLSL.
They are also using SampleSceneDepth() in shadergraph, but I cannot replicate the way they are calculating the UVs.

Anyone knows how to do that?
Thanks!

If you click “show generated code” on your shadergraph file, you can then scan it to see how it’s computing depth.

That’s what I tried, but it’s 2000 lines of mostly unreadable code.
From what I understood they are also using SampleSceneDepth()
The UV seems to be computed from:
TransformObjectToHClip(ObjectSpacePosition.xyz) / _ScaledScreenParams.xy;

I tried that as well, and while the result seems fine it still has the issue where if an object is close the camera you will see it duplicated in the wrong position in the depth sample. ( Same as in the video )

Finally found the issue, turns out I was missing UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX() in the fragment shader.