Writing depth to a RenderTarget with high precision

I do it like the former, so after ModelView transformation. That should work fine.

float4 viewPosition = mul(WorldPosition, View);
output.Depth = viewPosition.z / -FarClip;

Sure :wink: But some developers does this after the perspective transform, but before de divide.
Is it faster in the viewspace ?

it’s the same speed, one matrix multiplication for the step.

The question is only what you want to do with it, projection has no linear depth buffer in world space, but it is linear in view projection space so that’s very useful, too.