How to get vertex depth?

Hey,
I’m trying to get the depth of a pixel without using _CameraDepthTexture.
I’m sure I used to make it work with mul (UNITY_MATRIX_MV , v.vertex).z;
but now I’m only getting black as result.

I’m in unity 4.6.5, anyone knows what’s wrong?

Thanks!

That should work. Maybe the values are negative? Another way is distance:

distance(_WorldSpaceCameraPos, mul(UNITY_MATRIX_MV, v.vertex).xyz);

Not working either…
this is working but a bit complicated…

    //WorldPos
    half4 posWorld = mul(_Object2World,v.vertex);
    //z-depth
    half dist = distance(posWorld, _WorldSpaceCameraPos.xyz);
    //clamp z-depth to the camera range
    return ((dist - _ProjectionParams.y) / _ProjectionParams.z);